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

1.30    ! jperkin     1: # $NetBSD: pthread.buildlink3.mk,v 1.29 2010/02/06 11:06:19 obache 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
1.30    ! jperkin    85:
        !            86: CHECK_BUILTIN.pthread:=  yes
        !            87: .include "../../mk/pthread.builtin.mk"
        !            88: CHECK_BUILTIN.pthread:=  no
        !            89:
1.1       jlam       90: #
1.30    ! jperkin    91: # Set the value of PTHREAD_TYPE depending on the platform and what's
        !            92: # available in the base system.
1.1       jlam       93: #
                     94: .undef PTHREAD_TYPE
1.30    ! jperkin    95: .if defined(USE_BUILTIN.pthread) && \
        !            96:     !empty(USE_BUILTIN.pthread:M[yY][eE][sS]) && \
1.14      jlam       97:     !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
1.1       jlam       98: PTHREAD_TYPE=  native
                     99: .else
                    100: .  if !empty(PTHREAD_OPTS:Mnative)
                    101: PTHREAD_TYPE=  none
                    102: .    if !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
1.25      rillig    103: PKG_FAIL_REASON= "${PKGNAME} requires a native pthreads implementation."
1.1       jlam      104: .    endif
                    105: .  else
                    106: PTHREAD_TYPE=  none
                    107: .    for _pattern_ in ${_PKG_PTHREAD_COMPAT_PATTERNS}
                    108: .      if !empty(MACHINE_PLATFORM:M${_pattern_})
                    109: PTHREAD_TYPE=  ${_PKG_PTHREAD}
                    110: .      endif
                    111: .    endfor
                    112: .    if ${PTHREAD_TYPE} == "none" && \
                    113:        !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
1.25      rillig    114: PKG_FAIL_REASON= "${PKGNAME} requires a working pthreads implementation."
1.1       jlam      115: .    endif
                    116: .  endif
                    117: .endif
                    118:
1.18      jlam      119: PTHREAD_AUTO_VARS?=    no
1.17      jlam      120:
1.1       jlam      121: .if ${PTHREAD_TYPE} == "native"
1.28      joerg     122: BUILDLINK_TREE+=               pthread -pthread
1.14      jlam      123: BUILDLINK_BUILTIN_MK.pthread=  ../../mk/pthread.builtin.mk
1.17      jlam      124: BUILDLINK_AUTO_VARS.pthread?=  ${PTHREAD_AUTO_VARS}
1.1       jlam      125: .elif ${PTHREAD_TYPE} == "${_PKG_PTHREAD}"
                    126: .  if exists(${_PKG_PTHREAD_BUILDLINK3_MK})
                    127: .    if !empty(_PKG_PTHREAD_DEPENDS)
1.22      reed      128: BUILDLINK_API_DEPENDS.${_PKG_PTHREAD}+=        ${_PKG_PTHREAD_DEPENDS}
1.1       jlam      129: .    endif
                    130: .    include "${_PKG_PTHREAD_BUILDLINK3_MK}"
1.14      jlam      131: BUILDLINK_PREFIX.pthread=              ${BUILDLINK_PREFIX.${_PKG_PTHREAD}}
                    132: BUILDLINK_CFLAGS.pthread=              ${BUILDLINK_CFLAGS.${_PKG_PTHREAD}}
                    133: BUILDLINK_CPPFLAGS.${_PKG_PTHREAD}?=   -D_REENTRANT
                    134: BUILDLINK_CPPFLAGS.pthread=            ${BUILDLINK_CPPFLAGS.${_PKG_PTHREAD}}
                    135: BUILDLINK_LDFLAGS.pthread=             ${BUILDLINK_LDFLAGS.${_PKG_PTHREAD}}
                    136: BUILDLINK_LIBS.${_PKG_PTHREAD}?=       -lpthread
                    137: BUILDLINK_LIBS.pthread=                        ${BUILDLINK_LIBS.${_PKG_PTHREAD}}
1.17      jlam      138: BUILDLINK_AUTO_VARS.${_PKG_PTHREAD}?=  ${PTHREAD_AUTO_VARS}
                    139: BUILDLINK_AUTO_VARS.pthread=           ${BUILDLINK_AUTO_VARS.${_PKG_PTHREAD}}
1.1       jlam      140: .  else
1.25      rillig    141: PKG_FAIL_REASON= ${PKGNAME:Q}" needs pthreads, but "${_PKG_PTHREAD_BUILDLINK3_MK:Q}" is missing."
1.1       jlam      142: .  endif
                    143: .endif
                    144:
1.3       jlam      145: .if !empty(PTHREAD_BUILDLINK3_MK:M+)
                    146: #
1.14      jlam      147: # Define user-visible PTHREAD_{CFLAGS,LDFLAGS,LIBS} as compiler options
                    148: # used to compile/link pthreaded code.
1.1       jlam      149: #
                    150: PTHREAD_CFLAGS=                ${BUILDLINK_CFLAGS.pthread}
1.14      jlam      151: PTHREAD_CFLAGS+=       ${BUILDLINK_CPPFLAGS.pthread}
                    152: PTHREAD_LDFLAGS=       ${BUILDLINK_LDFLAGS.pthread}
                    153: PTHREAD_LIBS=          ${BUILDLINK_LIBS.pthread}
1.20      rillig    154: CONFIGURE_ENV+=                PTHREAD_CFLAGS=${PTHREAD_CFLAGS:Q}
                    155: CONFIGURE_ENV+=                PTHREAD_LDFLAGS=${PTHREAD_LDFLAGS:Q}
                    156: CONFIGURE_ENV+=                PTHREAD_LIBS=${PTHREAD_LIBS:Q}
                    157: MAKE_ENV+=             PTHREAD_CFLAGS=${PTHREAD_CFLAGS:Q}
                    158: MAKE_ENV+=             PTHREAD_LDFLAGS=${PTHREAD_LDFLAGS:Q}
                    159: MAKE_ENV+=             PTHREAD_LIBS=${PTHREAD_LIBS:Q}
1.1       jlam      160:
                    161: PTHREADBASE=           ${BUILDLINK_PREFIX.pthread}
1.20      rillig    162: CONFIGURE_ENV+=                PTHREADBASE=${PTHREADBASE:Q}
                    163: MAKE_ENV+=             PTHREADBASE=${PTHREADBASE:Q}
1.14      jlam      164:
1.1       jlam      165: .endif # PTHREAD_BUILDLINK3_MK

CVSweb <webmaster@jp.NetBSD.org>