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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20