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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20