Option to jump with up on keyboard.
[supertux.git] / mk / autoconf / binreloc.m4
1 # Check for binary relocation support
2 # Hongli Lai
3 #   slightly modified by Matze (don't enable automatically)
4 # http://autopackage.org/
5 AC_DEFUN([AM_BINRELOC],
6 [
7         AC_ARG_ENABLE(binreloc,
8                 [  --enable-binreloc       compile with binary relocation support
9                           (default=disabled)],
10                 enable_binreloc=$enableval,enable_binreloc=no)
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                                 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'
26                                 then
27                                         br_cv_valid_prefixes=yes
28                                 else
29                                         br_cv_valid_prefixes=no
30                                 fi
31                                 ])
32         fi
33         AC_CACHE_CHECK([whether binary relocation support should be enabled],
34                        [br_cv_binreloc],
35                        [if test "x$enable_binreloc" = "xyes"; then
36                                br_cv_binreloc=yes
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
40                                        br_cv_binreloc=yes
41                                else
42                                        br_cv_binreloc=no
43                                fi
44                        else
45                                br_cv_binreloc=no
46                        fi])
47
48         if test "x$br_cv_binreloc" = "xyes"; then
49                 #Matze: disabled, because it's already in config.h
50                 #BINRELOC_CFLAGS="-DENABLE_BINRELOC"
51                 AC_DEFINE(ENABLE_BINRELOC,,[Use binary relocation?])
52                 if test "x$enable_binreloc_threads" = "xyes"; then
53                         AC_CHECK_LIB([pthread], [pthread_getspecific])
54                 fi
55
56                 AC_CACHE_CHECK([whether binary relocation should use threads],
57                                [br_cv_binreloc_threads],
58                                [if test "x$enable_binreloc_threads" = "xyes"; then
59                                         if test "x$ac_cv_lib_pthread_pthread_getspecific" = "xyes"; then
60                                                 br_cv_binreloc_threads=yes
61                                         else
62                                                 br_cv_binreloc_threads=no
63                                         fi
64                                 else
65                                         br_cv_binreloc_threads=no
66                                 fi])
67
68                 if test "x$br_cv_binreloc_threads" = "xyes"; then
69                         BINRELOC_LIBS="-lpthread"
70                         AC_DEFINE(BR_PTHREAD,1,[Include pthread support for binary relocation?])
71                 else
72                         BINRELOC_CFLAGS="$BINRELOC_CFLAGS -DBR_PTHREADS=0"
73                         AC_DEFINE(BR_PTHREAD,0,[Include pthread support for binary relocation?])
74                 fi
75         fi
76         AC_SUBST(BINRELOC_CFLAGS)
77         AC_SUBST(BINRELOC_LIBS)
78 ])