• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl Process this file with autoconf to produce a configure script
2dnl
3dnl   Copyright (C) 2012-2014 Free Software Foundation, Inc.
4dnl
5dnl This file is free software; you can redistribute it and/or modify
6dnl it under the terms of the GNU General Public License as published by
7dnl the Free Software Foundation; either version 3 of the License, or
8dnl (at your option) any later version.
9dnl
10dnl This program is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13dnl GNU General Public License for more details.
14dnl
15dnl You should have received a copy of the GNU General Public License
16dnl along with this program; see the file COPYING3.  If not see
17dnl <http://www.gnu.org/licenses/>.
18dnl
19
20AC_PREREQ(2.59)
21m4_include([../bfd/version.m4])
22AC_INIT([ld], BFD_VERSION)
23AC_CONFIG_SRCDIR(ldmain.c)
24
25AC_CANONICAL_TARGET
26AC_CANONICAL_BUILD
27AC_ISC_POSIX
28
29AM_INIT_AUTOMAKE
30AM_MAINTAINER_MODE
31
32AC_PROG_CC
33AC_PROG_CXX
34AC_GNU_SOURCE
35AC_USE_SYSTEM_EXTENSIONS
36AC_PROG_INSTALL
37
38LT_INIT
39ACX_LARGEFILE
40
41AC_ARG_WITH(lib-path, [  --with-lib-path=dir1:dir2...  set default LIB_PATH],LIB_PATH=$withval)
42AC_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 ;;
49esac])dnl
50AC_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) ;;
56esac],[want64=false])dnl
57
58AC_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])
93AC_SUBST(use_sysroot)
94AC_SUBST(TARGET_SYSTEM_ROOT)
95AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
96
97AC_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])
101if 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])
105fi
106
107dnl Use --enable-gold to decide if this linker should be the default.
108dnl "install_as_default" is set to false if gold is the default linker.
109dnl "installed_linker" is the installed BFD linker name.
110AC_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])
127AC_SUBST(install_as_default)
128AC_SUBST(installed_linker)
129
130AC_ARG_ENABLE([got],
131AS_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) ;;
136esac],
137[got_handling=target])
138
139case "${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) ;;
153esac
154
155AM_BINUTILS_WARNINGS
156
157AM_LC_MESSAGES
158
159AC_CONFIG_HEADERS([config.h:config.in])
160
161# PR 14072
162AH_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
170if test -z "$target" ; then
171    AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
172fi
173if test -z "$host" ; then
174    AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
175fi
176
177# host-specific stuff:
178
179ALL_LINGUAS="fr sv tr es da vi zh_CN zh_TW ga fi id bg it uk"
180ZW_GNU_GETTEXT_SISTER_DIR
181AM_PO_SUBDIRS
182
183AC_EXEEXT
184
185AC_PROG_YACC
186AM_PROG_LEX
187
188AM_MAINTAINER_MODE
189AM_CONDITIONAL(GENINSRC_NEVER, false)
190ACX_PROG_CMP_IGNORE_INITIAL
191
192. ${srcdir}/configure.host
193
194AC_SUBST(HDEFINES)
195AC_SUBST(HOSTING_CRT0)
196AC_SUBST(HOSTING_SCRT0)
197AC_SUBST(HOSTING_LIBS)
198AC_SUBST(HOSTING_SLIBS)
199AC_SUBST(NATIVE_LIB_DIRS)
200
201AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h limits.h locale.h sys/param.h)
202AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h)
203ACX_HEADER_STRING
204AC_CHECK_FUNCS(glob mkstemp realpath sbrk setlocale waitpid)
205AC_CHECK_FUNCS(open lseek close)
206AC_HEADER_DIRENT
207
208AC_SEARCH_LIBS([dlopen], [dl])
209AM_CONDITIONAL([ENABLE_PLUGINS], [test x$plugins = xyes])
210
211AC_ARG_ENABLE(initfini-array,
212	[  --enable-initfini-array	use .init_array/.fini_array sections],
213	[], [
214AC_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([
218static int x = -1;
219int main (void) { return x; }
220int foo (void) { x = 0; }
221int (*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])
229AC_SUBST(enable_initfini_array)
230if test $enable_initfini_array = yes; then
231  AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
232    [Define .init_array/.fini_array sections are available and working.])
233fi
234
235AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
236AC_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 *);])],
238ld_cv_decl_getopt_unistd_h=yes, ld_cv_decl_getopt_unistd_h=no)])
239AC_MSG_RESULT($ld_cv_decl_getopt_unistd_h)
240if 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?])
243fi
244
245BFD_BINARY_FOPEN
246
247AC_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.
251AM_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.
259AC_MSG_CHECKING([whether ANSI C string concatenation works])
260AC_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)])
264AC_MSG_RESULT($ld_cv_string_concatenation)
265if test "$ld_cv_string_concatenation" = "yes"; then
266  STRINGIFY=astring.sed
267else
268  STRINGIFY=ostring.sed
269fi
270AC_SUBST(STRINGIFY)
271
272# target-specific stuff:
273
274all_targets=
275EMUL=
276all_emuls=
277all_emul_extras=
278all_libpath=
279
280dnl We need to get an arbitrary number of tdir definitions into
281dnl Makefile.  We can't do it using AC_SUBST, because autoconf does
282dnl not permit literal newlines in an AC_SUBST variables.  So we use a
283dnl file.
284rm -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.
288if 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
293fi
294
295for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
296do
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
358done
359
360AC_SUBST(EMUL)
361
362TDIRS=tdirs
363AC_SUBST_FILE(TDIRS)
364
365if 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
373else
374  EMULATION_OFILES=$all_emuls
375  EMUL_EXTRA_OFILES=$all_emul_extras
376fi
377AC_SUBST(EMULATION_OFILES)
378AC_SUBST(EMUL_EXTRA_OFILES)
379AC_SUBST(LIB_PATH)
380
381EMULATION_LIBPATH=$all_libpath
382AC_SUBST(EMULATION_LIBPATH)
383
384if test x${enable_static} = xno; then
385  TESTBFDLIB="--rpath ../bfd/.libs ../bfd/.libs/libbfd.so"
386else
387  TESTBFDLIB="../bfd/.libs/libbfd.a"
388fi
389AC_SUBST(TESTBFDLIB)
390
391target_vendor=${target_vendor=$host_vendor}
392case "$target_vendor" in
393  hp) EXTRA_SHLIB_EXTENSION=".sl" ;;
394  *)  EXTRA_SHLIB_EXTENSION= ;;
395esac
396
397case "$target_os" in
398  lynxos) EXTRA_SHLIB_EXTENSION=".a" ;;
399esac
400
401if 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.])
404fi
405
406dnl Required by html, pdf, install-pdf and install-html
407AC_SUBST(datarootdir)
408AC_SUBST(docdir)
409AC_SUBST(htmldir)
410AC_SUBST(pdfdir)
411
412AC_CONFIG_FILES(Makefile po/Makefile.in:po/Make-in)
413AC_OUTPUT
414