1 dnl Process this file with autoconf to produce a configure script
3 dnl Copyright (C) 2012-2021 Free Software Foundation, Inc.
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.
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.
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/>.
20 m4_include([../bfd/version.m4])
21 AC_INIT([ld], BFD_VERSION)
22 AC_CONFIG_SRCDIR(ldmain.c)
34 AC_USE_SYSTEM_EXTENSIONS
41 . ${srcdir}/../bfd/development.sh
42 test "$development" = true && ac_checking=yes
43 AC_ARG_ENABLE(checking,
44 [ --enable-checking enable run-time checks],
45 [case "${enableval}" in
46 no|none) ac_checking= ;;
49 if test x$ac_checking != x ; then
50 AC_DEFINE(ENABLE_CHECKING, 1, [Define if you want run-time sanity checks.])
53 AC_ARG_WITH(lib-path, [ --with-lib-path=dir1:dir2... set default LIB_PATH],LIB_PATH=$withval)
54 AC_ARG_ENABLE(targets,
55 [ --enable-targets alternative target configurations],
56 [case "${enableval}" in
57 yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all')
59 no) enable_targets= ;;
60 *) enable_targets=$enableval ;;
62 AC_ARG_ENABLE(64-bit-bfd,
63 [ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)],
64 [case "${enableval}" in
67 *) AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
68 esac],[want64=false])dnl
71 [ --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
73 case ${with_sysroot} in
74 yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_alias}/sys-root' ;;
75 *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
78 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
81 if test "x$prefix" = xNONE; then
82 test_prefix=/usr/local
86 if test "x$exec_prefix" = xNONE; then
87 test_exec_prefix=$test_prefix
89 test_exec_prefix=$exec_prefix
91 case ${TARGET_SYSTEM_ROOT} in
92 "${test_prefix}"|"${test_prefix}/"*|\
93 "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
94 '${prefix}'|'${prefix}/'*|\
95 '${exec_prefix}'|'${exec_prefix}/'*)
96 t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
97 TARGET_SYSTEM_ROOT_DEFINE="$t"
103 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
105 AC_SUBST(use_sysroot)
106 AC_SUBST(TARGET_SYSTEM_ROOT)
107 AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
109 dnl Use --enable-gold to decide if this linker should be the default.
110 dnl "install_as_default" is set to false if gold is the default linker.
111 dnl "installed_linker" is the installed BFD linker name.
113 [[ --enable-gold[=ARG] build gold [ARG={default,yes,no}]]],
114 [case "${enableval}" in
116 install_as_default=no
117 installed_linker=ld.bfd
120 install_as_default=yes
121 installed_linker=ld.bfd
124 AC_MSG_ERROR([invalid --enable-gold argument])
127 [install_as_default=yes
128 installed_linker=ld.bfd])
129 AC_SUBST(install_as_default)
130 AC_SUBST(installed_linker)
133 AS_HELP_STRING([--enable-got=<type>],
134 [GOT handling scheme (target, single, negative, multigot)]),
135 [case "${enableval}" in
136 target | single | negative | multigot) got_handling=$enableval ;;
137 *) AC_MSG_ERROR(bad value ${enableval} for --enable-got option) ;;
139 [got_handling=target])
141 case "${got_handling}" in
143 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_TARGET_DEFAULT],
144 [Define to choose default GOT handling scheme]) ;;
146 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_SINGLE],
147 [Define to choose default GOT handling scheme]) ;;
149 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_NEGATIVE],
150 [Define to choose default GOT handling scheme]) ;;
152 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_MULTIGOT],
153 [Define to choose default GOT handling scheme]) ;;
154 *) AC_MSG_ERROR(bad value ${got_handling} for --enable-got option) ;;
158 # Decide the default method for compressing debug sections.
159 ac_default_compressed_debug_sections=unset
160 # Provide a configure time option to override our default.
161 AC_ARG_ENABLE(compressed_debug_sections,
162 AS_HELP_STRING([--enable-compressed-debug-sections={all,ld,none}],
163 [compress debug sections by default])],
164 [case ,"${enableval}", in
165 ,yes, | ,all, | *,ld,*) ac_default_compressed_debug_sections=yes ;;
166 ,no, | ,none,) ac_default_compressed_debug_sections=no ;;
169 # Decide setting DT_RUNPATH instead of DT_RPATH by default
170 ac_default_new_dtags=unset
171 # Provide a configure time option to override our default.
172 AC_ARG_ENABLE(new_dtags,
173 AS_HELP_STRING([--enable-new-dtags],
174 [set DT_RUNPATH instead of DT_RPATH by default])],
175 [case "${enableval}" in
176 yes) ac_default_new_dtags=1 ;;
177 no) ac_default_new_dtags=0 ;;
180 # Decide if -z relro should be enabled in ELF linker by default.
181 ac_default_ld_z_relro=unset
182 # Provide a configure time option to override our default.
184 AS_HELP_STRING([--enable-relro],
185 [enable -z relro in ELF linker by default]),
186 [case "${enableval}" in
187 yes) ac_default_ld_z_relro=1 ;;
188 no) ac_default_ld_z_relro=0 ;;
191 # Decide if DT_TEXTREL check should be enabled in ELF linker.
192 ac_default_ld_textrel_check=unset
193 AC_ARG_ENABLE([textrel-check],
194 AC_HELP_STRING([--enable-textrel-check=@<:@yes|no|warning|error@:>@],
195 [enable DT_TEXTREL check in ELF linker]),
196 [case "${enableval}" in
197 yes|no|warning|error) ac_default_ld_textrel_check=${enableval} ;;
200 # Decide if -z separate-code should be enabled in ELF linker by default.
201 ac_default_ld_z_separate_code=unset
202 AC_ARG_ENABLE(separate-code,
203 AS_HELP_STRING([--enable-separate-code],
204 [enable -z separate-code in ELF linker by default]),
205 [case "${enableval}" in
206 yes) ac_default_ld_z_separate_code=1 ;;
207 no) ac_default_ld_z_separate_code=0 ;;
210 # Decide if --error-handling-script should be supported.
211 ac_support_error_handling_script=unset
212 AC_ARG_ENABLE(error-handling-script,
213 AS_HELP_STRING([--enable-error-handling-script],
214 [enable/disable support for the --error-handling-script option]),
215 [case "${enableval}" in
216 yes) ac_support_error_handling_script=1 ;;
217 no) ac_support_error_handling_script=0 ;;
220 # Decide which "--hash-style" to use by default
221 # Provide a configure time option to override our default.
222 AC_ARG_ENABLE([default-hash-style],
223 AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}],
224 [use this default hash style]),
225 [case "${enable_default_hash_style}" in
226 sysv | gnu | both) ;;
227 *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;;
230 # Enable gnu hash only on GNU targets, but not mips
231 mips*-*-*) enable_default_hash_style=sysv ;;
232 *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
233 *) enable_default_hash_style=sysv ;;
236 case "${enable_default_hash_style}" in
237 sysv | both) ac_default_emit_sysv_hash=1 ;;
238 *) ac_default_emit_sysv_hash=0 ;;
241 case "${enable_default_hash_style}" in
242 gnu | both) ac_default_emit_gnu_hash=1 ;;
243 *) ac_default_emit_gnu_hash=0 ;;
246 AC_ARG_ENABLE(initfini-array,
247 [ --disable-initfini-array do not use .init_array/.fini_array sections],
248 [case "${enableval}" in
250 *) AC_MSG_ERROR([invalid --enable-initfini-array argument]) ;;
251 esac], [enable_initfini_array=yes])
252 AC_SUBST(enable_initfini_array)
253 if test $enable_initfini_array = yes; then
254 AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
255 [Define .init_array/.fini_array sections are available and working.])
258 GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
259 if test "${enable_libctf}" = yes; then
260 AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
262 AM_CONDITIONAL(ENABLE_LIBCTF, test "${enable_libctf}" = yes)
263 AC_SUBST(enable_libctf)
269 AC_CONFIG_HEADERS([config.h:config.in])
272 AH_VERBATIM([00_CONFIG_H_CHECK],
273 [/* Check that config.h is #included before system headers
274 (this works only for glibc, but that should be enough). */
275 #if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
276 # error config.h must be #included before system headers
278 #define __CONFIG_H__ 1])
280 if test -z "$target" ; then
281 AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
283 if test -z "$host" ; then
284 AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
287 # host-specific stuff:
289 ALL_LINGUAS="bg da de es fi fr ga id it ja pt_BR ru sr sv tr uk vi zh_CN zh_TW"
290 ZW_GNU_GETTEXT_SISTER_DIR
299 AM_CONDITIONAL(GENINSRC_NEVER, false)
300 ACX_PROG_CMP_IGNORE_INITIAL
302 . ${srcdir}/configure.host
305 AC_SUBST(NATIVE_LIB_DIRS)
307 # We use headers from include/ that check various HAVE_*_H macros, thus
308 # should ensure they are set by configure. This is true even when C99
309 # guarantees they are available.
310 # sha1.h and md4.h test HAVE_LIMITS_H, HAVE_SYS_TYPES_H and HAVE_STDINT_H
311 # plugin-api.h tests HAVE_STDINT_H and HAVE_INTTYPES_H
312 # Besides those, we need to check anything used in ld/ not in C99.
313 AC_CHECK_HEADERS(fcntl.h elf-hints.h limits.h inttypes.h stdint.h \
314 sys/file.h sys/mman.h sys/param.h sys/stat.h sys/time.h \
315 sys/types.h unistd.h)
316 AC_CHECK_FUNCS(close glob lseek mkstemp open realpath sbrk waitpid)
320 AC_CHECK_DECLS([asprintf, environ, sbrk])
324 AC_SEARCH_LIBS([dlopen], [dl])
326 AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
327 AC_CACHE_VAL(ld_cv_decl_getopt_unistd_h,
328 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
329 ld_cv_decl_getopt_unistd_h=yes, ld_cv_decl_getopt_unistd_h=no)])
330 AC_MSG_RESULT($ld_cv_decl_getopt_unistd_h)
331 if test $ld_cv_decl_getopt_unistd_h = yes; then
332 AC_DEFINE([HAVE_DECL_GETOPT], 1,
333 [Is the prototype for getopt in <unistd.h> in the expected format?])
336 # Link in zlib if we can. This allows us to read and write
337 # compressed CTF sections.
340 # When converting linker scripts into strings for use in emulation
341 # files, use astring.sed if the compiler supports ANSI string
342 # concatenation, or ostring.sed otherwise. This is to support the
343 # broken Microsoft MSVC compiler, which limits the length of string
344 # constants, while still supporting pre-ANSI compilers which do not
345 # support string concatenation.
346 AC_MSG_CHECKING([whether ANSI C string concatenation works])
347 AC_CACHE_VAL(ld_cv_string_concatenation,
348 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [char *a = "a" "a";])],
349 ld_cv_string_concatenation=yes,
350 ld_cv_string_concatenation=no)])
351 AC_MSG_RESULT($ld_cv_string_concatenation)
352 if test "$ld_cv_string_concatenation" = "yes"; then
353 STRINGIFY=astring.sed
355 STRINGIFY=ostring.sed
359 # target-specific stuff:
368 # If the host is 64-bit, then we enable 64-bit targets by default.
369 # This is consistent with what ../bfd/configure.ac does.
370 if test x${want64} = xfalse; then
371 AC_CHECK_SIZEOF(void *)
372 if test "x${ac_cv_sizeof_void_p}" = "x8"; then
377 elf_list_options=false
378 elf_shlib_list_options=false
379 elf_plt_unwind_list_options=false
380 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
382 if test "$targ_alias" = "all"; then
384 elf_list_options=true
385 elf_shlib_list_options=true
386 elf_plt_unwind_list_options=true
388 # Canonicalize the secondary target names.
389 result=`$ac_config_sub $targ_alias 2>/dev/null`
390 if test -n "$result"; then
396 . ${srcdir}/configure.tgt
398 if test "$targ" = "$target"; then
402 if test x${want64} = xfalse; then
403 . ${srcdir}/../bfd/config.bfd
406 if test x${want64} = xtrue; then
407 targ_extra_emuls="$targ_extra_emuls $targ64_extra_emuls"
408 targ_extra_libpath="$targ_extra_libpath $targ64_extra_libpath"
411 for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
412 case " $all_emuls " in
415 all_emuls="$all_emuls e${i}.o"
416 eval result=\$tdir_$i
417 test -z "$result" && result=$targ_alias
422 elf_list_options=true
425 if $GREP "TEMPLATE_NAME=elf" ${srcdir}/emulparams/${i}.sh >/dev/null 2>/dev/null; then
426 elf_list_options=true
430 if test "$elf_list_options" = "true"; then
435 source_sh ${srcdir}/emulparams/${i}.sh
436 if test x${GENERATE_SHLIB_SCRIPT} = xyes; then
437 elf_shlib_list_options=true
439 if test x${PLT_UNWIND} = xyes; then
440 elf_plt_unwind_list_options=true
447 for i in $targ_emul $targ_extra_libpath; do
448 case " $all_libpath " in
451 if test -z "$all_libpath"; then
454 all_libpath="$all_libpath ${i}"
460 for i in $targ_extra_ofiles; do
461 case " $all_emul_extras " in
464 all_emul_extras="$all_emul_extras ${i}"
472 if test x$ac_default_compressed_debug_sections = xyes ; then
473 AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.])
476 if test "${ac_default_new_dtags}" = unset; then
477 ac_default_new_dtags=0
479 AC_DEFINE_UNQUOTED(DEFAULT_NEW_DTAGS,
480 $ac_default_new_dtags,
481 [Define to 1 if you want to set DT_RUNPATH instead of DT_RPATH by default.])
483 if test "${ac_default_ld_z_relro}" = unset; then
484 ac_default_ld_z_relro=0
486 AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_RELRO,
487 $ac_default_ld_z_relro,
488 [Define to 1 if you want to enable -z relro in ELF linker by default.])
490 ac_default_ld_textrel_check_warning=0
491 case "${ac_default_ld_textrel_check}" in
493 ac_default_ld_textrel_check=textrel_check_none
496 ac_default_ld_textrel_check=textrel_check_warning
497 ac_default_ld_textrel_check_warning=1
500 ac_default_ld_textrel_check=textrel_check_error
503 AC_DEFINE_UNQUOTED(DEFAULT_LD_TEXTREL_CHECK,
504 $ac_default_ld_textrel_check,
505 [The default method for DT_TEXTREL check in ELF linker.])
506 AC_DEFINE_UNQUOTED(DEFAULT_LD_TEXTREL_CHECK_WARNING,
507 $ac_default_ld_textrel_check_warning,
508 [Define to 1 if DT_TEXTREL check is warning in ELF linker by default.])
510 if test "${ac_default_ld_z_separate_code}" = unset; then
511 ac_default_ld_z_separate_code=0
513 AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_SEPARATE_CODE,
514 $ac_default_ld_z_separate_code,
515 [Define to 1 if you want to enable -z separate-code in ELF linker by default.])
517 if test "${ac_support_error_handling_script}" = unset; then
518 ac_support_error_handling_script=1
520 AC_DEFINE_UNQUOTED(SUPPORT_ERROR_HANDLING_SCRIPT,
521 $ac_support_error_handling_script,
522 [Define to 1 if you want to support the --error-handling-script command line option.])
524 AC_DEFINE_UNQUOTED([DEFAULT_EMIT_SYSV_HASH],
525 [$ac_default_emit_sysv_hash],
526 [Define to 1 if you want to emit sysv hash in the ELF linker by default.])
528 AC_DEFINE_UNQUOTED([DEFAULT_EMIT_GNU_HASH],
529 [$ac_default_emit_gnu_hash],
530 [Define to 1 if you want to emit gnu hash in the ELF linker by default.])
532 AC_SUBST(elf_list_options)
533 AC_SUBST(elf_shlib_list_options)
534 AC_SUBST(elf_plt_unwind_list_options)
538 AM_SUBST_NOTMAKE(TDIRS)
540 if test x${all_targets} = xtrue; then
541 if test x${want64} = xtrue; then
542 EMULATION_OFILES='$(ALL_EMULATIONS) $(ALL_64_EMULATIONS)'
543 EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES) $(ALL_64_EMUL_EXTRA_OFILES)'
545 EMULATION_OFILES='$(ALL_EMULATIONS)'
546 EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES)'
549 EMULATION_OFILES=$all_emuls
550 EMUL_EXTRA_OFILES=$all_emul_extras
552 AC_SUBST(EMULATION_OFILES)
553 AC_SUBST(EMUL_EXTRA_OFILES)
556 EMULATION_LIBPATH=$all_libpath
557 AC_SUBST(EMULATION_LIBPATH)
559 if test x${enable_static} = xno; then
560 TESTBFDLIB="-Wl,--rpath,../bfd/.libs ../bfd/.libs/libbfd.so"
561 TESTCTFLIB="-Wl,--rpath,../libctf/.libs ../libctf/.libs/libctf.so"
563 TESTBFDLIB="../bfd/.libs/libbfd.a"
564 TESTCTFLIB="../libctf/.libs/libctf.a"
566 if test "${enable_libctf}" = no; then
572 target_vendor=${target_vendor=$host_vendor}
573 case "$target_vendor" in
574 hp) EXTRA_SHLIB_EXTENSION=".sl" ;;
575 *) EXTRA_SHLIB_EXTENSION= ;;
579 lynxos) EXTRA_SHLIB_EXTENSION=".a" ;;
582 if test x${EXTRA_SHLIB_EXTENSION} != x ; then
583 AC_DEFINE_UNQUOTED(EXTRA_SHLIB_EXTENSION, "$EXTRA_SHLIB_EXTENSION",
584 [Additional extension a shared object might have.])
587 AC_CONFIG_COMMANDS([default],
591 *) srcdirpre='$(srcdir)/' ;;
595 for lang in dummy $OBSOLETE_ALL_LINGUAS; do
596 if test $lang != dummy; then
597 POFILES="$POFILES $srcdirpre$lang.po"
598 GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
601 sed -e '/^SRC-POTFILES =/r po/SRC-POTFILES' \
602 -e '/^BLD-POTFILES =/r po/BLD-POTFILES' \
603 -e "s,@POFILES@,$POFILES," \
604 -e "s,@GMOFILES@,$GMOFILES," \
605 po/Makefile.in > po/Makefile]],[[]])
607 dnl Required by html, pdf, install-pdf and install-html
608 AC_SUBST(datarootdir)
613 AC_CONFIG_FILES(Makefile po/Makefile.in:po/Make-in)