threadlibs.c raw

   1  /*
   2   * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
   3   * Copyright (c) 1996 by Silicon Graphics.  All rights reserved.
   4   * Copyright (c) 1998 by Fergus Henderson.  All rights reserved.
   5   * Copyright (c) 2000-2010 by Hewlett-Packard Development Company.
   6   * All rights reserved.
   7   *
   8   * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
   9   * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
  10   *
  11   * Permission is hereby granted to use or copy this program
  12   * for any purpose, provided the above notices are retained on all copies.
  13   * Permission to modify the code and to distribute modified code is granted,
  14   * provided the above notices are retained, and a notice that the code was
  15   * modified is included with the above copyright notice.
  16   */
  17  
  18  /*
  19   * A build-time utility used by `Makefile.direct` file.
  20   * Determines proper linker flags.
  21   */
  22  
  23  #ifdef HAVE_CONFIG_H
  24  #  include "config.h"
  25  #endif
  26  
  27  #include "private/gcconfig.h"
  28  
  29  #include <stdio.h>
  30  
  31  int
  32  main(void)
  33  {
  34  #if defined(GC_USE_LD_WRAP)
  35    printf("-Wl,--wrap -Wl,dlopen "
  36           "-Wl,--wrap -Wl,pthread_create -Wl,--wrap -Wl,pthread_join "
  37           "-Wl,--wrap -Wl,pthread_detach -Wl,--wrap -Wl,pthread_sigmask "
  38           "-Wl,--wrap -Wl,pthread_exit -Wl,--wrap -Wl,pthread_cancel\n");
  39  #endif
  40  #ifdef THREADS
  41  #  if defined(AIX) || defined(DARWIN) || defined(HURD) || defined(IRIX5) \
  42        || (defined(LINUX) && !defined(HOST_ANDROID)) || defined(NACL)
  43  #    ifdef GC_USE_DLOPEN_WRAP
  44    printf("-ldl -lpthread\n");
  45  #    else
  46    printf("-lpthread\n");
  47  #    endif
  48  #  endif
  49  #  ifdef OPENBSD
  50    printf("-pthread\n");
  51  #  endif
  52  #  ifdef FREEBSD
  53  #    ifdef GC_USE_DLOPEN_WRAP
  54    printf("-ldl ");
  55  #    endif
  56  #    if (__FREEBSD_version < 500000)
  57    printf("-pthread\n");
  58  #    else /* __FREEBSD__ || __DragonFly__ */
  59    printf("-lpthread\n");
  60  #    endif
  61  #  endif
  62  #  if defined(HPUX) || defined(NETBSD)
  63    printf("-lpthread -lrt\n");
  64  #  endif
  65  #  if defined(OSF1)
  66    /* DOB: must be `-pthread`, not `-lpthread`. */
  67    printf("-pthread -lrt\n");
  68  #  endif
  69  #  ifdef SOLARIS
  70    /* Is this right for recent versions? */
  71    printf("-lthread -lposix4\n");
  72  #  endif
  73  #  ifdef CYGWIN32
  74    printf("-lpthread\n");
  75  #  endif
  76  #  if defined(GC_WIN32_PTHREADS)
  77  #    ifdef PTW32_STATIC_LIB
  78    /* Assume suffix "s" for static variant of the pthreads-win32 library. */
  79    printf("-lpthreadGC2s -lws2_32\n");
  80  #    else
  81    printf("-lpthreadGC2\n");
  82  #    endif
  83  #  endif
  84  #  ifdef DGUX
  85    /*
  86     * You need gcc-3.0.3 to build this one!
  87     * DG/UX native gcc does not know what `-pthread` is.
  88     */
  89    printf("-ldl -pthread\n");
  90  #  endif
  91  #endif
  92    return 0;
  93  }
  94