diff --git a/configure.ac b/configure.ac index b891ab7..829a8bf 100755 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ ############################################################################# # Configuration for ctools - tools for science analysis of CTA data # # ------------------------------------------------------------------------- # -# Copyright (C) 2011-2020 Juergen Knoedlseder # +# Copyright (C) 2011-2021 Juergen Knoedlseder # # ------------------------------------------------------------------------- # # # # This program is free software: you can redistribute it and/or modify # @@ -360,6 +360,13 @@ AC_SUBST(RUNSHARED) ############################################################################# +# Determine values of RTLD_GLOBAL and RTLD_NOW # +############################################################################# +AX_DLFLAGS(RTLD_GLOBAL) +AX_DLFLAGS(RTLD_NOW) + + +############################################################################# # Set -arch flags for universal builds on OSX and tweak BASECFLAGS based on # # compiler and platform (note that BASECFLAGS are not yet used). # ############################################################################# diff --git a/m4/ax_dlflags.m4 b/m4/ax_dlflags.m4 new file mode 100644 index 0000000..c850fdb --- /dev/null +++ b/m4/ax_dlflags.m4 @@ -0,0 +1,52 @@ +# =========================================================================== +# +# SYNOPSIS +# +# AX_DLFLAGS +# +# DESCRIPTION +# +# This macro determines the value of a DL flags such as RTLD_GLOBAL or +# RTLD_NOW from the dlfcn.h file. +# +# USAGE +# +# AX_DLFLAGS(RTLD_GLOBAL) +# AC_MSG_RESULT($DLFLAGS_RTLD_GLOBAL) +# +# LICENSE +# +# Copyright (c) 2021 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +#serial 8 + +AC_DEFUN([AX_DLFLAGS], [ + DLFLAGS_$1="" + AC_CHECK_HEADERS([dlfcn.h]) + AS_IF([test "x$ac_cv_header_dlfcn_h" = "xyes"],[ + AC_MSG_CHECKING([for value of $1]) + for flags in 1 2 4 8 16 32 64 128 256 512 ; do + AC_EGREP_CPP([test_true],[ + #include + #if defined($1) && $1 == $flags + test_true + #endif + ],[DLFLAGS_$1=$flags],[]) + done + ]) + AC_MSG_RESULT($DLFLAGS_$1) + AC_SUBST([DLFLAGS_$1]) +]) diff --git a/pyext/ctools/__init__.py.in b/pyext/ctools/__init__.py.in index e6c4661..9ece481 100755 --- a/pyext/ctools/__init__.py.in +++ b/pyext/ctools/__init__.py.in @@ -20,9 +20,18 @@ # import gammalib first import gammalib +# Make sur that library symbols are exported by setting the dynamic library +# loading flag to RTLD_GLOBAL | RTLD_NOW. This is necessary on some systems. +import sys +flags = sys.getdlopenflags() +sys.setdlopenflags(@DLFLAGS_RTLD_GLOBAL@ | @DLFLAGS_RTLD_NOW@) + # Import sub modules from @PYTHON_RELATIVE_IMPORT@tools import * +# Reset original flags +sys.setdlopenflags(flags) + # Remove swig register stuff bad_entries = [entry for entry in list(locals()) if entry.endswith('_swigregister')]