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