summaryrefslogtreecommitdiff
path: root/mk/dlopen.builtin.mk
blob: 9b9478c45d3ff216f5c386d0ec28938304e20274 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# $NetBSD: dlopen.builtin.mk,v 1.2 2004/11/26 08:15:25 jlam Exp $

.for _lib_ in dl
.  if !defined(_BLNK_LIB_FOUND.${_lib_})
_BLNK_LIB_FOUND.${_lib_}!=	\
	if ${TEST} "`${ECHO} /usr/lib/lib${_lib_}.*`" = "/usr/lib/lib${_lib_}.*"; then \
		${ECHO} "no";						\
	elif ${TEST} "`${ECHO} /lib/lib${_lib_}.*`" = "/lib/lib${_lib_}.*"; then \
		${ECHO} "no";						\
	else								\
		${ECHO} "yes";						\
	fi
BUILDLINK_VARS+=	_BLNK_LIB_FOUND.${_lib_}
.  endif
.endfor
.undef _lib_

.if !defined(IS_BUILTIN.dl)
IS_BUILTIN.dl=		no
.  if exists(/usr/include/dlfcn.h)
IS_BUILTIN.dl=		yes
.  endif
BUILDLINK_VARS+=	IS_BUILTIN.dl
.endif	# IS_BUILTIN.pthread

.if !defined(USE_BUILTIN.dl)
USE_BUILTIN.dl=		${IS_BUILTIN.dl}
.  if ${OPSYS} == "Darwin"
USE_BUILTIN.dl=		no	# Darwin uses devel/dlcompat
.  endif
.endif

CHECK_BUILTIN.dl?=	no
.if !empty(CHECK_BUILTIN.dl:M[nN][oO])

.  if !empty(USE_BUILTIN.dl:M[yY][eE][sS])
BUILDLINK_PREFIX.dl=	/usr
.    if !empty(_BLNK_LIB_FOUND.dl:M[yY][eE][sS])
BUILDLINK_LIBS.dl=	-ldl
.    endif
#
# The following platforms require pthreads to be linked into the
# application if it uses dlopen() or else the applications will core
# dump when they dlopen a shared module that _is_ linked with pthread
# support.
#
_DLOPEN_REQUIRE_PTHREAD_PLATFORMS=					\
	NetBSD-2.[0-9]-* NetBSD-2.[0-8][0-9]*-* NetBSD-2.9[0-8]*-*	\
	NetBSD-2.99.[0-9]-* NetBSD-2.99.10-*

_DLOPEN_REQUIRE_PTHREADS?=	no
.    for _pattern_ in ${_DLOPEN_REQUIRE_PTHREAD_PLATFORMS}
.      if !empty(MACHINE_PLATFORM:M${_pattern_})
.        if !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
_DLOPEN_REQUIRE_PTHREADS=	yes
.        endif
.      endif
.    endfor
#
# DLOPEN_REQUIRE_PTHREADS is a user- and package-settable yes/no variable
#	whose value decides whether pthread.buildlink3.mk is automatically
#	included or not.  Its default value depends on whether native
#	pthreads exist.
#
.    if defined(DLOPEN_REQUIRE_PTHREADS)
_DLOPEN_REQUIRE_PTHREADS:=      ${DLOPEN_REQUIRE_PTHREADS}
.    else
DLOPEN_REQUIRE_PTHREADS=        ${_DLOPEN_REQUIRE_PTHREADS}
.    endif
.    if !empty(_DLOPEN_REQUIRE_PTHREADS:M[yY][eE][sS])
BUILDLINK_DEPTH:=	${BUILDLINK_DEPTH}+
.      include "../../mk/pthread.buildlink3.mk"
BUILDLINK_DEPTH:=	${BUILDLINK_DEPTH:S/+$//}
.      include "../../mk/pthread.builtin.mk"
BUILDLINK_CFLAGS.dl+=	${PTHREAD_CFLAGS}
BUILDLINK_LDFLAGS.dl+=	${PTHREAD_LDFLAGS}
BUILDLINK_LIBS.dl+=	${PTHREAD_LIBS}
.    endif
.  endif # USE_BUILTIN.dl == yes

.endif	# CHECK_BUILTIN.dl