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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20