Add files from parent branch HEAD:
[pkgsrc.git] / mk / dlopen.builtin.mk
1 # $NetBSD: dlopen.builtin.mk,v 1.15 2007/10/02 16:20:05 heinz Exp $
2
3 BUILTIN_PKG:=   dl
4
5 BUILTIN_FIND_LIBS:=             dl
6 BUILTIN_FIND_FILES_VAR:=        H_DL
7 BUILTIN_FIND_FILES.H_DL=        /usr/include/dlfcn.h                    \
8                                 /opt/gcc.3.3/include/dlfcn.h
9
10 .include "../../mk/buildlink3/bsd.builtin.mk"
11
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.dl)
17 IS_BUILTIN.dl=  no
18 .  if empty(H_DL:M${LOCALBASE}/*) && exists(${H_DL})
19 IS_BUILTIN.dl=  yes
20 .  endif
21 .endif
22 MAKEVARS+=      IS_BUILTIN.dl
23
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 ###
28 #
29 # We ignore the value of PREFER_PKGSRC and PREFER_NATIVE because for
30 # every platform except for Darwin-[56].*, we can only use the built-in
31 # dynamic linker functions, so USE_BUILTIN.dl must match IS_BUILTIN.dl.
32 #
33 .if !defined(USE_BUILTIN.dl)
34 USE_BUILTIN.dl=         ${IS_BUILTIN.dl}
35 .  if !empty(MACHINE_PLATFORM:MDarwin-[56].*)
36 USE_BUILTIN.dl=         no      # Darwin-[56].* uses devel/dlcompat
37 .  endif
38 .endif
39 MAKEVARS+=      USE_BUILTIN.dl
40
41 # The following platforms require pthreads to be linked into the
42 # application if it uses dlopen() or else the applications will core
43 # dump when they dlopen a shared module that _is_ linked with pthread
44 # support.
45 #
46 _BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS=                                 \
47         NetBSD-2.[0-9]_*-*                                              \
48         NetBSD-2.[0-9]-* NetBSD-2.[0-9].[0-9]*-*                        \
49         NetBSD-2.[0-8][0-9]*-* NetBSD-2.9[0-8]*-*                       \
50         NetBSD-2.99.[0-9]-* NetBSD-2.99.10-*                            \
51         NetBSD-3.[0-9]_*-*                                              \
52         NetBSD-3.[0-9]-* NetBSD-3.[0-9].[0-9]*-*
53
54 .if !defined(_BLNK_DLOPEN_REQUIRE_PTHREADS)
55 _BLNK_DLOPEN_REQUIRE_PTHREADS?= no
56 .  for _pattern_ in ${_BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS}
57 .    if !empty(MACHINE_PLATFORM:M${_pattern_})
58 .      if !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
59 _BLNK_DLOPEN_REQUIRE_PTHREADS=  yes
60 .      endif
61 .    endif
62 .  endfor
63 .endif
64 MAKEVARS+=      _BLNK_DLOPEN_REQUIRE_PTHREADS
65 #
66 # DLOPEN_REQUIRE_PTHREADS is a user- and package-settable yes/no variable
67 #       whose value decides whether pthread.buildlink3.mk is automatically
68 #       included or not.  Its default value depends on whether native
69 #       pthreads exist.
70 #
71 .if defined(DLOPEN_REQUIRE_PTHREADS)
72 _BLNK_DLOPEN_REQUIRE_PTHREADS:= ${DLOPEN_REQUIRE_PTHREADS}
73 .else
74 DLOPEN_REQUIRE_PTHREADS=        ${_BLNK_DLOPEN_REQUIRE_PTHREADS}
75 .endif
76
77 ###
78 ### The section below only applies if we are not including this file
79 ### solely to determine whether a built-in implementation exists.
80 ###
81 CHECK_BUILTIN.dl?=      no
82 .if !empty(CHECK_BUILTIN.dl:M[nN][oO])
83
84 .  if !empty(USE_BUILTIN.dl:M[yY][eE][sS])
85 BUILDLINK_PREFIX.dl=    /usr
86 .    if !empty(BUILTIN_LIB_FOUND.dl:M[yY][eE][sS])
87 #
88 # No need to add this to BUILDLINK_LIBS.dl since most GNU configure
89 # scripts already check for -ldl themselves.
90 #
91 BUILDLINK_LDADD.dl=     -ldl
92 .    endif
93 .    if !empty(_BLNK_DLOPEN_REQUIRE_PTHREADS:M[yY][eE][sS])
94 BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH}+
95 .      include "../../mk/pthread.buildlink3.mk"
96 BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH:S/+$//}
97 .      include "../../mk/pthread.builtin.mk"
98 BUILDLINK_CFLAGS.dl+=   ${PTHREAD_CFLAGS}
99 BUILDLINK_LDFLAGS.dl+=  ${PTHREAD_LDFLAGS}
100 BUILDLINK_LIBS.dl+=     ${PTHREAD_LIBS}
101 .    endif
102 .  endif
103
104 .endif  # CHECK_BUILTIN.dl