[BACK]Return to pthread.buildlink3.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / mk

Annotation of pkgsrc/mk/pthread.buildlink3.mk, Revision 1.11

1.11    ! xtraeme     1: # $NetBSD: pthread.buildlink3.mk,v 1.10 2004/07/27 11:28:41 xtraeme Exp $
1.1       jlam        2: #
                      3: # The pthreads strategy for pkgsrc is to "bless" a particular pthread
                      4: # package as the Official Pthread Replacement (OPR).  A package that uses
                      5: # pthreads may do one of the following:
                      6: #
                      7: #   (1) Simply include pthread.buildlink3.mk.  This will make the package
                      8: #      use the native pthread library if it's available, or else the OPR
                      9: #      package.  The value of PTHREAD_TYPE may be checked to be either
                     10: #      "native", or the name of the OPR package, or "none", e.g.
                     11: #
                     12: #      #
                     13: #      # package Makefile stuff...
                     14: #      #
                     15: #      .include "../../mk/pthread.buildlink3.mk"
                     16: #
                     17: #      .if defined(PTHREAD_TYPE) && ${PTHREAD_TYPE} == "none"
                     18: #      CONFIGURE_ARGS+=        --without-pthreads
                     19: #      .endif
                     20: #
                     21: #      .include "../../mk/bsd.pkg.mk"
                     22: #
                     23: #      Note that it's only safe to check and use the value of PTHREAD_TYPE
                     24: #      after all other buildlink3.mk files have been included.
                     25: #
                     26: #   (2) Add "native" to PTHREAD_OPTS prior to including
                     27: #      pthread.buildlink3.mk.  This is like case (1), but we only check for
                     28: #      the native pthread library, e.g.,
                     29: #
                     30: #      PTHREAD_OPTS+=  native
                     31: #      #
                     32: #      # package Makefile stuff...
                     33: #      #
                     34: #      .include "../../mk/pthread.buildlink3.mk"
                     35: #
                     36: #      .if defined(PTHREAD_TYPE) && ${PTHREAD_TYPE} == "none"
                     37: #      CONFIGURE_ARGS+=        --without-pthreads
                     38: #      .endif
                     39: #
                     40: #      .include "../../mk/bsd.pkg.mk"
                     41: #
                     42: #   (3)        Add "require" to PTHREAD_OPTS prior to including
                     43: #      pthread.buildlink3.mk.  This will make the package use the native
                     44: #      pthread library or else use the OPR package, and will otherwise set
                     45: #      PKG_SKIP_REASON if neither can be used, e.g.,
                     46: #
                     47: #      PTHREAD_OPTS+=  require
                     48: #      #
                     49: #      # package Makefile stuff...
                     50: #      #
                     51: #      .include "../../mk/pthread.buildlink3.mk"
                     52: #      .include "../../mk/bsd.pkg.mk"
                     53: #
                     54: #   (4) Add both "require" and "native" to PTHREAD_OPTS prior to including
                     55: #      pthread.buildlink3.mk.  This is like case (3), but we only check for
                     56: #      the native pthread library, e.g.,
                     57: #
                     58: #      PTHREAD_OPTS+=  require native
                     59: #      #
                     60: #      # more package Makefile stuff...
                     61: #      #
                     62: #      .include "../../mk/pthread.buildlink3.mk"
                     63: #      .include "../../mk/bsd.pkg.mk"
                     64: #
                     65: # The case where a package must use either the native pthread library or
                     66: # some pthread package aside from the OPR is a special case of (2), e.g.,
                     67: # if the required pthread package is "ptl2", then:
                     68: #
                     69: #      PTHREAD_OPTS+=  native
                     70: #      #
                     71: #      # more package Makefile stuff...
                     72: #      #
                     73: #      .include "../../mk/pthread.buildlink3.mk"
                     74: #
                     75: #      .if defined(PTHREAD_TYPE) && ${PTHREAD_TYPE} == "none"
                     76: #      .  include "../../devel/ptl2/buildlink3.mk"
                     77: #      .endif
                     78: #
                     79: #      .include "../../mk/bsd.pkg.mk"
                     80: #
                     81: # A package Makefile may add the word "optional" to PTHREAD_OPTS, which
                     82: # will override the effects of any instance of the word "require".  This
                     83: # should _only_ be used by those packages that can be built with or
                     84: # without pthreads _independently_ of whether any of its dependencies need
                     85: # pthreads.  Currently, this only only www/mozilla, which uses its own
                     86: # threading library if native pthreads is unavailable, despite that it
                     87: # uses GTK+, which _does_ need pthreads.
                     88: #
                     89: ###########################################################################
                     90: #
                     91: # PTHREAD_OPTS represents whether this package requires pthreads, and also
                     92: #      whether it needs to be native.  It may include the word "require"
                     93: #      to denote that a pthreads implementation is required, and may also
                     94: #      include the word "native" to denote that only native pthreads are
                     95: #      acceptable.
                     96: #
                     97: # _PKG_PTHREAD is the fall-back package pthread implementation use by
                     98: #      pthread.buildlink3.mk.
                     99: #
                    100: # _PKG_PTHREAD_COMPAT_PATTERNS matches the ONLY_FOR_PLATFORMS from the
                    101: #      Makefile for ${_PKG_PTHREAD}.  It's used to see if ${_PKG_PTHREADS}
                    102: #      can actually be used to replace a native pthreads.
                    103: #
