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