]> git.ipfire.org Git - thirdparty/gcc.git/blame - libmudflap/configure.ac
This avoids small data/gp reloc overflow errors.
[thirdparty/gcc.git] / libmudflap / configure.ac
CommitLineData
6de9cd9a
DN
1# Process this file with autoconf to produce a configure script, like so:
2# aclocal && autoconf && autoheader && automake
3
076e5443
PB
4AC_PREREQ(2.59)
5AC_INIT(libmudflap, 1.0)
6AC_CONFIG_SRCDIR(mf-runtime.c)
6de9cd9a 7AC_CANONICAL_SYSTEM
6de9cd9a 8
076e5443
PB
9AM_INIT_AUTOMAKE
10
42fcd7bb
AJ
11AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
12AC_ARG_ENABLE(version-specific-runtime-libs,
13[ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
14[case "$enableval" in
15 yes) version_specific_libs=yes ;;
16 no) version_specific_libs=no ;;
17 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
18 esac],
19[version_specific_libs=no])
20AC_MSG_RESULT($version_specific_libs)
21
6de9cd9a
DN
22AM_MAINTAINER_MODE
23AC_EXEEXT
24
42fcd7bb
AJ
25AM_ENABLE_MULTILIB(, ..)
26
124e22d4 27target_alias=${target_alias-$host_alias}
6de9cd9a
DN
28AC_SUBST(target_alias)
29
076e5443 30AC_CONFIG_HEADERS(config.h)
6de9cd9a
DN
31
32AC_LANG_C
42fcd7bb
AJ
33# The same as in boehm-gc and libstdc++. Have to borrow it from there.
34# We must force CC to /not/ be precious variables; otherwise
35# the wrong, non-multilib-adjusted value will be used in multilibs.
36# As a side effect, we have to subst CFLAGS ourselves.
37
38m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
39m4_define([_AC_ARG_VAR_PRECIOUS],[])
6de9cd9a 40AC_PROG_CC
42fcd7bb
AJ
41m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
42
43AC_SUBST(CFLAGS)
44
6de9cd9a
DN
45if test "x$GCC" != "xyes"; then
46 AC_MSG_ERROR([libmudflap must be built with GCC])
47fi
48AC_PROG_CPP
49
50# Some hosts don't have dlsym(RTLD_NEXT, "symbol") for use in
51# symbol interposition. We disable shared libraries for these.
52AC_MSG_CHECKING([whether dlsym(RTLD_NEXT,...) is available])
53AC_TRY_COMPILE([
54#define _GNU_SOURCE
55#include <dlfcn.h>
56],
57[void *foo = dlsym (RTLD_NEXT, "exit");],
58[AC_MSG_RESULT(yes)],
59[AC_MSG_RESULT(no)
60enable_shared=no])
61
66a5d3b1 62AC_CHECK_HEADERS(stdint.h execinfo.h signal.h dlfcn.h dirent.h pwd.h grp.h \
73407061 63 netdb.h sys/ipc.h sys/sem.h sys/shm.h sys/wait.h ctype.h mntent.h \
ddfabf89 64 sys/socket.h netinet/in.h arpa/inet.h dlfcn.h sys/mman.h)
6de9cd9a 65
07c2f075 66AC_CHECK_FUNCS(backtrace backtrace_symbols gettimeofday signal)
ddfabf89
FCE
67AC_CHECK_FUNCS(fopen64 fseeko64 ftello64 stat64 freopen64)
68AC_CHECK_FUNCS(setbuf setbuffer setlinebuf setvbuf)
7954e85c 69AC_CHECK_FUNCS(strnlen memrchr strncpy memmem sethostname)
dc88d66f 70AC_CHECK_FUNCS(__ctype_b_loc __ctype_tolower_loc __ctype_toupper_loc)
66a5d3b1
FCE
71AC_CHECK_FUNCS(getlogin cuserid getpwnam getpwuid getpwent getgrnam getgrgid getgrent)
72AC_CHECK_FUNCS(getlogin_r getpwnam_r getpwuid_r getgrnam_r getgrgid_r)
73AC_CHECK_FUNCS(getservent getservbyname getservbyport getaddrinfo gai_strerror)
07c2f075
FCE
74AC_CHECK_FUNCS(getprotoent getprotobyname getprotobynumber)
75AC_CHECK_FUNCS(getmntent setmntent addmntent)
ddfabf89 76AC_CHECK_FUNCS(inet_ntoa mmap munmap)
66a5d3b1 77
6de9cd9a
DN
78AC_TRY_COMPILE([#include <sys/types.h>
79#include <sys/ipc.h>
80#include <sys/sem.h>],[union semun foo;], [mf_have_semun=1], [mf_have_semun=0])
81if test $mf_have_semun = 1
82then
83 AC_DEFINE(HAVE_UNION_SEMUN, 1, [union semun defined in sys/ipc.h or sys/sem.h])
84fi
85
86
87AC_MSG_CHECKING([for socklen_t in sys/socket.h])
88AC_TRY_COMPILE([#define _POSIX_PII_SOCKET
42fcd7bb 89#include <sys/types.h>
6de9cd9a
DN
90#include <sys/socket.h>], [socklen_t x = 5;],
91 [AC_DEFINE(HAVE_SOCKLEN_T, 1, [Define it socklen_t typedef is in sys/socket.h.])
92 AC_MSG_RESULT(yes)],
93 [AC_MSG_RESULT(no)])
94
95AC_LIBTOOL_DLOPEN
96AM_PROG_LIBTOOL
97AC_SUBST(enable_shared)
98AC_SUBST(enable_static)
99
100AC_CHECK_HEADER(stdint.h, [MF_HAVE_STDINT_H=1], [MF_HAVE_STDINT_H=0])
101AC_SUBST(MF_HAVE_STDINT_H)
102if test $MF_HAVE_STDINT_H = 1
103then
104 MF_HAVE_UINTPTR_T=1
105else
106 AC_TRY_COMPILE([#include <sys/types.h>], [uintptr_t k = 0;],
42fcd7bb 107 [MF_HAVE_UINTPTR_T=1], [MF_HAVE_UINTPTR_T=0])
6de9cd9a
DN
108fi
109AC_SUBST(MF_HAVE_UINTPTR_T)
110
111if test ! -d pth
112then
113 # libmudflapth objects are built in this subdirectory
114 mkdir pth
115fi
116
cc6ac522
JW
117AC_CHECK_HEADERS(pthread.h)
118
119AC_MSG_CHECKING([for thread model used by GCC])
120target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
121AC_MSG_RESULT([$target_thread_file])
122
123# We only support posix threads, or no threads at all.
124posix_threads=
125case ${target_thread_file} in
126 posix)
127 posix_threads=yes
128 ;;
129 single)
130 ;;
131 *)
132 echo "${target_thread_file} is an unsupported thread package" 1>&2
133 exit 1
134 ;;
135esac
136
137AM_CONDITIONAL(LIBMUDFLAPTH, [test "x$posix_threads" != "x"])
138if test "x$posix_threads" != "x"
7954e85c
FCE
139then
140 build_libmudflapth=1
141else
142 build_libmudflapth=0
143fi
144AC_SUBST(build_libmudflapth)
6de9cd9a
DN
145
146AC_CHECK_LIB(dl, dlsym)
147
42fcd7bb
AJ
148# Calculate toolexeclibdir
149# Also toolexecdir, though it's only used in toolexeclibdir
150case ${version_specific_libs} in
151 yes)
152 # Need the gcc compiler version to know where to install libraries
153 # and header files if --enable-version-specific-runtime-libs option
154 # is selected.
155 toolexecdir='$(libdir)/gcc/$(target_alias)'
fd0811ef 156 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
42fcd7bb
AJ
157 ;;
158 no)
159 if test -n "$with_cross_host" &&
160 test x"$with_cross_host" != x"no"; then
161 # Install a library built with a cross compiler in tooldir, not libdir.
162 toolexecdir='$(exec_prefix)/$(target_alias)'
163 toolexeclibdir='$(toolexecdir)/lib'
164 else
165 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
166 toolexeclibdir='$(libdir)'
167 fi
168 multi_os_directory=`$CC -print-multi-os-directory`
169 case $multi_os_directory in
170 .) ;; # Avoid trailing /.
171 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
172 esac
173 ;;
174esac
175AC_SUBST(toolexecdir)
176AC_SUBST(toolexeclibdir)
177
cc6ac522
JW
178pthread_create_version='""'
179if test "x$enable_shared" = "xyes" && test "x$posix_threads" != "x"; then
6de9cd9a
DN
180 # NB: don't check for -lpthread here, because then it would be
181 # added to LIBS. For the thread-unaware libmudflap.la, we don't
182 # want it there.
183
184 # glibc-related hacks. dlsym() may pick the wrong version of
185 # interposed functions like pthread_create on modern glibc.
186 # We need to find the proper symbol version string, and use
187 # the nonstandard dlvsym().
188 AC_CHECK_FUNCS(dlvsym)
189 AC_CHECK_TOOL(NM, nm)
7954e85c 190 if test "x$ac_cv_have_dlvsym" != "x"; then
6de9cd9a
DN
191 # Try compiling a simple pthreads program. Find the shared libraries it
192 # ends up with. Then use "nm" on those libraries to extract the
193 # default symbol versioning suffix ("@@"), if any. But that's tricky.
194 # Rather, run nm on the resulting executable. Unfortunately, autoconf
195 # doesn't appear to have a macro that builds a test executable for
42fcd7bb 196 # subsequent analysis ... so we do it by hand here.
6de9cd9a
DN
197 cat >> conftest.c << EOF
198#include <pthread.h>
199int main () { void *p = (void *) & pthread_create; return (int) p; }
200EOF
201 oldLIBS="$LIBS"
202 LIBS="$LIBS -lpthread"
203 pthread_create_version="\"\""
204 AC_MSG_CHECKING(pthread_create symbol version)
205 if eval $ac_link 2>&5 && test -s conftest${ac_exeext}; then
206 version=`$NM conftest${ac_exeect} | grep 'pthread_create@@' | sed -e 's/^.*@@//'`
207 if test "x$version" != "x"; then
208 pthread_create_version="\"$version\""
209 fi
210 fi
211 AC_MSG_RESULT($pthread_create_version)
212 LIBS="$oldLIBS"
213 fi
214fi
42fcd7bb 215AC_DEFINE_UNQUOTED(PTHREAD_CREATE_VERSION, $pthread_create_version, [pthread_create symbol version])
6de9cd9a 216
7954e85c
FCE
217
218# Figure out whether the compiler supports "-ffunction-sections -fdata-sections",
219# similarly to how libstdc++ does it
220ac_test_CFLAGS="${CFLAGS+set}"
221ac_save_CFLAGS="$CFLAGS"
222
223# Check for -ffunction-sections -fdata-sections
224AC_MSG_CHECKING([for gcc that supports -ffunction-sections -fdata-sections])
225CFLAGS='-Werror -ffunction-sections -fdata-sections'
226AC_TRY_COMPILE(, [int foo;], [ac_fdsections=yes], [ac_fdsections=no])
227if test "$ac_test_CFLAGS" = set; then
228 CFLAGS="$ac_save_CFLAGS"
229else
230 # this is the suspicious part
231 CFLAGS=""
232fi
233if test x"$ac_fdsections" = x"yes"; then
234 SECTION_FLAGS='-ffunction-sections -fdata-sections'
235fi
236AC_MSG_RESULT($ac_fdsections)
237AC_SUBST(SECTION_FLAGS)
238
239
7741b451
MR
240# Check for the name of the symbol used for the entry point.
241AC_CACHE_CHECK([for the name of the symbol used for the entry point],
242 [mudflap_cv_entry_point], [
243for name in _start __start unknown; do
063e53d6 244 AC_LINK_IFELSE([AC_LANG_PROGRAM([extern char $name@<:@@:>@;], [$name@<:@0@:>@ = 0;])],
7741b451
MR
245 [break])
246done
247mudflap_cv_entry_point="$name"])
248if test "$mudflap_cv_entry_point" = unknown; then
249 AC_MSG_ERROR([none of the known symbol names works])
250fi
251AC_DEFINE_UNQUOTED([ENTRY_POINT], [$mudflap_cv_entry_point],
252 [Define to the name of the symbol used for the entry point.])
253
254
42fcd7bb
AJ
255if test ${multilib} = yes; then
256 multilib_arg="--enable-multilib"
257else
258 multilib_arg=
259fi
6de9cd9a 260
7544a87f 261# See if we support thread-local storage.
e1e73e8d 262GCC_CHECK_TLS
7544a87f 263
1330529e 264AC_CONFIG_FILES([Makefile testsuite/Makefile testsuite/mfconfig.exp])
076e5443 265AC_OUTPUT