1.3       jlam      104: PTHREAD_BUILDLINK3_MK:=        ${PTHREAD_BUILDLINK3_MK}+
                    105:
1.1       jlam      106: _PKG_PTHREAD?=                 pth
                    107: _PKG_PTHREAD_DEPENDS?=         pth>=2.0.0
                    108: _PKG_PTHREAD_PKGSRCDIR?=       ../../devel/${_PKG_PTHREAD}
                    109: _PKG_PTHREAD_BUILDLINK3_MK?=   ${_PKG_PTHREAD_PKGSRCDIR}/buildlink3.mk
                    110: _PKG_PTHREAD_COMPAT_PATTERNS=  *-*-*
                    111:
                    112: .include "../../mk/bsd.prefs.mk"
                    113:
                    114: PTHREAD_OPTS?= # empty
                    115: #
                    116: # We check for a native pthreads implementation by checking for the presence
                    117: # of /usr/include/pthread.h (we might want to make this check stricter).
                    118: #
                    119: .undef PTHREAD_TYPE
                    120: PREFER_NATIVE_PTHREADS?=       YES
                    121: .if exists(/usr/include/pthread.h) && ${PREFER_NATIVE_PTHREADS} == "YES"
                    122: PTHREAD_TYPE=  native
                    123: .else
                    124: .  if !empty(PTHREAD_OPTS:Mnative)
                    125: PTHREAD_TYPE=  none
                    126: .    if !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
                    127: PKG_SKIP_REASON= "${PKGNAME} requires a native pthreads implementation."
                    128: .    endif
                    129: .  else
                    130: PTHREAD_TYPE=  none
                    131: .    for _pattern_ in ${_PKG_PTHREAD_COMPAT_PATTERNS}
                    132: .      if !empty(MACHINE_PLATFORM:M${_pattern_})
                    133: PTHREAD_TYPE=  ${_PKG_PTHREAD}
                    134: .      endif
                    135: .    endfor
                    136: .    if ${PTHREAD_TYPE} == "none" && \
                    137:        !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
                    138: PKG_SKIP_REASON= "${PKGNAME} requires a working pthreads implementation."
                    139: .    endif
                    140: .  endif
                    141: .endif
                    142:
                    143: .if ${PTHREAD_TYPE} == "native"
1.5       seb       144: #
                    145: # Link the native pthread libraries and headers into ${BUILDLINK_DIR}.
                    146: #
1.1       jlam      147: BUILDLINK_PREFIX.pthread=      /usr
                    148: BUILDLINK_LDFLAGS.pthread=     # empty
1.6       grant     149:
                    150: # only pass -pthread on platforms known to support it.
