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

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

  ViewVC Help
Powered by ViewVC 1.1.20