1# -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3 4AC_PREREQ([2.64]) 5AC_INIT(package-unused, version-unused, libsanitizer) 6AC_CONFIG_SRCDIR([include/sanitizer/common_interface_defs.h]) 7 8AC_MSG_CHECKING([for --enable-version-specific-runtime-libs]) 9AC_ARG_ENABLE(version-specific-runtime-libs, 10[ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ], 11[case "$enableval" in 12 yes) version_specific_libs=yes ;; 13 no) version_specific_libs=no ;; 14 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; 15 esac], 16[version_specific_libs=no]) 17AC_MSG_RESULT($version_specific_libs) 18 19AC_USE_SYSTEM_EXTENSIONS 20 21# Do not delete or change the following two lines. For why, see 22# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html 23AC_CANONICAL_SYSTEM 24target_alias=${target_alias-$host_alias} 25AC_SUBST(target_alias) 26GCC_LIBSTDCXX_RAW_CXX_FLAGS 27 28AM_INIT_AUTOMAKE(foreign no-dist) 29AM_ENABLE_MULTILIB(, ..) 30AM_MAINTAINER_MODE 31 32# Calculate toolexeclibdir 33# Also toolexecdir, though it's only used in toolexeclibdir 34case ${version_specific_libs} in 35 yes) 36 # Need the gcc compiler version to know where to install libraries 37 # and header files if --enable-version-specific-runtime-libs option 38 # is selected. 39 toolexecdir='$(libdir)/gcc/$(target_alias)' 40 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' 41 ;; 42 no) 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' 48 else 49 toolexecdir='$(libdir)/gcc-lib/$(target_alias)' 50 toolexeclibdir='$(libdir)' 51 fi 52 multi_os_directory=`$CC -print-multi-os-directory` 53 case $multi_os_directory in 54 .) ;; # Avoid trailing /. 55 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; 56 esac 57 ;; 58esac 59AC_SUBST(toolexecdir) 60AC_SUBST(toolexeclibdir) 61 62# Checks for programs. 63AC_PROG_CC 64AC_PROG_CXX 65AM_PROG_AS 66AC_PROG_RANLIB 67 68AC_LIBTOOL_DLOPEN 69AM_PROG_LIBTOOL 70 71AC_PROG_AWK 72case "$AWK" in 73"") AC_MSG_ERROR([can't build without awk]) ;; 74esac 75 76AC_SUBST(enable_shared) 77AC_SUBST(enable_static) 78 79AC_CHECK_SIZEOF([void *]) 80 81if test "${multilib}" = "yes"; then 82 multilib_arg="--enable-multilib" 83else 84 multilib_arg= 85fi 86 87# Get target configury. 88unset TSAN_SUPPORTED 89unset LSAN_SUPPORTED 90. ${srcdir}/configure.tgt 91AM_CONDITIONAL(TSAN_SUPPORTED, [test "x$TSAN_SUPPORTED" = "xyes"]) 92AM_CONDITIONAL(LSAN_SUPPORTED, [test "x$LSAN_SUPPORTED" = "xyes"]) 93 94# Check for functions needed. 95AC_CHECK_FUNCS(clock_getres clock_gettime clock_settime) 96 97# Common libraries that we need to link against for all sanitizer libs. 98link_sanitizer_common='-lpthread -ldl -lm' 99 100# Set up the set of additional libraries that we need to link against for libasan. 101link_libasan=$link_sanitizer_common 102AC_SUBST(link_libasan) 103 104# Set up the set of additional libraries that we need to link against for libtsan. 105link_libtsan=$link_sanitizer_common 106AC_SUBST(link_libtsan) 107 108# Set up the set of additional libraries that we need to link against for libubsan. 109link_libubsan=$link_sanitizer_common 110AC_SUBST(link_libubsan) 111 112# Set up the set of additional libraries that we need to link against for liblsan. 113link_liblsan=$link_sanitizer_common 114AC_SUBST(link_liblsan) 115 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. 119if test $ac_cv_func_clock_gettime = no; then 120 AC_CHECK_LIB(rt, clock_gettime, 121 [link_libasan="-lrt $link_libasan" 122link_libtsan="-lrt $link_libtsan" 123# Other sanitizers do not override clock_* API 124]) 125fi 126 127case "$host" in 128 *-*-darwin*) MAC_INTERPOSE=true ; enable_static=no ;; 129 *) MAC_INTERPOSE=false ;; 130esac 131AM_CONDITIONAL(USING_MAC_INTERPOSE, $MAC_INTERPOSE) 132 133backtrace_supported=yes 134 135AC_MSG_CHECKING([for necessary platform features]) 136case "$target" in 137 *-*-linux*) 138 # Some old Linux distributions miss required syscalls. 139 sanitizer_supported=no 140 AC_TRY_COMPILE([#include <sys/syscall.h>],[ 141 syscall (__NR_gettid); 142 syscall (__NR_futex); 143 syscall (__NR_exit_group); 144 ], [sanitizer_supported=yes]) 145 ;; 146 *) 147 sanitizer_supported=yes 148 ;; 149esac 150AC_MSG_RESULT($sanitizer_supported) 151AM_CONDITIONAL(SANITIZER_SUPPORTED, test "$sanitizer_supported" = yes) 152 153# Test for __sync support. 154AC_CACHE_CHECK([__sync extensions], 155[libsanitizer_cv_sys_sync], 156[if test -n "${with_target_subdir}"; then 157 libsanitizer_cv_sys_sync=yes 158 else 159 AC_LINK_IFELSE( 160 [AC_LANG_PROGRAM([int i;], 161 [__sync_bool_compare_and_swap (&i, i, i); 162 __sync_lock_test_and_set (&i, 1); 163 __sync_lock_release (&i);])], 164 [libsanitizer_cv_sys_sync=yes], 165 [libsanitizer_cv_sys_sync=no]) 166 fi]) 167if test "$libsanitizer_cv_sys_sync" = "yes"; then 168 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1, 169 [Define to 1 if you have the __sync functions]) 170fi 171 172# Test for __atomic support. 173AC_CACHE_CHECK([__atomic extensions], 174[libsanitizer_cv_sys_atomic], 175[if test -n "${with_target_subdir}"; then 176 libsanitizer_cv_sys_atomic=yes 177 else 178 AC_LINK_IFELSE( 179 [AC_LANG_PROGRAM([int i;], 180 [__atomic_load_n (&i, __ATOMIC_ACQUIRE); 181 __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])], 182 [libsanitizer_cv_sys_atomic=yes], 183 [libsanitizer_cv_sys_atomic=no]) 184 fi]) 185if test "$libsanitizer_cv_sys_atomic" = "yes"; then 186 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1, 187 [Define to 1 if you have the __atomic functions]) 188fi 189 190# The library needs to be able to read the executable itself. Compile 191# a file to determine the executable format. The awk script 192# filetype.awk prints out the file type. 193AC_CACHE_CHECK([output filetype], 194[libsanitizer_cv_sys_filetype], 195[filetype= 196AC_COMPILE_IFELSE( 197 [AC_LANG_PROGRAM([int i;], [int j;])], 198 [filetype=`${AWK} -f $srcdir/../libbacktrace/filetype.awk conftest.$ac_objext`], 199 [AC_MSG_FAILURE([compiler failed])]) 200libsanitizer_cv_sys_filetype=$filetype]) 201 202# Match the file type to decide what files to compile. 203FORMAT_FILE= 204case "$libsanitizer_cv_sys_filetype" in 205elf*) FORMAT_FILE="elf.lo" ;; 206*) AC_MSG_WARN([could not determine output file type]) 207 FORMAT_FILE="unknown.lo" 208 backtrace_supported=no 209 ;; 210esac 211AC_SUBST(FORMAT_FILE) 212 213# ELF defines. 214elfsize= 215case "$libsanitizer_cv_sys_filetype" in 216elf32) elfsize=32 ;; 217elf64) elfsize=64 ;; 218esac 219AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64]) 220 221BACKTRACE_SUPPORTED=0 222if test "$backtrace_supported" = "yes"; then 223 BACKTRACE_SUPPORTED=1 224fi 225AC_SUBST(BACKTRACE_SUPPORTED) 226 227GCC_HEADER_STDINT(gstdint.h) 228 229AC_CHECK_HEADERS(sys/mman.h alloca.h) 230if test "$ac_cv_header_sys_mman_h" = "no"; then 231 have_mmap=no 232else 233 if test -n "${with_target_subdir}"; then 234 # When built as a GCC target library, we can't do a link test. We 235 # simply assume that if we have mman.h, we have mmap. 236 have_mmap=yes 237 else 238 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no]) 239 fi 240fi 241if test "$have_mmap" = "no"; then 242 VIEW_FILE=read.lo 243 ALLOC_FILE=alloc.lo 244else 245 VIEW_FILE=mmapio.lo 246 AC_PREPROC_IFELSE([ 247#include <sys/mman.h> 248#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) 249 #error no MAP_ANONYMOUS 250#endif 251], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo]) 252fi 253AC_SUBST(VIEW_FILE) 254AC_SUBST(ALLOC_FILE) 255 256BACKTRACE_USES_MALLOC=0 257if test "$ALLOC_FILE" = "alloc.lo"; then 258 BACKTRACE_USES_MALLOC=1 259fi 260AC_SUBST(BACKTRACE_USES_MALLOC) 261 262# Don't care about thread support 263BACKTRACE_SUPPORTS_THREADS=0 264AC_SUBST(BACKTRACE_SUPPORTS_THREADS) 265 266# Check for dl_iterate_phdr. 267AC_CHECK_HEADERS(link.h) 268if test "$ac_cv_header_link_h" = "no"; then 269 have_dl_iterate_phdr=no 270else 271 # When built as a GCC target library, we can't do a link test. 272 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes], 273 [have_dl_iterate_phdr=no]) 274 case "${host}" in 275 *-*-solaris2.10*) 276 # Avoid dl_iterate_phdr on Solaris 10, where it is in the 277 # header file but is only in -ldl. 278 have_dl_iterate_phdr=no ;; 279 esac 280fi 281if test "$have_dl_iterate_phdr" = "yes"; then 282 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.]) 283fi 284 285# Check for the fcntl function. 286if test -n "${with_target_subdir}"; then 287 case "${host}" in 288 *-*-mingw*) have_fcntl=no ;; 289 *) have_fcntl=yes ;; 290 esac 291else 292 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no]) 293fi 294if test "$have_fcntl" = "yes"; then 295 AC_DEFINE([HAVE_FCNTL], 1, 296 [Define to 1 if you have the fcntl function]) 297fi 298 299AC_CHECK_DECLS(strnlen) 300 301# Check for getexecname function. 302if test -n "${with_target_subdir}"; then 303 case "${host}" in 304 *-*-solaris2*) have_getexecname=yes ;; 305 *) have_getexecname=no ;; 306 esac 307else 308 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no]) 309fi 310if test "$have_getexecname" = "yes"; then 311 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.]) 312fi 313 314AM_CONDITIONAL(LIBBACKTRACE_SUPPORTED, 315 [test "x${BACKTRACE_SUPPORTED}x${BACKTRACE_USES_MALLOC}" = "x1x0"]) 316 317AH_BOTTOM([#include "libbacktrace/backtrace-rename.h"]) 318AC_CONFIG_FILES([Makefile libsanitizer.spec libbacktrace/backtrace-supported.h]) 319AC_CONFIG_HEADER(config.h) 320 321AC_CONFIG_FILES(AC_FOREACH([DIR], [interception sanitizer_common libbacktrace lsan asan ubsan], [DIR/Makefile ]), 322 [cat > vpsed$$ << \_EOF 323s!`test -f '$<' || echo '$(srcdir)/'`!! 324_EOF 325 sed -f vpsed$$ $ac_file > tmp$$ 326 mv tmp$$ $ac_file 327 rm vpsed$$ 328 echo 'MULTISUBDIR =' >> $ac_file 329 ml_norecursion=yes 330 . ${multi_basedir}/config-ml.in 331 AS_UNSET([ml_norecursion]) 332]) 333 334if test "x$TSAN_SUPPORTED" = "xyes"; then 335 AC_CONFIG_FILES(AC_FOREACH([DIR], [tsan], [DIR/Makefile ]), 336 [cat > vpsed$$ << \_EOF 337s!`test -f '$<' || echo '$(srcdir)/'`!! 338_EOF 339 sed -f vpsed$$ $ac_file > tmp$$ 340 mv tmp$$ $ac_file 341 rm vpsed$$ 342 echo 'MULTISUBDIR =' >> $ac_file 343 ml_norecursion=yes 344 . ${multi_basedir}/config-ml.in 345 AS_UNSET([ml_norecursion]) 346]) 347fi 348 349AC_OUTPUT 350