1.9       wiz       151: .  if ${OPSYS} == "FreeBSD" || ${OPSYS} == "Linux" || ${OPSYS} == "NetBSD"
1.6       grant     152: BUILDLINK_CFLAGS.pthread=       -pthread
                    153: .  else
                    154: BUILDLINK_CFLAGS.pthread=       # empty
                    155: .  endif
                    156:
1.1       jlam      157: #
                    158: # Handle systems which have pthreads functions in libc_r such as
                    159: # FreeBSD 5.x, or fall back to libc if we don't find libc_r.
                    160: #
                    161: .  if exists(/usr/lib/libpthread.so) || exists(/lib/libpthread.so)
                    162: BUILDLINK_LDADD.pthread=       -lpthread
                    163: .  elif exists(/usr/lib/libc_r.so)
                    164: BUILDLINK_LDADD.pthread=       -lc_r
1.7       xtraeme   165: # In OpenBSD there is no libpthread.so, just libpthread.so.X.X.
                    166: .  elif ${OPSYS} == "OpenBSD"
                    167: _CHECK_LIBPTH!=        \
1.11    ! xtraeme   168:        if ${TEST} -f /usr/lib/libpthread.so.*; then \
1.10      xtraeme   169:                ${ECHO} "yes";  \
1.7       xtraeme   170:        else                    \
1.10      xtraeme   171:                ${ECHO} "no";   \
1.7       xtraeme   172:        fi
                    173: .    if ${_CHECK_LIBPTH} == "yes"
                    174: BUILDLINK_LDADD.pthread=       -lpthread
                    175: .    endif
1.1       jlam      176: .  else
                    177: BUILDLINK_LDADD.pthread=       # empty
                    178: .  endif
                    179:
                    180: .elif ${PTHREAD_TYPE} == "${_PKG_PTHREAD}"
                    181: .  if exists(${_PKG_PTHREAD_BUILDLINK3_MK})
                    182: .    if !empty(_PKG_PTHREAD_DEPENDS)
1.2       jlam      183: BUILDLINK_DEPENDS.${_PKG_PTHREAD}+=    ${_PKG_PTHREAD_DEPENDS}
1.1       jlam      184: .    endif
                    185: BUILDLINK_PREFIX.pthread=      ${BUILDLINK_PREFIX.${_PKG_PTHREAD}}
                    186: BUILDLINK_CFLAGS.pthread=      ${BUILDLINK_CFLAGS.${_PKG_PTHREAD}}
                    187: BUILDLINK_LDFLAGS.pthread=     ${BUILDLINK_LDFLAGS.${_PKG_PTHREAD}}
                    188: BUILDLINK_LDADD.pthread=       -lpthread
                    189: .    include "${_PKG_PTHREAD_BUILDLINK3_MK}"
                    190: .  else
                    191: PKG_SKIP_REASON= "${PKGNAME} needs pthreads, but ${_PKG_PTHREAD_BUILDLINK3_MK} is missing."
                    192: .  endif
                    193: .endif
                    194:
1.3       jlam      195: .if !empty(PTHREAD_BUILDLINK3_MK:M+)
                    196: #
1.1       jlam      197: # Define user-visible PTHREAD_CFLAGS and PTHREAD_LDFLAGS as compiler
                    198: # options used to compile/link pthreaded code.
                    199: #
                    200: PTHREAD_CFLAGS=                ${BUILDLINK_CFLAGS.pthread}
                    201: PTHREAD_LDFLAGS=       ${BUILDLINK_LDFLAGS.pthread} ${BUILDLINK_LDADD.pthread}
                    202:
                    203: PTHREADBASE=           ${BUILDLINK_PREFIX.pthread}
                    204: CONFIGURE_ENV+=                PTHREADBASE=${PTHREADBASE}
                    205: MAKE_ENV+=             PTHREADBASE=${PTHREADBASE}
                    206: .endif # PTHREAD_BUILDLINK3_MK

CVSweb <webmaster@jp.NetBSD.org>