e979c6a16354c8a1d7e4c6f151d389b469a22619
[external/binutils.git] / ld / configure.in
1 dnl Process this file with autoconf to produce a configure script
2 dnl
3 AC_PREREG(2.0)
4 AC_INIT(ldmain.c)
5
6 AC_ARG_ENABLE(targets,
7 [  --enable-targets        alternative target configurations],
8 [case "${enableval}" in
9   yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
10             ;;
11   no)       enable_targets= ;;
12   *)        enable_targets=$enableval ;;
13 esac])dnl
14 AC_ARG_ENABLE(shared,
15 [  --enable-shared         build shared BFD library],
16 [case "${enableval}" in
17   yes) shared=true ;;
18   no)  shared=false ;;
19   *)   AC_MSG_ERROR([bad value ${enableval} for BFD shared option]) ;;
20 esac])dnl
21
22 AC_CONFIG_HEADER(config.h:config.in)
23
24 AC_CONFIG_AUX_DIR(`cd $srcdir/..; pwd`)
25 AC_CANONICAL_SYSTEM
26 if test -z "$target" ; then
27     AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
28 fi
29 if test -z "$host" ; then
30     AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
31 fi
32 AC_ARG_PROGRAM
33
34 # host-specific stuff:
35
36 . ${srcdir}/configure.host
37
38 AC_PROG_CC
39 AC_SUBST(CFLAGS)
40 AC_SUBST(HLDFLAGS)
41 AC_SUBST(HDEFINES)
42 AC_SUBST(HOSTING_CRT0)
43 AC_SUBST(HOSTING_LIBS)
44 AC_SUBST(NATIVE_LIB_DIRS)
45
46 # For most hosts we can use a simple definition to pick up the BFD and
47 # opcodes libraries.  However, if we are building shared libraries, we
48 # need to handle some hosts specially.
49 BFDLIB='-L../bfd -lbfd'
50 if test "${shared}" = "true"; then
51   case "${host}" in
52   *-*-sunos*)
53     # On SunOS, we must link against the name we are going to install,
54     # not -lbfd, since SunOS does not support SONAME.
55     BFDLIB='-L../bfd -l`echo bfd | sed '"'"'$(program_transform_name)'"'"'`'
56     ;;
57   esac
58 fi
59 AC_SUBST(BFDLIB)
60
61 AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h)
62 AC_CHECK_FUNCS(sbrk)
63 AC_HEADER_DIRENT
64
65 BFD_BINARY_FOPEN
66
67 BFD_NEED_DECLARATION(free)
68
69 # target-specific stuff:
70
71 all_targets=
72 EMUL=
73 all_emuls=
74 TDIRS=
75
76 for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
77 do
78   if test "$targ_alias" = "all"; then
79     all_targets=true
80   else
81     # Canonicalize the secondary target names.
82     result=`$ac_config_sub $targ_alias 2>/dev/null`
83     if test -n "$result"; then
84         targ=$result
85     else
86         targ=$targ_alias
87     fi
88
89     . ${srcdir}/configure.tgt
90
91     if test "$targ" = "$target"; then
92       EMUL=$targ_emul
93     fi
94
95     for i in $targ_emul $targ_extra_emuls; do
96         case " $all_emuls " in
97         *" e${i}.o "*) ;;
98         *)
99           all_emuls="$all_emuls e${i}.o"
100           eval result=\$tdir_$i
101           test -z "$result" && result=$targ_alias
102           TDIRS="$TDIRS\\
103 tdir_$i=$result"
104           ;;
105         esac
106     done
107   fi
108 done
109
110 AC_SUBST(EMUL)
111 AC_SUBST(TDIRS)
112
113 if test x${all_targets} = xtrue; then
114   EMULATION_OFILES='$(ALL_EMULATIONS)'
115 else
116   EMULATION_OFILES=$all_emuls
117 fi
118 AC_SUBST(EMULATION_OFILES)
119
120 AC_OUTPUT(Makefile,
121 [case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac])