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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


Revision 435 - (hide 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 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 435 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 vapier 61 dnl Checks for libraries.
37     dnl Checks for header files.
38 ferringb 2 AC_FUNC_ALLOCA
39     AC_HEADER_DIRENT
40     AC_HEADER_STDC
41     AC_HEADER_SYS_WAIT
42 vapier 370 AC_CHECK_HEADERS_ONCE([ \
43     dirent.h \
44     dlfcn.h \
45 vapier 396 elf.h \
46 vapier 370 errno.h \
47 vapier 396 execinfo.h \
48 vapier 370 fcntl.h \
49     libgen.h \
50     limits.h \
51     memory.h \
52     signal.h \
53 vapier 431 sigsegv.h \
54 vapier 370 stdarg.h \
55 vapier 396 stdbool.h \
56 vapier 370 stddef.h \
57     stdio.h \
58     stdlib.h \
59     string.h \
60     strings.h \
61 vapier 405 syscall.h \
62 vapier 370 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 vapier 21 ])
72 ferringb 2
73 vapier 61 dnl Checks for typedefs, structures, and compiler characteristics.
74 ferringb 2 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 vapier 61 dnl Checks for library functions.
81 ferringb 2 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 vapier 396 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 vapier 431 remove \
99 vapier 396 rmdir \
100     setenv \
101     strcasecmp \
102     strchr \
103     strdup \
104     strerror \
105     strndup \
106     strrchr \
107     strspn \
108     strstr \
109 vapier 356 strtok_r \
110 vapier 21 ])
111 vapier 431 AC_CHECK_LIB([sigsegv], [stackoverflow_install_handler],
112     [HAVE_LIBSIGSEGV=true],
113     [HAVE_LIBSIGSEGV=false])
114     AM_CONDITIONAL(HAVE_LIBSIGSEGV, $HAVE_LIBSIGSEGV)
115 ferringb 2
116 azarah 278 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 vapier 243 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 azarah 218 dnl Some libc's like those on bsd have dlopen() in libc, and not libdl
157     AC_CHECK_LIB([dl], [dlopen],
158 azarah 234 [have_libdl="yes"],
159     [have_libdl="no"]
160 azarah 218 )
161     if test x"$have_libdl" = xyes ; then
162 azarah 234 LIBDL="-ldl"
163     AC_SUBST([LIBDL])
164     DL_LIB="dl"
165 azarah 218 else
166 azarah 234 DL_LIB="c"
167     AC_CHECK_LIB([c], [dlopen],
168     [],
169     [AC_MSG_ERROR([Unable to determine library providing dlopen])]
170     )
171 azarah 218 fi
172    
173 vapier 62 dnl uClibc doesn't currently provide dlvsym() so lets
174     dnl verify the toolchain supports it
175 azarah 218 AC_CHECK_LIB([$DL_LIB], [dlvsym],
176 azarah 234 [AC_DEFINE([HAVE_DLVSYM], [1], [libdl supports dlvsym])],
177     [AC_DEFINE([HAVE_DLVSYM], [0], [libdl does not support dlvsym])]
178 vapier 62 )
179    
180 vapier 23 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 azarah 180 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 azarah 234 AC_MSG_RESULT([size_t])
186     AC_DEFINE([TRUNCATE_T], [size_t], [truncate arg type])
187 vapier 23 else
188 azarah 234 AC_MSG_RESULT([off_t])
189     AC_DEFINE([TRUNCATE_T], [off_t], [truncate arg type])
190 vapier 23 fi
191    
192 azarah 220 dnl Check if libc provides RTLD_NEXT
193     AC_MSG_CHECKING([for RTLD_NEXT])
194 azarah 216 AC_TRY_COMPILE([
195 azarah 234 #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 azarah 217 )
205 azarah 220 AC_MSG_RESULT([$have_rtld_next])
206 azarah 235 if test x"$have_rtld_next" = xyes ; then
207 vapier 370 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
208 azarah 235 AC_DEFINE([HAVE_RTLD_NEXT], [1], [Have RTLD_NEXT enabled libc])
209     fi
210 azarah 216
211 vapier 53 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 azarah 180 AC_MSG_CHECKING([libc path])
214 vapier 23 echo "int main(void) { return 0; }" > libctest.c
215 vapier 356 $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-verbose -o libctest libctest.c > libctest.log 2>&1
216 vapier 238 cat libctest.log 1>&AS_MESSAGE_LOG_FD
217 vapier 356 LIBC_PATH=$(
218     $AWK '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}' libctest.log
219     )
220 azarah 234 rm -f libctest*
221 vapier 239 if test x"$LIBC_PATH" = x || ! test -r "$LIBC_PATH" ; then
222 vapier 238 AC_MSG_ERROR([Unable to determine LIBC PATH ($LIBC_PATH)])
223 vapier 53 fi
224 azarah 180 AC_MSG_RESULT([$LIBC_PATH])
225     AC_SUBST([LIBC_PATH])
226 vapier 23
227 vapier 53 dnl when intercepting libc calls, we have to know the name of the
228     dnl libc to load and search with dl*() calls
229 azarah 180 AC_MSG_CHECKING([libc version])
230 vapier 53 dnl the sed script at the end here looks funny but it's ok ...
231 azarah 234 echo "int main(void) { return 0; }" > libctest.c
232 vapier 356 $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 azarah 234 rm -f libctest*
239 vapier 53 if test "$LIBC_VERSION"x = x ; then
240 azarah 234 AC_MSG_ERROR([Unable to determine LIBC VERSION])
241 vapier 53 fi
242 azarah 180 AC_MSG_RESULT([$LIBC_VERSION])
243 azarah 233 AC_DEFINE_UNQUOTED([LIBC_VERSION], ["$LIBC_VERSION"], [Name of libc to hook into])
244 vapier 53
245 vapier 356 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 azarah 309 SANDBOX_DEFINES='-DETCDIR="\"$(sysconfdir)\"" -DLIBSANDBOX_PATH="\"$(libdir)\"" -DSANDBOX_BASHRC_PATH="\"$(pkgdatadir)\""'
249     AC_SUBST([SANDBOX_DEFINES])
250    
251 vapier 404 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
252     if test "$GCC" = yes; then
253     CFLAGS="$CFLAGS -Wall"
254     fi
255    
256 vapier 405 AC_CONFIG_TESTDIR([tests])
257    
258 azarah 183 AC_OUTPUT([
259 vapier 356 Makefile
260     scripts/Makefile
261     etc/Makefile
262     data/Makefile
263     libsbutil/Makefile
264     libsandbox/Makefile
265     src/Makefile
266 vapier 405 tests/atlocal
267     tests/Makefile
268     tests/package.m4
269 azarah 183 ])

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20