OSDN Git Service

* acinclude.m4 (lt_cv_deplibs_check_method): Use pass_all on sh*.
[pf3gnuchains/gcc-fork.git] / libmudflap / configure.in
1 # Process this file with autoconf to produce a configure script, like so:
2 # aclocal && autoconf && autoheader && automake
3
4 AC_PREREQ(2.13)
5 AC_INIT(mf-runtime.c)
6 AC_CANONICAL_SYSTEM
7 AM_INIT_AUTOMAKE(libmudflap, 1.0)
8
9 AC_SUBST(PACKAGE)
10 # For libtool versioning info, format is CURRENT:REVISION:AGE
11 libtool_VERSION=1:0:0
12 AC_SUBST(libtool_VERSION)
13
14 dnl AM_ENABLE_MULTILIB
15 AM_MAINTAINER_MODE
16 AC_EXEEXT
17
18 target_alias=${target_alias-$target}
19 AC_SUBST(target_alias)
20
21 AM_CONFIG_HEADER(config.h)
22
23 AC_LANG_C
24 AC_PROG_CC
25 if test "x$GCC" != "xyes"; then
26   AC_MSG_ERROR([libmudflap must be built with GCC])
27 fi
28 AC_PROG_CPP
29
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])
33 AC_TRY_COMPILE([
34 #define _GNU_SOURCE
35 #include <dlfcn.h>
36 ],
37 [void *foo = dlsym (RTLD_NEXT, "exit");],
38 [AC_MSG_RESULT(yes)],
39 [AC_MSG_RESULT(no)
40 enable_shared=no])
41
42 AC_CHECK_HEADERS(stdint.h execinfo.h signal.h dlfcn.h)
43 AC_CHECK_FUNCS(backtrace backtrace_symbols gettimeofday signal)
44
45 dnl Check for 64-bit stdio calls related to Large File Support
46 AC_CHECK_FUNCS(fopen64 fseeko64 ftello64 stat64)
47
48 AC_TRY_COMPILE([#include <sys/types.h>
49 #include <sys/ipc.h>
50 #include <sys/sem.h>],[union semun foo;], [mf_have_semun=1], [mf_have_semun=0])
51 if test $mf_have_semun = 1
52 then
53   AC_DEFINE(HAVE_UNION_SEMUN, 1, [union semun defined in sys/ipc.h or sys/sem.h])
54 fi
55
56
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.])
62    AC_MSG_RESULT(yes)],
63   [AC_MSG_RESULT(no)])
64
65 AC_LIBTOOL_DLOPEN
66 AM_PROG_LIBTOOL
67 AC_SUBST(enable_shared)
68 AC_SUBST(enable_static)
69
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
73 then
74    MF_HAVE_UINTPTR_T=1
75 else
76    AC_TRY_COMPILE([#include <sys/types.h>], [uintptr_t k = 0;],
77         [MF_HAVE_UINTPTR_T=1], [MF_HAVE_UINTPTR_T=0])
78 fi
79 AC_SUBST(MF_HAVE_UINTPTR_T)
80
81 if test ! -d pth
82 then
83   # libmudflapth objects are built in this subdirectory
84   mkdir pth
85 fi
86
87 pthread_create_version='""'
88 AC_CHECK_HEADER(pthread.h,[
89 AC_DEFINE_UNQUOTED(HAVE_PTHREAD_H, 1, [define if you have <pthread.h>])
90 ac_have_pthread_h=yes
91 ],[
92 ac_have_pthread_h=
93 ])
94 AM_CONDITIONAL(LIBMUDFLAPTH, [test "x$ac_have_pthread_h" != ""])
95
96 AC_CHECK_LIB(dl, dlsym)
97
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
101   # want it there.
102
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
117 #include <pthread.h>
118 int main () { void *p = (void *) & pthread_create; return (int) p; }
119 EOF
120     oldLIBS="$LIBS"
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\""
128       fi
129     fi
130     AC_MSG_RESULT($pthread_create_version)
131     LIBS="$oldLIBS"
132   fi
133 fi
134 AC_DEFINE_UNQUOTED(PTHREAD_CREATE_VERSION, $pthread_create_version, [pthread_create symbol version])   
135
136
137 AC_OUTPUT([Makefile testsuite/Makefile mf-runtime.h])