1 # $NetBSD: pthread.builtin.mk,v 1.12 2012/05/04 07:24:50 obache Exp $
5 BUILTIN_FIND_LIBS
:= pthread c_r rt
6 BUILTIN_FIND_FILES_VAR
= H_PTHREAD
7 BUILTIN_FIND_FILES.H_PTHREAD
= /usr
/include/pthread.h \
8 /boot
/develop
/headers
/posix
/pthread.h
10 .
include "../../mk/buildlink3/bsd.builtin.mk"
13 ### Determine if there is a built-in implementation of the package and
14 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
16 .if
!defined
(IS_BUILTIN.pthread
)
17 IS_BUILTIN.pthread
= no
18 . if empty
(H_PTHREAD
:M
${LOCALBASE}/*) && exists
(${H_PTHREAD})
19 IS_BUILTIN.pthread
= yes
22 MAKEVARS
+= IS_BUILTIN.pthread
25 ### Determine whether we should use the built-in implementation if it
26 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
29 # We ignore the value of PREFER_PKGSRC and PREFER_NATIVE. Whether we
30 # prefer one or the other is dependent on the value of
31 # PREFER_NATIVE_PTHREADS, which is yes/no.
33 .if
!defined
(USE_BUILTIN.pthread
)
34 USE_BUILTIN.pthread
= ${IS_BUILTIN.pthread
}
35 . if
!empty
(PREFER_NATIVE_PTHREADS
:M
[nN
][oO
])
36 USE_BUILTIN.pthread
= no
39 MAKEVARS
+= USE_BUILTIN.pthread
42 ### The section below only applies if we are not including this file
43 ### solely to determine whether a built-in implementation exists.
45 CHECK_BUILTIN.pthread?
= no
46 .if
!empty
(CHECK_BUILTIN.pthread
:M
[nN
][oO
])
48 . if
!empty
(USE_BUILTIN.pthread
:M
[yY
][eE
][sS
])
49 BUILDLINK_PREFIX.pthread
= /usr
50 . if empty
(H_PTHREAD
:M__nonexistent__
)
51 . if
!empty
(H_PTHREAD
:M
/usr
/*)
52 BUILDLINK_PREFIX.pthread
= /usr
54 BUILDLINK_PREFIX.pthread
= # empty
57 BUILDLINK_CFLAGS.pthread
= # empty
58 BUILDLINK_LDFLAGS.pthread
= # empty
60 # only pass -pthread on platforms known to support it.
62 # XXX This should really be a check for GCC!
64 BUILDLINK_OPSYS_SUPPORT_PTHREAD
= DragonFly FreeBSD Linux MirBSD NetBSD OpenBSD
65 . if
!empty
(BUILDLINK_OPSYS_SUPPORT_PTHREAD
:M
${OPSYS})
66 BUILDLINK_CFLAGS.pthread
+= -pthread
67 BUILDLINK_LDFLAGS.pthread
+= -pthread
68 . elif
${OPSYS} == "OSF1"
69 BUILDLINK_CFLAGS.pthread
+= -pthread
72 BUILDLINK_CPPFLAGS.pthread
+= -D_REENTRANT
74 . if
${OPSYS} == "FreeBSD"
75 BUILDLINK_CPPFLAGS.pthread
+= -D_THREAD_SAFE
78 # Handle systems which have pthreads functions in libc_r such as
79 # FreeBSD 5.x, or fall back to libc if we don't find libc_r.
81 . if
${OPSYS} == "NetBSD"
82 BUILDLINK_LIBS.pthread
= # empty
83 . elif
!empty
(BUILTIN_LIB_FOUND.pthread
:M
[yY
][eE
][sS
])
84 BUILDLINK_LIBS.pthread
= -lpthread
85 . if
!empty
(BUILTIN_LIB_FOUND.rt
:M
[yY
][eE
][sS
])
86 BUILDLINK_LIBS.pthread
+= -lrt
88 . elif
!empty
(BUILTIN_LIB_FOUND.c_r
:M
[yY
][eE
][sS
])
89 BUILDLINK_LIBS.pthread
= -lc_r
91 BUILDLINK_LIBS.pthread
= # empty
95 .
endif # CHECK_BUILTIN.pthread