1 # $NetBSD: dlopen.builtin.mk,v 1.20 2009/03/20 19:25:01 joerg Exp $
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
10 .include "../../mk/buildlink3/bsd.builtin.mk"
13 ### Determine if there is a built-in implementation of the package and
14 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
16 .if !defined(IS_BUILTIN.dl)
18 . if empty(H_DL:M${LOCALBASE}/*) && exists(${H_DL})
22 MAKEVARS+= IS_BUILTIN.dl
25 ### Determine whether we should use the built-in implementation if it
26 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
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.
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
39 MAKEVARS+= USE_BUILTIN.dl
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
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().
48 _BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS= \
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-* \
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
66 MAKEVARS+= _BLNK_DLOPEN_REQUIRE_PTHREADS
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
73 .if defined(DLOPEN_REQUIRE_PTHREADS)
74 _BLNK_DLOPEN_REQUIRE_PTHREADS:= ${DLOPEN_REQUIRE_PTHREADS}
76 DLOPEN_REQUIRE_PTHREADS= ${_BLNK_DLOPEN_REQUIRE_PTHREADS}
80 ### The section below only applies if we are not including this file
81 ### solely to determine whether a built-in implementation exists.
84 .if !empty(CHECK_BUILTIN.dl:M[nN][oO])
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])
90 # No need to add this to BUILDLINK_LIBS.dl since most GNU configure
91 # scripts already check for -ldl themselves.
93 BUILDLINK_LDADD.dl= -ldl
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}
104 .endif # CHECK_BUILTIN.dl