1 # Process this file with autoconf to produce a configure script, like so:
2 # aclocal && autoconf && autoheader && automake
7 AM_INIT_AUTOMAKE(libmudflap, 1.0)
10 # For libtool versioning info, format is CURRENT:REVISION:AGE
12 AC_SUBST(libtool_VERSION)
14 dnl AM_ENABLE_MULTILIB
18 target_alias=${target_alias-$target}
19 AC_SUBST(target_alias)
21 AM_CONFIG_HEADER(config.h)
25 if test "x$GCC" != "xyes"; then
26 AC_MSG_ERROR([libmudflap must be built with GCC])
30 # Some hosts don't have dlsym(RTLD_NEXT, "symbol") for use in
31 # symbol interposition. We disable shared libraries for these.
32 AC_MSG_CHECKING([whether dlsym(RTLD_NEXT,...) is available])
37 [void *foo = dlsym (RTLD_NEXT, "exit");],
42 AC_CHECK_HEADERS(stdint.h execinfo.h signal.h dlfcn.h)
43 AC_CHECK_FUNCS(backtrace backtrace_symbols gettimeofday signal)
45 dnl Check for 64-bit stdio calls related to Large File Support
46 AC_CHECK_FUNCS(fopen64 fseeko64 ftello64 stat64)
48 AC_TRY_COMPILE([#include <sys/types.h>
50 #include <sys/sem.h>],[union semun foo;], [mf_have_semun=1], [mf_have_semun=0])
51 if test $mf_have_semun = 1
53 AC_DEFINE(HAVE_UNION_SEMUN, 1, [union semun defined in sys/ipc.h or sys/sem.h])
57 AC_MSG_CHECKING([for socklen_t in sys/socket.h])
58 AC_TRY_COMPILE([#define _POSIX_PII_SOCKET
59 #include <sys/types.h>
60 #include <sys/socket.h>], [socklen_t x = 5;],
61 [AC_DEFINE(HAVE_SOCKLEN_T, 1, [Define it socklen_t typedef is in sys/socket.h.])
67 AC_SUBST(enable_shared)
68 AC_SUBST(enable_static)
70 AC_CHECK_HEADER(stdint.h, [MF_HAVE_STDINT_H=1], [MF_HAVE_STDINT_H=0])
71 AC_SUBST(MF_HAVE_STDINT_H)
72 if test $MF_HAVE_STDINT_H = 1
76 AC_TRY_COMPILE([#include <sys/types.h>], [uintptr_t k = 0;],
77 [MF_HAVE_UINTPTR_T=1], [MF_HAVE_UINTPTR_T=0])
79 AC_SUBST(MF_HAVE_UINTPTR_T)
83 # libmudflapth objects are built in this subdirectory
87 pthread_create_version='""'
88 AC_CHECK_HEADER(pthread.h,[
89 AC_DEFINE_UNQUOTED(HAVE_PTHREAD_H, 1, [define if you have <pthread.h>])
94 AM_CONDITIONAL(LIBMUDFLAPTH, [test "x$ac_have_pthread_h" != ""])
96 AC_CHECK_LIB(dl, dlsym)
98 if test "x$enable_shared" = "xyes" && test "x$ac_have_pthread_h" != ""; then
99 # NB: don't check for -lpthread here, because then it would be
100 # added to LIBS. For the thread-unaware libmudflap.la, we don't
103 # glibc-related hacks. dlsym() may pick the wrong version of
104 # interposed functions like pthread_create on modern glibc.
105 # We need to find the proper symbol version string, and use
106 # the nonstandard dlvsym().
107 AC_CHECK_FUNCS(dlvsym)
108 AC_CHECK_TOOL(NM, nm)
109 if test "x$ac_cv_have_dlvsym" != ""; then
110 # Try compiling a simple pthreads program. Find the shared libraries it
111 # ends up with. Then use "nm" on those libraries to extract the
112 # default symbol versioning suffix ("@@"), if any. But that's tricky.
113 # Rather, run nm on the resulting executable. Unfortunately, autoconf
114 # doesn't appear to have a macro that builds a test executable for
115 # subsequent analysis ... so we do it by hand here.
116 cat >> conftest.c << EOF
118 int main () { void *p = (void *) & pthread_create; return (int) p; }
121 LIBS="$LIBS -lpthread"
122 pthread_create_version="\"\""
123 AC_MSG_CHECKING(pthread_create symbol version)
124 if eval $ac_link 2>&5 && test -s conftest${ac_exeext}; then
125 version=`$NM conftest${ac_exeect} | grep 'pthread_create@@' | sed -e 's/^.*@@//'`
126 if test "x$version" != "x"; then
127 pthread_create_version="\"$version\""
130 AC_MSG_RESULT($pthread_create_version)
134 AC_DEFINE_UNQUOTED(PTHREAD_CREATE_VERSION, $pthread_create_version, [pthread_create symbol version])
137 AC_OUTPUT([Makefile testsuite/Makefile mf-runtime.h])