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

Diff of /trunk/configure.ac

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

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

Legend:
Removed from v.167  
changed lines
  Added in v.396

  ViewVC Help
Powered by ViewVC 1.1.20