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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


Revision 431 - (show annotations) (download)
Sun Nov 16 16:13:01 2008 UTC (6 years ago) by vapier
File size: 6527 byte(s)
add test case for libsigsegv
1 AC_PREREQ([2.61])
2 AC_INIT([sandbox], [1.3.1], [sandbox@gentoo.org])
3 sb_configure_opts="$*"
4 AM_INIT_AUTOMAKE
5 AC_CONFIG_HEADER([config.h])
6
7 AC_DEFINE_UNQUOTED([SANDBOX_CONFIGURE_OPTS], ["${sb_configure_opts}"], [Arguments given to ./configure])
8
9 dnl Checks for programs.
10 AC_PROG_CC
11 AM_PROG_CC_C_O
12 AC_ISC_POSIX
13 AC_PROG_INSTALL
14 AC_PROG_MAKE_SET
15 AC_PROG_AWK
16 AC_CHECK_PROGS([READELF], [readelf eu-readelf], [false])
17 AM_MISSING_PROG([AUTOM4TE], [autom4te])
18
19 AC_ENABLE_SHARED
20 AC_DISABLE_STATIC
21 dnl Next four lines is a hack to prevent libtool checking for CXX/F77
22 m4_undefine([AC_PROG_CXX])
23 m4_defun([AC_PROG_CXX],[])
24 m4_undefine([AC_PROG_F77])
25 m4_defun([AC_PROG_F77],[])
26 AC_PROG_LIBTOOL
27
28 AC_PREFIX_DEFAULT([/usr])
29
30 dnl Checks for libraries.
31 dnl Checks for header files.
32 AC_FUNC_ALLOCA
33 AC_HEADER_DIRENT
34 AC_HEADER_STDC
35 AC_HEADER_SYS_WAIT
36 AC_CHECK_HEADERS_ONCE([ \
37 dirent.h \
38 dlfcn.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 \
65 ])
66
67 dnl Checks for typedefs, structures, and compiler characteristics.
68 AC_C_CONST
69 AC_TYPE_UID_T
70 AC_TYPE_MODE_T
71 AC_TYPE_SIZE_T
72 AC_CHECK_TYPES([ptrdiff_t])
73
74 dnl Checks for library functions.
75 AC_FUNC_CHOWN
76 AC_FUNC_FORK
77 AC_FUNC_LSTAT
78 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
79 AC_TYPE_SIGNAL
80 AC_FUNC_STAT
81 AC_CHECK_FUNCS_ONCE([ \
82 backtrace \
83 ftruncate \
84 getcwd \
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 \
104 ])
105 AC_CHECK_LIB([sigsegv], [stackoverflow_install_handler],
106 [HAVE_LIBSIGSEGV=true],
107 [HAVE_LIBSIGSEGV=false])
108 AM_CONDITIONAL(HAVE_LIBSIGSEGV, $HAVE_LIBSIGSEGV)
109
110 dnl Check if gcc provides va_copy or __va_copy (for librcutil)
111 AC_MSG_CHECKING([for va_copy])
112 AC_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 )
129 AC_MSG_RESULT([$va_copy])
130 if 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 )
134 fi
135
136 dnl Verify people aren't doing stupid shit
137 if test x"$enable_static" != xno ; then
138 AC_MSG_ERROR([dont be a Kumba, building a libsandbox.a is stupid])
139 fi
140 if test x"$enable_shared" != xyes ; then
141 AC_MSG_ERROR([dont be a Kumba, omitting a libsandbox.so is stupid])
142 fi
143 if echo $CFLAGS | $EGREP -e -static >/dev/null 2>&1; then
144 AC_MSG_ERROR([dont be a Kumba, using -static in CFLAGS is stupid])
145 fi
146 if echo $LDFLAGS | $EGREP -e -static >/dev/null 2>&1; then
147 AC_MSG_ERROR([dont be a Kumba, using -static in LDFLAGS is stupid])
148 fi
149
150 dnl Some libc's like those on bsd have dlopen() in libc, and not libdl
151 AC_CHECK_LIB([dl], [dlopen],
152 [have_libdl="yes"],
153 [have_libdl="no"]
154 )
155 if test x"$have_libdl" = xyes ; then
156 LIBDL="-ldl"
157 AC_SUBST([LIBDL])
158 DL_LIB="dl"
159 else
160 DL_LIB="c"
161 AC_CHECK_LIB([c], [dlopen],
162 [],
163 [AC_MSG_ERROR([Unable to determine library providing dlopen])]
164 )
165 fi
166
167 dnl uClibc doesn't currently provide dlvsym() so lets
168 dnl verify the toolchain supports it
169 AC_CHECK_LIB([$DL_LIB], [dlvsym],
170 [AC_DEFINE([HAVE_DLVSYM], [1], [libdl supports dlvsym])],
171 [AC_DEFINE([HAVE_DLVSYM], [0], [libdl does not support dlvsym])]
172 )
173
174 dnl when using libc5, (f)trucate's offset argument type is size_t with
175 dnl libc5, but it's off_t with libc6 (glibc2).
176 AC_MSG_CHECKING([truncate argument type])
177 TRUNC_ARG_TYPE=`echo '#include <unistd.h>' | $CC -E - | grep -q 'truncate.*size_t'`
178 if test "$TRUNC_ARG_TYPE"x != x ; then
179 AC_MSG_RESULT([size_t])
180 AC_DEFINE([TRUNCATE_T], [size_t], [truncate arg type])
181 else
182 AC_MSG_RESULT([off_t])
183 AC_DEFINE([TRUNCATE_T], [off_t], [truncate arg type])
184 fi
185
186 dnl Check if libc provides RTLD_NEXT
187 AC_MSG_CHECKING([for RTLD_NEXT])
188 AC_TRY_COMPILE([
189 #define _GNU_SOURCE
190 #include <dlfcn.h>
191 ], [
192 #if !defined(RTLD_NEXT)
193 # error no RTLD_NEXT
194 #endif
195 ],
196 [have_rtld_next="yes"],
197 [have_rtld_next="no"]
198 )
199 AC_MSG_RESULT([$have_rtld_next])
200 if 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])
203 fi
204
205 dnl we need to handle symbols differently based upon their version,
206 dnl but we have to know which symbols the libc supports first
207 AC_MSG_CHECKING([libc path])
208 echo "int main(void) { return 0; }" > libctest.c
209 $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-verbose -o libctest libctest.c > libctest.log 2>&1
210 cat libctest.log 1>&AS_MESSAGE_LOG_FD
211 LIBC_PATH=$(
212 $AWK '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}' libctest.log
213 )
214 rm -f libctest*
215 if test x"$LIBC_PATH" = x || ! test -r "$LIBC_PATH" ; then
216 AC_MSG_ERROR([Unable to determine LIBC PATH ($LIBC_PATH)])
217 fi
218 AC_MSG_RESULT([$LIBC_PATH])
219 AC_SUBST([LIBC_PATH])
220
221 dnl when intercepting libc calls, we have to know the name of the
222 dnl libc to load and search with dl*() calls
223 AC_MSG_CHECKING([libc version])
224 dnl the sed script at the end here looks funny but it's ok ...
225 echo "int main(void) { return 0; }" > libctest.c
226 $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wall -o libctest libctest.c
227 LIBC_VERSION=$(
228 $READELF -d libctest | \
229 grep NEEDED.*libc\\.so | \
230 $AWK '{print $NF}' | sed -e ['s:\[::' -e 's:\]::']
231 )
232 rm -f libctest*
233 if test "$LIBC_VERSION"x = x ; then
234 AC_MSG_ERROR([Unable to determine LIBC VERSION])
235 fi
236 AC_MSG_RESULT([$LIBC_VERSION])
237 AC_DEFINE_UNQUOTED([LIBC_VERSION], ["$LIBC_VERSION"], [Name of libc to hook into])
238
239 dnl We add to CPPFLAGS rather than doing AC_DEFINE_UNQUOTED
240 dnl so we dont have to worry about fully expanding all of
241 dnl the variables ($sysconfdir defaults to "$prefix/etc")
242 SANDBOX_DEFINES='-DETCDIR="\"$(sysconfdir)\"" -DLIBSANDBOX_PATH="\"$(libdir)\"" -DSANDBOX_BASHRC_PATH="\"$(pkgdatadir)\""'
243 AC_SUBST([SANDBOX_DEFINES])
244
245 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
246 if test "$GCC" = yes; then
247 CFLAGS="$CFLAGS -Wall"
248 fi
249
250 AC_CONFIG_TESTDIR([tests])
251
252 AC_OUTPUT([
253 Makefile
254 scripts/Makefile
255 etc/Makefile
256 data/Makefile
257 libsbutil/Makefile
258 libsandbox/Makefile
259 src/Makefile
260 tests/atlocal
261 tests/Makefile
262 tests/package.m4
263 ])

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20