| … | |
… | |
| 49 | mempcpy memset mkdir pathconf realpath \ |
49 | mempcpy memset mkdir pathconf realpath \ |
| 50 | rmdir setenv strcasecmp strchr strdup \ |
50 | rmdir setenv strcasecmp strchr strdup \ |
| 51 | strerror strndup strrchr strspn strstr \ |
51 | strerror strndup strrchr strspn strstr \ |
| 52 | ]) |
52 | ]) |
| 53 | |
53 | |
| 54 | dnl |
|
|
| 55 | dnl FIXME: the following needs to be made portable |
|
|
| 56 | dnl |
|
|
| 57 | |
|
|
| 58 | dnl when using libc5, (f)trucate's offset argument type is size_t with |
54 | 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). |
55 | dnl libc5, but it's off_t with libc6 (glibc2). |
| 60 | AC_MSG_CHECKING(truncate argument type) |
56 | AC_MSG_CHECKING(truncate argument type) |
| 61 | if grep -q 'truncate.*size_t' /usr/include/unistd.h ; then |
57 | if echo '#include <unistd.h>' | $CC -E - | grep -q 'truncate.*size_t' ; then |
| 62 | AC_MSG_RESULT(size_t) |
58 | AC_MSG_RESULT(size_t) |
| 63 | AC_DEFINE(TRUNCATE_T, size_t, [truncate arg type]) |
59 | AC_DEFINE(TRUNCATE_T, size_t, [truncate arg type]) |
| 64 | else |
60 | else |
| 65 | AC_MSG_RESULT(off_t) |
61 | AC_MSG_RESULT(off_t) |
| 66 | AC_DEFINE(TRUNCATE_T, off_t, [truncate arg type]) |
62 | AC_DEFINE(TRUNCATE_T, off_t, [truncate arg type]) |
| 67 | fi |
63 | fi |
| 68 | |
64 | |
| 69 | AC_MSG_CHECKING(Checking libc version) |
65 | dnl we need to handle symbols differently based upon their version, |
|
|
66 | dnl but we have to know which symbols the libc supports first |
|
|
67 | AC_MSG_CHECKING(libc path) |
| 70 | echo "int main(void) { return 0; }" > libctest.c |
68 | echo "int main(void) { return 0; }" > libctest.c |
| 71 | gcc -Wall -o libctest libctest.c |
69 | $CC -Wall -o libctest libctest.c |
| 72 | LIBC_VERSION=`ldd libctest | grep libc\\.so | grep -v 'ld-uClibc' | ${AWK} '{print $1}'` |
70 | LIBC_PATH=`$CC $CFLAGS -Wl,-verbose -o libctest libctest.c 2>&1 | \ |
| 73 | LIBC_PATH=`ldd libctest | grep libc\\.so | grep -v 'ld-uClibc' | ${AWK} '{print $3}'` |
71 | gawk '/attempt to open/ { if (($4 ~ /libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}'` |
|
|
72 | if test "$LIBC_PATH"x = x ; then |
|
|
73 | AC_MSG_ERROR(Unable to determine LIBC PATH) |
|
|
74 | fi |
|
|
75 | AC_MSG_RESULT($LIBC_PATH) |
|
|
76 | AC_SUBST(LIBC_PATH) |
|
|
77 | |
|
|
78 | dnl when intercepting libc calls, we have to know the name of the |
|
|
79 | dnl libc to load and search with dl*() calls |
|
|
80 | AC_MSG_CHECKING(libc version) |
|
|
81 | dnl the sed script at the end here looks funny but it's ok ... |
|
|
82 | dnl they're m4 escape sequences for left and right brackets |
|
|
83 | LIBC_VERSION=`readelf -d libctest | grep NEEDED.*libc\\.so | $AWK '{print $NF}' | sed -e 's:\@<:@::' -e 's:\@:>@::'` |
|
|
84 | if test "$LIBC_VERSION"x = x ; then |
|
|
85 | AC_MSG_ERROR(Unable to determine LIBC VERSION) |
|
|
86 | fi |
|
|
87 | AC_MSG_RESULT($LIBC_VERSION) |
|
|
88 | AC_DEFINE_UNQUOTED(LIBC_VERSION, "$LIBC_VERSION", [name of libc to hook into]) |
| 74 | rm -f libctest |
89 | rm -f libctest |
| 75 | AC_SUBST(LIBC_VERSION) |
|
|
| 76 | AC_SUBST(LIBC_PATH) |
|
|
| 77 | AC_MSG_RESULT(${LIBC_VERSION}) |
|
|
| 78 | |
90 | |
| 79 | AC_OUTPUT([Makefile]) |
91 | AC_OUTPUT([Makefile]) |