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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


Revision 431 - (hide annotations) (download)
Sun Nov 16 16:13:01 2008 UTC (6 years, 1 month ago) by vapier
File size: 6527 byte(s)
add test case for libsigsegv
1 vapier 377 AC_PREREQ([2.61])
2 vapier 428 AC_INIT([sandbox], [1.3.1], [sandbox@gentoo.org])
3 vapier 429 sb_configure_opts="$*"
4 ferringb 2 AM_INIT_AUTOMAKE
5 ferringb 16 AC_CONFIG_HEADER([config.h])
6 ferringb 2
7 vapier 429 AC_DEFINE_UNQUOTED([SANDBOX_CONFIGURE_OPTS], ["${sb_configure_opts}"], [Arguments given to ./configure])
8    
9 vapier 61 dnl Checks for programs.
10 ferringb 2 AC_PROG_CC
11 vapier 412 AM_PROG_CC_C_O
12 azarah 29 AC_ISC_POSIX
13     AC_PROG_INSTALL
14     AC_PROG_MAKE_SET
15     AC_PROG_AWK
16 azarah 236 AC_CHECK_PROGS([READELF], [readelf eu-readelf], [false])
17 vapier 405 AM_MISSING_PROG([AUTOM4TE], [autom4te])
18 azarah 29
19 vapier 21 AC_ENABLE_SHARED
20     AC_DISABLE_STATIC
21 vapier 61 dnl Next four lines is a hack to prevent libtool checking for CXX/F77
22 azarah 56 m4_undefine([AC_PROG_CXX])
23     m4_defun([AC_PROG_CXX],[])
24     m4_undefine([AC_PROG_F77])
25     m4_defun([AC_PROG_F77],[])
26 ferringb 2 AC_PROG_LIBTOOL
27    
28     AC_PREFIX_DEFAULT([/usr])
29 azarah 29
30 vapier 61 dnl Checks for libraries.
31     dnl Checks for header files.
32 ferringb 2 AC_FUNC_ALLOCA
33     AC_HEADER_DIRENT
34     AC_HEADER_STDC
35     AC_HEADER_SYS_WAIT
36 vapier 370 AC_CHECK_HEADERS_ONCE([ \
37     dirent.h \
38     dlfcn.h \
39 vapier 396 elf.h \
40 vapier 370 errno.h \
41 vapier 396 execinfo.h \
42 vapier 370 fcntl.h \
43     libgen.h \
44     limits.h \
45     memory.h \
46     signal.h \
47 vapier 431 sigsegv.h \
48 vapier 370 stdarg.h \
49 vapier 396 stdbool.h \
50 vapier 370 stddef.h \
51     stdio.h \
52     stdlib.h \
53     string.h \
54     strings.h \
55 vapier 405 syscall.h \
56 vapier 370 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 vapier 21 ])
66 ferringb 2
67 vapier 61 dnl Checks for typedefs, structures, and compiler characteristics.
68 ferringb 2 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 vapier 61 dnl Checks for library functions.
75 ferringb 2 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 vapier 396 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 vapier 431 remove \
93 vapier 396 rmdir \
94     setenv \
95     strcasecmp \
96     strchr \
97     strdup \
98     strerror \
99     strndup \
100     strrchr \
101     strspn \
102     strstr \
103 vapier 356 strtok_r \
104 vapier 21 ])
105 vapier 431 AC_CHECK_LIB([sigsegv], [stackoverflow_install_handler],
106     [HAVE_LIBSIGSEGV=true],
107     [HAVE_LIBSIGSEGV=false])
108     AM_CONDITIONAL(HAVE_LIBSIGSEGV, $HAVE_LIBSIGSEGV)
109 ferringb 2
110 azarah 278 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 vapier 243 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 azarah 218 dnl Some libc's like those on bsd have dlopen() in libc, and not libdl
151     AC_CHECK_LIB([dl], [dlopen],
152 azarah 234 [have_libdl="yes"],
153     [have_libdl="no"]
154 azarah 218 )
155     if test x"$have_libdl" = xyes ; then
156 azarah 234 LIBDL="-ldl"
157     AC_SUBST([LIBDL])
158     DL_LIB="dl"
159 azarah 218 else
160 azarah 234 DL_LIB="c"
161     AC_CHECK_LIB([c], [dlopen],
162     [],
163     [AC_MSG_ERROR([Unable to determine library providing dlopen])]
164     )
165 azarah 218 fi
166    
167 vapier 62 dnl uClibc doesn't currently provide dlvsym() so lets
168     dnl verify the toolchain supports it
169 azarah 218 AC_CHECK_LIB([$DL_LIB], [dlvsym],
170 azarah 234 [AC_DEFINE([HAVE_DLVSYM], [1], [libdl supports dlvsym])],
171     [AC_DEFINE([HAVE_DLVSYM], [0], [libdl does not support dlvsym])]
172 vapier 62 )
173    
174 vapier 23 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 azarah 180 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 azarah 234 AC_MSG_RESULT([size_t])
180     AC_DEFINE([TRUNCATE_T], [size_t], [truncate arg type])
181 vapier 23 else
182 azarah 234 AC_MSG_RESULT([off_t])
183     AC_DEFINE([TRUNCATE_T], [off_t], [truncate arg type])
184 vapier 23 fi
185    
186 azarah 220 dnl Check if libc provides RTLD_NEXT
187     AC_MSG_CHECKING([for RTLD_NEXT])
188 azarah 216 AC_TRY_COMPILE([
189 azarah 234 #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 azarah 217 )
199 azarah 220 AC_MSG_RESULT([$have_rtld_next])
200 azarah 235 if test x"$have_rtld_next" = xyes ; then
201 vapier 370 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
202 azarah 235 AC_DEFINE([HAVE_RTLD_NEXT], [1], [Have RTLD_NEXT enabled libc])
203     fi
204 azarah 216
205 vapier 53 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 azarah 180 AC_MSG_CHECKING([libc path])
208 vapier 23 echo "int main(void) { return 0; }" > libctest.c
209 vapier 356 $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-verbose -o libctest libctest.c > libctest.log 2>&1
210 vapier 238 cat libctest.log 1>&AS_MESSAGE_LOG_FD
211 vapier 356 LIBC_PATH=$(
212     $AWK '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}' libctest.log
213     )
214 azarah 234 rm -f libctest*
215 vapier 239 if test x"$LIBC_PATH" = x || ! test -r "$LIBC_PATH" ; then
216 vapier 238 AC_MSG_ERROR([Unable to determine LIBC PATH ($LIBC_PATH)])
217 vapier 53 fi
218 azarah 180 AC_MSG_RESULT([$LIBC_PATH])
219     AC_SUBST([LIBC_PATH])
220 vapier 23
221 vapier 53 dnl when intercepting libc calls, we have to know the name of the
222     dnl libc to load and search with dl*() calls
223 azarah 180 AC_MSG_CHECKING([libc version])
224 vapier 53 dnl the sed script at the end here looks funny but it's ok ...
225 azarah 234 echo "int main(void) { return 0; }" > libctest.c
226 vapier 356 $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 azarah 234 rm -f libctest*
233 vapier 53 if test "$LIBC_VERSION"x = x ; then
234 azarah 234 AC_MSG_ERROR([Unable to determine LIBC VERSION])
235 vapier 53 fi
236 azarah 180 AC_MSG_RESULT([$LIBC_VERSION])
237 azarah 233 AC_DEFINE_UNQUOTED([LIBC_VERSION], ["$LIBC_VERSION"], [Name of libc to hook into])
238 vapier 53
239 vapier 356 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 azarah 309 SANDBOX_DEFINES='-DETCDIR="\"$(sysconfdir)\"" -DLIBSANDBOX_PATH="\"$(libdir)\"" -DSANDBOX_BASHRC_PATH="\"$(pkgdatadir)\""'
243     AC_SUBST([SANDBOX_DEFINES])
244    
245 vapier 404 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
246     if test "$GCC" = yes; then
247     CFLAGS="$CFLAGS -Wall"
248     fi
249    
250 vapier 405 AC_CONFIG_TESTDIR([tests])
251    
252 azarah 183 AC_OUTPUT([
253 vapier 356 Makefile
254     scripts/Makefile
255     etc/Makefile
256     data/Makefile
257     libsbutil/Makefile
258     libsandbox/Makefile
259     src/Makefile
260 vapier 405 tests/atlocal
261     tests/Makefile
262     tests/package.m4
263 azarah 183 ])

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20