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

1.1     ! jlam        1: # $NetBSD$
        !             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: #
        !           104: _PKG_PTHREAD?=                 pth
        !           105: _PKG_PTHREAD_DEPENDS?=         pth>=2.0.0
        !           106: _PKG_PTHREAD_PKGSRCDIR?=       ../../devel/${_PKG_PTHREAD}
        !           107: _PKG_PTHREAD_BUILDLINK3_MK?=   ${_PKG_PTHREAD_PKGSRCDIR}/buildlink3.mk
        !           108: _PKG_PTHREAD_COMPAT_PATTERNS=  *-*-*
        !           109:
        !           110: .include "../../mk/bsd.prefs.mk"
        !           111:
        !           112: PTHREAD_OPTS?= # empty
        !           113: #
        !           114: # We check for a native pthreads implementation by checking for the presence
        !           115: # of /usr/include/pthread.h (we might want to make this check stricter).
        !           116: #
        !           117: .undef PTHREAD_TYPE
        !           118: PREFER_NATIVE_PTHREADS?=       YES
        !           119: .if exists(/usr/include/pthread.h) && ${PREFER_NATIVE_PTHREADS} == "YES"
        !           120: PTHREAD_TYPE=  native
        !           121: .else
        !           122: .  if !empty(PTHREAD_OPTS:Mnative)
        !           123: PTHREAD_TYPE=  none
        !           124: .    if !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
        !           125: PKG_SKIP_REASON= "${PKGNAME} requires a native pthreads implementation."
        !           126: .    endif
        !           127: .  else
        !           128: PTHREAD_TYPE=  none
        !           129: .    for _pattern_ in ${_PKG_PTHREAD_COMPAT_PATTERNS}
        !           130: .      if !empty(MACHINE_PLATFORM:M${_pattern_})
        !           131: PTHREAD_TYPE=  ${_PKG_PTHREAD}
        !           132: .      endif
        !           133: .    endfor
        !           134: .    if ${PTHREAD_TYPE} == "none" && \
        !           135:        !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
        !           136: PKG_SKIP_REASON= "${PKGNAME} requires a working pthreads implementation."
        !           137: .    endif
        !           138: .  endif
        !           139: .endif
        !           140:
        !           141: .if !defined(PTHREAD_BUILDLINK3_MK)
        !           142: PTHREAD_BUILDLINK3_MK= # defined
        !           143:
        !           144: .if ${PTHREAD_TYPE} == "native"
        !           145: #
        !           146: # Link the native pthread libraries and headers into ${BUILDLINK_DIR}.
        !           147: #
        !           148: BUILDLINK_PREFIX.pthread=      /usr
        !           149: BUILDLINK_CFLAGS.pthread=      -pthread
        !           150: BUILDLINK_LDFLAGS.pthread=     # empty
        !           151: #
        !           152: # Handle systems which have pthreads functions in libc_r such as
        !           153: # FreeBSD 5.x, or fall back to libc if we don't find libc_r.
        !           154: #
        !           155: .  if exists(/usr/lib/libpthread.so) || exists(/lib/libpthread.so)
        !           156: BUILDLINK_LDADD.pthread=       -lpthread
        !           157: .  elif exists(/usr/lib/libc_r.so)
        !           158: BUILDLINK_LDADD.pthread=       -lc_r
        !           159: .  else
        !           160: BUILDLINK_LDADD.pthread=       # empty
        !           161: .  endif
        !           162:
        !           163: .elif ${PTHREAD_TYPE} == "${_PKG_PTHREAD}"
        !           164: .  if exists(${_PKG_PTHREAD_BUILDLINK3_MK})
        !           165: .    if !empty(_PKG_PTHREAD_DEPENDS)
        !           166: BUILDLINK_DEPENDS.${_PKG_PTHREAD}=     ${_PKG_PTHREAD_DEPENDS}
        !           167: .    endif
        !           168: BUILDLINK_PREFIX.pthread=      ${BUILDLINK_PREFIX.${_PKG_PTHREAD}}
        !           169: BUILDLINK_CFLAGS.pthread=      ${BUILDLINK_CFLAGS.${_PKG_PTHREAD}}
        !           170: BUILDLINK_LDFLAGS.pthread=     ${BUILDLINK_LDFLAGS.${_PKG_PTHREAD}}
        !           171: BUILDLINK_LDADD.pthread=       -lpthread
        !           172: .    include "${_PKG_PTHREAD_BUILDLINK3_MK}"
        !           173: .  else
        !           174: PKG_SKIP_REASON= "${PKGNAME} needs pthreads, but ${_PKG_PTHREAD_BUILDLINK3_MK} is missing."
        !           175: .  endif
        !           176: .endif
        !           177:
        !           178: # Define user-visible PTHREAD_CFLAGS and PTHREAD_LDFLAGS as compiler
        !           179: # options used to compile/link pthreaded code.
        !           180: #
        !           181: PTHREAD_CFLAGS=                ${BUILDLINK_CFLAGS.pthread}
        !           182: PTHREAD_LDFLAGS=       ${BUILDLINK_LDFLAGS.pthread} ${BUILDLINK_LDADD.pthread}
        !           183:
        !           184: PTHREADBASE=           ${BUILDLINK_PREFIX.pthread}
        !           185: CONFIGURE_ENV+=                PTHREADBASE=${PTHREADBASE}
        !           186: MAKE_ENV+=             PTHREADBASE=${PTHREADBASE}
        !           187:
        !           188: .endif # PTHREAD_BUILDLINK3_MK

CVSweb <webmaster@jp.NetBSD.org>