From 317c335c7a2a1e9fe80c997f09a4cfc34eab13d0 Mon Sep 17 00:00:00 2001 From: jlam Date: Thu, 25 Nov 2004 21:33:36 +0000 Subject: 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. --- mk/bsd.pkg.mk | 10 +++++++++- mk/dlopen.buildlink3.mk | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 mk/dlopen.buildlink3.mk (limited to 'mk') 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 -- cgit v1.2.3