1 # $NetBSD: dlopen.builtin.mk,v 1.23 2010/07/04 16:25:13 obache 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 \
9 /boot
/develop
/headers
/posix
/dlfcn.h
11 .
include "../../mk/buildlink3/bsd.builtin.mk"
14 ### Determine if there is a built-in implementation of the package and
15 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
17 .if
!defined
(IS_BUILTIN.dl
)
19 . if empty
(H_DL
:M
${LOCALBASE}/*) && exists
(${H_DL})
23 MAKEVARS
+= IS_BUILTIN.dl
26 ### Determine whether we should use the built-in implementation if it
27 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
30 # We ignore the value of PREFER_PKGSRC and PREFER_NATIVE because for
31 # every platform except for Darwin-[56].*, we can only use the built-in
32 # dynamic linker functions, so USE_BUILTIN.dl must match IS_BUILTIN.dl.
34 .if
!defined
(USE_BUILTIN.dl
)
35 USE_BUILTIN.dl
= ${IS_BUILTIN.dl
}
36 . if
!empty
(MACHINE_PLATFORM
:MDarwin-
[56].
*)
37 USE_BUILTIN.dl
= no
# Darwin-[56].* uses devel/dlcompat
40 MAKEVARS
+= USE_BUILTIN.dl
42 # The following platforms require pthreads to be linked into the
43 # application if it uses dlopen() or else the applications will core
44 # dump when they dlopen a shared module that _is_ linked with pthread
46 # It is not required for NetBSD>=5 if just linked with pthread or using
47 # pthread_mutex_*(), but need if using pthread_create() / pthread_join().
49 _BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS
= \
51 NetBSD-2.
[0-9]-* NetBSD-2.
[0-9].
[0-9]*-* \
52 NetBSD-2.
[0-8][0-9]*-* NetBSD-2.9
[0-8]*-* \
53 NetBSD-2.99.
[0-9]-* NetBSD-2.99
.10-* \
55 NetBSD-
[1-9][0-9]*-* \
58 .if
!defined
(_BLNK_DLOPEN_REQUIRE_PTHREADS
)
59 _BLNK_DLOPEN_REQUIRE_PTHREADS?
= no
60 . for _pattern_ in
${_BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS}
61 . if
!empty
(MACHINE_PLATFORM
:M
${_pattern_})
62 . if
!empty
(PREFER_NATIVE_PTHREADS
:M
[yY
][eE
][sS
])
63 _BLNK_DLOPEN_REQUIRE_PTHREADS
= yes
68 MAKEVARS
+= _BLNK_DLOPEN_REQUIRE_PTHREADS
70 # DLOPEN_REQUIRE_PTHREADS is a user- and package-settable yes/no variable
71 # whose value decides whether pthread.buildlink3.mk is automatically
72 # included or not. Its default value depends on whether native
75 .if defined
(DLOPEN_REQUIRE_PTHREADS
)
76 _BLNK_DLOPEN_REQUIRE_PTHREADS
:= ${DLOPEN_REQUIRE_PTHREADS}
78 DLOPEN_REQUIRE_PTHREADS
= ${_BLNK_DLOPEN_REQUIRE_PTHREADS}
82 ### The section below only applies if we are not including this file
83 ### solely to determine whether a built-in implementation exists.
86 .if
!empty
(CHECK_BUILTIN.dl
:M
[nN
][oO
])
88 . if
!empty
(USE_BUILTIN.dl
:M
[yY
][eE
][sS
])
89 . if empty
(H_DL
:M__nonexistent__
) && !empty
(H_DL
:M
/usr
/*)
90 BUILDLINK_PREFIX.dl
= /usr
92 . if
!empty
(BUILTIN_LIB_FOUND.dl
:M
[yY
][eE
][sS
])
94 # No need to add this to BUILDLINK_LIBS.dl since most GNU configure
95 # scripts already check for -ldl themselves.
97 BUILDLINK_LDADD.dl
= -ldl
99 . if
!empty
(_BLNK_DLOPEN_REQUIRE_PTHREADS
:M
[yY
][eE
][sS
])
100 .
include "../../mk/pthread.buildlink3.mk"
101 .
include "../../mk/pthread.builtin.mk"
102 BUILDLINK_CFLAGS.dl
+= ${PTHREAD_CFLAGS}
103 BUILDLINK_LDFLAGS.dl
+= ${PTHREAD_LDFLAGS}
104 BUILDLINK_LIBS.dl
+= ${PTHREAD_LIBS}
108 .
endif # CHECK_BUILTIN.dl