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

1.17.2.1  tv          1: # $NetBSD$
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: #
1.17      jlam       97: # PTHREAD_AUTO_VARS is "yes" or "no" for whether the values of the variables
                     98: #      PTHREAD_{CFLAGS,CPPFLAGS,LDFLAGS,LIBS} should be automatically added
1.17.2.2  tv         99: #      to their respective variables.  Defaults to "no".
1.17      jlam      100: #
1.1       jlam      101: # _PKG_PTHREAD is the fall-back package pthread implementation use by
                    102: #      pthread.buildlink3.mk.
                    103: #
                    104: # _PKG_PTHREAD_COMPAT_PATTERNS matches the ONLY_FOR_PLATFORMS from the
                    105: #      Makefile for ${_PKG_PTHREAD}.  It's used to see if ${_PKG_PTHREADS}
                    106: #      can actually be used to replace a native pthreads.
                    107: #
1.3       jlam      108: PTHREAD_BUILDLINK3_MK:=        ${PTHREAD_BUILDLINK3_MK}+
                    109:
1.1       jlam      110: _PKG_PTHREAD?=                 pth
                    111: _PKG_PTHREAD_DEPENDS?=         pth>=2.0.0
                    112: _PKG_PTHREAD_PKGSRCDIR?=       ../../devel/${_PKG_PTHREAD}
                    113: _PKG_PTHREAD_BUILDLINK3_MK?=   ${_PKG_PTHREAD_PKGSRCDIR}/buildlink3.mk
                    114: _PKG_PTHREAD_COMPAT_PATTERNS=  *-*-*
                    115:
                    116: .include "../../mk/bsd.prefs.mk"
                    117:
                    118: PTHREAD_OPTS?= # empty
                    119: #
                    120: # We check for a native pthreads implementation by checking for the presence
                    121: # of /usr/include/pthread.h (we might want to make this check stricter).
                    122: #
                    123: .undef PTHREAD_TYPE
1.14      jlam      124: .if exists(/usr/include/pthread.h) && \
                    125:     !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
1.1       jlam      126: PTHREAD_TYPE=  native
                    127: .else
                    128: .  if !empty(PTHREAD_OPTS:Mnative)
                    129: PTHREAD_TYPE=  none
                    130: .    if !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
                    131: PKG_SKIP_REASON= "${PKGNAME} requires a native pthreads implementation."
                    132: .    endif
                    133: .  else
                    134: PTHREAD_TYPE=  none
                    135: .    for _pattern_ in ${_PKG_PTHREAD_COMPAT_PATTERNS}
                    136: .      if !empty(MACHINE_PLATFORM:M${_pattern_})
                    137: PTHREAD_TYPE=  ${_PKG_PTHREAD}
                    138: .      endif
                    139: .    endfor
                    140: .    if ${PTHREAD_TYPE} == "none" && \
                    141:        !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
                    142: PKG_SKIP_REASON= "${PKGNAME} requires a working pthreads implementation."
                    143: .    endif
                    144: .  endif
                    145: .endif
                    146:
1.17.2.1  tv        147: PTHREAD_AUTO_VARS?=    no
1.17      jlam      148:
1.1       jlam      149: .if ${PTHREAD_TYPE} == "native"
1.14      jlam      150: BUILDLINK_PACKAGES:=           ${BUILDLINK_PACKAGES:Npthread}
                    151: BUILDLINK_PACKAGES+=           pthread
                    152: BUILDLINK_BUILTIN_MK.pthread=  ../../mk/pthread.builtin.mk
1.17      jlam      153: BUILDLINK_AUTO_VARS.pthread?=  ${PTHREAD_AUTO_VARS}
1.1       jlam      154: .elif ${PTHREAD_TYPE} == "${_PKG_PTHREAD}"
                    155: .  if exists(${_PKG_PTHREAD_BUILDLINK3_MK})
                    156: .    if !empty(_PKG_PTHREAD_DEPENDS)
