Add files from parent branch HEAD:
[pkgsrc.git] / mk / pthread.builtin.mk
1 # $NetBSD: pthread.builtin.mk,v 1.9 2005/06/09 06:03:40 jlam Exp $
2
3 BUILTIN_PKG:=   pthread
4
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
9 .include "../../mk/buildlink3/bsd.builtin.mk"
10
11 ###
12 ### Determine if there is a built-in implementation of the package and
13 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
14 ###
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
19 .  endif
20 .endif
21 MAKEVARS+=      IS_BUILTIN.pthread
22
23 ###
24 ### Determine whether we should use the built-in implementation if it
25 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
26 ###
27 #
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.
31 #
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
36 .  endif
37 .endif
38 MAKEVARS+=      USE_BUILTIN.pthread
39
40 ###
41 ### The section below only applies if we are not including this file
42 ### solely to determine whether a built-in implementation exists.
43 ###
44 CHECK_BUILTIN.pthread?= no
45 .if !empty(CHECK_BUILTIN.pthread:M[nN][oO])
46
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
51
52 # only pass -pthread on platforms known to support it.
53 # XXX
54 # XXX This should really be a check for GCC!
55 # XXX
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
62 CFLAGS+=                        -D_REENTRANT
63 .    else
64 BUILDLINK_CPPFLAGS.pthread+=    -D_REENTRANT
65 .    endif
66 .    if ${OPSYS} == "FreeBSD"
67 BUILDLINK_CPPFLAGS.pthread+=    -D_THREAD_SAFE
68 .    endif
69
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.
72 #
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
79 .      endif
80 .    elif !empty(BUILTIN_LIB_FOUND.c_r:M[yY][eE][sS])
81 BUILDLINK_LIBS.pthread=         -lc_r
82 .    else
83 BUILDLINK_LIBS.pthread=         # empty
84 .    endif
85 .  endif
86
87 .endif  # CHECK_BUILTIN.pthread