/[path-sandbox]/trunk/configure.ac
Gentoo

Diff of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 232 Revision 431
1AC_PREREQ([2.59]) 1AC_PREREQ([2.61])
2AC_INIT([sandbox], [1.2.17], [sandbox@gentoo.org]) 2AC_INIT([sandbox], [1.3.1], [sandbox@gentoo.org])
3sb_configure_opts="$*"
3AM_INIT_AUTOMAKE 4AM_INIT_AUTOMAKE
4AC_CONFIG_HEADER([config.h]) 5AC_CONFIG_HEADER([config.h])
5 6
7AC_DEFINE_UNQUOTED([SANDBOX_CONFIGURE_OPTS], ["${sb_configure_opts}"], [Arguments given to ./configure])
8
6dnl Checks for programs. 9dnl Checks for programs.
7AC_PROG_CC 10AC_PROG_CC
11AM_PROG_CC_C_O
8AC_ISC_POSIX 12AC_ISC_POSIX
9AC_PROG_INSTALL 13AC_PROG_INSTALL
10AC_PROG_MAKE_SET 14AC_PROG_MAKE_SET
11AC_PROG_AWK 15AC_PROG_AWK
12AC_CHECK_PROGS([READELF], [readelf], [false]) 16AC_CHECK_PROGS([READELF], [readelf eu-readelf], [false])
17AM_MISSING_PROG([AUTOM4TE], [autom4te])
13 18
14AC_ENABLE_SHARED 19AC_ENABLE_SHARED
15AC_DISABLE_STATIC 20AC_DISABLE_STATIC
16dnl Next four lines is a hack to prevent libtool checking for CXX/F77 21dnl Next four lines is a hack to prevent libtool checking for CXX/F77
17m4_undefine([AC_PROG_CXX]) 22m4_undefine([AC_PROG_CXX])
26dnl Checks for header files. 31dnl Checks for header files.
27AC_FUNC_ALLOCA 32AC_FUNC_ALLOCA
28AC_HEADER_DIRENT 33AC_HEADER_DIRENT
29AC_HEADER_STDC 34AC_HEADER_STDC
30AC_HEADER_SYS_WAIT 35AC_HEADER_SYS_WAIT
31AC_CHECK_HEADERS([ \ 36AC_CHECK_HEADERS_ONCE([ \
32 fcntl.h limits.h memory.h stddef.h \ 37 dirent.h \
33 stdlib.h string.h strings.h sys/file.h \ 38 dlfcn.h \
34 sys/param.h sys/time.h unistd.h utime.h \ 39 elf.h \
40 errno.h \
41 execinfo.h \
42 fcntl.h \
43 libgen.h \
44 limits.h \
45 memory.h \
46 signal.h \
47 sigsegv.h \
48 stdarg.h \
49 stdbool.h \
50 stddef.h \
51 stdio.h \
52 stdlib.h \
53 string.h \
54 strings.h \
55 syscall.h \
56 unistd.h \
57 utime.h \
58 sys/file.h \
59 sys/mman.h \
60 sys/param.h \
61 sys/stat.h \
62 sys/time.h \
63 sys/types.h \
64 sys/wait.h \
35]) 65])
36 66
37dnl Checks for typedefs, structures, and compiler characteristics. 67dnl Checks for typedefs, structures, and compiler characteristics.
38AC_C_CONST 68AC_C_CONST
39AC_TYPE_UID_T 69AC_TYPE_UID_T
46AC_FUNC_FORK 76AC_FUNC_FORK
47AC_FUNC_LSTAT 77AC_FUNC_LSTAT
48AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK 78AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
49AC_TYPE_SIGNAL 79AC_TYPE_SIGNAL
50AC_FUNC_STAT 80AC_FUNC_STAT
51AC_CHECK_FUNCS([ \ 81AC_CHECK_FUNCS_ONCE([ \
52 bzero ftruncate getcwd lchown memmove \ 82 backtrace \
53 memcpy memset mkdir pathconf realpath \ 83 ftruncate \
54 rmdir setenv strcasecmp strchr strdup \ 84 getcwd \
55 strerror strndup strrchr strspn strstr \ 85 lchown \
86 memmove \
87 memcpy \
88 memset \
89 mkdir \
90 pathconf \
91 realpath \
92 remove \
93 rmdir \
94 setenv \
95 strcasecmp \
96 strchr \
97 strdup \
98 strerror \
99 strndup \
100 strrchr \
101 strspn \
102 strstr \
103 strtok_r \
56]) 104])
105AC_CHECK_LIB([sigsegv], [stackoverflow_install_handler],
106 [HAVE_LIBSIGSEGV=true],
107 [HAVE_LIBSIGSEGV=false])
108AM_CONDITIONAL(HAVE_LIBSIGSEGV, $HAVE_LIBSIGSEGV)
109
110dnl Check if gcc provides va_copy or __va_copy (for librcutil)
111AC_MSG_CHECKING([for va_copy])
112AC_TRY_COMPILE([
113 #include <stdarg.h>
114 ], [
115 va_list ap, aq;
116 va_copy(ap, aq);
117 ],
118 [va_copy="va_copy"],
119 [AC_TRY_COMPILE([
120 #include <stdarg.h>
121 ], [
122 va_list ap, aq;
123 __va_copy(ap, aq);
124 ],
125 [va_copy="__va_copy"],
126 [AC_MSG_ERROR([Unable to determine name of va_copy macro])]
127 )]
128)
129AC_MSG_RESULT([$va_copy])
130if test x"$va_copy" != xva_copy ; then
131 AC_DEFINE_UNQUOTED([va_copy], [$va_copy],
132 [Define to name of va_copy macro proviced by gcc if its not `va_copy'.]
133 )
134fi
135
136dnl Verify people aren't doing stupid shit
137if test x"$enable_static" != xno ; then
138 AC_MSG_ERROR([dont be a Kumba, building a libsandbox.a is stupid])
139fi
140if test x"$enable_shared" != xyes ; then
141 AC_MSG_ERROR([dont be a Kumba, omitting a libsandbox.so is stupid])
142fi
143if echo $CFLAGS | $EGREP -e -static >/dev/null 2>&1; then
144 AC_MSG_ERROR([dont be a Kumba, using -static in CFLAGS is stupid])
145fi
146if echo $LDFLAGS | $EGREP -e -static >/dev/null 2>&1; then
147 AC_MSG_ERROR([dont be a Kumba, using -static in LDFLAGS is stupid])
148fi
57 149
58dnl Some libc's like those on bsd have dlopen() in libc, and not libdl 150dnl Some libc's like those on bsd have dlopen() in libc, and not libdl
59AC_CHECK_LIB([dl], [dlopen], 151AC_CHECK_LIB([dl], [dlopen],
60 [have_libdl="yes"], 152 [have_libdl="yes"],
61 [have_libdl="no"] 153 [have_libdl="no"]
62) 154)
63if test x"$have_libdl" = xyes ; then 155if test x"$have_libdl" = xyes ; then
64 LIBDL="-ldl" 156 LIBDL="-ldl"
65 AC_SUBST([LIBDL]) 157 AC_SUBST([LIBDL])
66 DL_LIB="dl" 158 DL_LIB="dl"
67else 159else
68 DL_LIB="c" 160 DL_LIB="c"
69 AC_CHECK_LIB([c], [dlopen], 161 AC_CHECK_LIB([c], [dlopen],
70 [], 162 [],
71 [AC_MSG_ERROR([Unable to determine library providing dlopen])] 163 [AC_MSG_ERROR([Unable to determine library providing dlopen])]
72 ) 164 )
73fi 165fi
74 166
75dnl uClibc doesn't currently provide dlvsym() so lets 167dnl uClibc doesn't currently provide dlvsym() so lets
76dnl verify the toolchain supports it 168dnl verify the toolchain supports it
77AC_CHECK_LIB([$DL_LIB], [dlvsym], 169AC_CHECK_LIB([$DL_LIB], [dlvsym],
78 [AC_DEFINE([HAVE_DLVSYM], [1], [libdl supports dlvsym])], 170 [AC_DEFINE([HAVE_DLVSYM], [1], [libdl supports dlvsym])],
79 [AC_DEFINE([HAVE_DLVSYM], [0], [libdl does not support dlvsym])] 171 [AC_DEFINE([HAVE_DLVSYM], [0], [libdl does not support dlvsym])]
80) 172)
81 173
82dnl when using libc5, (f)trucate's offset argument type is size_t with 174dnl when using libc5, (f)trucate's offset argument type is size_t with
83dnl libc5, but it's off_t with libc6 (glibc2). 175dnl libc5, but it's off_t with libc6 (glibc2).
84AC_MSG_CHECKING([truncate argument type]) 176AC_MSG_CHECKING([truncate argument type])
85TRUNC_ARG_TYPE=`echo '#include <unistd.h>' | $CC -E - | grep -q 'truncate.*size_t'` 177TRUNC_ARG_TYPE=`echo '#include <unistd.h>' | $CC -E - | grep -q 'truncate.*size_t'`
86if test "$TRUNC_ARG_TYPE"x != x ; then 178if test "$TRUNC_ARG_TYPE"x != x ; then
87 AC_MSG_RESULT([size_t]) 179 AC_MSG_RESULT([size_t])
88 AC_DEFINE([TRUNCATE_T], [size_t], [truncate arg type]) 180 AC_DEFINE([TRUNCATE_T], [size_t], [truncate arg type])
89else 181else
90 AC_MSG_RESULT([off_t]) 182 AC_MSG_RESULT([off_t])
91 AC_DEFINE([TRUNCATE_T], [off_t], [truncate arg type]) 183 AC_DEFINE([TRUNCATE_T], [off_t], [truncate arg type])
92fi 184fi
93 185
94dnl Check if libc provides RTLD_NEXT 186dnl Check if libc provides RTLD_NEXT
95AC_MSG_CHECKING([for RTLD_NEXT]) 187AC_MSG_CHECKING([for RTLD_NEXT])
96AC_TRY_COMPILE([ 188AC_TRY_COMPILE([
97#define _GNU_SOURCE 189 #define _GNU_SOURCE
98#include <dlfcn.h> 190 #include <dlfcn.h>
99], [ 191 ], [
100#if !defined(RTLD_NEXT) 192 #if !defined(RTLD_NEXT)
101# error no RTLD_NEXT 193 # error no RTLD_NEXT
102#endif 194 #endif
103 195 ],
104int
105main (void)
106{
107 return 0;
108}
109],
110 [have_rtld_next="yes"], 196 [have_rtld_next="yes"],
111 [have_rtld_next="no"] 197 [have_rtld_next="no"]
112) 198)
113AC_MSG_RESULT([$have_rtld_next]) 199AC_MSG_RESULT([$have_rtld_next])
114AM_CONDITIONAL([HAVE_RTLD_NEXT], [test x"$have_rtld_next" = xyes]) 200if test x"$have_rtld_next" = xyes ; then
201 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
202 AC_DEFINE([HAVE_RTLD_NEXT], [1], [Have RTLD_NEXT enabled libc])
203fi
115 204
116dnl we need to handle symbols differently based upon their version, 205dnl we need to handle symbols differently based upon their version,
117dnl but we have to know which symbols the libc supports first 206dnl but we have to know which symbols the libc supports first
118AC_MSG_CHECKING([libc path]) 207AC_MSG_CHECKING([libc path])
119echo "int main(void) { return 0; }" > libctest.c 208echo "int main(void) { return 0; }" > libctest.c
120$CC -Wall -o libctest libctest.c 209$CC $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-verbose -o libctest libctest.c > libctest.log 2>&1
121LIBC_PATH=`$CC $CFLAGS -Wl,-verbose -o libctest libctest.c 2>&1 | \ 210cat libctest.log 1>&AS_MESSAGE_LOG_FD
211LIBC_PATH=$(
122 $AWK '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}'` 212 $AWK '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}' libctest.log
213)
123rm -f libctest.c 214rm -f libctest*
124if test "$LIBC_PATH"x = x || ! test -r "$LIBC_PATH"; then 215if test x"$LIBC_PATH" = x || ! test -r "$LIBC_PATH" ; then
125 AC_MSG_ERROR([Unable to determine LIBC PATH]) 216 AC_MSG_ERROR([Unable to determine LIBC PATH ($LIBC_PATH)])
126fi 217fi
127AC_MSG_RESULT([$LIBC_PATH]) 218AC_MSG_RESULT([$LIBC_PATH])
128AC_SUBST([LIBC_PATH]) 219AC_SUBST([LIBC_PATH])
129 220
130dnl when intercepting libc calls, we have to know the name of the 221dnl when intercepting libc calls, we have to know the name of the
131dnl libc to load and search with dl*() calls 222dnl libc to load and search with dl*() calls
132AC_MSG_CHECKING([libc version]) 223AC_MSG_CHECKING([libc version])
133dnl the sed script at the end here looks funny but it's ok ... 224dnl the sed script at the end here looks funny but it's ok ...
134dnl they're m4 escape sequences for left and right brackets 225echo "int main(void) { return 0; }" > libctest.c
135LIBC_VERSION=`readelf -d libctest | grep NEEDED.*libc\\.so | $AWK '{print $NF}' | sed -e 's:\@<:@::' -e 's:\@:>@::'` 226$CC $CFLAGS $CPPFLAGS $LDFLAGS -Wall -o libctest libctest.c
227LIBC_VERSION=$(
228 $READELF -d libctest | \
229 grep NEEDED.*libc\\.so | \
230 $AWK '{print $NF}' | sed -e ['s:\[::' -e 's:\]::']
231)
232rm -f libctest*
136if test "$LIBC_VERSION"x = x ; then 233if test "$LIBC_VERSION"x = x ; then
137 AC_MSG_ERROR([Unable to determine LIBC VERSION]) 234 AC_MSG_ERROR([Unable to determine LIBC VERSION])
138fi 235fi
139rm -f libctest
140AC_MSG_RESULT([$LIBC_VERSION]) 236AC_MSG_RESULT([$LIBC_VERSION])
141AC_DEFINE_UNQUOTED([LIBC_VERSION], ["$LIBC_VERSION"], [name of libc to hook into]) 237AC_DEFINE_UNQUOTED([LIBC_VERSION], ["$LIBC_VERSION"], [Name of libc to hook into])
142 238
143dnl check if we have 32bit or 64bit output 239dnl We add to CPPFLAGS rather than doing AC_DEFINE_UNQUOTED
144AC_ARG_ENABLE([multilib], 240dnl so we dont have to worry about fully expanding all of
145 AS_HELP_STRING([--enable-multilib], 241dnl the variables ($sysconfdir defaults to "$prefix/etc")
146 [enable building for multilib setups (default=disabled)]), 242SANDBOX_DEFINES='-DETCDIR="\"$(sysconfdir)\"" -DLIBSANDBOX_PATH="\"$(libdir)\"" -DSANDBOX_BASHRC_PATH="\"$(pkgdatadir)\""'
147 [enable_multilib="$enableval"], 243AC_SUBST([SANDBOX_DEFINES])
148 [enable_multilib="no"]
149)
150 244
151if test x"$enable_multilib" != xno ; then 245CPPFLAGS="$CPPFLAGS -D_REENTRANT"
152 AC_DEFINE_UNQUOTED([SB_HAVE_MULTILIB], [1], [have multilib enabled system]) 246if test "$GCC" = yes; then
247 CFLAGS="$CFLAGS -Wall"
153fi 248fi
249
250AC_CONFIG_TESTDIR([tests])
154 251
155AC_OUTPUT([ 252AC_OUTPUT([
156 Makefile 253 Makefile
157 scripts/Makefile 254 scripts/Makefile
255 etc/Makefile
158 data/Makefile 256 data/Makefile
257 libsbutil/Makefile
258 libsandbox/Makefile
159 src/Makefile 259 src/Makefile
260 tests/atlocal
261 tests/Makefile
262 tests/package.m4
160]) 263])

Legend:
Removed from v.232  
changed lines
  Added in v.431

  ViewVC Help
Powered by ViewVC 1.1.20