1 # Check for binary relocation support.
2 # Written by Hongli Lai
3 # http://autopackage.org/
5 AC_DEFUN([AM_BINRELOC],
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)
12 AC_ARG_ENABLE(binreloc-threads,
13 [ --enable-binreloc-threads compile binary relocation with threads support
15 enable_binreloc_threads=$enableval,enable_binreloc_threads=yes)
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 if test "$bindir" = '${exec_prefix}/bin' -a "$sbindir" = '${exec_prefix}/sbin' -a \
24 "$datadir" = '${prefix}/share' -a "$libdir" = '${exec_prefix}/lib' -a \
25 "$libexecdir" = '${exec_prefix}/libexec' -a "$sysconfdir" = '${prefix}/etc'
27 br_cv_valid_prefixes=yes
29 br_cv_valid_prefixes=no
33 AC_CACHE_CHECK([whether binary relocation support should be enabled],
35 [if test "x$enable_binreloc" = "xyes"; then
37 elif test "x$enable_binreloc" = "xauto"; then
38 if test "x$br_cv_valid_prefixes" = "xyes" -a \
39 "x$ac_cv_file__proc_self_maps" = "xyes"; then
48 if test "x$br_cv_binreloc" = "xyes"; then
49 BINRELOC_CFLAGS="-DENABLE_BINRELOC"
50 AC_DEFINE(ENABLE_BINRELOC,,[Use binary relocation?])
51 if test "x$enable_binreloc_threads" = "xyes"; then
52 AC_CHECK_LIB([pthread], [pthread_getspecific])
55 AC_CACHE_CHECK([whether binary relocation should use threads],
56 [br_cv_binreloc_threads],
57 [if test "x$enable_binreloc_threads" = "xyes"; then
58 if test "x$ac_cv_lib_pthread_pthread_getspecific" = "xyes"; then
59 br_cv_binreloc_threads=yes
61 br_cv_binreloc_threads=no
64 br_cv_binreloc_threads=no
67 if test "x$br_cv_binreloc_threads" = "xyes"; then
68 BINRELOC_LIBS="-lpthread"
69 AC_DEFINE(BR_PTHREAD,1,[Include pthread support for binary relocation?])
71 BINRELOC_CFLAGS="$BINRELOC_CFLAGS -DBR_PTHREADS=0"
72 AC_DEFINE(BR_PTHREAD,0,[Include pthread support for binary relocation?])
75 AC_SUBST(BINRELOC_CFLAGS)
76 AC_SUBST(BINRELOC_LIBS)