1 # $NetBSD: pthread.buildlink3.mk,v 1.28 2009/03/20 19:25:01 joerg Exp $
3 # The pthreads strategy for pkgsrc is to "bless" a particular pthread
4 # package as the Official Pthread Replacement (OPR). The following
5 # variables may be set before including this file:
7 # PTHREAD_OPTS?= # empty
8 # A list of options to configure the search for a suitable pthreads
11 # "native" means that only a native pthreads implementation is
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.
22 # "require" means that the package is skipped silently when no
23 # implementation can be found.
25 # By default, the native pthreads implementation is used if it's
26 # available. Otherwise the OPR is used.
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.
33 # After inclusion of this file, the following variables may be examined:
36 # The type of pthreads implementation that has been found.
38 # "native" means that the native pthreads implementation is used.
40 # "none" means that no suitable pthreads implementation could be
43 # Any other value is the name of the package that is used as the
44 # pthread implementation.
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.
49 # The case where a package must use either the native pthread library or
50 # some pthread package aside from the OPR (e.g. "ptl2") can be solved as
53 # PTHREAD_OPTS+= native
55 # # more package Makefile stuff...
57 # .include "../../mk/pthread.buildlink3.mk"
59 # .if defined(PTHREAD_TYPE) && ${PTHREAD_TYPE} == "none"
60 # . include "../../devel/ptl2/buildlink3.mk"
63 # .include "../../mk/bsd.pkg.mk"
65 PTHREAD_BUILDLINK3_MK
:= ${PTHREAD_BUILDLINK3_MK}+
68 _PKG_VARS.pthread
= PTHREAD_OPTS PTHREAD_AUTO_VARS
69 _SYS_VARS.pthread
= PTHREAD_TYPE PTHREAD_CFLAGS PTHREAD_LDFLAGS PTHREAD_LIBS
71 # The fall-back package pthread implementation
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
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.
80 _PKG_PTHREAD_COMPAT_PATTERNS
= *-*-*
82 .
include "../../mk/bsd.fast.prefs.mk"
84 PTHREAD_OPTS?
= # empty
86 # We check for a native pthreads implementation by checking for the presence
87 # of /usr/include/pthread.h (we might want to make this check stricter).
90 .if
(exists
(/usr
/include/pthread.h
) ||
${OPSYS} == "Haiku") && \
91 !empty
(PREFER_NATIVE_PTHREADS
:M
[yY
][eE
][sS
])
94 . if
!empty
(PTHREAD_OPTS
:Mnative
)
96 . if
!empty
(PTHREAD_OPTS
:Mrequire
) && empty
(PTHREAD_OPTS
:Moptional
)
97 PKG_FAIL_REASON
= "${PKGNAME} requires a native pthreads implementation."
101 . for _pattern_ in
${_PKG_PTHREAD_COMPAT_PATTERNS}
102 . if
!empty
(MACHINE_PLATFORM
:M
${_pattern_})
103 PTHREAD_TYPE
= ${_PKG_PTHREAD}
106 . if
${PTHREAD_TYPE} == "none" && \
107 !empty
(PTHREAD_OPTS
:Mrequire
) && empty
(PTHREAD_OPTS
:Moptional
)
108 PKG_FAIL_REASON
= "${PKGNAME} requires a working pthreads implementation."
113 PTHREAD_AUTO_VARS?
= no
115 .if
${PTHREAD_TYPE} == "native"
116 BUILDLINK_TREE
+= pthread
-pthread
117 BUILDLINK_BUILTIN_MK.pthread
= ..
/..
/mk
/pthread.builtin.mk
118 BUILDLINK_AUTO_VARS.pthread?
= ${PTHREAD_AUTO_VARS}
119 .elif
${PTHREAD_TYPE} == "${_PKG_PTHREAD}"
120 . if exists
(${_PKG_PTHREAD_BUILDLINK3_MK})
121 . if
!empty
(_PKG_PTHREAD_DEPENDS
)
122 BUILDLINK_API_DEPENDS.
${_PKG_PTHREAD}+= ${_PKG_PTHREAD_DEPENDS}
124 .
include "${_PKG_PTHREAD_BUILDLINK3_MK}"
125 BUILDLINK_PREFIX.pthread
= ${BUILDLINK_PREFIX.
${_PKG_PTHREAD}}
126 BUILDLINK_CFLAGS.pthread
= ${BUILDLINK_CFLAGS.
${_PKG_PTHREAD}}
127 BUILDLINK_CPPFLAGS.
${_PKG_PTHREAD}?
= -D_REENTRANT
128 BUILDLINK_CPPFLAGS.pthread
= ${BUILDLINK_CPPFLAGS.
${_PKG_PTHREAD}}
129 BUILDLINK_LDFLAGS.pthread
= ${BUILDLINK_LDFLAGS.
${_PKG_PTHREAD}}
130 BUILDLINK_LIBS.
${_PKG_PTHREAD}?
= -lpthread
131 BUILDLINK_LIBS.pthread
= ${BUILDLINK_LIBS.
${_PKG_PTHREAD}}
132 BUILDLINK_AUTO_VARS.
${_PKG_PTHREAD}?
= ${PTHREAD_AUTO_VARS}
133 BUILDLINK_AUTO_VARS.pthread
= ${BUILDLINK_AUTO_VARS.
${_PKG_PTHREAD}}
135 PKG_FAIL_REASON
= ${PKGNAME
:Q
}" needs pthreads, but "${_PKG_PTHREAD_BUILDLINK3_MK
:Q
}" is missing."
139 .if
!empty
(PTHREAD_BUILDLINK3_MK
:M
+)
141 # Define user-visible PTHREAD_{CFLAGS,LDFLAGS,LIBS} as compiler options
142 # used to compile/link pthreaded code.
144 PTHREAD_CFLAGS
= ${BUILDLINK_CFLAGS.pthread
}
145 PTHREAD_CFLAGS
+= ${BUILDLINK_CPPFLAGS.pthread
}
146 PTHREAD_LDFLAGS
= ${BUILDLINK_LDFLAGS.pthread
}
147 PTHREAD_LIBS
= ${BUILDLINK_LIBS.pthread
}
148 CONFIGURE_ENV
+= PTHREAD_CFLAGS
=${PTHREAD_CFLAGS
:Q
}
149 CONFIGURE_ENV
+= PTHREAD_LDFLAGS
=${PTHREAD_LDFLAGS
:Q
}
150 CONFIGURE_ENV
+= PTHREAD_LIBS
=${PTHREAD_LIBS
:Q
}
151 MAKE_ENV
+= PTHREAD_CFLAGS
=${PTHREAD_CFLAGS
:Q
}
152 MAKE_ENV
+= PTHREAD_LDFLAGS
=${PTHREAD_LDFLAGS
:Q
}
153 MAKE_ENV
+= PTHREAD_LIBS
=${PTHREAD_LIBS
:Q
}
155 PTHREADBASE
= ${BUILDLINK_PREFIX.pthread
}
156 CONFIGURE_ENV
+= PTHREADBASE
=${PTHREADBASE
:Q
}
157 MAKE_ENV
+= PTHREADBASE
=${PTHREADBASE
:Q
}
159 .
endif # PTHREAD_BUILDLINK3_MK