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)
28 AM_SILENT_RULES([yes])
35 AC_USE_SYSTEM_EXTENSIONS
42 . ${srcdir}/../bfd/development.sh
43 test "$development" = true && ac_checking=yes
44 AC_ARG_ENABLE(checking,
45 [ --enable-checking enable run-time checks],
46 [case "${enableval}" in
47 no|none) ac_checking= ;;
50 if test x$ac_checking != x ; then
51 AC_DEFINE(ENABLE_CHECKING, 1, [Define if you want run-time sanity checks.])
54 AC_ARG_WITH(lib-path, [ --with-lib-path=dir1:dir2... set default LIB_PATH],LIB_PATH=$withval)
55 AC_ARG_ENABLE(targets,
56 [ --enable-targets alternative target configurations],
57 [case "${enableval}" in
58 yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all')
60 no) enable_targets= ;;
61 *) enable_targets=$enableval ;;
63 AC_ARG_ENABLE(64-bit-bfd,
64 [ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)],
65 [case "${enableval}" in
68 *) AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
69 esac],[want64=false])dnl
72 [ --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
74 case ${with_sysroot} in
75 yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_alias}/sys-root' ;;
76 *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
79 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
82 if test "x$prefix" = xNONE; then
83 test_prefix=/usr/local
87 if test "x$exec_prefix" = xNONE; then
88 test_exec_prefix=$test_prefix
90 test_exec_prefix=$exec_prefix
92 case ${TARGET_SYSTEM_ROOT} in
93 "${test_prefix}"|"${test_prefix}/"*|\
94 "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
95 '${prefix}'|'${prefix}/'*|\
96 '${exec_prefix}'|'${exec_prefix}/'*)
97 t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
98 TARGET_SYSTEM_ROOT_DEFINE="$t"
104 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
106 AC_SUBST(use_sysroot)
107 AC_SUBST(TARGET_SYSTEM_ROOT)
108 AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
110 dnl Use --enable-gold to decide if this linker should be the default.
111 dnl "install_as_default" is set to false if gold is the default linker.
112 dnl "installed_linker" is the installed BFD linker name.
114 [[ --enable-gold[=ARG] build gold [ARG={default,yes,no}]]],
115 [case "${enableval}" in
117 install_as_default=no
118 installed_linker=ld.bfd
121 install_as_default=yes
122 installed_linker=ld.bfd
125 AC_MSG_ERROR([invalid --enable-gold argument])
128 [install_as_default=yes
129 installed_linker=ld.bfd])
130 AC_SUBST(install_as_default)
131 AC_SUBST(installed_linker)
134 AS_HELP_STRING([--enable-got=<type>],
135 [GOT handling scheme (target, single, negative, multigot)]),
136 [case "${enableval}" in
137 target | single | negative | multigot) got_handling=$enableval ;;
138 *) AC_MSG_ERROR(bad value ${enableval} for --enable-got option) ;;
140 [got_handling=target])
142 case "${got_handling}" in
144 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_TARGET_DEFAULT],
145 [Define to choose default GOT handling scheme]) ;;
147 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_SINGLE],
148 [Define to choose default GOT handling scheme]) ;;
150 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_NEGATIVE],
151 [Define to choose default GOT handling scheme]) ;;
153 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_MULTIGOT],
154 [Define to choose default GOT handling scheme]) ;;
155 *) AC_MSG_ERROR(bad value ${got_handling} for --enable-got option) ;;
159 # Decide the default method for compressing debug sections.
160 ac_default_compressed_debug_sections=unset
161 # Provide a configure time option to override our default.
162 AC_ARG_ENABLE(compressed_debug_sections,
163 AS_HELP_STRING([--enable-compressed-debug-sections={all,ld,none}],
164 [compress debug sections by default])],
165 [case ,"${enableval}", in
166 ,yes, | ,all, | *,ld,*) ac_default_compressed_debug_sections=yes ;;
167 ,no, | ,none,) ac_default_compressed_debug_sections=no ;;
170 # Decide setting DT_RUNPATH instead of DT_RPATH by default
171 ac_default_new_dtags=unset
172 # Provide a configure time option to override our default.
173 AC_ARG_ENABLE(new_dtags,
174 AS_HELP_STRING([--enable-new-dtags],
175 [set DT_RUNPATH instead of DT_RPATH by default])],
176 [case "${enableval}" in
177 yes) ac_default_new_dtags=1 ;;
178 no) ac_default_new_dtags=0 ;;
181 # Decide if -z relro should be enabled in ELF linker by default.
182 ac_default_ld_z_relro=unset
183 # Provide a configure time option to override our default.
185 AS_HELP_STRING([--enable-relro],
186 [enable -z relro in ELF linker by default]),
187 [case "${enableval}" in
188 yes) ac_default_ld_z_relro=1 ;;
189 no) ac_default_ld_z_relro=0 ;;
192 # Decide if DT_TEXTREL check should be enabled in ELF linker.
193 ac_default_ld_textrel_check=unset
194 AC_ARG_ENABLE([textrel-check],
195 AC_HELP_STRING([--enable-textrel-check=@<:@yes|no|warning|error@:>@],
196 [enable DT_TEXTREL check in ELF linker]),
197 [case "${enableval}" in
198 yes|no|warning|error) ac_default_ld_textrel_check=${enableval} ;;
201 # Decide if -z separate-code should be enabled in ELF linker by default.
202 ac_default_ld_z_separate_code=unset
203 AC_ARG_ENABLE(separate-code,
204 AS_HELP_STRING([--enable-separate-code],
205 [enable -z separate-code in ELF linker by default]),
206 [case "${enableval}" in
207 yes) ac_default_ld_z_separate_code=1 ;;
208 no) ac_default_ld_z_separate_code=0 ;;
211 # Decide if --error-handling-script should be supported.
212 ac_support_error_handling_script=unset
213 AC_ARG_ENABLE(error-handling-script,
214 AS_HELP_STRING([--enable-error-handling-script],
215 [enable/disable support for the --error-handling-script option]),
216 [case "${enableval}" in
217 yes) ac_support_error_handling_script=1 ;;
218 no) ac_support_error_handling_script=0 ;;
221 # Decide which "--hash-style" to use by default
222 # Provide a configure time option to override our default.
223 AC_ARG_ENABLE([default-hash-style],
224 AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}],
225 [use this default hash style]),
226 [case "${enable_default_hash_style}" in
227 sysv | gnu | both) ;;
228 *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;;
231 # Enable gnu hash only on GNU targets, but not mips
232 mips*-*-*) enable_default_hash_style=sysv ;;
233 *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
234 *) enable_default_hash_style=sysv ;;
237 case "${enable_default_hash_style}" in
238 sysv | both) ac_default_emit_sysv_hash=1 ;;
239 *) ac_default_emit_sysv_hash=0 ;;
242 case "${enable_default_hash_style}" in
243 gnu | both) ac_default_emit_gnu_hash=1 ;;
244 *) ac_default_emit_gnu_hash=0 ;;
247 AC_ARG_ENABLE(initfini-array,
248 [ --disable-initfini-array do not use .init_array/.fini_array sections],
249 [case "${enableval}" in
251 *) AC_MSG_ERROR([invalid --enable-initfini-array argument]) ;;
252 esac], [enable_initfini_array=yes])
253 AC_SUBST(enable_initfini_array)
254 if test $enable_initfini_array = yes; then
255 AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
256 [Define .init_array/.fini_array sections are available and working.])
259 GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
260 if test "${enable_libctf}" = yes; then
261 AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
263 AM_CONDITIONAL(ENABLE_LIBCTF, test "${enable_libctf}" = yes)
264 AC_SUBST(enable_libctf)
270 AC_CONFIG_HEADERS([config.h:config.in])
273 AH_VERBATIM([00_CONFIG_H_CHECK],
274 [/* Check that config.h is #included before system headers
275 (this works only for glibc, but that should be enough). */
276 #if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
277 # error config.h must be #included before system headers
279 #define __CONFIG_H__ 1])
281 if test -z "$target" ; then
282 AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
284 if test -z "$host" ; then
285 AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
288 # host-specific stuff:
290 ALL_LINGUAS="bg da de es fi fr ga id it ja pt_BR ru sr sv tr uk vi zh_CN zh_TW"
291 ZW_GNU_GETTEXT_SISTER_DIR
300 AM_CONDITIONAL(GENINSRC_NEVER, false)
301 ACX_PROG_CMP_IGNORE_INITIAL
303 . ${srcdir}/configure.host
306 AC_SUBST(NATIVE_LIB_DIRS)
308 # We use headers from include/ that check various HAVE_*_H macros, thus
309 # should ensure they are set by configure. This is true even when C99
310 # guarantees they are available.
311 # sha1.h and md4.h test HAVE_LIMITS_H, HAVE_SYS_TYPES_H and HAVE_STDINT_H
312 # plugin-api.h tests HAVE_STDINT_H and HAVE_INTTYPES_H
313 # Besides those, we need to check anything used in ld/ not in C99.
314 AC_CHECK_HEADERS(fcntl.h elf-hints.h limits.h inttypes.h stdint.h \
315 sys/file.h sys/mman.h sys/param.h sys/stat.h sys/time.h \
316 sys/types.h unistd.h)
317 AC_CHECK_FUNCS(close glob lseek mkstemp open realpath sbrk waitpid)
321 AC_CHECK_DECLS([asprintf, environ, sbrk])
325 AC_SEARCH_LIBS([dlopen], [dl])
327 AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
328 AC_CACHE_VAL(ld_cv_decl_getopt_unistd_h,
329 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
330 ld_cv_decl_getopt_unistd_h=yes, ld_cv_decl_getopt_unistd_h=no)])
331 AC_MSG_RESULT($ld_cv_decl_getopt_unistd_h)
332 if test $ld_cv_decl_getopt_unistd_h = yes; then
333 AC_DEFINE([HAVE_DECL_GETOPT], 1,
334 [Is the prototype for getopt in <unistd.h> in the expected format?])
337 # Link in zlib if we can. This allows us to read and write
338 # compressed CTF sections.
341 # When converting linker scripts into strings for use in emulation
342 # files, use astring.sed if the compiler supports ANSI string
343 # concatenation, or ostring.sed otherwise. This is to support the
344 # broken Microsoft MSVC compiler, which limits the length of string
345 # constants, while still supporting pre-ANSI compilers which do not
346 # support string concatenation.
347 AC_MSG_CHECKING([whether ANSI C string concatenation works])
348 AC_CACHE_VAL(ld_cv_string_concatenation,
349 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [char *a = "a" "a";])],
350 ld_cv_string_concatenation=yes,
351 ld_cv_string_concatenation=no)])
352 AC_MSG_RESULT($ld_cv_string_concatenation)
353 if test "$ld_cv_string_concatenation" = "yes"; then
354 STRINGIFY=astring.sed
356 STRINGIFY=ostring.sed
360 # target-specific stuff:
369 # If the host is 64-bit, then we enable 64-bit targets by default.
370 # This is consistent with what ../bfd/configure.ac does.
371 if test x${want64} = xfalse; then
372 AC_CHECK_SIZEOF(void *)
373 if test "x${ac_cv_sizeof_void_p}" = "x8"; then
378 elf_list_options=false
379 elf_shlib_list_options=false
380 elf_plt_unwind_list_options=false
381 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
383 if test "$targ_alias" = "all"; then
385 elf_list_options=true
386 elf_shlib_list_options=true
387 elf_plt_unwind_list_options=true
389 # Canonicalize the secondary target names.
390 result=`$ac_config_sub $targ_alias 2>/dev/null`
391 if test -n "$result"; then
397 . ${srcdir}/configure.tgt
399 if test "$targ" = "$target"; then
403 if test x${want64} = xfalse; then
404 . ${srcdir}/../bfd/config.bfd
407 if test x${want64} = xtrue; then
408 targ_extra_emuls="$targ_extra_emuls $targ64_extra_emuls"
409 targ_extra_libpath="$targ_extra_libpath $targ64_extra_libpath"
412 for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
413 case " $all_emuls " in
416 all_emuls="$all_emuls e${i}.o"
417 eval result=\$tdir_$i
418 test -z "$result" && result=$targ_alias
423 elf_list_options=true
426 if $GREP "TEMPLATE_NAME=elf" ${srcdir}/emulparams/${i}.sh >/dev/null 2>/dev/null; then
427 elf_list_options=true
431 if test "$elf_list_options" = "true"; then
436 source_sh ${srcdir}/emulparams/${i}.sh
437 if test x${GENERATE_SHLIB_SCRIPT} = xyes; then
438 elf_shlib_list_options=true
440 if test x${PLT_UNWIND} = xyes; then
441 elf_plt_unwind_list_options=true
448 for i in $targ_emul $targ_extra_libpath; do
449 case " $all_libpath " in
452 if test -z "$all_libpath"; then
455 all_libpath="$all_libpath ${i}"
461 for i in $targ_extra_ofiles; do
462 case " $all_emul_extras " in
465 all_emul_extras="$all_emul_extras ${i}"
473 if test x$ac_default_compressed_debug_sections = xyes ; then
474 AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.])
477 if test "${ac_default_new_dtags}" = unset; then
478 ac_default_new_dtags=0
480 AC_DEFINE_UNQUOTED(DEFAULT_NEW_DTAGS,
481 $ac_default_new_dtags,
482 [Define to 1 if you want to set DT_RUNPATH instead of DT_RPATH by default.])
484 if test "${ac_default_ld_z_relro}" = unset; then
485 ac_default_ld_z_relro=0
487 AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_RELRO,
488 $ac_default_ld_z_relro,
489 [Define to 1 if you want to enable -z relro in ELF linker by default.])
491 ac_default_ld_textrel_check_warning=0
492 case "${ac_default_ld_textrel_check}" in
494 ac_default_ld_textrel_check=textrel_check_none
497 ac_default_ld_textrel_check=textrel_check_warning
498 ac_default_ld_textrel_check_warning=1
501 ac_default_ld_textrel_check=textrel_check_error
504 AC_DEFINE_UNQUOTED(DEFAULT_LD_TEXTREL_CHECK,
505 $ac_default_ld_textrel_check,
506 [The default method for DT_TEXTREL check in ELF linker.])
507 AC_DEFINE_UNQUOTED(DEFAULT_LD_TEXTREL_CHECK_WARNING,
508 $ac_default_ld_textrel_check_warning,
509 [Define to 1 if DT_TEXTREL check is warning in ELF linker by default.])
511 if test "${ac_default_ld_z_separate_code}" = unset; then
512 ac_default_ld_z_separate_code=0
514 AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_SEPARATE_CODE,
515 $ac_default_ld_z_separate_code,
516 [Define to 1 if you want to enable -z separate-code in ELF linker by default.])
518 if test "${ac_support_error_handling_script}" = unset; then
519 ac_support_error_handling_script=1
521 AC_DEFINE_UNQUOTED(SUPPORT_ERROR_HANDLING_SCRIPT,
522 $ac_support_error_handling_script,
523 [Define to 1 if you want to support the --error-handling-script command line option.])
525 AC_DEFINE_UNQUOTED([DEFAULT_EMIT_SYSV_HASH],
526 [$ac_default_emit_sysv_hash],
527 [Define to 1 if you want to emit sysv hash in the ELF linker by default.])
529 AC_DEFINE_UNQUOTED([DEFAULT_EMIT_GNU_HASH],
530 [$ac_default_emit_gnu_hash],
531 [Define to 1 if you want to emit gnu hash in the ELF linker by default.])
533 AC_SUBST(elf_list_options)
534 AC_SUBST(elf_shlib_list_options)
535 AC_SUBST(elf_plt_unwind_list_options)
539 AM_SUBST_NOTMAKE(TDIRS)
541 if test x${all_targets} = xtrue; then
542 if test x${want64} = xtrue; then
543 EMULATION_OFILES='$(ALL_EMULATIONS) $(ALL_64_EMULATIONS)'
544 EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES) $(ALL_64_EMUL_EXTRA_OFILES)'
546 EMULATION_OFILES='$(ALL_EMULATIONS)'
547 EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES)'
550 EMULATION_OFILES=$all_emuls
551 EMUL_EXTRA_OFILES=$all_emul_extras
553 AC_SUBST(EMULATION_OFILES)
554 AC_SUBST(EMUL_EXTRA_OFILES)
557 EMULATION_LIBPATH=$all_libpath
558 AC_SUBST(EMULATION_LIBPATH)
560 if test x${enable_static} = xno; then
561 TESTBFDLIB="-Wl,--rpath,../bfd/.libs ../bfd/.libs/libbfd.so"
562 TESTCTFLIB="-Wl,--rpath,../libctf/.libs ../libctf/.libs/libctf.so"
564 TESTBFDLIB="../bfd/.libs/libbfd.a"
565 TESTCTFLIB="../libctf/.libs/libctf.a"
567 if test "${enable_libctf}" = no; then
573 target_vendor=${target_vendor=$host_vendor}
574 case "$target_vendor" in
575 hp) EXTRA_SHLIB_EXTENSION=".sl" ;;
576 *) EXTRA_SHLIB_EXTENSION= ;;
580 lynxos) EXTRA_SHLIB_EXTENSION=".a" ;;
583 if test x${EXTRA_SHLIB_EXTENSION} != x ; then
584 AC_DEFINE_UNQUOTED(EXTRA_SHLIB_EXTENSION, "$EXTRA_SHLIB_EXTENSION",
585 [Additional extension a shared object might have.])
588 AC_CONFIG_COMMANDS([default],
592 *) srcdirpre='$(srcdir)/' ;;
596 for lang in dummy $OBSOLETE_ALL_LINGUAS; do
597 if test $lang != dummy; then
598 POFILES="$POFILES $srcdirpre$lang.po"
599 GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
602 sed -e '/^SRC-POTFILES =/r po/SRC-POTFILES' \
603 -e '/^BLD-POTFILES =/r po/BLD-POTFILES' \
604 -e "s,@POFILES@,$POFILES," \
605 -e "s,@GMOFILES@,$GMOFILES," \
606 po/Makefile.in > po/Makefile]],[[]])
608 dnl Required by html, pdf, install-pdf and install-html
609 AC_SUBST(datarootdir)
614 AC_CONFIG_FILES(Makefile po/Makefile.in:po/Make-in)