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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


Revision 435 - (show annotations) (download)
Sun Nov 16 21:14:00 2008 UTC (5 years, 7 months ago) by vapier
File size: 6766 byte(s)
move libsigsegv disable to configure.ac
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 this test fills up the stack and then triggers a segfault ...
31 dnl but it's hard to wrap things without a stack, so let's ignore
32 dnl this test for now ...
33 ac_cv_header_sigsegv_h=no
34 ac_cv_lib_sigsegv_stackoverflow_install_handler=false
35
36 dnl Checks for libraries.
37 dnl Checks for header files.
38 AC_FUNC_ALLOCA
39 AC_HEADER_DIRENT
40 AC_HEADER_STDC
41 AC_HEADER_SYS_WAIT
42 AC_CHECK_HEADERS_ONCE([ \
43 dirent.h \
44 dlfcn.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 \
71 ])
72
73 dnl Checks for typedefs, structures, and compiler characteristics.
74 AC_C_CONST
75 AC_TYPE_UID_T
76 AC_TYPE_MODE_T
77 AC_TYPE_SIZE_T
78 AC_CHECK_TYPES([ptrdiff_t])
79
80 dnl Checks for library functions.
81 AC_FUNC_CHOWN
82 AC_FUNC_FORK
83 AC_FUNC_LSTAT
84 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
85 AC_TYPE_SIGNAL
86 AC_FUNC_STAT
87 AC_CHECK_FUNCS_ONCE([ \
88 backtrace \
89 ftruncate \
90 getcwd \
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 \
110 ])
111 AC_CHECK_LIB([sigsegv], [stackoverflow_install_handler],
112 [HAVE_LIBSIGSEGV=true],
113 [HAVE_LIBSIGSEGV=false])
114 AM_CONDITIONAL(HAVE_LIBSIGSEGV, $HAVE_LIBSIGSEGV)
115
116 dnl Check if gcc provides va_copy or __va_copy (for librcutil)
117 AC_MSG_CHECKING([for va_copy])
118 AC_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 )
135 AC_MSG_RESULT([$va_copy])
136 if 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 )
140 fi
141
142 dnl Verify people aren't doing stupid shit
143 if test x"$enable_static" != xno ; then
144 AC_MSG_ERROR([dont be a Kumba, building a libsandbox.a is stupid])
145 fi
146 if test x"$enable_shared" != xyes ; then
147 AC_MSG_ERROR([dont be a Kumba, omitting a libsandbox.so is stupid])
148 fi
149 if echo $CFLAGS | $EGREP -e -static >/dev/null 2>&1; then
150 AC_MSG_ERROR([dont be a Kumba, using -static in CFLAGS is stupid])
151 fi
152 if echo $LDFLAGS | $EGREP -e -static >/dev/null 2>&1; then
153 AC_MSG_ERROR([dont be a Kumba, using -static in LDFLAGS is stupid])
154 fi
155
156 dnl Some libc's like those on bsd have dlopen() in libc, and not libdl
157 AC_CHECK_LIB([dl], [dlopen],
158 [have_libdl="yes"],
159 [have_libdl="no"]
160 )
161 if test x"$have_libdl" = xyes ; then
162 LIBDL="-ldl"
163 AC_SUBST([LIBDL])
164 DL_LIB="dl"
165 else
166 DL_LIB="c"
167 AC_CHECK_LIB([c], [dlopen],
168 [],
169 [AC_MSG_ERROR([Unable to determine library providing dlopen])]
170 )
171 fi
172
173 dnl uClibc doesn't currently provide dlvsym() so lets
174 dnl verify the toolchain supports it
175 AC_CHECK_LIB([$DL_LIB], [dlvsym],
176 [AC_DEFINE([HAVE_DLVSYM], [1], [libdl supports dlvsym])],
177 [AC_DEFINE([HAVE_DLVSYM], [0], [libdl does not support dlvsym])]
178 )
179
180 dnl when using libc5, (f)trucate's offset argument type is size_t with
181 dnl libc5, but it's off_t with libc6 (glibc2).
182 AC_MSG_CHECKING([truncate argument type])
183 TRUNC_ARG_TYPE=`echo '#include <unistd.h>' | $CC -E - | grep -q 'truncate.*size_t'`
184 if test "$TRUNC_ARG_TYPE"x != x ; then
185 AC_MSG_RESULT([size_t])
186 AC_DEFINE([TRUNCATE_T], [size_t], [truncate arg type])
187 else
188 AC_MSG_RESULT([off_t])
189 AC_DEFINE([TRUNCATE_T], [off_t], [truncate arg type])
190 fi
191
192 dnl Check if libc provides RTLD_NEXT
193 AC_MSG_CHECKING([for RTLD_NEXT])
194 AC_TRY_COMPILE([
195 #define _GNU_SOURCE
196 #include <dlfcn.h>
197 ], [
198 #if !defined(RTLD_NEXT)
199 # error no RTLD_NEXT
200 #endif
201 ],
202 [have_rtld_next="yes"],
203 [have_rtld_next="no"]
204 )
205 AC_MSG_RESULT([$have_rtld_next])
206 if 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])
209 fi
210
211 dnl we need to handle symbols differently based upon their version,
212 dnl but we have to know which symbols the libc supports first
213 AC_MSG_CHECKING([libc path])
214 echo "int main(void) { return 0; }" > libctest.c
215 $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-verbose -o libctest libctest.c > libctest.log 2>&1
216 cat libctest.log 1>&AS_MESSAGE_LOG_FD
217 LIBC_PATH=$(
218 $AWK '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}' libctest.log
219 )
220 rm -f libctest*
221 if test x"$LIBC_PATH" = x || ! test -r "$LIBC_PATH" ; then
222 AC_MSG_ERROR([Unable to determine LIBC PATH ($LIBC_PATH)])
223 fi
224 AC_MSG_RESULT([$LIBC_PATH])
225 AC_SUBST([LIBC_PATH])
226
227 dnl when intercepting libc calls, we have to know the name of the
228 dnl libc to load and search with dl*() calls
229 AC_MSG_CHECKING([libc version])
230 dnl the sed script at the end here looks funny but it's ok ...
231 echo "int main(void) { return 0; }" > libctest.c
232 $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wall -o libctest libctest.c
233 LIBC_VERSION=$(
234 $READELF -d libctest | \
235 grep NEEDED.*libc\\.so | \
236 $AWK '{print $NF}' | sed -e ['s:\[::' -e 's:\]::']
237 )
238 rm -f libctest*
239 if test "$LIBC_VERSION"x = x ; then
240 AC_MSG_ERROR([Unable to determine LIBC VERSION])
241 fi
242 AC_MSG_RESULT([$LIBC_VERSION])
243 AC_DEFINE_UNQUOTED([LIBC_VERSION], ["$LIBC_VERSION"], [Name of libc to hook into])
244
245 dnl We add to CPPFLAGS rather than doing AC_DEFINE_UNQUOTED
246 dnl so we dont have to worry about fully expanding all of
247 dnl the variables ($sysconfdir defaults to "$prefix/etc")
248 SANDBOX_DEFINES='-DETCDIR="\"$(sysconfdir)\"" -DLIBSANDBOX_PATH="\"$(libdir)\"" -DSANDBOX_BASHRC_PATH="\"$(pkgdatadir)\""'
249 AC_SUBST([SANDBOX_DEFINES])
250
251 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
252 if test "$GCC" = yes; then
253 CFLAGS="$CFLAGS -Wall"
254 fi
255
256 AC_CONFIG_TESTDIR([tests])
257
258 AC_OUTPUT([
259 Makefile
260 scripts/Makefile
261 etc/Makefile
262 data/Makefile
263 libsbutil/Makefile
264 libsandbox/Makefile
265 src/Makefile
266 tests/atlocal
267 tests/Makefile
268 tests/package.m4
269 ])

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20