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

Contents of /trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20