2006-07-09 01:10:35 +02:00
|
|
|
# $NetBSD: pthread.buildlink3.mk,v 1.24 2006/07/08 23:11:17 jlam Exp $
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
|
|
|
# The pthreads strategy for pkgsrc is to "bless" a particular pthread
|
2005-11-04 15:36:23 +01:00
|
|
|
# package as the Official Pthread Replacement (OPR). The following
|
|
|
|
# variables may be set before including this file:
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# PTHREAD_OPTS?= # empty
|
|
|
|
# A list of options to configure the search for a suitable pthreads
|
|
|
|
# implementation.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# "native" means that only a native pthreads implementation is
|
|
|
|
# acceptable.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# "optional" will override the effects of any instance of
|
|
|
|
# "require". This should _only_ be used by those packages
|
|
|
|
# that can be built with or without pthreads independently
|
|
|
|
# of whether any of its dependencies need pthreads.
|
|
|
|
# Currently, this is only www/mozilla, which uses its own
|
|
|
|
# threading library if native pthreads are unavailable,
|
|
|
|
# despite that it uses GTK+, which _does_ need pthreads.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# "require" means that the package is skipped silently when no
|
|
|
|
# implementation can be found.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# By default, the native pthreads implementation is used if it's
|
|
|
|
# available. Otherwise the OPR is used.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# PTHREAD_AUTO_VARS?= no
|
|
|
|
# This variable specifies whether the values of the variables
|
|
|
|
# PTHREAD_{CFLAGS,CPPFLAGS,LDFLAGS,LIBS} should be automatically
|
|
|
|
# added to their respective variables.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# After inclusion of this file, the following variables may be examined:
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# PTHREAD_TYPE
|
|
|
|
# The type of pthreads implementation that has been found.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# "native" means that the native pthreads implementation is used.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# "none" means that no suitable pthreads implementation could be
|
|
|
|
# found.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# Any other value is the name of the package that is used as the
|
|
|
|
# pthread implementation.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
2005-11-04 15:36:23 +01:00
|
|
|
# Note that it's only safe to check and use the value of PTHREAD_TYPE
|
|
|
|
# after all other buildlink3.mk files have been included.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
|
|
|
# The case where a package must use either the native pthread library or
|
2005-11-04 15:36:23 +01:00
|
|
|
# some pthread package aside from the OPR (e.g. "ptl2") can be solved as
|
|
|
|
# follows:
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
|
|
|
# PTHREAD_OPTS+= native
|
|
|
|
# #
|
|
|
|
# # more package Makefile stuff...
|
|
|
|
# #
|
|
|
|
# .include "../../mk/pthread.buildlink3.mk"
|
|
|
|
#
|
|
|
|
# .if defined(PTHREAD_TYPE) && ${PTHREAD_TYPE} == "none"
|
|
|
|
# . include "../../devel/ptl2/buildlink3.mk"
|
|
|
|
# .endif
|
|
|
|
#
|
|
|
|
# .include "../../mk/bsd.pkg.mk"
|
2005-11-04 15:36:23 +01:00
|
|
|
|
2004-03-18 10:12:08 +01:00
|
|
|
PTHREAD_BUILDLINK3_MK:= ${PTHREAD_BUILDLINK3_MK}+
|
|
|
|
|
2005-11-04 15:36:23 +01:00
|
|
|
# The fall-back package pthread implementation
|
2004-01-04 00:06:43 +01:00
|
|
|
_PKG_PTHREAD?= pth
|
|
|
|
_PKG_PTHREAD_DEPENDS?= pth>=2.0.0
|
|
|
|
_PKG_PTHREAD_PKGSRCDIR?= ../../devel/${_PKG_PTHREAD}
|
|
|
|
_PKG_PTHREAD_BUILDLINK3_MK?= ${_PKG_PTHREAD_PKGSRCDIR}/buildlink3.mk
|
2005-11-04 15:36:23 +01:00
|
|
|
|
|
|
|
# _PKG_PTHREAD_COMPAT_PATTERNS matches the ONLY_FOR_PLATFORMS from the
|
|
|
|
# Makefile for ${_PKG_PTHREAD}. It is used to see if ${_PKG_PTHREADS}
|
|
|
|
# can actually be used to replace a native pthreads.
|
2004-01-04 00:06:43 +01:00
|
|
|
_PKG_PTHREAD_COMPAT_PATTERNS= *-*-*
|
|
|
|
|
|
|
|
.include "../../mk/bsd.prefs.mk"
|
|
|
|
|
|
|
|
PTHREAD_OPTS?= # empty
|
|
|
|
#
|
|
|
|
# We check for a native pthreads implementation by checking for the presence
|
|
|
|
# of /usr/include/pthread.h (we might want to make this check stricter).
|
|
|
|
#
|
|
|
|
.undef PTHREAD_TYPE
|
2004-11-12 06:20:01 +01:00
|
|
|
.if exists(/usr/include/pthread.h) && \
|
|
|
|
!empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
|
2004-01-04 00:06:43 +01:00
|
|
|
PTHREAD_TYPE= native
|
|
|
|
.else
|
|
|
|
. if !empty(PTHREAD_OPTS:Mnative)
|
|
|
|
PTHREAD_TYPE= none
|
|
|
|
. if !empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
|
|
|
|
PKG_SKIP_REASON= "${PKGNAME} requires a native pthreads implementation."
|
|
|
|
. endif
|
|
|
|
. else
|
|
|
|
PTHREAD_TYPE= none
|
|
|
|
. for _pattern_ in ${_PKG_PTHREAD_COMPAT_PATTERNS}
|
|
|
|
. if !empty(MACHINE_PLATFORM:M${_pattern_})
|
|
|
|
PTHREAD_TYPE= ${_PKG_PTHREAD}
|
|
|
|
. endif
|
|
|
|
. endfor
|
|
|
|
. if ${PTHREAD_TYPE} == "none" && \
|
|
|
|
!empty(PTHREAD_OPTS:Mrequire) && empty(PTHREAD_OPTS:Moptional)
|
|
|
|
PKG_SKIP_REASON= "${PKGNAME} requires a working pthreads implementation."
|
|
|
|
. endif
|
|
|
|
. endif
|
|
|
|
.endif
|
|
|
|
|
2004-11-25 20:34:03 +01:00
|
|
|
PTHREAD_AUTO_VARS?= no
|
2004-11-17 22:05:24 +01:00
|
|
|
|
2004-01-04 00:06:43 +01:00
|
|
|
.if ${PTHREAD_TYPE} == "native"
|
2004-11-12 06:20:01 +01:00
|
|
|
BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Npthread}
|
|
|
|
BUILDLINK_PACKAGES+= pthread
|
2006-07-09 01:10:35 +02:00
|
|
|
BUILDLINK_ORDER:= ${BUILDLINK_ORDER} ${BUILDLINK_DEPTH}pthread
|
2004-11-12 06:20:01 +01:00
|
|
|
BUILDLINK_BUILTIN_MK.pthread= ../../mk/pthread.builtin.mk
|
2004-11-17 22:05:24 +01:00
|
|
|
BUILDLINK_AUTO_VARS.pthread?= ${PTHREAD_AUTO_VARS}
|
2004-01-04 00:06:43 +01:00
|
|
|
.elif ${PTHREAD_TYPE} == "${_PKG_PTHREAD}"
|
|
|
|
. if exists(${_PKG_PTHREAD_BUILDLINK3_MK})
|
|
|
|
. if !empty(_PKG_PTHREAD_DEPENDS)
|
2006-04-06 08:21:32 +02:00
|
|
|
BUILDLINK_API_DEPENDS.${_PKG_PTHREAD}+= ${_PKG_PTHREAD_DEPENDS}
|
2004-01-04 00:06:43 +01:00
|
|
|
. endif
|
|
|
|
. include "${_PKG_PTHREAD_BUILDLINK3_MK}"
|
2004-11-12 06:20:01 +01:00
|
|
|
BUILDLINK_PREFIX.pthread= ${BUILDLINK_PREFIX.${_PKG_PTHREAD}}
|
|
|
|
BUILDLINK_CFLAGS.pthread= ${BUILDLINK_CFLAGS.${_PKG_PTHREAD}}
|
|
|
|
BUILDLINK_CPPFLAGS.${_PKG_PTHREAD}?= -D_REENTRANT
|
|
|
|
BUILDLINK_CPPFLAGS.pthread= ${BUILDLINK_CPPFLAGS.${_PKG_PTHREAD}}
|
|
|
|
BUILDLINK_LDFLAGS.pthread= ${BUILDLINK_LDFLAGS.${_PKG_PTHREAD}}
|
|
|
|
BUILDLINK_LIBS.${_PKG_PTHREAD}?= -lpthread
|
|
|
|
BUILDLINK_LIBS.pthread= ${BUILDLINK_LIBS.${_PKG_PTHREAD}}
|
2004-11-17 22:05:24 +01:00
|
|
|
BUILDLINK_AUTO_VARS.${_PKG_PTHREAD}?= ${PTHREAD_AUTO_VARS}
|
|
|
|
BUILDLINK_AUTO_VARS.pthread= ${BUILDLINK_AUTO_VARS.${_PKG_PTHREAD}}
|
2004-01-04 00:06:43 +01:00
|
|
|
. else
|
2005-04-13 18:16:50 +02:00
|
|
|
PKG_SKIP_REASON= ${PKGNAME:Q}" needs pthreads, but "${_PKG_PTHREAD_BUILDLINK3_MK:Q}" is missing."
|
2004-01-04 00:06:43 +01:00
|
|
|
. endif
|
|
|
|
.endif
|
|
|
|
|
2004-03-18 10:12:08 +01:00
|
|
|
.if !empty(PTHREAD_BUILDLINK3_MK:M+)
|
|
|
|
#
|
2004-11-12 06:20:01 +01:00
|
|
|
# Define user-visible PTHREAD_{CFLAGS,LDFLAGS,LIBS} as compiler options
|
|
|
|
# used to compile/link pthreaded code.
|
2004-01-04 00:06:43 +01:00
|
|
|
#
|
|
|
|
PTHREAD_CFLAGS= ${BUILDLINK_CFLAGS.pthread}
|
2004-11-12 06:20:01 +01:00
|
|
|
PTHREAD_CFLAGS+= ${BUILDLINK_CPPFLAGS.pthread}
|
|
|
|
PTHREAD_LDFLAGS= ${BUILDLINK_LDFLAGS.pthread}
|
|
|
|
PTHREAD_LIBS= ${BUILDLINK_LIBS.pthread}
|
2005-04-13 18:16:50 +02:00
|
|
|
CONFIGURE_ENV+= PTHREAD_CFLAGS=${PTHREAD_CFLAGS:Q}
|
|
|
|
CONFIGURE_ENV+= PTHREAD_LDFLAGS=${PTHREAD_LDFLAGS:Q}
|
|
|
|
CONFIGURE_ENV+= PTHREAD_LIBS=${PTHREAD_LIBS:Q}
|
|
|
|
MAKE_ENV+= PTHREAD_CFLAGS=${PTHREAD_CFLAGS:Q}
|
|
|
|
MAKE_ENV+= PTHREAD_LDFLAGS=${PTHREAD_LDFLAGS:Q}
|
|
|
|
MAKE_ENV+= PTHREAD_LIBS=${PTHREAD_LIBS:Q}
|
2004-01-04 00:06:43 +01:00
|
|
|
|
|
|
|
PTHREADBASE= ${BUILDLINK_PREFIX.pthread}
|
2005-04-13 18:16:50 +02:00
|
|
|
CONFIGURE_ENV+= PTHREADBASE=${PTHREADBASE:Q}
|
|
|
|
MAKE_ENV+= PTHREADBASE=${PTHREADBASE:Q}
|
2004-11-12 06:20:01 +01:00
|
|
|
|
2004-01-04 00:06:43 +01:00
|
|
|
.endif # PTHREAD_BUILDLINK3_MK
|