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