1 # $NetBSD: dlopen.builtin.mk,v 1.13 2005/06/09 05:59:51 jlam 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
46 _BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS= \
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-*
52 .if !defined(_BLNK_DLOPEN_REQUIRE_PTHREADS)
53 _BLNK_DLOPEN_REQUIRE_PTHREADS?= no
54 . for _pattern_ in ${_BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS}
55 . if !empty(MACHINE_PLATFORM:M${_pattern_})
56 . if !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
57 _BLNK_DLOPEN_REQUIRE_PTHREADS= yes
62 MAKEVARS+= _BLNK_DLOPEN_REQUIRE_PTHREADS
64 # DLOPEN_REQUIRE_PTHREADS is a user- and package-settable yes/no variable
65 # whose value decides whether pthread.buildlink3.mk is automatically
66 # included or not. Its default value depends on whether native
69 .if defined(DLOPEN_REQUIRE_PTHREADS)
70 _BLNK_DLOPEN_REQUIRE_PTHREADS:= ${DLOPEN_REQUIRE_PTHREADS}
72 DLOPEN_REQUIRE_PTHREADS= ${_BLNK_DLOPEN_REQUIRE_PTHREADS}
76 ### The section below only applies if we are not including this file
77 ### solely to determine whether a built-in implementation exists.
80 .if !empty(CHECK_BUILTIN.dl:M[nN][oO])
82 . if !empty(USE_BUILTIN.dl:M[yY][eE][sS])
83 BUILDLINK_PREFIX.dl= /usr
84 . if !empty(BUILTIN_LIB_FOUND.dl:M[yY][eE][sS])
86 # No need to add this to BUILDLINK_LIBS.dl since most GNU configure
87 # scripts already check for -ldl themselves.
89 BUILDLINK_LDADD.dl= -ldl
91 . if !empty(_BLNK_DLOPEN_REQUIRE_PTHREADS:M[yY][eE][sS])
92 BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
93 . include "../../mk/pthread.buildlink3.mk"
94 BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
95 . include "../../mk/pthread.builtin.mk"
96 BUILDLINK_CFLAGS.dl+= ${PTHREAD_CFLAGS}
97 BUILDLINK_LDFLAGS.dl+= ${PTHREAD_LDFLAGS}
98 BUILDLINK_LIBS.dl+= ${PTHREAD_LIBS}
102 .endif # CHECK_BUILTIN.dl