Fix potential use-after-free bugs.
[deliverable/binutils-gdb.git] / ld / configure.in
CommitLineData
252b5132
RH
1dnl Process this file with autoconf to produce a configure script
2dnl
da594c4a
AM
3AC_PREREQ(2.59)
4AC_INIT
5AC_CONFIG_SRCDIR(ldmain.c)
252b5132 6
da594c4a 7AC_CANONICAL_TARGET
5d64ca4e 8AC_ISC_POSIX
252b5132 9
27b7e12d
AM
10changequote(,)dnl
11BFD_VERSION=`sed -n -e 's/^.._INIT_AUTOMAKE.*,[ ]*\([^ ]*\)[ ]*).*/\1/p' < ${srcdir}/../bfd/configure.in`
12changequote([,])dnl
13AM_INIT_AUTOMAKE(ld, ${BFD_VERSION})
64ac50ac 14AM_MAINTAINER_MODE
252b5132 15
8e523c23 16AC_ARG_WITH(lib-path, [ --with-lib-path=dir1:dir2... set default LIB_PATH],LIB_PATH=$withval)
252b5132
RH
17AC_ARG_ENABLE(targets,
18[ --enable-targets alternative target configurations],
19[case "${enableval}" in
da594c4a 20 yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all')
252b5132
RH
21 ;;
22 no) enable_targets= ;;
23 *) enable_targets=$enableval ;;
24esac])dnl
25AC_ARG_ENABLE(64-bit-bfd,
26[ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)],
27[case "${enableval}" in
28 yes) want64=true ;;
29 no) want64=false ;;
30 *) AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
31esac],[want64=false])dnl
32
9c8ebd6a
DJ
33AC_ARG_WITH(sysroot,
34[ --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
35[
36 case ${with_sysroot} in
715d1656 37 yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_alias}/sys-root' ;;
9c8ebd6a
DJ
38 *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
39 esac
40
41 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
42 use_sysroot=yes
43
fa1e8d8e
RS
44 if test "x$prefix" = xNONE; then
45 test_prefix=/usr/local
46 else
47 test_prefix=$prefix
48 fi
9c8ebd6a 49 if test "x$exec_prefix" = xNONE; then
fa1e8d8e 50 test_exec_prefix=$test_prefix
9c8ebd6a 51 else
fa1e8d8e 52 test_exec_prefix=$exec_prefix
9c8ebd6a
DJ
53 fi
54 case ${TARGET_SYSTEM_ROOT} in
715d1656 55 "${test_prefix}"|"${test_prefix}/"*|\
fa1e8d8e
RS
56 "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
57 '${prefix}'|'${prefix}/'*|\
715d1656 58 '${exec_prefix}'|'${exec_prefix}/'*)
9c8ebd6a
DJ
59 t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
60 TARGET_SYSTEM_ROOT_DEFINE="$t"
61 ;;
62 esac
63], [
64 use_sysroot=no
65 TARGET_SYSTEM_ROOT=
66 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
67])
68AC_SUBST(use_sysroot)
69AC_SUBST(TARGET_SYSTEM_ROOT)
70AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
71
4fda8867
NC
72dnl Use --enable-gold to decide if this linker should be the default.
73dnl "install_as_default" is set to false if gold is the default linker.
74dnl "installed_linker" is the installed BFD linker name.
75AC_ARG_ENABLE(gold,
76[[ --enable-gold[=ARG] build gold [ARG={both}[/{gold,ld}]]]],
77[case "${enableval}" in
78 yes|both/gold)
79 install_as_default=no
80 installed_linker=ld.bfd
81 ;;
82 both|both/ld)
83 install_as_default=yes
84 installed_linker=ld.bfd
85 ;;
86 *)
87 AC_MSG_ERROR([invalid --enable-gold argument])
88 ;;
89 esac],
90[install_as_default=ld
91 installed_linker=ld])
92AC_SUBST(install_as_default)
93AC_SUBST(installed_linker)
94
7fb9f789
NC
95AC_ARG_ENABLE([got],
96AS_HELP_STRING([--enable-got=<type>],
97 [GOT handling scheme (target, single, negative, multigot)]),
98[case "${enableval}" in
99 target | single | negative | multigot) got_handling=$enableval ;;
da594c4a 100 *) AC_MSG_ERROR(bad value ${enableval} for --enable-got option) ;;
7fb9f789
NC
101esac],
102[got_handling=target])
103
104case "${got_handling}" in
105 target)
106 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_TARGET_DEFAULT],
107 [Define to choose default GOT handling scheme]) ;;
108 single)
109 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_SINGLE],
110 [Define to choose default GOT handling scheme]) ;;
111 negative)
112 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_NEGATIVE],
113 [Define to choose default GOT handling scheme]) ;;
114 multigot)
115 AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_MULTIGOT],
116 [Define to choose default GOT handling scheme]) ;;
da594c4a 117 *) AC_MSG_ERROR(bad value ${got_handling} for --enable-got option) ;;
7fb9f789
NC
118esac
119
502bdb00 120AM_BINUTILS_WARNINGS
a2d91340 121
da594c4a 122AC_CONFIG_HEADERS([config.h:config.in])
252b5132
RH
123
124if test -z "$target" ; then
125 AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
126fi
127if test -z "$host" ; then
128 AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
129fi
130
131# host-specific stuff:
132
133AC_PROG_CC
67310ccd 134AC_GNU_SOURCE
7357c5b6 135AC_USE_SYSTEM_EXTENSIONS
da2f07f1 136ACX_LARGEFILE
252b5132
RH
137AC_PROG_INSTALL
138
da594c4a 139LT_INIT
ce2cded5 140
ef3f88be 141ALL_LINGUAS="fr sv tr es da vi zh_CN zh_TW ga fi id bg"
20e95c23
DJ
142ZW_GNU_GETTEXT_SISTER_DIR
143AM_PO_SUBDIRS
252b5132
RH
144
145AC_EXEEXT
146
147AC_PROG_YACC
148AM_PROG_LEX
149
150AM_MAINTAINER_MODE
d5fbea21 151AM_CONDITIONAL(GENINSRC_NEVER, false)
eccbf555 152ACX_PROG_CMP_IGNORE_INITIAL
252b5132
RH
153
154. ${srcdir}/configure.host
155
156AC_SUBST(HDEFINES)
157AC_SUBST(HOSTING_CRT0)
158AC_SUBST(HOSTING_LIBS)
159AC_SUBST(NATIVE_LIB_DIRS)
160
a3ffa599 161AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h limits.h sys/param.h)
5d3236ee 162AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h)
dc27aea4 163AC_CHECK_FUNCS(glob mkstemp realpath sbrk waitpid)
5d3236ee 164AC_CHECK_FUNCS(open lseek close)
252b5132
RH
165AC_HEADER_DIRENT
166
5d3236ee
DK
167# Check for dlopen support and enable plugins if possible.
168enable_plugins=yes
169AC_CHECK_HEADER([dlfcn.h],[],[enable_plugins=no],[AC_INCLUDES_DEFAULT])
170AC_SEARCH_LIBS([dlopen],[dl],[],[enable_plugins=no],[])
171AC_CHECK_FUNCS([dlopen dlsym dlclose],[],[enable_plugins=no])
172AM_CONDITIONAL([ENABLE_PLUGINS], [test x$enable_plugins = xyes])
173
34875e64
NC
174AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
175AC_CACHE_VAL(ld_cv_decl_getopt_unistd_h,
da594c4a 176[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
34875e64
NC
177ld_cv_decl_getopt_unistd_h=yes, ld_cv_decl_getopt_unistd_h=no)])
178AC_MSG_RESULT($ld_cv_decl_getopt_unistd_h)
179if test $ld_cv_decl_getopt_unistd_h = yes; then
180 AC_DEFINE([HAVE_DECL_GETOPT], 1,
181 [Is the prototype for getopt in <unistd.h> in the expected format?])
182fi
183
252b5132
RH
184BFD_BINARY_FOPEN
185
502bdb00 186AC_CHECK_DECLS([strstr, free, sbrk, getenv, environ])
252b5132 187
4474d12b
CS
188# Link in zlib if we can. This is needed only for the bootstrap tests
189# right now, since those tests use libbfd, which depends on zlib.
190AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)])
191
597e2591
ILT
192# When converting linker scripts into strings for use in emulation
193# files, use astring.sed if the compiler supports ANSI string
194# concatenation, or ostring.sed otherwise. This is to support the
195# broken Microsoft MSVC compiler, which limits the length of string
196# constants, while still supporting pre-ANSI compilers which do not
197# support string concatenation.
e4dabd0e 198AC_MSG_CHECKING([whether ANSI C string concatenation works])
597e2591 199AC_CACHE_VAL(ld_cv_string_concatenation,
da594c4a
AM
200[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [char *a = "a" "a";])],
201 ld_cv_string_concatenation=yes,
202 ld_cv_string_concatenation=no)])
e4dabd0e
AS
203AC_MSG_RESULT($ld_cv_string_concatenation)
204if test "$ld_cv_string_concatenation" = "yes"; then
597e2591
ILT
205 STRINGIFY=astring.sed
206else
207 STRINGIFY=ostring.sed
208fi
209AC_SUBST(STRINGIFY)
210
252b5132
RH
211# target-specific stuff:
212
213all_targets=
214EMUL=
215all_emuls=
216all_emul_extras=
ba2be581 217all_libpath=
252b5132
RH
218
219dnl We need to get an arbitrary number of tdir definitions into
220dnl Makefile. We can't do it using AC_SUBST, because autoconf does
221dnl not permit literal newlines in an AC_SUBST variables. So we use a
222dnl file.
223rm -f tdirs
224
225for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
226do
227 if test "$targ_alias" = "all"; then
228 all_targets=true
229 else
230 # Canonicalize the secondary target names.
42ecbf5e 231 result=`$ac_config_sub $targ_alias 2>/dev/null`
252b5132
RH
232 if test -n "$result"; then
233 targ=$result
234 else
235 targ=$targ_alias
236 fi
237
238 . ${srcdir}/configure.tgt
239
240 if test "$targ" = "$target"; then
241 EMUL=$targ_emul
242 fi
243
314e9a4e
L
244 if test x${want64} = xfalse; then
245 . ${srcdir}/../bfd/config.bfd
246 fi
247
534d3119
L
248 if test x${want64} = xtrue; then
249 targ_extra_emuls="$targ_extra_emuls $targ64_extra_emuls"
250 targ_extra_libpath="$targ_extra_libpath $targ64_extra_libpath"
251 fi
252
3336653a 253 for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
252b5132
RH
254 case " $all_emuls " in
255 *" e${i}.o "*) ;;
256 *)
257 all_emuls="$all_emuls e${i}.o"
258 eval result=\$tdir_$i
259 test -z "$result" && result=$targ_alias
260 echo tdir_$i=$result >> tdirs
261 ;;
262 esac
263 done
264
ba2be581 265 for i in $targ_emul $targ_extra_libpath; do
3336653a
RH
266 case " $all_libpath " in
267 *" ${i} "*) ;;
268 *)
ba2be581
RH
269 if test -z "$all_libpath"; then
270 all_libpath=${i}
271 else
272 all_libpath="$all_libpath ${i}"
273 fi
3336653a
RH
274 ;;
275 esac
276 done
277
252b5132
RH
278 for i in $targ_extra_ofiles; do
279 case " $all_emul_extras " in
280 *" ${i} "*) ;;
281 *)
282 all_emul_extras="$all_emul_extras ${i}"
283 ;;
284 esac
285 done
286 fi
287done
288
289AC_SUBST(EMUL)
290
291TDIRS=tdirs
292AC_SUBST_FILE(TDIRS)
293
252b5132 294if test x${all_targets} = xtrue; then
314e9a4e
L
295 if test x${want64} = xfalse; then
296 AC_CHECK_SIZEOF(long)
297 if test "x${ac_cv_sizeof_long}" = "x8"; then
298 want64=true
299 fi
300 fi
252b5132
RH
301 if test x${want64} = xtrue; then
302 EMULATION_OFILES='$(ALL_EMULATIONS) $(ALL_64_EMULATIONS)'
303 else
304 EMULATION_OFILES='$(ALL_EMULATIONS)'
305 fi
306 EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES)'
307else
308 EMULATION_OFILES=$all_emuls
309 EMUL_EXTRA_OFILES=$all_emul_extras
310fi
311AC_SUBST(EMULATION_OFILES)
312AC_SUBST(EMUL_EXTRA_OFILES)
8e523c23 313AC_SUBST(LIB_PATH)
252b5132 314
3336653a
RH
315EMULATION_LIBPATH=$all_libpath
316AC_SUBST(EMULATION_LIBPATH)
317
252b5132
RH
318if test x${enable_static} = xno; then
319 TESTBFDLIB="--rpath ../bfd/.libs ../bfd/.libs/libbfd.so"
320else
321 TESTBFDLIB="../bfd/.libs/libbfd.a"
322fi
323AC_SUBST(TESTBFDLIB)
324
93a6d436
JL
325target_vendor=${target_vendor=$host_vendor}
326case "$target_vendor" in
327 hp) EXTRA_SHLIB_EXTENSION=".sl" ;;
328 *) EXTRA_SHLIB_EXTENSION= ;;
329esac
f234d5fe
NC
330
331case "$target_os" in
332 lynxos) EXTRA_SHLIB_EXTENSION=".a" ;;
333esac
334
93a6d436
JL
335if test x${EXTRA_SHLIB_EXTENSION} != x ; then
336 AC_DEFINE_UNQUOTED(EXTRA_SHLIB_EXTENSION, "$EXTRA_SHLIB_EXTENSION",
337 [Additional extension a shared object might have.])
338fi
339
31dd3154 340dnl Required by html, pdf, install-pdf and install-html
108a6f8e
CD
341AC_SUBST(datarootdir)
342AC_SUBST(docdir)
343AC_SUBST(htmldir)
31dd3154 344AC_SUBST(pdfdir)
108a6f8e 345
da594c4a
AM
346AC_CONFIG_FILES(Makefile po/Makefile.in:po/Make-in)
347AC_OUTPUT
This page took 0.506652 seconds and 4 git commands to generate.