Home | History | Annotate | Download | only in ld
      1 dnl Process this file with autoconf to produce a configure script
      2 dnl
      3 dnl   Copyright (C) 2012-2014 Free Software Foundation, Inc.
      4 dnl
      5 dnl This file is free software; you can redistribute it and/or modify
      6 dnl it under the terms of the GNU General Public License as published by
      7 dnl the Free Software Foundation; either version 3 of the License, or
      8 dnl (at your option) any later version.
      9 dnl 
     10 dnl This program is distributed in the hope that it will be useful,
     11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 dnl GNU General Public License for more details.
     14 dnl 
     15 dnl You should have received a copy of the GNU General Public License
     16 dnl along with this program; see the file COPYING3.  If not see
     17 dnl <http://www.gnu.org/licenses/>.
     18 dnl
     19 
     20 AC_PREREQ(2.59)
     21 m4_include([../bfd/version.m4])
     22 AC_INIT([ld], BFD_VERSION)
     23 AC_CONFIG_SRCDIR(ldmain.c)
     24 
     25 AC_CANONICAL_TARGET
     26 AC_CANONICAL_BUILD
     27 AC_ISC_POSIX
     28 
     29 AM_INIT_AUTOMAKE
     30 AM_MAINTAINER_MODE
     31 
     32 AC_PROG_CC
     33 AC_PROG_CXX
     34 AC_GNU_SOURCE
     35 AC_USE_SYSTEM_EXTENSIONS
     36 AC_PROG_INSTALL
     37 
     38 LT_INIT
     39 ACX_LARGEFILE
     40 
     41 AC_ARG_WITH(lib-path, [  --with-lib-path=dir1:dir2...  set default LIB_PATH],LIB_PATH=$withval)
     42 AC_ARG_ENABLE(targets,
     43 [  --enable-targets        alternative target configurations],
     44 [case "${enableval}" in
     45   yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all')
     46             ;;
     47   no)       enable_targets= ;;
     48   *)        enable_targets=$enableval ;;
     49 esac])dnl
     50 AC_ARG_ENABLE(64-bit-bfd,
     51 [  --enable-64-bit-bfd     64-bit support (on hosts with narrower word sizes)],
     52 [case "${enableval}" in
     53   yes)  want64=true  ;;
     54   no)   want64=false ;;
     55   *)    AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
     56 esac],[want64=false])dnl
     57 
     58 AC_ARG_WITH(sysroot,
     59 [  --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
     60 [
     61  case ${with_sysroot} in
     62  yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_alias}/sys-root' ;;
     63  *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
     64  esac
     65 
     66  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
     67  use_sysroot=yes
     68 
     69  if test "x$prefix" = xNONE; then
     70   test_prefix=/usr/local
     71  else
     72   test_prefix=$prefix
     73  fi
     74  if test "x$exec_prefix" = xNONE; then
     75   test_exec_prefix=$test_prefix
     76  else
     77   test_exec_prefix=$exec_prefix
     78  fi
     79  case ${TARGET_SYSTEM_ROOT} in
     80  "${test_prefix}"|"${test_prefix}/"*|\
     81  "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
     82  '${prefix}'|'${prefix}/'*|\
     83  '${exec_prefix}'|'${exec_prefix}/'*)
     84    t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
     85    TARGET_SYSTEM_ROOT_DEFINE="$t"
     86    ;;
     87  esac
     88 ], [
     89  use_sysroot=no
     90  TARGET_SYSTEM_ROOT=
     91  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
     92 ])
     93 AC_SUBST(use_sysroot)
     94 AC_SUBST(TARGET_SYSTEM_ROOT)
     95 AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
     96 
     97 AC_ARG_ENABLE([poison-system-directories],
     98          AS_HELP_STRING([--enable-poison-system-directories],
     99                 [warn for use of native system library directories]),,
    100          [enable_poison_system_directories=no])
    101 if test "x${enable_poison_system_directories}" = "xyes"; then
    102   AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
    103        [1],
    104        [Define to warn for use of native system library directories])
    105 fi
    106 
    107 dnl Use --enable-gold to decide if this linker should be the default.
    108 dnl "install_as_default" is set to false if gold is the default linker.
    109 dnl "installed_linker" is the installed BFD linker name.
    110 AC_ARG_ENABLE(gold,
    111 [[  --enable-gold[=ARG]     build gold [ARG={default,yes,no}]]],
    112 [case "${enableval}" in
    113  default)
    114    install_as_default=no
    115    installed_linker=ld.bfd
    116    ;;
    117  yes|no)
    118    install_as_default=yes
    119    installed_linker=ld.bfd
    120    ;;
    121  *)
    122    AC_MSG_ERROR([invalid --enable-gold argument])
    123    ;;
    124  esac],
    125 [install_as_default=yes
    126  installed_linker=ld.bfd])
    127 AC_SUBST(install_as_default)
    128 AC_SUBST(installed_linker)
    129 
    130 AC_ARG_ENABLE([got],
    131 AS_HELP_STRING([--enable-got=<type>],
    132                [GOT handling scheme (target, single, negative, multigot)]),
    133 [case "${enableval}" in
    134   target | single | negative | multigot)  got_handling=$enableval ;;
    135   *)  AC_MSG_ERROR(bad value ${enableval} for --enable-got option) ;;
    136 esac],
    137 [got_handling=target])
    138 
    139 case "${got_handling}" in
    140   target)
    141     AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_TARGET_DEFAULT],
    142               [Define to choose default GOT handling scheme]) ;;
    143   single)
    144     AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_SINGLE],
    145               [Define to choose default GOT handling scheme]) ;;
    146   negative)
    147     AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_NEGATIVE],
    148               [Define to choose default GOT handling scheme]) ;;
    149   multigot)
    150     AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_MULTIGOT],
    151               [Define to choose default GOT handling scheme]) ;;
    152   *)  AC_MSG_ERROR(bad value ${got_handling} for --enable-got option) ;;
    153 esac
    154 
    155 AM_BINUTILS_WARNINGS
    156 
    157 AM_LC_MESSAGES
    158 
    159 AC_CONFIG_HEADERS([config.h:config.in])
    160 
    161 # PR 14072
    162 AH_VERBATIM([00_CONFIG_H_CHECK],
    163 [/* Check that config.h is #included before system headers
    164    (this works only for glibc, but that should be enough).  */
    165 #if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
    166 #  error config.h must be #included before system headers
    167 #endif
    168 #define __CONFIG_H__ 1])
    169 
    170 if test -z "$target" ; then
    171     AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
    172 fi
    173 if test -z "$host" ; then
    174     AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
    175 fi
    176 
    177 # host-specific stuff:
    178 
    179 ALL_LINGUAS="fr sv tr es da vi zh_CN zh_TW ga fi id bg it uk"
    180 ZW_GNU_GETTEXT_SISTER_DIR
    181 AM_PO_SUBDIRS
    182 
    183 AC_EXEEXT
    184 
    185 AC_PROG_YACC
    186 AM_PROG_LEX
    187 
    188 AM_MAINTAINER_MODE
    189 AM_CONDITIONAL(GENINSRC_NEVER, false)
    190 ACX_PROG_CMP_IGNORE_INITIAL
    191 
    192 . ${srcdir}/configure.host
    193 
    194 AC_SUBST(HDEFINES)
    195 AC_SUBST(HOSTING_CRT0)
    196 AC_SUBST(HOSTING_SCRT0)
    197 AC_SUBST(HOSTING_LIBS)
    198 AC_SUBST(HOSTING_SLIBS)
    199 AC_SUBST(NATIVE_LIB_DIRS)
    200 
    201 AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h limits.h locale.h sys/param.h)
    202 AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h)
    203 ACX_HEADER_STRING
    204 AC_CHECK_FUNCS(glob mkstemp realpath sbrk setlocale waitpid)
    205 AC_CHECK_FUNCS(open lseek close)
    206 AC_HEADER_DIRENT
    207 
    208 AC_SEARCH_LIBS([dlopen], [dl])
    209 AM_CONDITIONAL([ENABLE_PLUGINS], [test x$plugins = xyes])
    210 
    211 AC_ARG_ENABLE(initfini-array,
    212 	[  --enable-initfini-array	use .init_array/.fini_array sections],
    213 	[], [
    214 AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
    215 		 gcc_cv_initfini_array, [dnl
    216   if test "x${build}" = "x${target}" ; then
    217     AC_RUN_IFELSE([AC_LANG_SOURCE([
    218 static int x = -1;
    219 int main (void) { return x; }
    220 int foo (void) { x = 0; }
    221 int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;])],
    222 	     [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
    223 	     [gcc_cv_initfini_array=no])
    224    else
    225      gcc_cv_initfini_array=no
    226    fi])
    227   enable_initfini_array=$gcc_cv_initfini_array
    228 ])
    229 AC_SUBST(enable_initfini_array)
    230 if test $enable_initfini_array = yes; then
    231   AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
    232     [Define .init_array/.fini_array sections are available and working.])
    233 fi
    234 
    235 AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
    236 AC_CACHE_VAL(ld_cv_decl_getopt_unistd_h,
    237 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
    238 ld_cv_decl_getopt_unistd_h=yes, ld_cv_decl_getopt_unistd_h=no)])
    239 AC_MSG_RESULT($ld_cv_decl_getopt_unistd_h)
    240 if test $ld_cv_decl_getopt_unistd_h = yes; then
    241   AC_DEFINE([HAVE_DECL_GETOPT], 1,
    242 	    [Is the prototype for getopt in <unistd.h> in the expected format?])
    243 fi
    244 
    245 BFD_BINARY_FOPEN
    246 
    247 AC_CHECK_DECLS([strstr, free, sbrk, getenv, environ])
    248 
    249 # Link in zlib if we can.  This is needed only for the bootstrap tests
    250 # right now, since those tests use libbfd, which depends on zlib.
    251 AM_ZLIB
    252 
    253 # When converting linker scripts into strings for use in emulation
    254 # files, use astring.sed if the compiler supports ANSI string
    255 # concatenation, or ostring.sed otherwise.  This is to support the
    256 # broken Microsoft MSVC compiler, which limits the length of string
    257 # constants, while still supporting pre-ANSI compilers which do not
    258 # support string concatenation.
    259 AC_MSG_CHECKING([whether ANSI C string concatenation works])
    260 AC_CACHE_VAL(ld_cv_string_concatenation,
    261 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [char *a = "a" "a";])],
    262   ld_cv_string_concatenation=yes,
    263   ld_cv_string_concatenation=no)])
    264 AC_MSG_RESULT($ld_cv_string_concatenation)
    265 if test "$ld_cv_string_concatenation" = "yes"; then
    266   STRINGIFY=astring.sed
    267 else
    268   STRINGIFY=ostring.sed
    269 fi
    270 AC_SUBST(STRINGIFY)
    271 
    272 # target-specific stuff:
    273 
    274 all_targets=
    275 EMUL=
    276 all_emuls=
    277 all_emul_extras=
    278 all_libpath=
    279 
    280 dnl We need to get an arbitrary number of tdir definitions into
    281 dnl Makefile.  We can't do it using AC_SUBST, because autoconf does
    282 dnl not permit literal newlines in an AC_SUBST variables.  So we use a
    283 dnl file.
    284 rm -f tdirs
    285 
    286 # If the host is 64-bit, then we enable 64-bit targets by default.
    287 # This is consistent with what ../bfd/configure.ac does.
    288 if test x${want64} = xfalse; then
    289   AC_CHECK_SIZEOF(void *)
    290   if test "x${ac_cv_sizeof_void_p}" = "x8"; then
    291     want64=true
    292   fi
    293 fi
    294 
    295 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
    296 do
    297   if test "$targ_alias" = "all"; then
    298     all_targets=true
    299   else
    300     # Canonicalize the secondary target names.
    301     result=`$ac_config_sub $targ_alias 2>/dev/null`
    302     if test -n "$result"; then
    303 	targ=$result
    304     else
    305 	targ=$targ_alias
    306     fi
    307 
    308     . ${srcdir}/configure.tgt
    309 
    310     if test "$targ" = "$target"; then
    311       EMUL=$targ_emul
    312     fi
    313 
    314     if test x${want64} = xfalse; then
    315       . ${srcdir}/../bfd/config.bfd
    316     fi
    317 
    318     if test x${want64} = xtrue; then
    319       targ_extra_emuls="$targ_extra_emuls $targ64_extra_emuls"
    320       targ_extra_libpath="$targ_extra_libpath $targ64_extra_libpath"
    321     fi
    322 
    323     for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
    324 	case " $all_emuls " in
    325 	*" e${i}.o "*) ;;
    326 	*)
    327 	  all_emuls="$all_emuls e${i}.o"
    328 	  eval result=\$tdir_$i
    329 	  test -z "$result" && result=$targ_alias
    330 	  echo tdir_$i=$result >> tdirs
    331 	  ;;
    332 	esac
    333     done
    334 
    335     for i in $targ_emul $targ_extra_libpath; do
    336 	case " $all_libpath " in
    337 	*" ${i} "*) ;;
    338 	*)
    339 	  if test -z "$all_libpath"; then
    340 	    all_libpath=${i}
    341 	  else
    342 	    all_libpath="$all_libpath ${i}"
    343 	  fi
    344 	  ;;
    345 	esac
    346     done
    347 
    348     for i in $targ_extra_ofiles; do
    349 	case " $all_emul_extras " in
    350 	*" ${i} "*) ;;
    351 	*)
    352 	  all_emul_extras="$all_emul_extras ${i}"
    353 	  ;;
    354 	esac
    355     done
    356 
    357   fi
    358 done
    359 
    360 AC_SUBST(EMUL)
    361 
    362 TDIRS=tdirs
    363 AC_SUBST_FILE(TDIRS)
    364 
    365 if test x${all_targets} = xtrue; then
    366   if test x${want64} = xtrue; then
    367     EMULATION_OFILES='$(ALL_EMULATIONS) $(ALL_64_EMULATIONS)'
    368     EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES) $(ALL_64_EMUL_EXTRA_OFILES)'
    369   else
    370     EMULATION_OFILES='$(ALL_EMULATIONS)'
    371     EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES)'
    372   fi
    373 else
    374   EMULATION_OFILES=$all_emuls
    375   EMUL_EXTRA_OFILES=$all_emul_extras
    376 fi
    377 AC_SUBST(EMULATION_OFILES)
    378 AC_SUBST(EMUL_EXTRA_OFILES)
    379 AC_SUBST(LIB_PATH)
    380 
    381 EMULATION_LIBPATH=$all_libpath
    382 AC_SUBST(EMULATION_LIBPATH)
    383 
    384 if test x${enable_static} = xno; then
    385   TESTBFDLIB="--rpath ../bfd/.libs ../bfd/.libs/libbfd.so"
    386 else
    387   TESTBFDLIB="../bfd/.libs/libbfd.a"
    388 fi
    389 AC_SUBST(TESTBFDLIB)
    390 
    391 target_vendor=${target_vendor=$host_vendor}
    392 case "$target_vendor" in
    393   hp) EXTRA_SHLIB_EXTENSION=".sl" ;;
    394   *)  EXTRA_SHLIB_EXTENSION= ;;
    395 esac
    396 
    397 case "$target_os" in
    398   lynxos) EXTRA_SHLIB_EXTENSION=".a" ;;
    399 esac
    400 
    401 if test x${EXTRA_SHLIB_EXTENSION} != x ; then
    402   AC_DEFINE_UNQUOTED(EXTRA_SHLIB_EXTENSION, "$EXTRA_SHLIB_EXTENSION",
    403    [Additional extension a shared object might have.])
    404 fi
    405 
    406 dnl Required by html, pdf, install-pdf and install-html
    407 AC_SUBST(datarootdir)
    408 AC_SUBST(docdir)
    409 AC_SUBST(htmldir)
    410 AC_SUBST(pdfdir)
    411 
    412 AC_CONFIG_FILES(Makefile po/Makefile.in:po/Make-in)
    413 AC_OUTPUT
    414