| 1 | dnl Process this file with autoconf to produce a configure script. |
| 2 | |
| 3 | AC_PREREQ(2.59) |
| 4 | |
| 5 | AC_INIT(gold, 0.1) |
| 6 | AC_CONFIG_SRCDIR(gold.cc) |
| 7 | |
| 8 | AC_CANONICAL_TARGET |
| 9 | |
| 10 | AM_INIT_AUTOMAKE([no-dist parallel-tests]) |
| 11 | |
| 12 | AM_CONFIG_HEADER(config.h:config.in) |
| 13 | |
| 14 | # PR 14072 |
| 15 | AH_VERBATIM([00_CONFIG_H_CHECK], |
| 16 | [/* Check that config.h is #included before system headers |
| 17 | (this works only for glibc, but that should be enough). */ |
| 18 | #if defined(__GLIBC__) && !defined(__CONFIG_H__) |
| 19 | # error config.h must be #included before system headers |
| 20 | #endif |
| 21 | #define __CONFIG_H__ 1]) |
| 22 | |
| 23 | AC_ARG_WITH(sysroot, |
| 24 | [ --with-sysroot[=DIR] search for usr/lib et al within DIR], |
| 25 | [sysroot=$withval], [sysroot=no]) |
| 26 | |
| 27 | if test "$sysroot" = "yes"; then |
| 28 | sysroot='${exec_prefix}/${target_alias}/sys-root' |
| 29 | elif test "$sysroot" = "no"; then |
| 30 | sysroot= |
| 31 | fi |
| 32 | |
| 33 | sysroot_relocatable=0 |
| 34 | if test -n "$sysroot"; then |
| 35 | case "sysroot" in |
| 36 | "${prefix}" | "${prefix}/"* | \ |
| 37 | "${exec_prefix}" | "${exec_prefix}/"* | \ |
| 38 | '${prefix}' | '${prefix}/'*| \ |
| 39 | '${exec_prefix}' | '${exec_prefix}/'*) |
| 40 | sysroot_relocatable=1 |
| 41 | ;; |
| 42 | esac |
| 43 | fi |
| 44 | |
| 45 | AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT, "$sysroot", |
| 46 | [System root for target files]) |
| 47 | AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT_RELOCATABLE, $sysroot_relocatable, |
| 48 | [Whether the system root can be relocated]) |
| 49 | |
| 50 | dnl "install_as_default" is true if the linker to be installed as the |
| 51 | dnl default linker, ld. |
| 52 | dnl "installed_linker" is the installed gold linker name. |
| 53 | |
| 54 | default_ld= |
| 55 | AC_ARG_ENABLE(ld, |
| 56 | [[ --enable-ld[=ARG] build ld [ARG={default,yes,no}]]], |
| 57 | [case "${enableval}" in |
| 58 | default) |
| 59 | default_ld=ld.bfd |
| 60 | ;; |
| 61 | esac]) |
| 62 | |
| 63 | AC_ARG_ENABLE(gold, |
| 64 | [[ --enable-gold[=ARG] build gold [ARG={default,yes,no}]]], |
| 65 | [case "${enableval}" in |
| 66 | yes|default) |
| 67 | if test x${default_ld} = x; then |
| 68 | install_as_default=yes |
| 69 | fi |
| 70 | installed_linker=ld.gold |
| 71 | ;; |
| 72 | no) |
| 73 | ;; |
| 74 | *) |
| 75 | AC_MSG_ERROR([invalid --enable-gold argument]) |
| 76 | ;; |
| 77 | esac], |
| 78 | [install_as_default=no |
| 79 | installed_linker=ld.gold]) |
| 80 | AC_SUBST(install_as_default) |
| 81 | AC_SUBST(installed_linker) |
| 82 | |
| 83 | dnl For now threads are a configure time option. |
| 84 | AC_ARG_ENABLE([threads], |
| 85 | [ --enable-threads multi-threaded linking], |
| 86 | [case "${enableval}" in |
| 87 | yes | "") threads=yes ;; |
| 88 | no) threads=no ;; |
| 89 | *) threads=yes ;; |
| 90 | esac], |
| 91 | [threads=no]) |
| 92 | if test "$threads" = "yes"; then |
| 93 | AC_DEFINE(ENABLE_THREADS, 1, |
| 94 | [Define to do multi-threaded linking]) |
| 95 | fi |
| 96 | AM_CONDITIONAL(THREADS, test "$threads" = "yes") |
| 97 | |
| 98 | AC_ARG_ENABLE([plugins], |
| 99 | [ --enable-plugins linker plugins], |
| 100 | [case "${enableval}" in |
| 101 | yes | "") plugins=yes ;; |
| 102 | no) plugins=no ;; |
| 103 | *) plugins=yes ;; |
| 104 | esac], |
| 105 | [plugins=no]) |
| 106 | if test "$plugins" = "yes"; then |
| 107 | AC_DEFINE(ENABLE_PLUGINS, 1, |
| 108 | [Define to enable linker plugins]) |
| 109 | fi |
| 110 | AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes") |
| 111 | |
| 112 | AC_ARG_ENABLE([targets], |
| 113 | [ --enable-targets alternative target configurations], |
| 114 | [case "${enableval}" in |
| 115 | yes | "") |
| 116 | AC_MSG_ERROR([--enable-targets option must specify target names or 'all']) |
| 117 | ;; |
| 118 | no) |
| 119 | enable_targets= |
| 120 | ;; |
| 121 | *) |
| 122 | enable_targets=$enableval |
| 123 | ;; |
| 124 | esac], |
| 125 | [# For now, enable all targets by default |
| 126 | enable_targets=all |
| 127 | ]) |
| 128 | |
| 129 | # Canonicalize the enabled targets. |
| 130 | if test -n "$enable_targets"; then |
| 131 | for targ in `echo $enable_targets | sed -e 's/,/ /g'`; do |
| 132 | result=`$ac_config_sub $targ 2>/dev/null` |
| 133 | if test -n "$result"; then |
| 134 | canon_targets="$canon_targets $result" |
| 135 | else |
| 136 | # Permit unrecognized target names, like "all". |
| 137 | canon_targets="$canon_targets $targ" |
| 138 | fi |
| 139 | done |
| 140 | fi |
| 141 | |
| 142 | # See which specific instantiations we need. |
| 143 | targetobjs= |
| 144 | all_targets= |
| 145 | default_machine= |
| 146 | default_size= |
| 147 | default_big_endian= |
| 148 | default_osabi=ELFOSABI_NONE |
| 149 | targ_32_little= |
| 150 | targ_32_big= |
| 151 | targ_64_little= |
| 152 | targ_64_big= |
| 153 | for targ in $target $canon_targets; do |
| 154 | if test "$targ" = "all"; then |
| 155 | targ_32_little=yes |
| 156 | targ_32_big=yes |
| 157 | targ_64_little=yes |
| 158 | targ_64_big=yes |
| 159 | all_targets=yes |
| 160 | else |
| 161 | . ${srcdir}/configure.tgt |
| 162 | |
| 163 | if test "$targ_obj" = "UNKNOWN"; then |
| 164 | AC_MSG_ERROR("unsupported target $targ") |
| 165 | else |
| 166 | targetobjs="$targetobjs ${targ_obj}.\$(OBJEXT)" |
| 167 | if test "$targ_extra_obj" != ""; then |
| 168 | targetobjs="$targetobjs ${targ_extra_obj}.\$(OBJEXT)" |
| 169 | fi |
| 170 | if test "$targ_size" = "32" -o "$targ_extra_size" = "32"; then |
| 171 | if test "$targ_big_endian" = "true" \ |
| 172 | -o "$targ_extra_big_endian" = "true"; then |
| 173 | targ_32_big=yes |
| 174 | fi |
| 175 | if test "$targ_big_endian" = "false" \ |
| 176 | -o "$targ_extra_big_endian" = "false"; then |
| 177 | targ_32_little=yes |
| 178 | fi |
| 179 | fi |
| 180 | if test "$targ_size" = "64" -o "$targ_extra_size" = "64"; then |
| 181 | if test "$targ_big_endian" = "true" \ |
| 182 | -o "$targ_extra_big_endian" = "true"; then |
| 183 | targ_64_big=yes |
| 184 | fi |
| 185 | if test "$targ_big_endian" = "false" \ |
| 186 | -o "$targ_extra_big_endian" = "false"; then |
| 187 | targ_64_little=yes |
| 188 | fi |
| 189 | fi |
| 190 | |
| 191 | if test "$target" = "$targ"; then |
| 192 | default_machine=$targ_machine |
| 193 | default_size=$targ_size |
| 194 | default_big_endian=$targ_big_endian |
| 195 | default_osabi=$targ_osabi |
| 196 | |
| 197 | AM_CONDITIONAL(DEFAULT_TARGET_ARM, test "$targ_obj" = "arm") |
| 198 | AM_CONDITIONAL(DEFAULT_TARGET_I386, test "$targ_obj" = "i386") |
| 199 | AM_CONDITIONAL(DEFAULT_TARGET_POWERPC, test "$targ_obj" = "powerpc") |
| 200 | AM_CONDITIONAL(DEFAULT_TARGET_SPARC, test "$targ_obj" = "sparc") |
| 201 | AM_CONDITIONAL(DEFAULT_TARGET_X86_64, test "$targ_obj" = "x86_64") |
| 202 | fi |
| 203 | fi |
| 204 | fi |
| 205 | done |
| 206 | |
| 207 | # Remove any duplicates. |
| 208 | to="" |
| 209 | for t in $targetobjs; do |
| 210 | case " $to " in |
| 211 | *" $t "*) ;; |
| 212 | *) to="$to $t" ;; |
| 213 | esac |
| 214 | done |
| 215 | targetobjs=$to |
| 216 | |
| 217 | if test -n "$targ_32_little"; then |
| 218 | AC_DEFINE(HAVE_TARGET_32_LITTLE, 1, |
| 219 | [Define to support 32-bit little-endian targets]) |
| 220 | fi |
| 221 | if test -n "$targ_32_big"; then |
| 222 | AC_DEFINE(HAVE_TARGET_32_BIG, 1, |
| 223 | [Define to support 32-bit big-endian targets]) |
| 224 | fi |
| 225 | if test -n "$targ_64_little"; then |
| 226 | AC_DEFINE(HAVE_TARGET_64_LITTLE, 1, |
| 227 | [Define to support 64-bit little-endian targets]) |
| 228 | fi |
| 229 | if test -n "$targ_64_big"; then |
| 230 | AC_DEFINE(HAVE_TARGET_64_BIG, 1, |
| 231 | [Define to support 64-bit big-endian targets]) |
| 232 | fi |
| 233 | |
| 234 | if test -n "$all_targets"; then |
| 235 | TARGETOBJS='$(ALL_TARGETOBJS)' |
| 236 | else |
| 237 | TARGETOBJS="$targetobjs" |
| 238 | fi |
| 239 | AC_SUBST(TARGETOBJS) |
| 240 | |
| 241 | AC_DEFINE_UNQUOTED(GOLD_DEFAULT_MACHINE, $default_machine, |
| 242 | [Default machine code]) |
| 243 | AC_DEFINE_UNQUOTED(GOLD_DEFAULT_SIZE, $default_size, |
| 244 | [Default size (32 or 64)]) |
| 245 | AC_DEFINE_UNQUOTED(GOLD_DEFAULT_BIG_ENDIAN, $default_big_endian, |
| 246 | [Default big endian (true or false)]) |
| 247 | AC_DEFINE_UNQUOTED(GOLD_DEFAULT_OSABI, $default_osabi, |
| 248 | [Default OSABI code]) |
| 249 | |
| 250 | AC_ARG_WITH(lib-path, |
| 251 | [ --with-lib-path=dir1:dir2... set default LIB_PATH], |
| 252 | [case "$withval" in |
| 253 | yes) LIB_PATH='"/lib:/usr/lib"' ;; |
| 254 | no) LIB_PATH='""' ;; |
| 255 | *) LIB_PATH='"'"$withval"'"' ;; |
| 256 | esac], |
| 257 | [LIB_PATH='"::DEFAULT::"']) |
| 258 | AC_DEFINE_UNQUOTED(LIB_PATH, $LIB_PATH, |
| 259 | [Default library search path]) |
| 260 | if test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias"; then |
| 261 | AC_DEFINE(NATIVE_LINKER, 1, [Whether configured as a native linker]) |
| 262 | fi |
| 263 | |
| 264 | AC_CHECK_TOOL(NM, nm) |
| 265 | |
| 266 | AC_PROG_CC |
| 267 | AC_PROG_CXX |
| 268 | AC_PROG_YACC |
| 269 | AC_PROG_RANLIB |
| 270 | AC_PROG_INSTALL |
| 271 | AC_PROG_LN_S |
| 272 | |
| 273 | AC_GNU_SOURCE |
| 274 | |
| 275 | ZW_GNU_GETTEXT_SISTER_DIR |
| 276 | AM_PO_SUBDIRS |
| 277 | |
| 278 | AC_C_BIGENDIAN |
| 279 | |
| 280 | AC_EXEEXT |
| 281 | |
| 282 | AM_CONDITIONAL(NATIVE_LINKER, |
| 283 | test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias") |
| 284 | AM_CONDITIONAL(GCC, test "$GCC" = yes) |
| 285 | |
| 286 | AM_CONDITIONAL(NATIVE_OR_CROSS_LINKER, |
| 287 | test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias" -o "x$host_alias" = "x$build_alias") |
| 288 | |
| 289 | dnl Test for whether static linking is supported. Some systems do not |
| 290 | dnl install static libraries. This only affects the set of tests that |
| 291 | dnl we run. |
| 292 | AC_CACHE_CHECK([whether static linking works], [gold_cv_lib_static], |
| 293 | [LDFLAGS_hold=$LDFLAGS |
| 294 | LDFLAGS="$LDFLAGS -static" |
| 295 | AC_LINK_IFELSE([ |
| 296 | AC_LANG_PROGRAM([[void f() { }]])], |
| 297 | [gold_cv_lib_static=yes], [gold_cv_lib_static=no]) |
| 298 | LDFLAGS=$LDFLAGS_hold]) |
| 299 | AM_CONDITIONAL(HAVE_STATIC, test "$gold_cv_lib_static" = "yes") |
| 300 | |
| 301 | dnl Some architectures do not support taking pointers of functions |
| 302 | dnl defined in shared libraries except in -fPIC mode. We need to |
| 303 | dnl tell the unittest framework if we're compiling for one of those |
| 304 | dnl targets, so it doesn't try to run the tests that do that. |
| 305 | AM_CONDITIONAL(FN_PTRS_IN_SO_WITHOUT_PIC, [ |
| 306 | case $target_cpu in |
| 307 | powerpc*) false;; |
| 308 | x86_64) false;; |
| 309 | sparc64) false;; |
| 310 | *) true;; |
| 311 | esac]) |
| 312 | |
| 313 | dnl Test for gcc 4.1 or later. Full support for -mcmodel=medium is |
| 314 | dnl only available in gcc 4.1. |
| 315 | AC_CACHE_CHECK([for gcc >= 4.1], [gold_cv_prog_gcc41], |
| 316 | [AC_COMPILE_IFELSE([ |
| 317 | #if !defined __GNUC__ |
| 318 | error |
| 319 | #elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) |
| 320 | error |
| 321 | #endif |
| 322 | ], [gold_cv_prog_gcc41=yes], [gold_cv_prog_gcc41=no])]) |
| 323 | |
| 324 | save_CFLAGS="$CFLAGS" |
| 325 | CFLAGS="$CFLAGS -mcmodel=medium" |
| 326 | AC_COMPILE_IFELSE([int i;], [have_mcmodel_medium=yes], [have_mcmodel_medium=no]) |
| 327 | CFLAGS="$save_CFLAGS" |
| 328 | dnl Whether we can test -mcmodel=medium. |
| 329 | AM_CONDITIONAL(MCMODEL_MEDIUM, |
| 330 | [test "$target_cpu" = "x86_64" -a "$have_mcmodel_medium" = "yes" -a "$gold_cv_prog_gcc41" = "yes"]) |
| 331 | |
| 332 | dnl Test for __thread support. |
| 333 | AC_CACHE_CHECK([for thread support], [gold_cv_c_thread], |
| 334 | [AC_COMPILE_IFELSE([__thread int i = 1;], |
| 335 | [gold_cv_c_thread=yes], [gold_cv_c_thread=no])]) |
| 336 | |
| 337 | AM_CONDITIONAL(TLS, test "$gold_cv_c_thread" = "yes") |
| 338 | |
| 339 | dnl On GNU/Linux TLS in static programs only works when using glibc |
| 340 | dnl 2.4 or later. |
| 341 | AC_CACHE_CHECK([for glibc >= 2.4], [gold_cv_lib_glibc24], |
| 342 | [AC_COMPILE_IFELSE([ |
| 343 | #include <features.h> |
| 344 | #if !defined __GLIBC__ |
| 345 | error |
| 346 | #elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4) |
| 347 | error |
| 348 | #endif |
| 349 | ], [gold_cv_lib_glibc24=yes], [gold_cv_lib_glibc24=no])]) |
| 350 | |
| 351 | AM_CONDITIONAL(STATIC_TLS, test "$gold_cv_lib_glibc24" = "yes") |
| 352 | |
| 353 | dnl Test for #pragma omp threadprivate |
| 354 | AC_CACHE_CHECK([for omp support], [gold_cv_c_threadprivate], |
| 355 | [save_CFLAGS="$CFLAGS" |
| 356 | CFLAGS="$CFLAGS -fopenmp" |
| 357 | AC_COMPILE_IFELSE([ |
| 358 | #include <omp.h> |
| 359 | int i; |
| 360 | #pragma omp threadprivate (i) |
| 361 | ], [gold_cv_c_threadprivate=yes], [gold_cv_c_threadprivate=no]) |
| 362 | CFLAGS="$save_CFLAGS"]) |
| 363 | if test "$gold_cv_c_threadprivate" = "yes"; then |
| 364 | AC_DEFINE(HAVE_OMP_SUPPORT, 1, |
| 365 | [Define if compiler supports #pragma omp threadprivate]) |
| 366 | fi |
| 367 | AM_CONDITIONAL(OMP_SUPPORT, test "$gold_cv_c_threadprivate" = "yes") |
| 368 | |
| 369 | dnl Test for the -ftls-dialect=gnu2 option. |
| 370 | save_CFLAGS="$CFLAGS" |
| 371 | CFLAGS="$CFLAGS -fpic -mtls-dialect=gnu2" |
| 372 | AC_COMPILE_IFELSE([ |
| 373 | __thread int i; |
| 374 | void foo (void) |
| 375 | { |
| 376 | i = 10; |
| 377 | } |
| 378 | ], [have_tls_gnu2=yes], [have_tls_gnu2=no]) |
| 379 | CFLAGS="$save_CFLAGS" |
| 380 | AM_CONDITIONAL(TLS_GNU2_DIALECT, test "$have_tls_gnu2" = "yes") |
| 381 | |
| 382 | dnl On GNU/Linux TLS descriptors are supported by the dynamic loader |
| 383 | dnl only with glibc 2.9 or later. |
| 384 | AC_CACHE_CHECK([for glibc >= 2.9], [gold_cv_lib_glibc29], |
| 385 | [AC_COMPILE_IFELSE([ |
| 386 | #include <features.h> |
| 387 | #if !defined __GLIBC__ |
| 388 | error |
| 389 | #elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 9) |
| 390 | error |
| 391 | #endif |
| 392 | ], [gold_cv_lib_glibc29=yes], [gold_cv_lib_glibc29=no])]) |
| 393 | |
| 394 | AM_CONDITIONAL(TLS_DESCRIPTORS, test "$gold_cv_lib_glibc29" = "yes") |
| 395 | |
| 396 | dnl Test for the -frandom-seed option. |
| 397 | AC_CACHE_CHECK([for -frandom-seed support], [gold_cv_c_random_seed], |
| 398 | [save_CFLAGS="$CFLAGS" |
| 399 | CFLAGS="$CFLAGS -frandom-seed=foo" |
| 400 | AC_COMPILE_IFELSE([int i;], [gold_cv_c_random_seed=yes], |
| 401 | [gold_cv_c_random_seed=no]) |
| 402 | CFLAGS="$save_CFLAGS"]) |
| 403 | if test "$gold_cv_c_random_seed" = "yes"; then |
| 404 | # In Makefile, '$@' will be expanded to be the name of the file |
| 405 | # being built, providing a unique seed for each file. |
| 406 | RANDOM_SEED_CFLAGS=-frandom-seed=\$@ |
| 407 | fi |
| 408 | AC_SUBST(RANDOM_SEED_CFLAGS) |
| 409 | |
| 410 | dnl On GNU/Linux ifunc is supported by the dynamic linker in glibc |
| 411 | dnl 2.11 or later, and by binutils 2.20.1 or later. |
| 412 | AC_CACHE_CHECK([for glibc ifunc support], [gold_cv_lib_glibc_ifunc], |
| 413 | [save_LDFLAGS="$LDFLAGS" |
| 414 | LDFLAGS="$LDFLAGS -static" |
| 415 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
| 416 | #include <features.h> |
| 417 | #if !defined __GLIBC__ |
| 418 | error |
| 419 | #elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 11) |
| 420 | error |
| 421 | #endif |
| 422 | void func (void) { } |
| 423 | void invoke (void); |
| 424 | __asm__(".type invoke, %gnu_indirect_function"); |
| 425 | typedef void (*funcptr) (void); |
| 426 | funcptr dispatch (void) __asm__ ("invoke"); |
| 427 | funcptr dispatch (void) { return &func; }]], |
| 428 | [[invoke();]]) |
| 429 | ], [ |
| 430 | if ${NM} conftest$EXEEXT | grep "__rela\?_iplt_start" >/dev/null 2>&1; then |
| 431 | gold_cv_lib_glibc_ifunc=both |
| 432 | else |
| 433 | gold_cv_lib_glibc_ifunc=dyn |
| 434 | fi], [gold_cv_lib_glibc_ifunc=no]) |
| 435 | LDFLAGS="$save_LDFLAGS"]) |
| 436 | |
| 437 | AM_CONDITIONAL(IFUNC, test "$gold_cv_lib_glibc_ifunc" != "no") |
| 438 | AM_CONDITIONAL(IFUNC_STATIC, test "$gold_cv_lib_glibc_ifunc" = "both") |
| 439 | |
| 440 | AM_BINUTILS_WARNINGS |
| 441 | |
| 442 | WARN_CXXFLAGS=`echo ${WARN_CFLAGS} | sed -e 's/-Wstrict-prototypes//' -e 's/-Wmissing-prototypes//' -e 's/-Wshadow//'` |
| 443 | AC_SUBST(WARN_CXXFLAGS) |
| 444 | |
| 445 | AC_ARG_WITH(gold-ldflags, |
| 446 | [ --with-gold-ldflags=FLAGS additional link flags for gold], |
| 447 | [if test "$withval" = "no" -o "$withval" = "yes"; then |
| 448 | GOLD_LDFLAGS= |
| 449 | else |
| 450 | GOLD_LDFLAGS=$withval |
| 451 | fi], |
| 452 | [GOLD_LDFLAGS=]) |
| 453 | AC_SUBST(GOLD_LDFLAGS) |
| 454 | |
| 455 | AC_ARG_WITH(gold-ldadd, |
| 456 | [ --with-gold-ldadd=LIBS additional libraries for gold], |
| 457 | [if test "$withval" = "no" -o "$withval" = "yes"; then |
| 458 | GOLD_LDADD= |
| 459 | else |
| 460 | GOLD_LDADD=$withval |
| 461 | fi], |
| 462 | [GOLD_LDADD=]) |
| 463 | AC_SUBST(GOLD_LDADD) |
| 464 | |
| 465 | dnl Force support for large files by default. This may need to be |
| 466 | dnl host dependent. If build == host, we can check getconf LFS_CFLAGS. |
| 467 | LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" |
| 468 | AC_SUBST(LFS_CFLAGS) |
| 469 | |
| 470 | AC_CHECK_HEADERS(sys/mman.h) |
| 471 | AC_CHECK_FUNCS(chsize mmap) |
| 472 | AC_REPLACE_FUNCS(pread ftruncate ffsll) |
| 473 | |
| 474 | AC_CACHE_CHECK([mremap with MREMAP_MAYMOVE], [gold_cv_lib_mremap_maymove], |
| 475 | [AC_LINK_IFELSE([ |
| 476 | AC_LANG_PROGRAM([[ |
| 477 | #include <sys/mman.h> |
| 478 | void f() { mremap (0, 0, 0, MREMAP_MAYMOVE); } |
| 479 | ]])], [gold_cv_lib_mremap_maymove=yes], [gold_cv_lib_mremap_maymove=no])]) |
| 480 | if test "$gold_cv_lib_mremap_maymove" = "yes"; then |
| 481 | AC_DEFINE(HAVE_MREMAP, 1, |
| 482 | [Define to 1 if you have the mremap function with MREMAP_MAYMOVE support]) |
| 483 | else |
| 484 | AC_LIBOBJ(mremap) |
| 485 | fi |
| 486 | |
| 487 | # Link in zlib if we can. This allows us to write compressed sections. |
| 488 | AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)]) |
| 489 | AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_search_zlibVersion" != "no") |
| 490 | |
| 491 | dnl We have to check these in C, not C++, because autoconf generates |
| 492 | dnl tests which have no type information, and current glibc provides |
| 493 | dnl multiple declarations of functions like basename when compiling |
| 494 | dnl with C++. |
| 495 | AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp]) |
| 496 | |
| 497 | AC_LANG_PUSH(C++) |
| 498 | |
| 499 | AC_CHECK_HEADERS(tr1/unordered_set tr1/unordered_map) |
| 500 | AC_CHECK_HEADERS(ext/hash_map ext/hash_set) |
| 501 | AC_CHECK_HEADERS(byteswap.h) |
| 502 | AC_CHECK_FUNCS(mallinfo posix_fallocate fallocate readv sysconf times) |
| 503 | AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem]) |
| 504 | |
| 505 | # Use of ::std::tr1::unordered_map::rehash causes undefined symbols |
| 506 | # at link time with some versions of GCC. |
| 507 | AC_CACHE_CHECK([whether ::std::tr1::unordered_map::rehash is usable.], |
| 508 | [gold_cv_unordered_map_rehash], |
| 509 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
| 510 | #include <tr1/unordered_map> |
| 511 | void bar() { ::std::tr1::unordered_map<int, int> x; x.rehash(10); } |
| 512 | ]])], [gold_cv_unordered_map_rehash=yes], [gold_cv_unordered_map_rehash=no])]) |
| 513 | if test "$gold_cv_unordered_map_rehash" = "yes"; then |
| 514 | AC_DEFINE(HAVE_TR1_UNORDERED_MAP_REHASH, 1, |
| 515 | [Define if ::std::tr1::unordered_map::rehash is usable]) |
| 516 | fi |
| 517 | |
| 518 | # Use of tr1/unordered_map with off_t as a key is not supported on GCC |
| 519 | # 4.1.xx when compiling in 32-bit mode with a 64-bit off_t type. |
| 520 | AC_CACHE_CHECK([whether std::tr1::hash<off_t> is defined], |
| 521 | [gold_cv_hash_off_t], |
| 522 | [CXXFLAGS_hold=$CXXFLAGS |
| 523 | CXXFLAGS="$CXXFLAGS $LFS_CFLAGS" |
| 524 | AC_COMPILE_IFELSE([ |
| 525 | #include <sys/types.h> |
| 526 | #include <tr1/unordered_map> |
| 527 | std::tr1::hash<off_t> h; |
| 528 | ], |
| 529 | [gold_cv_hash_off_t=yes], |
| 530 | [gold_cv_hash_off_t=no]) |
| 531 | CXXFLAGS=$CFLAGS_hold]) |
| 532 | if test "$gold_cv_hash_off_t" = "yes"; then |
| 533 | AC_DEFINE(HAVE_TR1_HASH_OFF_T, 1, |
| 534 | [Define if std::tr1::hash<off_t> is usable]) |
| 535 | fi |
| 536 | |
| 537 | # gcc 4.3.0 doesn't recognize the printf attribute on a template |
| 538 | # function. Check for that. This is gcc bug 35546. This test can |
| 539 | # probably be removed after the bug has been fixed for a while. |
| 540 | AC_CACHE_CHECK([whether we can use attributes with template functions], |
| 541 | [gold_cv_template_attribute], |
| 542 | [AC_COMPILE_IFELSE([ |
| 543 | template<typename T> extern void foo(const char*, ...) |
| 544 | __attribute__ ((__format__ (__printf__, 1, 2))); |
| 545 | template<typename T> void foo(const char* format, ...) {} |
| 546 | void bar() { foo<int>("%s\n", "foo"); } |
| 547 | ], [gold_cv_template_attribute=yes], [gold_cv_template_attribute=no])]) |
| 548 | if test "$gold_cv_template_attribute" = "yes"; then |
| 549 | AC_DEFINE(HAVE_TEMPLATE_ATTRIBUTES, 1, |
| 550 | [Define if attributes work on C++ templates]) |
| 551 | fi |
| 552 | |
| 553 | dnl Check if the system has struct stat::st_mtim. |
| 554 | AC_CACHE_CHECK([for struct stat::st_mtim.], |
| 555 | [gold_cv_stat_st_mtim], |
| 556 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
| 557 | #include <sys/stat.h> |
| 558 | long bar() { struct stat s; return (long)(s.st_mtim.tv_sec + s.st_mtim.tv_sec);} |
| 559 | ]])], [gold_cv_stat_st_mtim=yes], [gold_cv_stat_st_mtim=no])]) |
| 560 | if test "$gold_cv_stat_st_mtim" = "yes"; then |
| 561 | AC_DEFINE(HAVE_STAT_ST_MTIM, 1, |
| 562 | [Define if struct stat has a field st_mtim with timespec for mtime]) |
| 563 | fi |
| 564 | |
| 565 | dnl Check if gcc supports the -gpubnames option. |
| 566 | save_CXXFLAGS="$CXXFLAGS" |
| 567 | CXXFLAGS="$CXXFLAGS -gpubnames" |
| 568 | AC_COMPILE_IFELSE([int i;], [have_pubnames=yes], [have_pubnames=no]) |
| 569 | CXXFLAGS="$save_CXXFLAGS" |
| 570 | AM_CONDITIONAL(HAVE_PUBNAMES, test "$have_pubnames" = "yes") |
| 571 | |
| 572 | AC_LANG_POP(C++) |
| 573 | |
| 574 | AC_CHECK_HEADERS(locale.h) |
| 575 | AC_CHECK_FUNCS(setlocale) |
| 576 | AM_LC_MESSAGES |
| 577 | |
| 578 | AM_MAINTAINER_MODE |
| 579 | |
| 580 | AC_OUTPUT(Makefile testsuite/Makefile po/Makefile.in:po/Make-in) |