1# Check for binary relocation support. 2# Written by Hongli Lai 3# http://autopackage.org/ 4 5AC_DEFUN([AM_BINRELOC], 6[ 7 AC_ARG_ENABLE(binreloc, 8 [ --enable-binreloc compile with binary relocation support 9 (default=enable when available)], 10 enable_binreloc=$enableval,enable_binreloc=auto) 11 12 AC_ARG_ENABLE(binreloc-threads, 13 [ --enable-binreloc-threads compile binary relocation with threads support 14 (default=yes)], 15 enable_binreloc_threads=$enableval,enable_binreloc_threads=yes) 16 17 BINRELOC_CFLAGS= 18 BINRELOC_LIBS= 19 if test "x$enable_binreloc" = "xauto"; then 20 AC_CHECK_FILE([/proc/self/maps]) 21 AC_CACHE_CHECK([whether everything is installed to the same prefix], 22 [br_cv_valid_prefixes], [ 23 # datarootdir variables was introduced with autoconf-2.60 24 if test "$bindir" = '${exec_prefix}/bin' -a "$sbindir" = '${exec_prefix}/sbin' -a \ 25 \( "$datadir" = '${prefix}/share' -o \( "$datadir" = '${datarootdir}' -a "$datarootdir" = '${prefix}/share' \) \) -a \ 26 "$libdir" = '${exec_prefix}/lib' -a \ 27 "$libexecdir" = '${exec_prefix}/libexec' -a "$sysconfdir" = '${prefix}/etc' 28 then 29 br_cv_valid_prefixes=yes 30 else 31 br_cv_valid_prefixes=no 32 fi 33 ]) 34 fi 35 AC_CACHE_CHECK([whether binary relocation support should be enabled], 36 [br_cv_binreloc], 37 [if test "x$enable_binreloc" = "xyes"; then 38 br_cv_binreloc=yes 39 elif test "x$enable_binreloc" = "xauto"; then 40 if test "x$br_cv_valid_prefixes" = "xyes" -a \ 41 "x$ac_cv_file__proc_self_maps" = "xyes"; then 42 br_cv_binreloc=yes 43 else 44 br_cv_binreloc=no 45 fi 46 else 47 br_cv_binreloc=no 48 fi]) 49 50 if test "x$br_cv_binreloc" = "xyes"; then 51 BINRELOC_CFLAGS="-DENABLE_BINRELOC" 52 AC_DEFINE(ENABLE_BINRELOC,,[Use binary relocation?]) 53 if test "x$enable_binreloc_threads" = "xyes"; then 54 AC_CHECK_LIB([pthread], [pthread_getspecific]) 55 fi 56 57 AC_CACHE_CHECK([whether binary relocation should use threads], 58 [br_cv_binreloc_threads], 59 [if test "x$enable_binreloc_threads" = "xyes"; then 60 if test "x$ac_cv_lib_pthread_pthread_getspecific" = "xyes"; then 61 br_cv_binreloc_threads=yes 62 else 63 br_cv_binreloc_threads=no 64 fi 65 else 66 br_cv_binreloc_threads=no 67 fi]) 68 69 if test "x$br_cv_binreloc_threads" = "xyes"; then 70 BINRELOC_LIBS="-lpthread" 71 AC_DEFINE(BR_PTHREAD,1,[Include pthread support for binary relocation?]) 72 else 73 BINRELOC_CFLAGS="$BINRELOC_CFLAGS -DBR_PTHREADS=0" 74 AC_DEFINE(BR_PTHREAD,0,[Include pthread support for binary relocation?]) 75 fi 76 fi 77 AC_SUBST(BINRELOC_CFLAGS) 78 AC_SUBST(BINRELOC_LIBS) 79]) 80