update Thu Jun 17 12:37:00 PDT 2010
[pkgsrc.git] / mk / dlopen.builtin.mk
1 # $NetBSD: dlopen.builtin.mk,v 1.22 2010/06/17 18:09:40 drochner 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 # It is not required for NetBSD>=5 if just linked with pthread or using
46 # pthread_mutex_*(), but need if using pthread_create() / pthread_join().
47 #
48 _BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS=                                 \
49         NetBSD-2.[0-9]_*-*                                              \
50         NetBSD-2.[0-9]-* NetBSD-2.[0-9].[0-9]*-*                        \
51         NetBSD-2.[0-8][0-9]*-* NetBSD-2.9[0-8]*-*                       \
52         NetBSD-2.99.[0-9]-* NetBSD-2.99.10-*                            \
53         NetBSD-[3-9]*-*                                                 \
54         NetBSD-[1-9][0-9]*-*
55
56 .if !defined(_BLNK_DLOPEN_REQUIRE_PTHREADS)
57 _BLNK_DLOPEN_REQUIRE_PTHREADS?= no
58 .  for _pattern_ in ${_BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS}
59 .    if !empty(MACHINE_PLATFORM:M${_pattern_})
60 .      if !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
61 _BLNK_DLOPEN_REQUIRE_PTHREADS=  yes
62 .      endif
63 .    endif
64 .  endfor
65 .endif
66 MAKEVARS+=      _BLNK_DLOPEN_REQUIRE_PTHREADS
67 #
68 # DLOPEN_REQUIRE_PTHREADS is a user- and package-settable yes/no variable
69 #       whose value decides whether pthread.buildlink3.mk is automatically
70 #       included or not.  Its default value depends on whether native
71 #       pthreads exist.
72 #
73 .if defined(DLOPEN_REQUIRE_PTHREADS)
74 _BLNK_DLOPEN_REQUIRE_PTHREADS:= ${DLOPEN_REQUIRE_PTHREADS}
75 .else
76 DLOPEN_REQUIRE_PTHREADS=        ${_BLNK_DLOPEN_REQUIRE_PTHREADS}
77 .endif
78
79 ###
80 ### The section below only applies if we are not including this file
81 ### solely to determine whether a built-in implementation exists.
82 ###
83 CHECK_BUILTIN.dl?=      no
84 .if !empty(CHECK_BUILTIN.dl:M[nN][oO])
85
86 .  if !empty(USE_BUILTIN.dl:M[yY][eE][sS])
87 BUILDLINK_PREFIX.dl=    /usr
88 .    if !empty(BUILTIN_LIB_FOUND.dl:M[yY][eE][sS])
89 #
90 # No need to add this to BUILDLINK_LIBS.dl since most GNU configure
91 # scripts already check for -ldl themselves.
92 #
93 BUILDLINK_LDADD.dl=     -ldl
94 .    endif
95 .    if !empty(_BLNK_DLOPEN_REQUIRE_PTHREADS:M[yY][eE][sS])
96 .      include "../../mk/pthread.buildlink3.mk"
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