1 # $NetBSD: pthread.builtin.mk,v 1.9 2005/06/09 06:03:40 jlam 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
9 .include "../../mk/buildlink3/bsd.builtin.mk"
12 ### Determine if there is a built-in implementation of the package and
13 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
15 .if !defined(IS_BUILTIN.pthread)
16 IS_BUILTIN.pthread= no
17 . if empty(H_PTHREAD:M${LOCALBASE}/*) && exists(${H_PTHREAD})
18 IS_BUILTIN.pthread= yes
21 MAKEVARS+= IS_BUILTIN.pthread
24 ### Determine whether we should use the built-in implementation if it
25 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
28 # We ignore the value of PREFER_PKGSRC and PREFER_NATIVE. Whether we
29 # prefer one or the other is dependent on the value of
30 # PREFER_NATIVE_PTHREADS, which is yes/no.
32 .if !defined(USE_BUILTIN.pthread)
33 USE_BUILTIN.pthread= ${IS_BUILTIN.pthread}
34 . if !empty(PREFER_NATIVE_PTHREADS:M[nN][oO])
35 USE_BUILTIN.pthread= no
38 MAKEVARS+= USE_BUILTIN.pthread
41 ### The section below only applies if we are not including this file
42 ### solely to determine whether a built-in implementation exists.
44 CHECK_BUILTIN.pthread?= no
45 .if !empty(CHECK_BUILTIN.pthread:M[nN][oO])
47 . if !empty(USE_BUILTIN.pthread:M[yY][eE][sS])
48 BUILDLINK_PREFIX.pthread= /usr
49 BUILDLINK_CFLAGS.pthread= # empty
50 BUILDLINK_LDFLAGS.pthread= # empty
52 # only pass -pthread on platforms known to support it.
54 # XXX This should really be a check for GCC!
56 BUILDLINK_OPSYS_SUPPORT_PTHREAD= DragonFly FreeBSD Linux NetBSD
57 . if !empty(BUILDLINK_OPSYS_SUPPORT_PTHREAD:M${OPSYS})
58 BUILDLINK_CFLAGS.pthread+= -pthread
59 BUILDLINK_LDFLAGS.pthread+= -pthread
60 . elif ${OPSYS} == "OSF1"
61 BUILDLINK_CFLAGS.pthread+= -pthread
64 BUILDLINK_CPPFLAGS.pthread+= -D_REENTRANT
66 . if ${OPSYS} == "FreeBSD"
67 BUILDLINK_CPPFLAGS.pthread+= -D_THREAD_SAFE
70 # Handle systems which have pthreads functions in libc_r such as
71 # FreeBSD 5.x, or fall back to libc if we don't find libc_r.
73 . if ${OPSYS} == "NetBSD"
74 BUILDLINK_LIBS.pthread= # empty
75 . elif !empty(BUILTIN_LIB_FOUND.pthread:M[yY][eE][sS])
76 BUILDLINK_LIBS.pthread= -lpthread
77 . if !empty(BUILTIN_LIB_FOUND.rt:M[yY][eE][sS])
78 BUILDLINK_LIBS.pthread+= -lrt
80 . elif !empty(BUILTIN_LIB_FOUND.c_r:M[yY][eE][sS])
81 BUILDLINK_LIBS.pthread= -lc_r
83 BUILDLINK_LIBS.pthread= # empty
87 .endif # CHECK_BUILTIN.pthread