Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / pthread.builtin.mk
blob927802715db7b4af2d22cb515d5ea6c7168bae30
1 # $NetBSD: pthread.builtin.mk,v 1.12 2012/05/04 07:24:50 obache Exp $
3 BUILTIN_PKG:= pthread
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"
12 ###
13 ### Determine if there is a built-in implementation of the package and
14 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
15 ###
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
20 . endif
21 .endif
22 MAKEVARS+= IS_BUILTIN.pthread
24 ###
25 ### Determine whether we should use the built-in implementation if it
26 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
27 ###
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
37 . endif
38 .endif
39 MAKEVARS+= USE_BUILTIN.pthread
41 ###
42 ### The section below only applies if we are not including this file
43 ### solely to determine whether a built-in implementation exists.
44 ###
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
53 . else
54 BUILDLINK_PREFIX.pthread= # empty
55 . endif
56 . endif
57 BUILDLINK_CFLAGS.pthread= # empty
58 BUILDLINK_LDFLAGS.pthread= # empty
60 # only pass -pthread on platforms known to support it.
61 # XXX
62 # XXX This should really be a check for GCC!
63 # XXX
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
70 CFLAGS+= -D_REENTRANT
71 . else
72 BUILDLINK_CPPFLAGS.pthread+= -D_REENTRANT
73 . endif
74 . if ${OPSYS} == "FreeBSD"
75 BUILDLINK_CPPFLAGS.pthread+= -D_THREAD_SAFE
76 . endif
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
87 . endif
88 . elif !empty(BUILTIN_LIB_FOUND.c_r:M[yY][eE][sS])
89 BUILDLINK_LIBS.pthread= -lc_r
90 . else
91 BUILDLINK_LIBS.pthread= # empty
92 . endif
93 . endif
95 .endif # CHECK_BUILTIN.pthread