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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


Revision 429 - (show annotations) (download)
Sun Nov 16 14:39:45 2008 UTC (5 years, 8 months ago) by vapier
File size: 6389 byte(s)
make -h/--help/-V/--version options to sandbox print out something useful
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 Checks for libraries.
31 dnl Checks for header files.
32 AC_FUNC_ALLOCA
33 AC_HEADER_DIRENT
34 AC_HEADER_STDC
35 AC_HEADER_SYS_WAIT
36 AC_CHECK_HEADERS_ONCE([ \
37 dirent.h \
38 dlfcn.h \
39 elf.h \
40 errno.h \
41 execinfo.h \
42 fcntl.h \
43 libgen.h \
44 limits.h \
45 memory.h \
46 signal.h \
47 stdarg.h \
48 stdbool.h \
49 stddef.h \
50 stdio.h \
51 stdlib.h \
52 string.h \
53 strings.h \
54 syscall.h \
55 unistd.h \
56 utime.h \
57 sys/file.h \
58 sys/mman.h \
59 sys/param.h \
60 sys/stat.h \
61 sys/time.h \
62 sys/types.h \
63 sys/wait.h \
64 ])
65
66 dnl Checks for typedefs, structures, and compiler characteristics.
67 AC_C_CONST
68 AC_TYPE_UID_T
69 AC_TYPE_MODE_T
70 AC_TYPE_SIZE_T
71 AC_CHECK_TYPES([ptrdiff_t])
72
73 dnl Checks for library functions.
74 AC_FUNC_CHOWN
75 AC_FUNC_FORK
76 AC_FUNC_LSTAT
77 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
78 AC_TYPE_SIGNAL
79 AC_FUNC_STAT
80 AC_CHECK_FUNCS_ONCE([ \
81 backtrace \
82 ftruncate \
83 getcwd \
84 lchown \
85 memmove \
86 memcpy \
87 memset \
88 mkdir \
89 pathconf \
90 realpath \
91 rmdir \
92 setenv \
93 strcasecmp \
94 strchr \
95 strdup \
96 strerror \
97 strndup \
98 strrchr \
99 strspn \
100 strstr \
101 strtok_r \
102 ])
103 dnl For librcutil
104 AC_CHECK_FUNCS([remove])
105
106 dnl Check if gcc provides va_copy or __va_copy (for librcutil)
107 AC_MSG_CHECKING([for va_copy])
108 AC_TRY_COMPILE([
109 #include <stdarg.h>
110 ], [
111 va_list ap, aq;
112 va_copy(ap, aq);
113 ],
114 [va_copy="va_copy"],
115 [AC_TRY_COMPILE([
116 #include <stdarg.h>
117 ], [
118 va_list ap, aq;
119 __va_copy(ap, aq);
120 ],
121 [va_copy="__va_copy"],
122 [AC_MSG_ERROR([Unable to determine name of va_copy macro])]
123 )]
124 )
125 AC_MSG_RESULT([$va_copy])
126 if test x"$va_copy" != xva_copy ; then
127 AC_DEFINE_UNQUOTED([va_copy], [$va_copy],
128 [Define to name of va_copy macro proviced by gcc if its not `va_copy'.]
129 )
130 fi
131
132 dnl Verify people aren't doing stupid shit
133 if test x"$enable_static" != xno ; then
134 AC_MSG_ERROR([dont be a Kumba, building a libsandbox.a is stupid])
135 fi
136 if test x"$enable_shared" != xyes ; then
137 AC_MSG_ERROR([dont be a Kumba, omitting a libsandbox.so is stupid])
138 fi
139 if echo $CFLAGS | $EGREP -e -static >/dev/null 2>&1; then
140 AC_MSG_ERROR([dont be a Kumba, using -static in CFLAGS is stupid])
141 fi
142 if echo $LDFLAGS | $EGREP -e -static >/dev/null 2>&1; then
143 AC_MSG_ERROR([dont be a Kumba, using -static in LDFLAGS is stupid])
144 fi
145
146 dnl Some libc's like those on bsd have dlopen() in libc, and not libdl
147 AC_CHECK_LIB([dl], [dlopen],
148 [have_libdl="yes"],
149 [have_libdl="no"]
150 )
151 if test x"$have_libdl" = xyes ; then
152 LIBDL="-ldl"
153 AC_SUBST([LIBDL])
154 DL_LIB="dl"
155 else
156 DL_LIB="c"
157 AC_CHECK_LIB([c], [dlopen],
158 [],
159 [AC_MSG_ERROR([Unable to determine library providing dlopen])]
160 )
161 fi
162
163 dnl uClibc doesn't currently provide dlvsym() so lets
164 dnl verify the toolchain supports it
165 AC_CHECK_LIB([$DL_LIB], [dlvsym],
166 [AC_DEFINE([HAVE_DLVSYM], [1], [libdl supports dlvsym])],
167 [AC_DEFINE([HAVE_DLVSYM], [0], [libdl does not support dlvsym])]
168 )
169
170 dnl when using libc5, (f)trucate's offset argument type is size_t with
171 dnl libc5, but it's off_t with libc6 (glibc2).
172 AC_MSG_CHECKING([truncate argument type])
173 TRUNC_ARG_TYPE=`echo '#include <unistd.h>' | $CC -E - | grep -q 'truncate.*size_t'`
174 if test "$TRUNC_ARG_TYPE"x != x ; then
175 AC_MSG_RESULT([size_t])
176 AC_DEFINE([TRUNCATE_T], [size_t], [truncate arg type])
177 else
178 AC_MSG_RESULT([off_t])
179 AC_DEFINE([TRUNCATE_T], [off_t], [truncate arg type])
180 fi
181
182 dnl Check if libc provides RTLD_NEXT
183 AC_MSG_CHECKING([for RTLD_NEXT])
184 AC_TRY_COMPILE([
185 #define _GNU_SOURCE
186 #include <dlfcn.h>
187 ], [
188 #if !defined(RTLD_NEXT)
189 # error no RTLD_NEXT
190 #endif
191 ],
192 [have_rtld_next="yes"],
193 [have_rtld_next="no"]
194 )
195 AC_MSG_RESULT([$have_rtld_next])
196 if test x"$have_rtld_next" = xyes ; then
197 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
198 AC_DEFINE([HAVE_RTLD_NEXT], [1], [Have RTLD_NEXT enabled libc])
199 fi
200
201 dnl we need to handle symbols differently based upon their version,
202 dnl but we have to know which symbols the libc supports first
203 AC_MSG_CHECKING([libc path])
204 echo "int main(void) { return 0; }" > libctest.c
205 $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-verbose -o libctest libctest.c > libctest.log 2>&1
206 cat libctest.log 1>&AS_MESSAGE_LOG_FD
207 LIBC_PATH=$(
208 $AWK '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}' libctest.log
209 )
210 rm -f libctest*
211 if test x"$LIBC_PATH" = x || ! test -r "$LIBC_PATH" ; then
212 AC_MSG_ERROR([Unable to determine LIBC PATH ($LIBC_PATH)])
213 fi
214 AC_MSG_RESULT([$LIBC_PATH])
215 AC_SUBST([LIBC_PATH])
216
217 dnl when intercepting libc calls, we have to know the name of the
218 dnl libc to load and search with dl*() calls
219 AC_MSG_CHECKING([libc version])
220 dnl the sed script at the end here looks funny but it's ok ...
221 echo "int main(void) { return 0; }" > libctest.c
222 $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wall -o libctest libctest.c
223 LIBC_VERSION=$(
224 $READELF -d libctest | \
225 grep NEEDED.*libc\\.so | \
226 $AWK '{print $NF}' | sed -e ['s:\[::' -e 's:\]::']
227 )
228 rm -f libctest*
229 if test "$LIBC_VERSION"x = x ; then
230 AC_MSG_ERROR([Unable to determine LIBC VERSION])
231 fi
232 AC_MSG_RESULT([$LIBC_VERSION])
233 AC_DEFINE_UNQUOTED([LIBC_VERSION], ["$LIBC_VERSION"], [Name of libc to hook into])
234
235 dnl We add to CPPFLAGS rather than doing AC_DEFINE_UNQUOTED
236 dnl so we dont have to worry about fully expanding all of
237 dnl the variables ($sysconfdir defaults to "$prefix/etc")
238 SANDBOX_DEFINES='-DETCDIR="\"$(sysconfdir)\"" -DLIBSANDBOX_PATH="\"$(libdir)\"" -DSANDBOX_BASHRC_PATH="\"$(pkgdatadir)\""'
239 AC_SUBST([SANDBOX_DEFINES])
240
241 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
242 if test "$GCC" = yes; then
243 CFLAGS="$CFLAGS -Wall"
244 fi
245
246 AC_CONFIG_TESTDIR([tests])
247
248 AC_OUTPUT([
249 Makefile
250 scripts/Makefile
251 etc/Makefile
252 data/Makefile
253 libsbutil/Makefile
254 libsandbox/Makefile
255 src/Makefile
256 tests/atlocal
257 tests/Makefile
258 tests/package.m4
259 ])

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20