Convert DTrace probe interface to C++ (and perform some cleanups)
[external/binutils.git] / ld / configure.ac
1 dnl Process this file with autoconf to produce a configure script
2 dnl
3 dnl   Copyright (C) 2012-2017 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_PROG_GREP
35 AC_GNU_SOURCE
36 AC_USE_SYSTEM_EXTENSIONS
37 AC_PROG_INSTALL
38
39 LT_INIT
40 ACX_LARGEFILE
41
42 AC_ARG_WITH(lib-path, [  --with-lib-path=dir1:dir2...  set default LIB_PATH],LIB_PATH=$withval)
43 AC_ARG_ENABLE(targets,
44 [  --enable-targets        alternative target configurations],
45 [case "${enableval}" in
46   yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all')
47             ;;
48   no)       enable_targets= ;;
49   *)        enable_targets=$enableval ;;
50 esac])dnl
51 AC_ARG_ENABLE(64-bit-bfd,
52 [  --enable-64-bit-bfd     64-bit support (on hosts with narrower word sizes)],
53 [case "${enableval}" in
54   yes)  want64=true  ;;
55   no)   want64=false ;;
56   *)    AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
57 esac],[want64=false])dnl
58
59 AC_ARG_WITH(sysroot,
60 [  --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
61 [
62  case ${with_sysroot} in
63  yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_alias}/sys-root' ;;
64  *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
65  esac
66
67  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
68  use_sysroot=yes
69
70  if test "x$prefix" = xNONE; then
71   test_prefix=/usr/local
72  else
73   test_prefix=$prefix
74  fi
75  if test "x$exec_prefix" = xNONE; then
76   test_exec_prefix=$test_prefix
77  else
78   test_exec_prefix=$exec_prefix
79  fi
80  case ${TARGET_SYSTEM_ROOT} in
81  "${test_prefix}"|"${test_prefix}/"*|\
82  "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
83  '${prefix}'|'${prefix}/'*|\
84  '${exec_prefix}'|'${exec_prefix}/'*)
85    t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
86    TARGET_SYSTEM_ROOT_DEFINE="$t"
87    ;;
88  esac
89 ], [
90  use_sysroot=no
91  TARGET_SYSTEM_ROOT=
92  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
93 ])
94 AC_SUBST(use_sysroot)
95 AC_SUBST(TARGET_SYSTEM_ROOT)
96 AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
97
98 dnl Use --enable-gold to decide if this linker should be the default.
99 dnl "install_as_default" is set to false if gold is the default linker.
100 dnl "installed_linker" is the installed BFD linker name.
101 AC_ARG_ENABLE(gold,
102 [[  --enable-gold[=ARG]     build gold [ARG={default,yes,no}]]],
103 [case "${enableval}" in
104  default)
105    install_as_default=no
106    installed_linker=ld.bfd
107    ;;
108  yes|no)
109    install_as_default=yes
110    installed_linker=ld.bfd
111    ;;
112  *)
113    AC_MSG_ERROR([invalid --enable-gold argument])
114    ;;
115  esac],
116 [install_as_default=yes
117  installed_linker=ld.bfd])
118 AC_SUBST(install_as_default)
119 AC_SUBST(installed_linker)
120
121 AC_ARG_ENABLE([got],
122 AS_HELP_STRING([--enable-got=<type>],
123                [GOT handling scheme (target, single, negative, multigot)]),
124 [case "${enableval}" in
125   target | single | negative | multigot)  got_handling=$enableval ;;
126   *)  AC_MSG_ERROR(bad value ${enableval} for --enable-got option) ;;
127 esac],
128 [got_handling=target])
129
130 case "${got_handling}" in
131   target)
132     AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_TARGET_DEFAULT],
133               [Define to choose default GOT handling scheme]) ;;
134   single)
135     AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_SINGLE],
136               [Define to choose default GOT handling scheme]) ;;
137   negative)
138     AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_NEGATIVE],
139               [Define to choose default GOT handling scheme]) ;;
140   multigot)
141     AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_MULTIGOT],
142               [Define to choose default GOT handling scheme]) ;;
143   *)  AC_MSG_ERROR(bad value ${got_handling} for --enable-got option) ;;
144 esac
145
146 # PR gas/19109
147 # Decide the default method for compressing debug sections.
148 ac_default_compressed_debug_sections=unset
149 # Provide a configure time option to override our default.
150 AC_ARG_ENABLE(compressed_debug_sections,
151               AS_HELP_STRING([--enable-compressed-debug-sections={all,ld,none}],
152               [compress debug sections by default])],
153 [case ,"${enableval}", in
154   ,yes, | ,all, | *,ld,*) ac_default_compressed_debug_sections=yes ;;
155   ,no, | ,none,)  ac_default_compressed_debug_sections=no ;;
156 esac])dnl
157
158 # Decide setting DT_RUNPATH instead of DT_RPATH by default
159 ac_default_new_dtags=unset
160 # Provide a configure time option to override our default.
161 AC_ARG_ENABLE(new_dtags,
162               AS_HELP_STRING([--enable-new-dtags],
163               [set DT_RUNPATH instead of DT_RPATH by default])],
164 [case "${enableval}" in
165   yes) ac_default_new_dtags=1 ;;
166   no) ac_default_new_dtags=0 ;;
167 esac])dnl
168
169 # Decide if -z relro should be enabled in ELF linker by default.
170 ac_default_ld_z_relro=unset
171 # Provide a configure time option to override our default.
172 AC_ARG_ENABLE(relro,
173               AS_HELP_STRING([--enable-relro],
174               [enable -z relro in ELF linker by default]),
175 [case "${enableval}" in
176   yes)  ac_default_ld_z_relro=1 ;;
177   no)  ac_default_ld_z_relro=0 ;;
178 esac])dnl
179
180 # Decide which "--hash-style" to use by default
181 # Provide a configure time option to override our default.
182 AC_ARG_ENABLE([default-hash-style],
183 AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}],
184                [use this default hash style]),
185 [case "${enable_default_hash_style}" in
186   sysv | gnu | both) ;;
187   *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;;
188 esac],
189 [case "${target}" in
190   # Enable gnu hash only on GNU targets, but not mips
191   mips*-*-*) enable_default_hash_style=sysv ;;
192   *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
193   *) enable_default_hash_style=sysv ;;
194 esac])
195
196 case "${enable_default_hash_style}" in
197   sysv | both) ac_default_emit_sysv_hash=1 ;;
198   *) ac_default_emit_sysv_hash=0 ;;
199 esac
200
201 case "${enable_default_hash_style}" in
202   gnu | both) ac_default_emit_gnu_hash=1 ;;
203   *) ac_default_emit_gnu_hash=0 ;;
204 esac
205
206 AM_BINUTILS_WARNINGS
207
208 AM_LC_MESSAGES
209
210 AC_CONFIG_HEADERS([config.h:config.in])
211
212 # PR 14072
213 AH_VERBATIM([00_CONFIG_H_CHECK],
214 [/* Check that config.h is #included before system headers
215    (this works only for glibc, but that should be enough).  */
216 #if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
217 #  error config.h must be #included before system headers
218 #endif
219 #define __CONFIG_H__ 1])
220
221 if test -z "$target" ; then
222     AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
223 fi
224 if test -z "$host" ; then
225     AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
226 fi
227
228 # host-specific stuff:
229
230 ALL_LINGUAS="bg da de es fi fr ga id it ru sr sv tr uk vi zh_CN zh_TW pt_BR"
231 ZW_GNU_GETTEXT_SISTER_DIR
232 AM_PO_SUBDIRS
233
234 AC_EXEEXT
235
236 AC_PROG_YACC
237 AM_PROG_LEX
238
239 AM_MAINTAINER_MODE
240 AM_CONDITIONAL(GENINSRC_NEVER, false)
241 ACX_PROG_CMP_IGNORE_INITIAL
242
243 . ${srcdir}/configure.host
244
245 AC_SUBST(HDEFINES)
246 AC_SUBST(NATIVE_LIB_DIRS)
247
248 AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h limits.h locale.h sys/param.h)
249 AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h)
250 ACX_HEADER_STRING
251 AC_CHECK_FUNCS(glob mkstemp realpath sbrk setlocale waitpid)
252 AC_CHECK_FUNCS(open lseek close)
253 AC_HEADER_DIRENT
254
255 dnl AC_CHECK_HEADERS(sys/mman.h)
256 AC_FUNC_MMAP
257
258 AC_SEARCH_LIBS([dlopen], [dl])
259 AM_CONDITIONAL([ENABLE_PLUGINS], [test x$plugins = xyes])
260
261 AC_ARG_ENABLE(initfini-array,
262 [  --disable-initfini-array do not use .init_array/.fini_array sections],
263 [case "${enableval}" in
264  yes|no) ;;
265  *) AC_MSG_ERROR([invalid --enable-initfini-array argument]) ;;
266  esac], [enable_initfini_array=yes])
267 AC_SUBST(enable_initfini_array)
268 if test $enable_initfini_array = yes; then
269   AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
270     [Define .init_array/.fini_array sections are available and working.])
271 fi
272
273 AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
274 AC_CACHE_VAL(ld_cv_decl_getopt_unistd_h,
275 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
276 ld_cv_decl_getopt_unistd_h=yes, ld_cv_decl_getopt_unistd_h=no)])
277 AC_MSG_RESULT($ld_cv_decl_getopt_unistd_h)
278 if test $ld_cv_decl_getopt_unistd_h = yes; then
279   AC_DEFINE([HAVE_DECL_GETOPT], 1,
280             [Is the prototype for getopt in <unistd.h> in the expected format?])
281 fi
282
283 BFD_BINARY_FOPEN
284
285 AC_CHECK_DECLS([strstr, free, sbrk, getenv, environ])
286
287 # When converting linker scripts into strings for use in emulation
288 # files, use astring.sed if the compiler supports ANSI string
289 # concatenation, or ostring.sed otherwise.  This is to support the
290 # broken Microsoft MSVC compiler, which limits the length of string
291 # constants, while still supporting pre-ANSI compilers which do not
292 # support string concatenation.
293 AC_MSG_CHECKING([whether ANSI C string concatenation works])
294 AC_CACHE_VAL(ld_cv_string_concatenation,
295 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [char *a = "a" "a";])],
296   ld_cv_string_concatenation=yes,
297   ld_cv_string_concatenation=no)])
298 AC_MSG_RESULT($ld_cv_string_concatenation)
299 if test "$ld_cv_string_concatenation" = "yes"; then
300   STRINGIFY=astring.sed
301 else
302   STRINGIFY=ostring.sed
303 fi
304 AC_SUBST(STRINGIFY)
305
306 # target-specific stuff:
307
308 all_targets=
309 EMUL=
310 all_emuls=
311 all_emul_extras=
312 all_libpath=
313
314 dnl We need to get an arbitrary number of tdir definitions into
315 dnl Makefile.  We can't do it using AC_SUBST, because autoconf does
316 dnl not permit literal newlines in an AC_SUBST variables.  So we use a
317 dnl file.
318 rm -f tdirs
319
320 # If the host is 64-bit, then we enable 64-bit targets by default.
321 # This is consistent with what ../bfd/configure.ac does.
322 if test x${want64} = xfalse; then
323   AC_CHECK_SIZEOF(void *)
324   if test "x${ac_cv_sizeof_void_p}" = "x8"; then
325     want64=true
326   fi
327 fi
328
329 elf_list_options=FALSE
330 elf_shlib_list_options=FALSE
331 elf_plt_unwind_list_options=FALSE
332 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
333 do
334   if test "$targ_alias" = "all"; then
335     all_targets=true
336     elf_list_options=TRUE
337     elf_shlib_list_options=TRUE
338     elf_plt_unwind_list_options=TRUE
339   else
340     # Canonicalize the secondary target names.
341     result=`$ac_config_sub $targ_alias 2>/dev/null`
342     if test -n "$result"; then
343         targ=$result
344     else
345         targ=$targ_alias
346     fi
347
348     . ${srcdir}/configure.tgt
349
350     if test "$targ" = "$target"; then
351       EMUL=$targ_emul
352     fi
353
354     if test x${want64} = xfalse; then
355       . ${srcdir}/../bfd/config.bfd
356     fi
357
358     if test x${want64} = xtrue; then
359       targ_extra_emuls="$targ_extra_emuls $targ64_extra_emuls"
360       targ_extra_libpath="$targ_extra_libpath $targ64_extra_libpath"
361     fi
362
363     for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
364         case " $all_emuls " in
365         *" e${i}.o "*) ;;
366         *)
367           all_emuls="$all_emuls e${i}.o"
368           eval result=\$tdir_$i
369           test -z "$result" && result=$targ_alias
370           echo tdir_$i=$result >> tdirs
371           case "${i}" in
372           *elf*)
373             elf_list_options=TRUE
374             ;;
375           *)
376             if $GREP "TEMPLATE_NAME=elf32" ${srcdir}/emulparams/${i}.sh >/dev/null 2>/dev/null; then
377               elf_list_options=TRUE
378             fi
379             ;;
380           esac
381           if test "$elf_list_options" = "TRUE"; then
382             . ${srcdir}/emulparams/${i}.sh
383             if test x${GENERATE_SHLIB_SCRIPT} = xyes; then
384               elf_shlib_list_options=TRUE
385             fi
386             if test x${PLT_UNWIND} = xyes; then
387               elf_plt_unwind_list_options=TRUE
388             fi
389           fi
390           ;;
391         esac
392     done
393
394     for i in $targ_emul $targ_extra_libpath; do
395         case " $all_libpath " in
396         *" ${i} "*) ;;
397         *)
398           if test -z "$all_libpath"; then
399             all_libpath=${i}
400           else
401             all_libpath="$all_libpath ${i}"
402           fi
403           ;;
404         esac
405     done
406
407     for i in $targ_extra_ofiles; do
408         case " $all_emul_extras " in
409         *" ${i} "*) ;;
410         *)
411           all_emul_extras="$all_emul_extras ${i}"
412           ;;
413         esac
414     done
415
416   fi
417 done
418
419 if test x$ac_default_compressed_debug_sections = xyes ; then
420   AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.])
421 fi
422
423 if test "${ac_default_new_dtags}" = unset; then
424   ac_default_new_dtags=0
425 fi
426 AC_DEFINE_UNQUOTED(DEFAULT_NEW_DTAGS,
427   $ac_default_new_dtags,
428   [Define to 1 if you want to set DT_RUNPATH instead of DT_RPATH by default.])
429
430 if test "${ac_default_ld_z_relro}" = unset; then
431   ac_default_ld_z_relro=0
432 fi
433 AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_RELRO,
434   $ac_default_ld_z_relro,
435   [Define to 1 if you want to enable -z relro in ELF linker by default.])
436
437 AC_DEFINE_UNQUOTED([DEFAULT_EMIT_SYSV_HASH],
438   [$ac_default_emit_sysv_hash],
439   [Define to 1 if you want to emit sysv hash in the ELF linker by default.])
440
441 AC_DEFINE_UNQUOTED([DEFAULT_EMIT_GNU_HASH],
442   [$ac_default_emit_gnu_hash],
443   [Define to 1 if you want to emit gnu hash in the ELF linker by default.])
444
445 AC_SUBST(elf_list_options)
446 AC_SUBST(elf_shlib_list_options)
447 AC_SUBST(elf_plt_unwind_list_options)
448 AC_SUBST(EMUL)
449
450 TDIRS=tdirs
451 AC_SUBST_FILE(TDIRS)
452
453 if test x${all_targets} = xtrue; then
454   if test x${want64} = xtrue; then
455     EMULATION_OFILES='$(ALL_EMULATIONS) $(ALL_64_EMULATIONS)'
456     EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES) $(ALL_64_EMUL_EXTRA_OFILES)'
457   else
458     EMULATION_OFILES='$(ALL_EMULATIONS)'
459     EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES)'
460   fi
461 else
462   EMULATION_OFILES=$all_emuls
463   EMUL_EXTRA_OFILES=$all_emul_extras
464 fi
465 AC_SUBST(EMULATION_OFILES)
466 AC_SUBST(EMUL_EXTRA_OFILES)
467 AC_SUBST(LIB_PATH)
468
469 EMULATION_LIBPATH=$all_libpath
470 AC_SUBST(EMULATION_LIBPATH)
471
472 if test x${enable_static} = xno; then
473   TESTBFDLIB="-Wl,--rpath,../bfd/.libs ../bfd/.libs/libbfd.so"
474 else
475   TESTBFDLIB="../bfd/.libs/libbfd.a"
476 fi
477 AC_SUBST(TESTBFDLIB)
478
479 target_vendor=${target_vendor=$host_vendor}
480 case "$target_vendor" in
481   hp) EXTRA_SHLIB_EXTENSION=".sl" ;;
482   *)  EXTRA_SHLIB_EXTENSION= ;;
483 esac
484
485 case "$target_os" in
486   lynxos) EXTRA_SHLIB_EXTENSION=".a" ;;
487 esac
488
489 if test x${EXTRA_SHLIB_EXTENSION} != x ; then
490   AC_DEFINE_UNQUOTED(EXTRA_SHLIB_EXTENSION, "$EXTRA_SHLIB_EXTENSION",
491    [Additional extension a shared object might have.])
492 fi
493
494 dnl Required by html, pdf, install-pdf and install-html
495 AC_SUBST(datarootdir)
496 AC_SUBST(docdir)
497 AC_SUBST(htmldir)
498 AC_SUBST(pdfdir)
499
500 AC_CONFIG_FILES(Makefile po/Makefile.in:po/Make-in)
501 AC_OUTPUT