github.com/axw/llgo@v0.0.0-20160805011314-95b5fe4dca20/third_party/gofrontend/libbacktrace/configure.ac (about) 1 # configure.ac -- Backtrace configure script. 2 # Copyright (C) 2012-2015 Free Software Foundation, Inc. 3 4 # Redistribution and use in source and binary forms, with or without 5 # modification, are permitted provided that the following conditions are 6 # met: 7 8 # (1) Redistributions of source code must retain the above copyright 9 # notice, this list of conditions and the following disclaimer. 10 11 # (2) Redistributions in binary form must reproduce the above copyright 12 # notice, this list of conditions and the following disclaimer in 13 # the documentation and/or other materials provided with the 14 # distribution. 15 16 # (3) The name of the author may not be used to 17 # endorse or promote products derived from this software without 18 # specific prior written permission. 19 20 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 # POSSIBILITY OF SUCH DAMAGE. 31 32 AC_PREREQ(2.64) 33 AC_INIT(package-unused, version-unused,, libbacktrace) 34 AC_CONFIG_SRCDIR(backtrace.h) 35 AC_CONFIG_HEADER(config.h) 36 37 AC_CANONICAL_SYSTEM 38 target_alias=${target_alias-$host_alias} 39 40 AC_USE_SYSTEM_EXTENSIONS 41 42 libtool_VERSION=1:0:0 43 AC_SUBST(libtool_VERSION) 44 45 # 1.11.1: Require that version of automake. 46 # foreign: Don't require README, INSTALL, NEWS, etc. 47 # no-define: Don't define PACKAGE and VERSION. 48 # no-dependencies: Don't generate automatic dependencies. 49 # (because it breaks when using bootstrap-lean, since some of the 50 # headers are gone at "make install" time). 51 # -Wall: Issue all automake warnings. 52 # -Wno-portability: Don't warn about constructs supported by GNU make. 53 # (because GCC requires GNU make anyhow). 54 AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability]) 55 56 AM_MAINTAINER_MODE 57 58 AC_ARG_WITH(target-subdir, 59 [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target]) 60 61 # We must force CC to /not/ be precious variables; otherwise 62 # the wrong, non-multilib-adjusted value will be used in multilibs. 63 # As a side effect, we have to subst CFLAGS ourselves. 64 m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS]) 65 m4_define([_AC_ARG_VAR_PRECIOUS],[]) 66 AC_PROG_CC 67 m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) 68 69 AC_SUBST(CFLAGS) 70 71 AC_PROG_RANLIB 72 73 AC_PROG_AWK 74 case "$AWK" in 75 "") AC_MSG_ERROR([can't build without awk]) ;; 76 esac 77 78 LT_INIT([disable-shared]) 79 AM_PROG_LIBTOOL 80 81 backtrace_supported=yes 82 83 if test -n "${with_target_subdir}"; then 84 # We are compiling a GCC library. We can assume that the unwind 85 # library exists. 86 AM_ENABLE_MULTILIB(, ..) 87 BACKTRACE_FILE="backtrace.lo simple.lo" 88 else 89 AC_CHECK_HEADER([unwind.h], 90 [AC_CHECK_FUNC([_Unwind_Backtrace], 91 [BACKTRACE_FILE="backtrace.lo simple.lo"], 92 [BACKTRACE_FILE="nounwind.lo" 93 backtrace_supported=no])], 94 [BACKTRACE_FILE="nounwind.lo" 95 backtrace_supported=no]) 96 fi 97 AC_SUBST(BACKTRACE_FILE) 98 99 EXTRA_FLAGS= 100 if test -n "${with_target_subdir}"; then 101 EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@" 102 else 103 AC_CACHE_CHECK([for -funwind-tables option], 104 [libbacktrace_cv_c_unwind_tables], 105 [CFLAGS_hold="$CFLAGS" 106 CFLAGS="$CFLAGS -funwind-tables" 107 AC_COMPILE_IFELSE( 108 [AC_LANG_PROGRAM([static int f() { return 0; }], [return f();])], 109 [libbacktrace_cv_c_unwind_tables=yes], 110 [libbacktrace_cv_c_unwind_tables=no]) 111 CFLAGS="$CFLAGS_hold"]) 112 if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then 113 EXTRA_FLAGS=-funwind-tables 114 fi 115 AC_CACHE_CHECK([for -frandom-seed=string option], 116 [libbacktrace_cv_c_random_seed_string], 117 [CFLAGS_hold="$CFLAGS" 118 CFLAGS="$CFLAGS -frandom-seed=conftest.lo" 119 AC_COMPILE_IFELSE( 120 [AC_LANG_PROGRAM([], [return 0;])], 121 [libbacktrace_cv_c_random_seed_string=yes], 122 [libbacktrace_cv_c_random_seed_string=no]) 123 CFLAGS="$CFLAGS_hold"]) 124 if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then 125 EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@" 126 fi 127 fi 128 AC_SUBST(EXTRA_FLAGS) 129 130 ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \ 131 -Wmissing-prototypes -Wold-style-definition \ 132 -Wmissing-format-attribute -Wcast-qual], 133 [WARN_FLAGS]) 134 135 if test -n "${with_target_subdir}"; then 136 WARN_FLAGS="$WARN_FLAGS -Werror" 137 fi 138 139 AC_SUBST(WARN_FLAGS) 140 141 if test -n "${with_target_subdir}"; then 142 GCC_CHECK_UNWIND_GETIPINFO 143 else 144 ac_save_CFFLAGS="$CFLAGS" 145 CFLAGS="$CFLAGS -Werror-implicit-function-declaration" 146 AC_MSG_CHECKING([for _Unwind_GetIPInfo]) 147 AC_LINK_IFELSE( 148 [AC_LANG_PROGRAM( 149 [#include "unwind.h" 150 struct _Unwind_Context *context; 151 int ip_before_insn = 0;], 152 [return _Unwind_GetIPInfo (context, &ip_before_insn);])], 153 [have_unwind_getipinfo=yes], [have_unwind_getipinfo=no]) 154 CFLAGS="$ac_save_CFLAGS" 155 AC_MSG_RESULT([$have_unwind_getipinfo]) 156 if test "$have_unwind_getipinfo" = "yes"; then 157 AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.]) 158 fi 159 fi 160 161 # When building as a target library, shared libraries may want to link 162 # this in. We don't want to provide another shared library to 163 # complicate dependencies. Instead, we just compile with -fPIC. 164 PIC_FLAG= 165 if test -n "${with_target_subdir}"; then 166 PIC_FLAG=-fPIC 167 fi 168 # Similarly, use -fPIC with --enable-host-shared: 169 AC_ARG_ENABLE(host-shared, 170 [AS_HELP_STRING([--enable-host-shared], 171 [build host code as shared libraries])], 172 [PIC_FLAG=-fPIC], []) 173 AC_SUBST(PIC_FLAG) 174 175 # Test for __sync support. 176 AC_CACHE_CHECK([__sync extensions], 177 [libbacktrace_cv_sys_sync], 178 [if test -n "${with_target_subdir}"; then 179 libbacktrace_cv_sys_sync=yes 180 else 181 AC_LINK_IFELSE( 182 [AC_LANG_PROGRAM([int i;], 183 [__sync_bool_compare_and_swap (&i, i, i); 184 __sync_lock_test_and_set (&i, 1); 185 __sync_lock_release (&i);])], 186 [libbacktrace_cv_sys_sync=yes], 187 [libbacktrace_cv_sys_sync=no]) 188 fi]) 189 BACKTRACE_SUPPORTS_THREADS=0 190 if test "$libbacktrace_cv_sys_sync" = "yes"; then 191 BACKTRACE_SUPPORTS_THREADS=1 192 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1, 193 [Define to 1 if you have the __sync functions]) 194 fi 195 AC_SUBST(BACKTRACE_SUPPORTS_THREADS) 196 197 # Test for __atomic support. 198 AC_CACHE_CHECK([__atomic extensions], 199 [libbacktrace_cv_sys_atomic], 200 [if test -n "${with_target_subdir}"; then 201 libbacktrace_cv_sys_atomic=yes 202 else 203 AC_LINK_IFELSE( 204 [AC_LANG_PROGRAM([int i;], 205 [__atomic_load_n (&i, __ATOMIC_ACQUIRE); 206 __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])], 207 [libbacktrace_cv_sys_atomic=yes], 208 [libbacktrace_cv_sys_atomic=no]) 209 fi]) 210 if test "$libbacktrace_cv_sys_atomic" = "yes"; then 211 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1, 212 [Define to 1 if you have the __atomic functions]) 213 fi 214 215 # The library needs to be able to read the executable itself. Compile 216 # a file to determine the executable format. The awk script 217 # filetype.awk prints out the file type. 218 AC_CACHE_CHECK([output filetype], 219 [libbacktrace_cv_sys_filetype], 220 [filetype= 221 AC_COMPILE_IFELSE( 222 [AC_LANG_PROGRAM([int i;], [int j;])], 223 [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`], 224 [AC_MSG_FAILURE([compiler failed])]) 225 libbacktrace_cv_sys_filetype=$filetype]) 226 227 # Match the file type to decide what files to compile. 228 FORMAT_FILE= 229 case "$libbacktrace_cv_sys_filetype" in 230 elf*) FORMAT_FILE="elf.lo" ;; 231 *) AC_MSG_WARN([could not determine output file type]) 232 FORMAT_FILE="unknown.lo" 233 backtrace_supported=no 234 ;; 235 esac 236 AC_SUBST(FORMAT_FILE) 237 238 # ELF defines. 239 elfsize= 240 case "$libbacktrace_cv_sys_filetype" in 241 elf32) elfsize=32 ;; 242 elf64) elfsize=64 ;; 243 esac 244 AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64]) 245 246 BACKTRACE_SUPPORTED=0 247 if test "$backtrace_supported" = "yes"; then 248 BACKTRACE_SUPPORTED=1 249 fi 250 AC_SUBST(BACKTRACE_SUPPORTED) 251 252 GCC_HEADER_STDINT(gstdint.h) 253 254 AC_CHECK_HEADERS(sys/mman.h) 255 if test "$ac_cv_header_sys_mman_h" = "no"; then 256 have_mmap=no 257 else 258 if test -n "${with_target_subdir}"; then 259 # When built as a GCC target library, we can't do a link test. We 260 # simply assume that if we have mman.h, we have mmap. 261 have_mmap=yes 262 else 263 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no]) 264 fi 265 fi 266 if test "$have_mmap" = "no"; then 267 VIEW_FILE=read.lo 268 ALLOC_FILE=alloc.lo 269 else 270 VIEW_FILE=mmapio.lo 271 AC_PREPROC_IFELSE([ 272 #include <sys/mman.h> 273 #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) 274 #error no MAP_ANONYMOUS 275 #endif 276 ], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo]) 277 fi 278 AC_SUBST(VIEW_FILE) 279 AC_SUBST(ALLOC_FILE) 280 281 BACKTRACE_USES_MALLOC=0 282 if test "$ALLOC_FILE" = "alloc.lo"; then 283 BACKTRACE_USES_MALLOC=1 284 fi 285 AC_SUBST(BACKTRACE_USES_MALLOC) 286 287 # Check for dl_iterate_phdr. 288 AC_CHECK_HEADERS(link.h) 289 if test "$ac_cv_header_link_h" = "no"; then 290 have_dl_iterate_phdr=no 291 else 292 if test -n "${with_target_subdir}"; then 293 # When built as a GCC target library, we can't do a link test. 294 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes], 295 [have_dl_iterate_phdr=no]) 296 case "${host}" in 297 *-*-solaris2.10*) 298 # Avoid dl_iterate_phdr on Solaris 10, where it is in the 299 # header file but is only in -ldl. 300 have_dl_iterate_phdr=no ;; 301 esac 302 else 303 AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes], 304 [have_dl_iterate_phdr=no]) 305 fi 306 fi 307 if test "$have_dl_iterate_phdr" = "yes"; then 308 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.]) 309 fi 310 311 # Check for the fcntl function. 312 if test -n "${with_target_subdir}"; then 313 case "${host}" in 314 *-*-mingw*) have_fcntl=no ;; 315 *) have_fcntl=yes ;; 316 esac 317 else 318 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no]) 319 fi 320 if test "$have_fcntl" = "yes"; then 321 AC_DEFINE([HAVE_FCNTL], 1, 322 [Define to 1 if you have the fcntl function]) 323 fi 324 325 AC_CHECK_DECLS(strnlen) 326 327 # Check for getexecname function. 328 if test -n "${with_target_subdir}"; then 329 case "${host}" in 330 *-*-solaris2*) have_getexecname=yes ;; 331 *) have_getexecname=no ;; 332 esac 333 else 334 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no]) 335 fi 336 if test "$have_getexecname" = "yes"; then 337 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.]) 338 fi 339 340 AC_CACHE_CHECK([whether tests can run], 341 [libbacktrace_cv_sys_native], 342 [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])], 343 [libbacktrace_cv_sys_native=yes], 344 [libbacktrace_cv_sys_native=no], 345 [libbacktrace_cv_sys_native=no])]) 346 AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes") 347 348 if test "${multilib}" = "yes"; then 349 multilib_arg="--enable-multilib" 350 else 351 multilib_arg= 352 fi 353 354 AC_CONFIG_FILES(Makefile backtrace-supported.h) 355 356 # We need multilib support, but only if configuring for the target. 357 AC_CONFIG_COMMANDS([default], 358 [if test -n "$CONFIG_FILES"; then 359 if test -n "${with_target_subdir}"; then 360 # Multilibs need MULTISUBDIR defined correctly in certain makefiles so 361 # that multilib installs will end up installed in the correct place. 362 # The testsuite needs it for multilib-aware ABI baseline files. 363 # To work around this not being passed down from config-ml.in -> 364 # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually 365 # append it here. Only modify Makefiles that have just been created. 366 # 367 # Also, get rid of this simulated-VPATH thing that automake does. 368 cat > vpsed << \_EOF 369 s!`test -f '$<' || echo '$(srcdir)/'`!! 370 _EOF 371 for i in $SUBDIRS; do 372 case $CONFIG_FILES in 373 *${i}/Makefile*) 374 #echo "Adding MULTISUBDIR to $i/Makefile" 375 sed -f vpsed $i/Makefile > tmp 376 grep '^MULTISUBDIR =' Makefile >> tmp 377 mv tmp $i/Makefile 378 ;; 379 esac 380 done 381 rm vpsed 382 fi 383 fi 384 ], 385 [ 386 # Variables needed in config.status (file generation) which aren't already 387 # passed by autoconf. 388 SUBDIRS="$SUBDIRS" 389 ]) 390 391 AC_OUTPUT