1 |
AC_PREREQ(2.59) |
2 |
AC_INIT(sandbox, 1.2.2, dev-portage@gentoo.org) |
3 |
AM_INIT_AUTOMAKE |
4 |
AC_CONFIG_HEADER([config.h]) |
5 |
|
6 |
# 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 |
|
13 |
AC_ENABLE_SHARED |
14 |
AC_DISABLE_STATIC |
15 |
m4_undefine([AC_PROG_CXX]) |
16 |
m4_defun([AC_PROG_CXX],[]) |
17 |
m4_undefine([AC_PROG_F77]) |
18 |
m4_defun([AC_PROG_F77],[]) |
19 |
AC_PROG_LIBTOOL |
20 |
|
21 |
AC_PREFIX_DEFAULT([/usr]) |
22 |
|
23 |
# Checks for libraries. |
24 |
# Checks for header files. |
25 |
AC_FUNC_ALLOCA |
26 |
AC_HEADER_DIRENT |
27 |
AC_HEADER_STDC |
28 |
AC_HEADER_SYS_WAIT |
29 |
AC_CHECK_HEADERS([ \ |
30 |
fcntl.h limits.h memory.h stddef.h \ |
31 |
stdlib.h string.h strings.h sys/file.h \ |
32 |
sys/param.h sys/time.h unistd.h utime.h \ |
33 |
]) |
34 |
|
35 |
# Checks for typedefs, structures, and compiler characteristics. |
36 |
AC_C_CONST |
37 |
AC_TYPE_UID_T |
38 |
AC_TYPE_MODE_T |
39 |
AC_TYPE_SIZE_T |
40 |
AC_CHECK_TYPES([ptrdiff_t]) |
41 |
|
42 |
# Checks for library functions. |
43 |
AC_FUNC_CHOWN |
44 |
AC_FUNC_FORK |
45 |
AC_FUNC_LSTAT |
46 |
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK |
47 |
AC_FUNC_MALLOC |
48 |
AC_FUNC_REALLOC |
49 |
AC_TYPE_SIGNAL |
50 |
AC_FUNC_STAT |
51 |
AC_CHECK_FUNCS([ \ |
52 |
bzero ftruncate getcwd lchown memmove \ |
53 |
mempcpy memset mkdir pathconf realpath \ |
54 |
rmdir setenv strcasecmp strchr strdup \ |
55 |
strerror strndup strrchr strspn strstr \ |
56 |
]) |
57 |
|
58 |
dnl when using libc5, (f)trucate's offset argument type is size_t with |
59 |
dnl libc5, but it's off_t with libc6 (glibc2). |
60 |
AC_MSG_CHECKING(truncate argument type) |
61 |
if echo '#include <unistd.h>' | $CC -E - | grep -q 'truncate.*size_t' ; then |
62 |
AC_MSG_RESULT(size_t) |
63 |
AC_DEFINE(TRUNCATE_T, size_t, [truncate arg type]) |
64 |
else |
65 |
AC_MSG_RESULT(off_t) |
66 |
AC_DEFINE(TRUNCATE_T, off_t, [truncate arg type]) |
67 |
fi |
68 |
|
69 |
dnl we need to handle symbols differently based upon their version, |
70 |
dnl but we have to know which symbols the libc supports first |
71 |
AC_MSG_CHECKING(libc path) |
72 |
echo "int main(void) { return 0; }" > libctest.c |
73 |
$CC -Wall -o libctest libctest.c |
74 |
LIBC_PATH=`$CC $CFLAGS -Wl,-verbose -o libctest libctest.c 2>&1 | \ |
75 |
$AWK '/attempt to open/ { if (($4 ~ /libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}'` |
76 |
if test "$LIBC_PATH"x = x ; then |
77 |
AC_MSG_ERROR(Unable to determine LIBC PATH) |
78 |
fi |
79 |
AC_MSG_RESULT($LIBC_PATH) |
80 |
AC_SUBST(LIBC_PATH) |
81 |
|
82 |
dnl when intercepting libc calls, we have to know the name of the |
83 |
dnl libc to load and search with dl*() calls |
84 |
AC_MSG_CHECKING(libc version) |
85 |
dnl the sed script at the end here looks funny but it's ok ... |
86 |
dnl they're m4 escape sequences for left and right brackets |
87 |
LIBC_VERSION=`readelf -d libctest | grep NEEDED.*libc\\.so | $AWK '{print $NF}' | sed -e 's:\@<:@::' -e 's:\@:>@::'` |
88 |
if test "$LIBC_VERSION"x = x ; then |
89 |
AC_MSG_ERROR(Unable to determine LIBC VERSION) |
90 |
fi |
91 |
AC_MSG_RESULT($LIBC_VERSION) |
92 |
AC_DEFINE_UNQUOTED(LIBC_VERSION, "$LIBC_VERSION", [name of libc to hook into]) |
93 |
rm -f libctest |
94 |
|
95 |
AC_OUTPUT([Makefile]) |