[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.28

1.28    ! joerg       1: # $NetBSD: pthread.buildlink3.mk,v 1.27 2008/01/23 17:35:20 tnn Exp $
1.1       jlam        2: #
                      3: # The pthreads strategy for pkgsrc is to "bless" a particular pthread
1.21      rillig      4: # package as the Official Pthread Replacement (OPR).  The following
                      5: # variables may be set before including this file:
1.1       jlam        6: #
1.21      rillig      7: # PTHREAD_OPTS?= # empty
                      8: #      A list of options to configure the search for a suitable pthreads
                      9: #      implementation.
1.1       jlam       10: #
1.21      rillig     11: #      "native" means that only a native pthreads implementation is
                     12: #              acceptable.
1.1       jlam       13: #
1.21      rillig     14: #      "optional" will override the effects of any instance of
                     15: #              "require".  This should _only_ be used by those packages
                     16: #              that can be built with or without pthreads independently
                     17: #              of whether any of its dependencies need pthreads.
                     18: #              Currently, this is only www/mozilla, which uses its own
                     19: #              threading library if native pthreads are unavailable,
                     20: #              despite that it uses GTK+, which _does_ need pthreads.
1.1       jlam       21: #
1.21      rillig     22: #      "require" means that the package is skipped silently when no
                     23: #              implementation can be found.
1.1       jlam       24: #
1.21      rillig     25: #      By default, the native pthreads implementation is used if it's
                     26: #      available. Otherwise the OPR is used.
1.1       jlam       27: #
1.21      rillig     28: # PTHREAD_AUTO_VARS?= no
                     29: #      This variable specifies whether the values of the variables
                     30: #      PTHREAD_{CFLAGS,CPPFLAGS,LDFLAGS,LIBS} should be automatically
                     31: #      added to their respective variables.
1.1       jlam       32: #
1.21      rillig     33: # After inclusion of this file, the following variables may be examined:
1.1       jlam       34: #
1.21      rillig     35: # PTHREAD_TYPE
                     36: #      The type of pthreads implementation that has been found.
1.1       jlam       37: #
1.21      rillig     38: #      "native" means that the native pthreads implementation is used.
1.1       jlam       39: #
1.21      rillig     40: #      "none" means that no suitable pthreads implementation could be
                     41: #              found.
1.1       jlam       42: #
1.21      rillig     43: #      Any other value is the name of the package that is used as the
                     44: #      pthread implementation.
1.1       jlam       45: #
1.21      rillig     46: #      Note that it's only safe to check and use the value of PTHREAD_TYPE
                     47: #      after all other buildlink3.mk files have been included.
1.1       jlam       48: #
                     49: # The case where a package must use either the native pthread library or
1.21      rillig     50: # some pthread package aside from the OPR (e.g. "ptl2") can be solved as
                     51: # follows:
1.1       jlam       52: #
                     53: #      PTHREAD_OPTS+=  native
                     54: #      #
                     55: #      # more package Makefile stuff...
                     56: #      #
                     57: #      .include "../../mk/pthread.buildlink3.mk"
                     58: #
                     59: #      .if defined(PTHREAD_TYPE) && ${PTHREAD_TYPE} == "none"
                     60: #      .  include "../../devel/ptl2/buildlink3.mk"
                     61: #      .endif
                     62: #
                     63: #      .include "../../mk/bsd.pkg.mk"
1.21      rillig     64:
1.3       jlam       65: PTHREAD_BUILDLINK3_MK:=        ${PTHREAD_BUILDLINK3_MK}+
                     66:
1.26      rillig     67: _VARGROUPS+=           pthread
                     68: _PKG_VARS.pthread=     PTHREAD_OPTS PTHREAD_AUTO_VARS
                     69: _SYS_VARS.pthread=     PTHREAD_TYPE PTHREAD_CFLAGS PTHREAD_LDFLAGS PTHREAD_LIBS
                     70:
1.21      rillig     71: # The fall-back package pthread implementation
1.1       jlam       72: _PKG_PTHREAD?=                 pth
                     73: _PKG_PTHREAD_DEPENDS?=         pth>=2.0.0
                     74: _PKG_PTHREAD_PKGSRCDIR?=       ../../devel/${_PKG_PTHREAD}
                     75: _PKG_PTHREAD_BUILDLINK3_MK?=   ${_PKG_PTHREAD_PKGSRCDIR}/buildlink3.mk
1.21      rillig     76:
                     77: # _PKG_PTHREAD_COMPAT_PATTERNS matches the ONLY_FOR_PLATFORMS from the
                     78: # Makefile for ${_PKG_PTHREAD}.  It is used to see if ${_PKG_PTHREADS}
                     79: # can actually be used to replace a native pthreads.
1.1       jlam       80: _PKG_PTHREAD_COMPAT_PATTERNS=  *-*-*
                     81:
1.27      tnn        82: .include "../../mk/bsd.fast.prefs.mk"
1.1       jlam       83:
                     84: PTHREAD_OPTS?= # empty
                     85: #
                     86: # We check for a native pthreads implementation by checking for the presence
                     87: # of /usr/include/pthread.h (we might want to make this check stricter).
                     88: #
                     89: .undef PTHREAD_TYPE
1.14      jlam       90: .if exists(/usr/include/pthread.h) && \
                     91:     !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
1.1       jlam       92: PTHREAD_TYPE=  native
                     93: .else
                     94: .  if !empty(PTHREAD_OPTS:Mnative)
                     95: PTHREAD_TYPE=  none
                     96: .    if !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
1.25      rillig     97: PKG_FAIL_REASON= "${PKGNAME} requires a native pthreads implementation."
1.1       jlam       98: .    endif
                     99: .  else
                    100: PTHREAD_TYPE=  none
                    101: .    for _pattern_ in ${_PKG_PTHREAD_COMPAT_PATTERNS}
                    102: .      if !empty(MACHINE_PLATFORM:M${_pattern_})
                    103: PTHREAD_TYPE=  ${_PKG_PTHREAD}
                    104: .      endif
                    105: .    endfor
                    106: .    if ${PTHREAD_TYPE} == "none" && \
                    107:        !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
1.25      rillig    108: PKG_FAIL_REASON= "${PKGNAME} requires a working pthreads implementation."
1.1       jlam      109: .    endif
                    110: .  endif
                    111: .endif
                    112:
1.18      jlam      113: PTHREAD_AUTO_VARS?=    no
1.17      jlam      114:
1.1       jlam      115: .if ${PTHREAD_TYPE} == "native"
1.28    ! joerg     116: BUILDLINK_TREE+=               pthread -pthread
1.14      jlam      117: BUILDLINK_BUILTIN_MK.pthread=  ../../mk/pthread.builtin.mk
1.17      jlam      118: BUILDLINK_AUTO_VARS.pthread?=  ${PTHREAD_AUTO_VARS}
1.1       jlam      119: .elif ${PTHREAD_TYPE} == "${_PKG_PTHREAD}"
                    120: .  if exists(${_PKG_PTHREAD_BUILDLINK3_MK})
                    121: .    if !empty(_PKG_PTHREAD_DEPENDS)
1.22      reed      122: BUILDLINK_API_DEPENDS.${_PKG_PTHREAD}+=        ${_PKG_PTHREAD_DEPENDS}
1.1       jlam      123: .    endif
                    124: .    include "${_PKG_PTHREAD_BUILDLINK3_MK}"
1.14      jlam      125: BUILDLINK_PREFIX.pthread=              ${BUILDLINK_PREFIX.${_PKG_PTHREAD}}
                    126: BUILDLINK_CFLAGS.pthread=              ${BUILDLINK_CFLAGS.${_PKG_PTHREAD}}
                    127: BUILDLINK_CPPFLAGS.${_PKG_PTHREAD}?=   -D_REENTRANT
                    128: BUILDLINK_CPPFLAGS.pthread=            ${BUILDLINK_CPPFLAGS.${_PKG_PTHREAD}}
                    129: BUILDLINK_LDFLAGS.pthread=             ${BUILDLINK_LDFLAGS.${_PKG_PTHREAD}}
                    130: BUILDLINK_LIBS.${_PKG_PTHREAD}?=       -lpthread
                    131: BUILDLINK_LIBS.pthread=                        ${BUILDLINK_LIBS.${_PKG_PTHREAD}}
1.17      jlam      132: BUILDLINK_AUTO_VARS.${_PKG_PTHREAD}?=  ${PTHREAD_AUTO_VARS}
                    133: BUILDLINK_AUTO_VARS.pthread=           ${BUILDLINK_AUTO_VARS.${_PKG_PTHREAD}}
1.1       jlam      134: .  else
1.25      rillig    135: PKG_FAIL_REASON= ${PKGNAME:Q}" needs pthreads, but "${_PKG_PTHREAD_BUILDLINK3_MK:Q}" is missing."
1.1       jlam      136: .  endif
                    137: .endif
                    138:
1.3       jlam      139: .if !empty(PTHREAD_BUILDLINK3_MK:M+)
                    140: #
1.14      jlam      141: # Define user-visible PTHREAD_{CFLAGS,LDFLAGS,LIBS} as compiler options
                    142: # used to compile/link pthreaded code.
1.1       jlam      143: #
                    144: PTHREAD_CFLAGS=                ${BUILDLINK_CFLAGS.pthread}
1.14      jlam      145: PTHREAD_CFLAGS+=       ${BUILDLINK_CPPFLAGS.pthread}
                    146: PTHREAD_LDFLAGS=       ${BUILDLINK_LDFLAGS.pthread}
                    147: PTHREAD_LIBS=          ${BUILDLINK_LIBS.pthread}
1.20      rillig    148: CONFIGURE_ENV+=                PTHREAD_CFLAGS=${PTHREAD_CFLAGS:Q}
                    149: CONFIGURE_ENV+=                PTHREAD_LDFLAGS=${PTHREAD_LDFLAGS:Q}
                    150: CONFIGURE_ENV+=                PTHREAD_LIBS=${PTHREAD_LIBS:Q}
                    151: MAKE_ENV+=             PTHREAD_CFLAGS=${PTHREAD_CFLAGS:Q}
                    152: MAKE_ENV+=             PTHREAD_LDFLAGS=${PTHREAD_LDFLAGS:Q}
                    153: MAKE_ENV+=             PTHREAD_LIBS=${PTHREAD_LIBS:Q}
1.1       jlam      154:
                    155: PTHREADBASE=           ${BUILDLINK_PREFIX.pthread}
1.20      rillig    156: CONFIGURE_ENV+=                PTHREADBASE=${PTHREADBASE:Q}
                    157: MAKE_ENV+=             PTHREADBASE=${PTHREADBASE:Q}
1.14      jlam      158:
1.1       jlam      159: .endif # PTHREAD_BUILDLINK3_MK

CVSweb <webmaster@jp.NetBSD.org>