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

1.21    ! rillig      1: # $NetBSD: pthread.buildlink3.mk,v 1.20 2005/04/13 16:16:50 rillig 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.21    ! rillig     67: # The fall-back package pthread implementation
1.1       jlam       68: _PKG_PTHREAD?=                 pth
                     69: _PKG_PTHREAD_DEPENDS?=         pth>=2.0.0
                     70: _PKG_PTHREAD_PKGSRCDIR?=       ../../devel/${_PKG_PTHREAD}
                     71: _PKG_PTHREAD_BUILDLINK3_MK?=   ${_PKG_PTHREAD_PKGSRCDIR}/buildlink3.mk
1.21    ! rillig     72:
        !            73: # _PKG_PTHREAD_COMPAT_PATTERNS matches the ONLY_FOR_PLATFORMS from the
        !            74: # Makefile for ${_PKG_PTHREAD}.  It is used to see if ${_PKG_PTHREADS}
        !            75: # can actually be used to replace a native pthreads.
1.1       jlam       76: _PKG_PTHREAD_COMPAT_PATTERNS=  *-*-*
                     77:
                     78: .include "../../mk/bsd.prefs.mk"
                     79:
                     80: PTHREAD_OPTS?= # empty
                     81: #
                     82: # We check for a native pthreads implementation by checking for the presence
                     83: # of /usr/include/pthread.h (we might want to make this check stricter).
                     84: #
                     85: .undef PTHREAD_TYPE
1.14      jlam       86: .if exists(/usr/include/pthread.h) && \
                     87:     !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
1.1       jlam       88: PTHREAD_TYPE=  native
                     89: .else
                     90: .  if !empty(PTHREAD_OPTS:Mnative)
                     91: PTHREAD_TYPE=  none
                     92: .    if !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
                     93: PKG_SKIP_REASON= "${PKGNAME} requires a native pthreads implementation."
                     94: .    endif
                     95: .  else
                     96: PTHREAD_TYPE=  none
                     97: .    for _pattern_ in ${_PKG_PTHREAD_COMPAT_PATTERNS}
                     98: .      if !empty(MACHINE_PLATFORM:M${_pattern_})
                     99: PTHREAD_TYPE=  ${_PKG_PTHREAD}
                    100: .      endif
                    101: .    endfor
                    102: .    if ${PTHREAD_TYPE} == "none" && \
                    103:        !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
                    104: PKG_SKIP_REASON= "${PKGNAME} requires a working pthreads implementation."
                    105: .    endif
                    106: .  endif
                    107: .endif
                    108:
1.18      jlam      109: PTHREAD_AUTO_VARS?=    no
1.17      jlam      110:
1.1       jlam      111: .if ${PTHREAD_TYPE} == "native"
1.14      jlam      112: BUILDLINK_PACKAGES:=           ${BUILDLINK_PACKAGES:Npthread}
                    113: BUILDLINK_PACKAGES+=           pthread
                    114: BUILDLINK_BUILTIN_MK.pthread=  ../../mk/pthread.builtin.mk
1.17      jlam      115: BUILDLINK_AUTO_VARS.pthread?=  ${PTHREAD_AUTO_VARS}
1.1       jlam      116: .elif ${PTHREAD_TYPE} == "${_PKG_PTHREAD}"
                    117: .  if exists(${_PKG_PTHREAD_BUILDLINK3_MK})
                    118: .    if !empty(_PKG_PTHREAD_DEPENDS)
1.2       jlam      119: BUILDLINK_DEPENDS.${_PKG_PTHREAD}+=    ${_PKG_PTHREAD_DEPENDS}
1.1       jlam      120: .    endif
                    121: .    include "${_PKG_PTHREAD_BUILDLINK3_MK}"
1.14      jlam      122: BUILDLINK_PREFIX.pthread=              ${BUILDLINK_PREFIX.${_PKG_PTHREAD}}
                    123: BUILDLINK_CFLAGS.pthread=              ${BUILDLINK_CFLAGS.${_PKG_PTHREAD}}
                    124: BUILDLINK_CPPFLAGS.${_PKG_PTHREAD}?=   -D_REENTRANT
                    125: BUILDLINK_CPPFLAGS.pthread=            ${BUILDLINK_CPPFLAGS.${_PKG_PTHREAD}}
                    126: BUILDLINK_LDFLAGS.pthread=             ${BUILDLINK_LDFLAGS.${_PKG_PTHREAD}}
                    127: BUILDLINK_LIBS.${_PKG_PTHREAD}?=       -lpthread
                    128: BUILDLINK_LIBS.pthread=                        ${BUILDLINK_LIBS.${_PKG_PTHREAD}}
1.17      jlam      129: BUILDLINK_AUTO_VARS.${_PKG_PTHREAD}?=  ${PTHREAD_AUTO_VARS}
                    130: BUILDLINK_AUTO_VARS.pthread=           ${BUILDLINK_AUTO_VARS.${_PKG_PTHREAD}}
1.1       jlam      131: .  else
1.20      rillig    132: PKG_SKIP_REASON= ${PKGNAME:Q}" needs pthreads, but "${_PKG_PTHREAD_BUILDLINK3_MK:Q}" is missing."
1.1       jlam      133: .  endif
                    134: .endif
                    135:
1.3       jlam      136: .if !empty(PTHREAD_BUILDLINK3_MK:M+)
                    137: #
1.14      jlam      138: # Define user-visible PTHREAD_{CFLAGS,LDFLAGS,LIBS} as compiler options
                    139: # used to compile/link pthreaded code.
1.1       jlam      140: #
                    141: PTHREAD_CFLAGS=                ${BUILDLINK_CFLAGS.pthread}
1.14      jlam      142: PTHREAD_CFLAGS+=       ${BUILDLINK_CPPFLAGS.pthread}
                    143: PTHREAD_LDFLAGS=       ${BUILDLINK_LDFLAGS.pthread}
                    144: PTHREAD_LIBS=          ${BUILDLINK_LIBS.pthread}
1.20      rillig    145: CONFIGURE_ENV+=                PTHREAD_CFLAGS=${PTHREAD_CFLAGS:Q}
                    146: CONFIGURE_ENV+=                PTHREAD_LDFLAGS=${PTHREAD_LDFLAGS:Q}
                    147: CONFIGURE_ENV+=                PTHREAD_LIBS=${PTHREAD_LIBS:Q}
                    148: MAKE_ENV+=             PTHREAD_CFLAGS=${PTHREAD_CFLAGS:Q}
                    149: MAKE_ENV+=             PTHREAD_LDFLAGS=${PTHREAD_LDFLAGS:Q}
                    150: MAKE_ENV+=             PTHREAD_LIBS=${PTHREAD_LIBS:Q}
1.1       jlam      151:
                    152: PTHREADBASE=           ${BUILDLINK_PREFIX.pthread}
1.20      rillig    153: CONFIGURE_ENV+=                PTHREADBASE=${PTHREADBASE:Q}
                    154: MAKE_ENV+=             PTHREADBASE=${PTHREADBASE:Q}
1.14      jlam      155:
1.1       jlam      156: .endif # PTHREAD_BUILDLINK3_MK

CVSweb <webmaster@jp.NetBSD.org>