Commit 21f54c53b96c7a70ec2a0b4472578c7c70838ee2
1 parent
cba5a8c1
Autodetect RTLD_GLOBAL and RTLD_NOW values and use those in __init__.py.in (#35)
Showing
3 changed files
with
64 additions
and
14 deletions
configure.ac
| ... | ... | @@ -289,21 +289,17 @@ AC_MSG_CHECKING([for the shared library paths environment variable]) |
| 289 | 289 | case $ac_sys_system in |
| 290 | 290 | BeOS*) |
| 291 | 291 | SHAREDSUFFIX='.so' |
| 292 | - DLFLAGS=258 | |
| 293 | 292 | ;; |
| 294 | 293 | CYGWIN*) |
| 295 | 294 | SHAREDSUFFIX='.dll.a' |
| 296 | - DLFLAGS=258 | |
| 297 | 295 | ;; |
| 298 | 296 | SunOS*) |
| 299 | 297 | SHAREDSUFFIX='.so' |
| 300 | 298 | RUNSHARED='LD_LIBRARY_PATH' |
| 301 | - DLFLAGS=258 | |
| 302 | 299 | ;; |
| 303 | 300 | Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*) |
| 304 | 301 | SHAREDSUFFIX='.so' |
| 305 | 302 | RUNSHARED='LD_LIBRARY_PATH' |
| 306 | - DLFLAGS=258 | |
| 307 | 303 | ;; |
| 308 | 304 | hp*|HP*) |
| 309 | 305 | case `uname -m` in |
| ... | ... | @@ -315,33 +311,34 @@ case $ac_sys_system in |
| 315 | 311 | ;; |
| 316 | 312 | esac |
| 317 | 313 | RUNSHARED='SHLIB_PATH' |
| 318 | - DLFLAGS=258 | |
| 319 | 314 | ;; |
| 320 | 315 | OSF*) |
| 321 | 316 | SHAREDSUFFIX='.so' |
| 322 | 317 | RUNSHARED='LD_LIBRARY_PATH' |
| 323 | - DLFLAGS=258 | |
| 324 | 318 | ;; |
| 325 | 319 | atheos*) |
| 326 | 320 | SHAREDSUFFIX='.so' |
| 327 | 321 | RUNSHARED='DLL_PATH' |
| 328 | - DLFLAGS=258 | |
| 329 | 322 | ;; |
| 330 | 323 | Darwin*) |
| 331 | 324 | SHAREDSUFFIX='.dylib' |
| 332 | 325 | RUNSHARED='DYLD_LIBRARY_PATH' |
| 333 | - DLFLAGS=10 | |
| 334 | 326 | ;; |
| 335 | 327 | AIX*) |
| 336 | 328 | SHAREDSUFFIX='.so' |
| 337 | 329 | RUNSHARED='LIBPATH' |
| 338 | - DLFLAGS=258 | |
| 339 | 330 | ;; |
| 340 | 331 | esac |
| 341 | 332 | AC_MSG_RESULT($RUNSHARED) |
| 342 | 333 | AC_SUBST(SHAREDSUFFIX) |
| 343 | 334 | AC_SUBST(RUNSHARED) |
| 344 | -AC_SUBST(DLFLAGS) | |
| 335 | + | |
| 336 | + | |
| 337 | +############################################################################# | |
| 338 | +# Determine values of RTLD_GLOBAL and RTLD_NOW # | |
| 339 | +############################################################################# | |
| 340 | +AX_DLFLAGS(RTLD_GLOBAL) | |
| 341 | +AX_DLFLAGS(RTLD_NOW) | |
| 345 | 342 | |
| 346 | 343 | |
| 347 | 344 | ############################################################################# | ... | ... |
m4/ax_dlflags.m4
0 → 100644
| 1 | +# =========================================================================== | |
| 2 | +# | |
| 3 | +# SYNOPSIS | |
| 4 | +# | |
| 5 | +# AX_DLFLAGS | |
| 6 | +# | |
| 7 | +# DESCRIPTION | |
| 8 | +# | |
| 9 | +# This macro determines the value of a DL flags such as RTLD_GLOBAL or | |
| 10 | +# RTLD_NOW from the dlfcn.h file. | |
| 11 | +# | |
| 12 | +# USAGE | |
| 13 | +# | |
| 14 | +# AX_DLFLAGS(RTLD_GLOBAL) | |
| 15 | +# AC_MSG_RESULT($DLFLAGS_RTLD_GLOBAL) | |
| 16 | +# | |
| 17 | +# LICENSE | |
| 18 | +# | |
| 19 | +# Copyright (c) 2021 Juergen Knodlseder | |
| 20 | +# | |
| 21 | +# This program is free software: you can redistribute it and/or modify | |
| 22 | +# it under the terms of the GNU General Public License as published by | |
| 23 | +# the Free Software Foundation, either version 3 of the License, or | |
| 24 | +# (at your option) any later version. | |
| 25 | +# | |
| 26 | +# This program is distributed in the hope that it will be useful, | |
| 27 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 28 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 29 | +# GNU General Public License for more details. | |
| 30 | +# | |
| 31 | +# You should have received a copy of the GNU General Public License | |
| 32 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 33 | + | |
| 34 | +#serial 8 | |
| 35 | + | |
| 36 | +AC_DEFUN([AX_DLFLAGS], [ | |
| 37 | + DLFLAGS_$1="" | |
| 38 | + AC_CHECK_HEADERS([dlfcn.h]) | |
| 39 | + AS_IF([test "x$ac_cv_header_dlfcn_h" = "xyes"],[ | |
| 40 | + AC_MSG_CHECKING([for value of $1]) | |
| 41 | + for flags in 1 2 4 8 16 32 64 128 256 512 ; do | |
| 42 | + AC_EGREP_CPP([test_true],[ | |
| 43 | + #include <dlfcn.h> | |
| 44 | + #if defined($1) && $1 == $flags | |
| 45 | + test_true | |
| 46 | + #endif | |
| 47 | + ],[DLFLAGS_$1=$flags],[]) | |
| 48 | + done | |
| 49 | + ]) | |
| 50 | + AC_MSG_RESULT($DLFLAGS_$1) | |
| 51 | + AC_SUBST([DLFLAGS_$1]) | |
| 52 | +]) | ... | ... |
pyext/gammalib/__init__.py.in
| ... | ... | @@ -18,11 +18,12 @@ |
| 18 | 18 | # |
| 19 | 19 | # ========================================================================== |
| 20 | 20 | |
| 21 | -# Make sur that library symbols are exported by setting the RTLD_GLOBAL flag. | |
| 22 | -# This is necessary on some systems. | |
| 21 | +# Make sur that library symbols are exported by setting the dynamic library | |
| 22 | +# loading flag to RTLD_GLOBAL | RTLD_NOWflag. This is necessary on some | |
| 23 | +# systems. | |
| 23 | 24 | import sys |
| 24 | -flags = sys.getdlopenflags() # Get original flags | |
| 25 | -sys.setdlopenflags(@DLFLAGS@) # Set RTLD_GLOBAL | RTLD_NOW | |
| 25 | +flags = sys.getdlopenflags() | |
| 26 | +sys.setdlopenflags(@DLFLAGS_RTLD_GLOBAL@ | @DLFLAGS_RTLD_NOW@) | |
| 26 | 27 | |
| 27 | 28 | # Import modules |
| 28 | 29 | from gammalib.app import * | ... | ... |