1dnl $MirOS: src/gnu/usr.bin/binutils/ld/configure.in,v 1.6 2005/07/07 16:23:12 tg Exp $
2
3dnl Process this file with autoconf to produce a configure script
4dnl
5AC_PREREQ(2.57)
6AC_INIT(ldmain.c)
7
8AC_CANONICAL_SYSTEM
9AC_ISC_POSIX
10
11changequote(,)dnl
12BFD_VERSION=`sed -n -e 's/^.._INIT_AUTOMAKE.*,[ 	]*\([^ 	]*\)[ 	]*).*/\1/p' < ${srcdir}/../bfd/configure.in`
13changequote([,])dnl
14AM_INIT_AUTOMAKE(ld, ${BFD_VERSION})
15
16AM_PROG_LIBTOOL
17
18AC_ARG_WITH(lib-path, [  --with-lib-path=dir1:dir2...  set default LIB_PATH],LIB_PATH=$withval)
19AC_ARG_ENABLE(targets,
20[  --enable-targets        alternative target configurations],
21[case "${enableval}" in
22  yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
23            ;;
24  no)       enable_targets= ;;
25  *)        enable_targets=$enableval ;;
26esac])dnl
27AC_ARG_ENABLE(64-bit-bfd,
28[  --enable-64-bit-bfd     64-bit support (on hosts with narrower word sizes)],
29[case "${enableval}" in
30  yes)  want64=true  ;;
31  no)   want64=false ;;
32  *)    AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
33esac],[want64=false])dnl
34
35AC_ARG_WITH(sysroot,
36[  --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
37[
38 case ${with_sysroot} in
39 yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_alias}/sys-root' ;;
40 *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
41 esac
42
43 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
44 use_sysroot=yes
45
46 if test "x$exec_prefix" = xNONE; then
47  if test "x$prefix" = xNONE; then
48   test_prefix=/usr/local
49  else
50   test_prefix=$prefix
51  fi
52 else
53  test_prefix=$exec_prefix
54 fi
55 case ${TARGET_SYSTEM_ROOT} in
56 "${test_prefix}"|"${test_prefix}/"*|\
57 '${exec_prefix}'|'${exec_prefix}/'*)
58   t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
59   TARGET_SYSTEM_ROOT_DEFINE="$t"
60   ;;
61 esac
62], [
63 use_sysroot=no
64 TARGET_SYSTEM_ROOT=
65 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
66])
67AC_SUBST(use_sysroot)
68AC_SUBST(TARGET_SYSTEM_ROOT)
69AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
70
71AM_BINUTILS_WARNINGS
72
73AM_CONFIG_HEADER(config.h:config.in)
74
75if test -z "$target" ; then
76    AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
77fi
78if test -z "$host" ; then
79    AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
80fi
81
82# host-specific stuff:
83
84AC_PROG_CC
85AC_PROG_INSTALL
86
87AC_EXEEXT
88
89AC_PROG_YACC
90AM_PROG_LEX
91
92AM_MAINTAINER_MODE
93
94. ${srcdir}/configure.host
95
96AC_SUBST(HDEFINES)
97AC_SUBST(HOSTING_CRT0)
98AC_SUBST(HOSTING_LIBS)
99AC_SUBST(NATIVE_LIB_DIRS)
100
101AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h stdbool.h)
102AC_CHECK_FUNCS(sbrk realpath glob)
103AC_HEADER_DIRENT
104
105AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
106AC_CACHE_VAL(ld_cv_decl_getopt_unistd_h,
107[AC_TRY_COMPILE([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);],
108ld_cv_decl_getopt_unistd_h=yes, ld_cv_decl_getopt_unistd_h=no)])
109AC_MSG_RESULT($ld_cv_decl_getopt_unistd_h)
110if test $ld_cv_decl_getopt_unistd_h = yes; then
111  AC_DEFINE([HAVE_DECL_GETOPT], 1,
112	    [Is the prototype for getopt in <unistd.h> in the expected format?])
113fi
114
115BFD_BINARY_FOPEN
116
117AC_CHECK_DECLS([strstr, free, sbrk, getenv, environ])
118
119# These look needed for ../bfd/sysdep.h
120AC_CHECK_DECLS([malloc, realloc])
121
122# When converting linker scripts into strings for use in emulation
123# files, use astring.sed if the compiler supports ANSI string
124# concatenation, or ostring.sed otherwise.  This is to support the
125# broken Microsoft MSVC compiler, which limits the length of string
126# constants, while still supporting pre-ANSI compilers which do not
127# support string concatenation.
128AC_MSG_CHECKING([whether ANSI C string concatenation works])
129AC_CACHE_VAL(ld_cv_string_concatenation,
130[AC_TRY_COMPILE(,[char *a = "a" "a";],
131  [ld_cv_string_concatenation=yes],
132  [ld_cv_string_concatenation=no])])
133AC_MSG_RESULT($ld_cv_string_concatenation)
134if test "$ld_cv_string_concatenation" = "yes"; then
135  STRINGIFY=astring.sed
136else
137  STRINGIFY=ostring.sed
138fi
139AC_SUBST(STRINGIFY)
140
141# target-specific stuff:
142
143all_targets=
144EMUL=
145all_emuls=
146all_emul_extras=
147all_libpath=
148
149dnl We need to get an arbitrary number of tdir definitions into
150dnl Makefile.  We can't do it using AC_SUBST, because autoconf does
151dnl not permit literal newlines in an AC_SUBST variables.  So we use a
152dnl file.
153rm -f tdirs
154
155for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
156do
157  if test "$targ_alias" = "all"; then
158    all_targets=true
159  else
160    # Canonicalize the secondary target names.
161    result=`$ac_config_sub $targ_alias 2>/dev/null`
162    if test -n "$result"; then
163	targ=$result
164    else
165	targ=$targ_alias
166    fi
167
168    . ${srcdir}/configure.tgt
169
170    if test "$targ" = "$target"; then
171      EMUL=$targ_emul
172    fi
173
174    for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
175	case " $all_emuls " in
176	*" e${i}.o "*) ;;
177	*)
178	  all_emuls="$all_emuls e${i}.o"
179	  eval result=\$tdir_$i
180	  test -z "$result" && result=$targ_alias
181	  echo tdir_$i=$result >> tdirs
182	  ;;
183	esac
184    done
185
186    for i in $targ_emul $targ_extra_libpath; do
187	case " $all_libpath " in
188	*" ${i} "*) ;;
189	*)
190	  if test -z "$all_libpath"; then
191	    all_libpath=${i}
192	  else
193	    all_libpath="$all_libpath ${i}"
194	  fi
195	  ;;
196	esac
197    done
198
199    for i in $targ_extra_ofiles; do
200	case " $all_emul_extras " in
201	*" ${i} "*) ;;
202	*)
203	  all_emul_extras="$all_emul_extras ${i}"
204	  ;;
205	esac
206    done
207  fi
208done
209
210AC_SUBST(EMUL)
211
212TDIRS=tdirs
213AC_SUBST_FILE(TDIRS)
214
215dnl FIXME: We will build a 64 bit BFD for a 64 bit host or a 64 bit
216dnl target, and in those cases we should also build the 64 bit
217dnl emulations.
218if test x${all_targets} = xtrue; then
219  if test x${want64} = xtrue; then
220    EMULATION_OFILES='$(ALL_EMULATIONS) $(ALL_64_EMULATIONS)'
221  else
222    EMULATION_OFILES='$(ALL_EMULATIONS)'
223  fi
224  EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES)'
225else
226  EMULATION_OFILES=$all_emuls
227  EMUL_EXTRA_OFILES=$all_emul_extras
228fi
229AC_SUBST(EMULATION_OFILES)
230AC_SUBST(EMUL_EXTRA_OFILES)
231AC_SUBST(LIB_PATH)
232
233EMULATION_LIBPATH=$all_libpath
234AC_SUBST(EMULATION_LIBPATH)
235
236if test x${enable_static} = xno; then
237  TESTBFDLIB="--rpath ../bfd/.libs ../bfd/.libs/libbfd.so"
238else
239  TESTBFDLIB="../bfd/.libs/libbfd.a"
240fi
241AC_SUBST(TESTBFDLIB)
242
243target_vendor=${target_vendor=$host_vendor}
244case "$target_vendor" in
245  hp) EXTRA_SHLIB_EXTENSION=".sl" ;;
246  *)  EXTRA_SHLIB_EXTENSION= ;;
247esac
248
249case "$target_os" in
250  lynxos) EXTRA_SHLIB_EXTENSION=".a" ;;
251esac
252
253if test x${EXTRA_SHLIB_EXTENSION} != x ; then
254  AC_DEFINE_UNQUOTED(EXTRA_SHLIB_EXTENSION, "$EXTRA_SHLIB_EXTENSION",
255   [Additional extension a shared object might have.])
256fi
257
258AC_OUTPUT(Makefile)
259