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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


Revision 439 - (show annotations) (download)
Mon Nov 17 14:25:55 2008 UTC (5 years, 9 months ago) by vapier
File size: 6874 byte(s)
moved to git
1 AC_PREREQ([2.61])
2 AC_INIT([sandbox], [1.3.1], [sandbox@gentoo.org])
3
4 AC_MSG_ERROR([SVN is dead, use GIT: http://git.overlays.gentoo.org/gitweb/?p=proj/sandbox.git;a=summary])
5
6 sb_configure_opts="$*"
7 AM_INIT_AUTOMAKE
8 AC_CONFIG_HEADER([config.h])
9
10 AC_DEFINE_UNQUOTED([SANDBOX_CONFIGURE_OPTS], ["${sb_configure_opts}"], [Arguments given to ./configure])
11
12 dnl Checks for programs.
13 AC_PROG_CC
14 AM_PROG_CC_C_O
15 AC_ISC_POSIX
16 AC_PROG_INSTALL
17 AC_PROG_MAKE_SET
18 AC_PROG_AWK
19 AC_CHECK_PROGS([READELF], [readelf eu-readelf], [false])
20 AM_MISSING_PROG([AUTOM4TE], [autom4te])
21
22 AC_ENABLE_SHARED
23 AC_DISABLE_STATIC
24 dnl Next four lines is a hack to prevent libtool checking for CXX/F77
25 m4_undefine([AC_PROG_CXX])
26 m4_defun([AC_PROG_CXX],[])
27 m4_undefine([AC_PROG_F77])
28 m4_defun([AC_PROG_F77],[])
29 AC_PROG_LIBTOOL
30
31 AC_PREFIX_DEFAULT([/usr])
32
33 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 dnl Checks for libraries.
40 dnl Checks for header files.
41 AC_FUNC_ALLOCA
42 AC_HEADER_DIRENT
43 AC_HEADER_STDC
44 AC_HEADER_SYS_WAIT
45 AC_CHECK_HEADERS_ONCE([ \
46 dirent.h \
47 dlfcn.h \
48 elf.h \
49 errno.h \
50 execinfo.h \
51 fcntl.h \
52 libgen.h \
53 limits.h \
54 memory.h \
55 signal.h \
56 sigsegv.h \
57 stdarg.h \
58 stdbool.h \
59 stddef.h \
60 stdio.h \
61 stdlib.h \
62 string.h \
63 strings.h \
64 syscall.h \
65 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 ])
75
76 dnl Checks for typedefs, structures, and compiler characteristics.
77 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 dnl Checks for library functions.
84 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 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 remove \
102 rmdir \
103 setenv \
104 strcasecmp \
105 strchr \
106 strdup \
107 strerror \
108 strndup \
109 strrchr \
110 strspn \
111 strstr \
112 strtok_r \
113 ])
114 AC_CHECK_LIB([sigsegv], [stackoverflow_install_handler],
115 [HAVE_LIBSIGSEGV=true],
116 [HAVE_LIBSIGSEGV=false])
117 AM_CONDITIONAL(HAVE_LIBSIGSEGV, $HAVE_LIBSIGSEGV)
118
119 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 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 dnl Some libc's like those on bsd have dlopen() in libc, and not libdl
160 AC_CHECK_LIB([dl], [dlopen],
161 [have_libdl="yes"],
162 [have_libdl="no"]
163 )
164 if test x"$have_libdl" = xyes ; then
165 LIBDL="-ldl"
166 AC_SUBST([LIBDL])
167 DL_LIB="dl"
168 else
169 DL_LIB="c"
170 AC_CHECK_LIB([c], [dlopen],
171 [],
172 [AC_MSG_ERROR([Unable to determine library providing dlopen])]
173 )
174 fi
175
176 dnl uClibc doesn't currently provide dlvsym() so lets
177 dnl verify the toolchain supports it
178 AC_CHECK_LIB([$DL_LIB], [dlvsym],
179 [AC_DEFINE([HAVE_DLVSYM], [1], [libdl supports dlvsym])],
180 [AC_DEFINE([HAVE_DLVSYM], [0], [libdl does not support dlvsym])]
181 )
182
183 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 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 AC_MSG_RESULT([size_t])
189 AC_DEFINE([TRUNCATE_T], [size_t], [truncate arg type])
190 else
191 AC_MSG_RESULT([off_t])
192 AC_DEFINE([TRUNCATE_T], [off_t], [truncate arg type])
193 fi
194
195 dnl Check if libc provides RTLD_NEXT
196 AC_MSG_CHECKING([for RTLD_NEXT])
197 AC_TRY_COMPILE([
198 #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 )
208 AC_MSG_RESULT([$have_rtld_next])
209 if test x"$have_rtld_next" = xyes ; then
210 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
211 AC_DEFINE([HAVE_RTLD_NEXT], [1], [Have RTLD_NEXT enabled libc])
212 fi
213
214 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 AC_MSG_CHECKING([libc path])
217 echo "int main(void) { return 0; }" > libctest.c
218 $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-verbose -o libctest libctest.c > libctest.log 2>&1
219 cat libctest.log 1>&AS_MESSAGE_LOG_FD
220 LIBC_PATH=$(
221 $AWK '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}' libctest.log
222 )
223 rm -f libctest*
224 if test x"$LIBC_PATH" = x || ! test -r "$LIBC_PATH" ; then
225 AC_MSG_ERROR([Unable to determine LIBC PATH ($LIBC_PATH)])
226 fi
227 AC_MSG_RESULT([$LIBC_PATH])
228 AC_SUBST([LIBC_PATH])
229
230 dnl when intercepting libc calls, we have to know the name of the
231 dnl libc to load and search with dl*() calls
232 AC_MSG_CHECKING([libc version])
233 dnl the sed script at the end here looks funny but it's ok ...
234 echo "int main(void) { return 0; }" > libctest.c
235 $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 rm -f libctest*
242 if test "$LIBC_VERSION"x = x ; then
243 AC_MSG_ERROR([Unable to determine LIBC VERSION])
244 fi
245 AC_MSG_RESULT([$LIBC_VERSION])
246 AC_DEFINE_UNQUOTED([LIBC_VERSION], ["$LIBC_VERSION"], [Name of libc to hook into])
247
248 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 SANDBOX_DEFINES='-DETCDIR="\"$(sysconfdir)\"" -DLIBSANDBOX_PATH="\"$(libdir)\"" -DSANDBOX_BASHRC_PATH="\"$(pkgdatadir)\""'
252 AC_SUBST([SANDBOX_DEFINES])
253
254 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
255 if test "$GCC" = yes; then
256 CFLAGS="$CFLAGS -Wall"
257 fi
258
259 AC_CONFIG_TESTDIR([tests])
260
261 AC_OUTPUT([
262 Makefile
263 scripts/Makefile
264 etc/Makefile
265 data/Makefile
266 libsbutil/Makefile
267 libsandbox/Makefile
268 src/Makefile
269 tests/atlocal
270 tests/Makefile
271 tests/package.m4
272 ])

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20