summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2004-11-25 21:33:36 +0000
committerjlam <jlam@pkgsrc.org>2004-11-25 21:33:36 +0000
commit317c335c7a2a1e9fe80c997f09a4cfc34eab13d0 (patch)
treefbde1b1b76ee7c6985a9504e23c69509d4bf8721
parent5f7a595c12d89cefac7ba6726a36357fdd84b26f (diff)
downloadpkgsrc-317c335c7a2a1e9fe80c997f09a4cfc34eab13d0.tar.gz
dlopen.buildlink3.mk should be added to packages that use dlopen() to
load shared objects. Some 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. Including dlopen.buildlink3.mk in a package Makefile will cause pthread.buildlink3.mk to also be included. It is up to the package to ensure that PTHREAD_{CFLAGS,LDFLAGS,LIBS} (defined by pthread.buildlink3.mk) are passed to the compiler when building/linking the applications, possibly by setting PTHREAD_AUTO_VARS to "yes" in the package Makefile.
-rw-r--r--mk/bsd.pkg.mk10
-rw-r--r--mk/dlopen.buildlink3.mk35
2 files changed, 44 insertions, 1 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index cf47afa2595..ca3c7f77859 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1540 2004/11/17 22:55:14 jlam Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1541 2004/11/25 21:33:36 jlam Exp $
#
# This file is in the public domain.
#
@@ -349,6 +349,14 @@ MAKEFLAGS+= PERL5_ARCHLIB=${PERL5_ARCHLIB:Q}
. endif # !defined(PERL5_*)
.endif # USE_PERL5 == run
+# _DLOPEN_REQUIRE_PTHREADS is defined by dlopen.buildlink3.mk.
+.if defined(_DLOPEN_REQUIRE_PTHREADS) && \
+ !empty(_DLOPEN_REQUIRE_PTHREADS:M[yY][eE][sS])
+. if !empty(USE_BUILDLINK3:M[yY][eE][sS])
+. include "../../mk/pthread.buildlink3.mk"
+. endif
+.endif
+
.if defined(USE_FORTRAN)
. if !exists(/usr/bin/f77)
PKG_FC?= f2c-f77
diff --git a/mk/dlopen.buildlink3.mk b/mk/dlopen.buildlink3.mk
new file mode 100644
index 00000000000..40907688e82
--- /dev/null
+++ b/mk/dlopen.buildlink3.mk
@@ -0,0 +1,35 @@
+# $NetBSD: dlopen.buildlink3.mk,v 1.1 2004/11/25 21:33:37 jlam Exp $
+#
+# This Makefile fragment is included by package Makefiles and
+# buildlink3.mk files for the packages that use dlopen().
+#
+# 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.
+#
+# Including pthread.buildlink3.mk is deferred until bsd.pkg.mk.
+
+.include "../../mk/bsd.prefs.mk"
+
+# 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:${_pattern_})
+_DLOPEN_REQUIRE_PTHREADS= yes
+. endif
+.endfor
+
+.if defined(DLOPEN_REQUIRE_PTHREADS)
+_DLOPEN_REQUIRE_PTHREADS= ${DLOPEN_REQUIRE_PTHREADS}
+.else
+DLOPEN_REQUIRE_PTHREADS= ${_DLOPEN_REQUIRE_PTHREADS}
+.endif