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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


Revision 405 - (hide annotations) (download)
Tue Nov 11 08:23:51 2008 UTC (6 years ago) by vapier
File size: 6245 byte(s)
initial test framework
1 vapier 377 AC_PREREQ([2.61])
2     AC_INIT([sandbox], [1.3.0], [sandbox@gentoo.org])
3 ferringb 2 AM_INIT_AUTOMAKE
4 ferringb 16 AC_CONFIG_HEADER([config.h])
5 ferringb 2
6 vapier 61 dnl Checks for programs.
7 ferringb 2 AC_PROG_CC
8 azarah 29 AC_ISC_POSIX
9     AC_PROG_INSTALL
10     AC_PROG_MAKE_SET
11     AC_PROG_AWK
12 azarah 236 AC_CHECK_PROGS([READELF], [readelf eu-readelf], [false])
13 vapier 405 AM_MISSING_PROG([AUTOM4TE], [autom4te])
14 azarah 29
15 vapier 21 AC_ENABLE_SHARED
16     AC_DISABLE_STATIC
17 vapier 61 dnl Next four lines is a hack to prevent libtool checking for CXX/F77
18 azarah 56 m4_undefine([AC_PROG_CXX])
19     m4_defun([AC_PROG_CXX],[])
20     m4_undefine([AC_PROG_F77])
21     m4_defun([AC_PROG_F77],[])
22 ferringb 2 AC_PROG_LIBTOOL
23    
24     AC_PREFIX_DEFAULT([/usr])
25 azarah 29
26 vapier 61 dnl Checks for libraries.
27     dnl Checks for header files.
28 ferringb 2 AC_FUNC_ALLOCA
29     AC_HEADER_DIRENT
30     AC_HEADER_STDC
31     AC_HEADER_SYS_WAIT
32 vapier 370 AC_CHECK_HEADERS_ONCE([ \
33     dirent.h \
34     dlfcn.h \
35 vapier 396 elf.h \
36 vapier 370 errno.h \
37 vapier 396 execinfo.h \
38 vapier 370 fcntl.h \
39     libgen.h \
40     limits.h \
41     memory.h \
42     signal.h \
43     stdarg.h \
44 vapier 396 stdbool.h \
45 vapier 370 stddef.h \
46     stdio.h \
47     stdlib.h \
48     string.h \
49     strings.h \
50 vapier 405 syscall.h \
51 vapier 370 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 vapier 21 ])
61 ferringb 2
62 vapier 61 dnl Checks for typedefs, structures, and compiler characteristics.
63 ferringb 2 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 vapier 61 dnl Checks for library functions.
70 ferringb 2 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 vapier 396 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 vapier 356 strtok_r \
98 vapier 21 ])
99 azarah 278 dnl For librcutil
100     AC_CHECK_FUNCS([remove])
101 ferringb 2
102 azarah 278 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 vapier 243 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 azarah 218 dnl Some libc's like those on bsd have dlopen() in libc, and not libdl
143     AC_CHECK_LIB([dl], [dlopen],
144 azarah 234 [have_libdl="yes"],
145     [have_libdl="no"]
146 azarah 218 )
147     if test x"$have_libdl" = xyes ; then
148 azarah 234 LIBDL="-ldl"
149     AC_SUBST([LIBDL])
150     DL_LIB="dl"
151 azarah 218 else
152 azarah 234 DL_LIB="c"
153     AC_CHECK_LIB([c], [dlopen],
154     [],
155     [AC_MSG_ERROR([Unable to determine library providing dlopen])]
156     )
157 azarah 218 fi
158    
159 vapier 62 dnl uClibc doesn't currently provide dlvsym() so lets
160     dnl verify the toolchain supports it
161 azarah 218 AC_CHECK_LIB([$DL_LIB], [dlvsym],
162 azarah 234 [AC_DEFINE([HAVE_DLVSYM], [1], [libdl supports dlvsym])],
163     [AC_DEFINE([HAVE_DLVSYM], [0], [libdl does not support dlvsym])]
164 vapier 62 )
165    
166 vapier 23 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 azarah 180 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 azarah 234 AC_MSG_RESULT([size_t])
172     AC_DEFINE([TRUNCATE_T], [size_t], [truncate arg type])
173 vapier 23 else
174 azarah 234 AC_MSG_RESULT([off_t])
175     AC_DEFINE([TRUNCATE_T], [off_t], [truncate arg type])
176 vapier 23 fi
177    
178 azarah 220 dnl Check if libc provides RTLD_NEXT
179     AC_MSG_CHECKING([for RTLD_NEXT])
180 azarah 216 AC_TRY_COMPILE([
181 azarah 234 #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 azarah 217 )
191 azarah 220 AC_MSG_RESULT([$have_rtld_next])
192 azarah 235 if test x"$have_rtld_next" = xyes ; then
193 vapier 370 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
194 azarah 235 AC_DEFINE([HAVE_RTLD_NEXT], [1], [Have RTLD_NEXT enabled libc])
195     fi
196 azarah 216
197 vapier 53 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 azarah 180 AC_MSG_CHECKING([libc path])
200 vapier 23 echo "int main(void) { return 0; }" > libctest.c
201 vapier 356 $CC $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-verbose -o libctest libctest.c > libctest.log 2>&1
202 vapier 238 cat libctest.log 1>&AS_MESSAGE_LOG_FD
203 vapier 356 LIBC_PATH=$(
204     $AWK '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}' libctest.log
205     )
206 azarah 234 rm -f libctest*
207 vapier 239 if test x"$LIBC_PATH" = x || ! test -r "$LIBC_PATH" ; then
208 vapier 238 AC_MSG_ERROR([Unable to determine LIBC PATH ($LIBC_PATH)])
209 vapier 53 fi
210 azarah 180 AC_MSG_RESULT([$LIBC_PATH])
211     AC_SUBST([LIBC_PATH])
212 vapier 23
213 vapier 53 dnl when intercepting libc calls, we have to know the name of the
214     dnl libc to load and search with dl*() calls
215 azarah 180 AC_MSG_CHECKING([libc version])
216 vapier 53 dnl the sed script at the end here looks funny but it's ok ...
217 azarah 234 echo "int main(void) { return 0; }" > libctest.c
218 vapier 356 $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 azarah 234 rm -f libctest*
225 vapier 53 if test "$LIBC_VERSION"x = x ; then
226 azarah 234 AC_MSG_ERROR([Unable to determine LIBC VERSION])
227 vapier 53 fi
228 azarah 180 AC_MSG_RESULT([$LIBC_VERSION])
229 azarah 233 AC_DEFINE_UNQUOTED([LIBC_VERSION], ["$LIBC_VERSION"], [Name of libc to hook into])
230 vapier 53
231 vapier 356 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 azarah 309 SANDBOX_DEFINES='-DETCDIR="\"$(sysconfdir)\"" -DLIBSANDBOX_PATH="\"$(libdir)\"" -DSANDBOX_BASHRC_PATH="\"$(pkgdatadir)\""'
235     AC_SUBST([SANDBOX_DEFINES])
236    
237 vapier 404 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
238     if test "$GCC" = yes; then
239     CFLAGS="$CFLAGS -Wall"
240     fi
241    
242 vapier 405 AC_CONFIG_TESTDIR([tests])
243    
244 azarah 183 AC_OUTPUT([
245 vapier 356 Makefile
246     scripts/Makefile
247     etc/Makefile
248     data/Makefile
249     libsbutil/Makefile
250     libsandbox/Makefile
251     src/Makefile
252 vapier 405 tests/atlocal
253     tests/Makefile
254     tests/package.m4
255 azarah 183 ])

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20