2 # Process this file with autoconf to produce a configure script.
5 AC_INIT(package-unused, version-unused, libsanitizer)
6 AC_CONFIG_SRCDIR([include/sanitizer/common_interface_defs.h])
8 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
9 AC_ARG_ENABLE(version-specific-runtime-libs,
10 [ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
12 yes) version_specific_libs=yes ;;
13 no) version_specific_libs=no ;;
14 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
16 [version_specific_libs=no])
17 AC_MSG_RESULT($version_specific_libs)
19 AC_USE_SYSTEM_EXTENSIONS
21 # Do not delete or change the following two lines. For why, see
22 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
24 target_alias=${target_alias-$host_alias}
25 AC_SUBST(target_alias)
26 GCC_LIBSTDCXX_RAW_CXX_FLAGS
28 AM_INIT_AUTOMAKE(foreign no-dist)
29 AM_ENABLE_MULTILIB(, ..)
32 # Calculate toolexeclibdir
33 # Also toolexecdir, though it's only used in toolexeclibdir
34 case ${version_specific_libs} in
36 # Need the gcc compiler version to know where to install libraries
37 # and header files if --enable-version-specific-runtime-libs option
39 toolexecdir='$(libdir)/gcc/$(target_alias)'
40 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
43 if test -n "$with_cross_host" &&
44 test x"$with_cross_host" != x"no"; then
45 # Install a library built with a cross compiler in tooldir, not libdir.
46 toolexecdir='$(exec_prefix)/$(target_alias)'
47 toolexeclibdir='$(toolexecdir)/lib'
49 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
50 toolexeclibdir='$(libdir)'
52 multi_os_directory=`$CC -print-multi-os-directory`
53 case $multi_os_directory in
54 .) ;; # Avoid trailing /.
55 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
60 AC_SUBST(toolexeclibdir)
62 # Checks for programs.
73 "") AC_MSG_ERROR([can't build without awk]) ;;
76 AC_SUBST(enable_shared)
77 AC_SUBST(enable_static)
79 AC_CHECK_SIZEOF([void *])
81 if test "${multilib}" = "yes"; then
82 multilib_arg="--enable-multilib"
87 # Get target configury.
90 . ${srcdir}/configure.tgt
91 AM_CONDITIONAL(TSAN_SUPPORTED, [test "x$TSAN_SUPPORTED" = "xyes"])
92 AM_CONDITIONAL(LSAN_SUPPORTED, [test "x$LSAN_SUPPORTED" = "xyes"])
94 # Check for functions needed.
95 AC_CHECK_FUNCS(clock_getres clock_gettime clock_settime)
97 # Common libraries that we need to link against for all sanitizer libs.
98 link_sanitizer_common='-lpthread -ldl -lm'
100 # Set up the set of additional libraries that we need to link against for libasan.
101 link_libasan=$link_sanitizer_common
102 AC_SUBST(link_libasan)
104 # Set up the set of additional libraries that we need to link against for libtsan.
105 link_libtsan=$link_sanitizer_common
106 AC_SUBST(link_libtsan)
108 # Set up the set of additional libraries that we need to link against for libubsan.
109 link_libubsan=$link_sanitizer_common
110 AC_SUBST(link_libubsan)
112 # Set up the set of additional libraries that we need to link against for liblsan.
113 link_liblsan=$link_sanitizer_common
114 AC_SUBST(link_liblsan)
116 # At least for glibc, clock_gettime is in librt. But don't pull that
117 # in if it still doesn't give us the function we want. This
118 # test is copied from libgomp.
119 if test $ac_cv_func_clock_gettime = no; then
120 AC_CHECK_LIB(rt, clock_gettime,
121 [link_libasan="-lrt $link_libasan"
122 link_libtsan="-lrt $link_libtsan"
123 # Other sanitizers do not override clock_* API
128 *-*-darwin*) MAC_INTERPOSE=true ; enable_static=no ;;
129 *) MAC_INTERPOSE=false ;;
131 AM_CONDITIONAL(USING_MAC_INTERPOSE, $MAC_INTERPOSE)
133 backtrace_supported=yes
135 # Test for __sync support.
136 AC_CACHE_CHECK([__sync extensions],
137 [libsanitizer_cv_sys_sync],
138 [if test -n "${with_target_subdir}"; then
139 libsanitizer_cv_sys_sync=yes
142 [AC_LANG_PROGRAM([int i;],
143 [__sync_bool_compare_and_swap (&i, i, i);
144 __sync_lock_test_and_set (&i, 1);
145 __sync_lock_release (&i);])],
146 [libsanitizer_cv_sys_sync=yes],
147 [libsanitizer_cv_sys_sync=no])
149 if test "$libsanitizer_cv_sys_sync" = "yes"; then
150 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
151 [Define to 1 if you have the __sync functions])
154 # Test for __atomic support.
155 AC_CACHE_CHECK([__atomic extensions],
156 [libsanitizer_cv_sys_atomic],
157 [if test -n "${with_target_subdir}"; then
158 libsanitizer_cv_sys_atomic=yes
161 [AC_LANG_PROGRAM([int i;],
162 [__atomic_load_n (&i, __ATOMIC_ACQUIRE);
163 __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
164 [libsanitizer_cv_sys_atomic=yes],
165 [libsanitizer_cv_sys_atomic=no])
167 if test "$libsanitizer_cv_sys_atomic" = "yes"; then
168 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
169 [Define to 1 if you have the __atomic functions])
172 # The library needs to be able to read the executable itself. Compile
173 # a file to determine the executable format. The awk script
174 # filetype.awk prints out the file type.
175 AC_CACHE_CHECK([output filetype],
176 [libsanitizer_cv_sys_filetype],
179 [AC_LANG_PROGRAM([int i;], [int j;])],
180 [filetype=`${AWK} -f $srcdir/../libbacktrace/filetype.awk conftest.$ac_objext`],
181 [AC_MSG_FAILURE([compiler failed])])
182 libsanitizer_cv_sys_filetype=$filetype])
184 # Match the file type to decide what files to compile.
186 case "$libsanitizer_cv_sys_filetype" in
187 elf*) FORMAT_FILE="elf.lo" ;;
188 *) AC_MSG_WARN([could not determine output file type])
189 FORMAT_FILE="unknown.lo"
190 backtrace_supported=no
193 AC_SUBST(FORMAT_FILE)
197 case "$libsanitizer_cv_sys_filetype" in
201 AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
203 BACKTRACE_SUPPORTED=0
204 if test "$backtrace_supported" = "yes"; then
205 BACKTRACE_SUPPORTED=1
207 AC_SUBST(BACKTRACE_SUPPORTED)
209 GCC_HEADER_STDINT(gstdint.h)
211 AC_CHECK_HEADERS(sys/mman.h alloca.h)
212 if test "$ac_cv_header_sys_mman_h" = "no"; then
215 if test -n "${with_target_subdir}"; then
216 # When built as a GCC target library, we can't do a link test. We
217 # simply assume that if we have mman.h, we have mmap.
220 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
223 if test "$have_mmap" = "no"; then
229 #include <sys/mman.h>
230 #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
231 #error no MAP_ANONYMOUS
233 ], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
238 BACKTRACE_USES_MALLOC=0
239 if test "$ALLOC_FILE" = "alloc.lo"; then
240 BACKTRACE_USES_MALLOC=1
242 AC_SUBST(BACKTRACE_USES_MALLOC)
244 # Don't care about thread support
245 BACKTRACE_SUPPORTS_THREADS=0
246 AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
248 # Check for dl_iterate_phdr.
249 AC_CHECK_HEADERS(link.h)
250 if test "$ac_cv_header_link_h" = "no"; then
251 have_dl_iterate_phdr=no
253 # When built as a GCC target library, we can't do a link test.
254 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
255 [have_dl_iterate_phdr=no])
258 # Avoid dl_iterate_phdr on Solaris 10, where it is in the
259 # header file but is only in -ldl.
260 have_dl_iterate_phdr=no ;;
263 if test "$have_dl_iterate_phdr" = "yes"; then
264 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
267 # Check for the fcntl function.
268 if test -n "${with_target_subdir}"; then
270 *-*-mingw*) have_fcntl=no ;;
274 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
276 if test "$have_fcntl" = "yes"; then
277 AC_DEFINE([HAVE_FCNTL], 1,
278 [Define to 1 if you have the fcntl function])
281 AC_CHECK_DECLS(strnlen)
283 # Check for getexecname function.
284 if test -n "${with_target_subdir}"; then
286 *-*-solaris2*) have_getexecname=yes ;;
287 *) have_getexecname=no ;;
290 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
292 if test "$have_getexecname" = "yes"; then
293 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
296 AM_CONDITIONAL(LIBBACKTRACE_SUPPORTED,
297 [test "x${BACKTRACE_SUPPORTED}x${BACKTRACE_USES_MALLOC}" = "x1x0"])
299 AH_BOTTOM([#include "libbacktrace/backtrace-rename.h"])
300 AC_CONFIG_FILES([Makefile libsanitizer.spec libbacktrace/backtrace-supported.h])
301 AC_CONFIG_HEADER(config.h)
303 AC_CONFIG_FILES(AC_FOREACH([DIR], [interception sanitizer_common libbacktrace lsan asan ubsan], [DIR/Makefile ]),
304 [cat > vpsed$$ << \_EOF
305 s!`test -f '$<' || echo '$(srcdir)/'`!!
307 sed -f vpsed$$ $ac_file > tmp$$
310 echo 'MULTISUBDIR =' >> $ac_file
312 . ${multi_basedir}/config-ml.in
313 AS_UNSET([ml_norecursion])
316 if test "x$TSAN_SUPPORTED" = "xyes"; then
317 AC_CONFIG_FILES(AC_FOREACH([DIR], [tsan], [DIR/Makefile ]),
318 [cat > vpsed$$ << \_EOF
319 s!`test -f '$<' || echo '$(srcdir)/'`!!
321 sed -f vpsed$$ $ac_file > tmp$$
324 echo 'MULTISUBDIR =' >> $ac_file
326 . ${multi_basedir}/config-ml.in
327 AS_UNSET([ml_norecursion])