1.2       jlam      157: BUILDLINK_DEPENDS.${_PKG_PTHREAD}+=    ${_PKG_PTHREAD_DEPENDS}
1.1       jlam      158: .    endif
                    159: .    include "${_PKG_PTHREAD_BUILDLINK3_MK}"
1.14      jlam      160: BUILDLINK_PREFIX.pthread=              ${BUILDLINK_PREFIX.${_PKG_PTHREAD}}
                    161: BUILDLINK_CFLAGS.pthread=              ${BUILDLINK_CFLAGS.${_PKG_PTHREAD}}
                    162: BUILDLINK_CPPFLAGS.${_PKG_PTHREAD}?=   -D_REENTRANT
                    163: BUILDLINK_CPPFLAGS.pthread=            ${BUILDLINK_CPPFLAGS.${_PKG_PTHREAD}}
                    164: BUILDLINK_LDFLAGS.pthread=             ${BUILDLINK_LDFLAGS.${_PKG_PTHREAD}}
                    165: BUILDLINK_LIBS.${_PKG_PTHREAD}?=       -lpthread
                    166: BUILDLINK_LIBS.pthread=                        ${BUILDLINK_LIBS.${_PKG_PTHREAD}}
1.17      jlam      167: BUILDLINK_AUTO_VARS.${_PKG_PTHREAD}?=  ${PTHREAD_AUTO_VARS}
                    168: BUILDLINK_AUTO_VARS.pthread=           ${BUILDLINK_AUTO_VARS.${_PKG_PTHREAD}}
1.1       jlam      169: .  else
1.17.2.3! tv        170: PKG_SKIP_REASON= ${PKGNAME:Q}" needs pthreads, but "${_PKG_PTHREAD_BUILDLINK3_MK:Q}" is missing."
1.1       jlam      171: .  endif
                    172: .endif
                    173:
1.3       jlam      174: .if !empty(PTHREAD_BUILDLINK3_MK:M+)
                    175: #
1.14      jlam      176: # Define user-visible PTHREAD_{CFLAGS,LDFLAGS,LIBS} as compiler options
                    177: # used to compile/link pthreaded code.
1.1       jlam      178: #
                    179: PTHREAD_CFLAGS=                ${BUILDLINK_CFLAGS.pthread}
1.14      jlam      180: PTHREAD_CFLAGS+=       ${BUILDLINK_CPPFLAGS.pthread}
                    181: PTHREAD_LDFLAGS=       ${BUILDLINK_LDFLAGS.pthread}
                    182: PTHREAD_LIBS=          ${BUILDLINK_LIBS.pthread}
1.17.2.3! tv        183: CONFIGURE_ENV+=                PTHREAD_CFLAGS=${PTHREAD_CFLAGS:Q}
        !           184: CONFIGURE_ENV+=                PTHREAD_LDFLAGS=${PTHREAD_LDFLAGS:Q}
        !           185: CONFIGURE_ENV+=                PTHREAD_LIBS=${PTHREAD_LIBS:Q}
        !           186: MAKE_ENV+=             PTHREAD_CFLAGS=${PTHREAD_CFLAGS:Q}
        !           187: MAKE_ENV+=             PTHREAD_LDFLAGS=${PTHREAD_LDFLAGS:Q}
        !           188: MAKE_ENV+=             PTHREAD_LIBS=${PTHREAD_LIBS:Q}
1.1       jlam      189:
                    190: PTHREADBASE=           ${BUILDLINK_PREFIX.pthread}
1.17.2.3! tv        191: CONFIGURE_ENV+=                PTHREADBASE=${PTHREADBASE:Q}
        !           192: MAKE_ENV+=             PTHREADBASE=${PTHREADBASE:Q}
1.14      jlam      193:
1.1       jlam      194: .endif # PTHREAD_BUILDLINK3_MK

CVSweb <webmaster@jp.NetBSD.org>