configure.in revision 80018
1dnl Process this file with autoconf to produce a configure script.
2dnl
3dnl And be careful when changing it!  If you must add tests with square
4dnl brackets, be sure changequote invocations surround it.
5dnl
6dnl $FreeBSD: head/contrib/binutils/gas/configure.in 80018 2001-07-20 03:48:47Z obrien $
7dnl
8dnl v2.5 needed for --bindir et al
9AC_PREREQ(2.13)
10AC_INIT(as.h)
11
12AC_CANONICAL_SYSTEM
13AC_ISC_POSIX
14
15changequote(,)dnl
16BFD_VERSION=`sed -n -e 's/^.._INIT_AUTOMAKE.*,[ 	]*\([^ 	]*\)[ 	]*).*/\1/p' < ${srcdir}/../bfd/configure.in`
17changequote([,])dnl
18AM_INIT_AUTOMAKE(gas, ${BFD_VERSION})
19
20AM_PROG_LIBTOOL
21
22user_bfd_gas=
23AC_ARG_ENABLE(bfd-assembler,
24[  --enable-bfd-assembler  use BFD back end for writing object files],
25[case "${enableval}" in
26  yes) need_bfd=yes user_bfd_gas=yes ;;
27  no)  user_bfd_gas=no ;;
28  *)   AC_MSG_ERROR(bad value ${enableval} given for bfd-assembler option) ;;
29esac])dnl
30AC_ARG_ENABLE(targets,
31[    targets            alternative target configurations besides the primary],
32[case "${enableval}" in
33  yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
34	    ;;
35  no)	    enable_targets= ;;
36  *)	    enable_targets=$enableval ;;
37esac])dnl
38AC_ARG_ENABLE(commonbfdlib,
39[  --enable-commonbfdlib   build shared BFD/opcodes/libiberty library],
40[case "${enableval}" in
41  yes) commonbfdlib=true ;;
42  no)  commonbfdlib=false ;;
43  *)   AC_MSG_ERROR([bad value ${enableval} for BFD commonbfdlib option]) ;;
44esac])dnl
45
46using_cgen=no
47
48build_warnings="-W -Wall"
49AC_ARG_ENABLE(build-warnings,
50[  --enable-build-warnings Enable build-time compiler warnings if gcc is used],
51[case "${enableval}" in
52  yes)	;;
53  no)	build_warnings="-w";;
54  ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
55        build_warnings="${build_warnings} ${t}";;
56  *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
57        build_warnings="${t} ${build_warnings}";;
58  *)    build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
59esac
60if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
61  echo "Setting warning flags = $build_warnings" 6>&1
62fi])dnl
63WARN_CFLAGS=""
64if test "x${build_warnings}" != x -a "x$GCC" = xyes ; then
65    WARN_CFLAGS="${build_warnings}"
66fi
67AC_SUBST(WARN_CFLAGS)
68
69# Generate a header file
70AM_CONFIG_HEADER(config.h:config.in)
71
72# If we are on a DOS filesystem, we must use gdb.ini rather than
73# .gdbinit.
74GDBINIT=".gdbinit"
75case "${host}" in
76  *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
77    GDBINIT="gdb.ini"
78    ;;
79esac
80AC_SUBST(GDBINIT)
81
82te_file=generic
83
84# Makefile target for installing gas in $(tooldir)/bin.
85install_tooldir=install-exec-tooldir
86
87canon_targets=""
88all_targets=no
89if test -n "$enable_targets" ; then
90  for t in `echo $enable_targets | sed 's/,/ /g'`; do
91    if test $t = "all"; then
92      all_targets=yes
93      continue
94    fi
95    result=`$ac_config_sub $t 2>/dev/null`
96    if test -n "$result" ; then
97      canon_targets="$canon_targets $result"
98#    else
99#      # Permit "all", etc.  We don't support it yet though.
100#      canon_targets="$canon_targets $t"
101    fi
102  done
103  GAS_UNIQ(canon_targets)
104fi
105
106emulations=""
107
108for this_target in $target $canon_targets ; do
109
110changequote(,)dnl
111    eval `echo $this_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/'`
112changequote([,])dnl
113
114    # check for architecture variants
115    arch=
116    endian=
117    case ${cpu} in
118      alpha*)		cpu_type=alpha ;;
119      armeb)		cpu_type=arm endian=big ;;
120      arm*)		cpu_type=arm endian=little ;;
121      armb*)		cpu_type=arm endian=little ;;
122      armv*l)		cpu_type=arm endian=little ;;
123      armv*b)		cpu_type=arm endian=big ;;
124      xscale*)		cpu_type=arm endian=little ;;
125      strongarm*)	cpu_type=arm endian=little ;;
126      thumb*)		cpu_type=arm endian=little ;;
127      hppa*)		cpu_type=hppa ;;
128changequote(,)dnl
129      i[3456]86)	cpu_type=i386 arch=i386;;
130      x86_64)		cpu_type=i386 arch=x86_64;;
131      ia64)		cpu_type=ia64 ;;
132      m6811|m6812|m68hc12) cpu_type=m68hc11 ;;
133      m680[012346]0)	cpu_type=m68k ;;
134changequote([,])dnl
135      m68008)		cpu_type=m68k ;;
136      m683??)		cpu_type=m68k ;;
137      m5200)		cpu_type=m68k ;;
138      m8*)		cpu_type=m88k ;;
139      mips*el)		cpu_type=mips endian=little ;;
140      mips*)		cpu_type=mips endian=big ;;
141      pjl*)		cpu_type=pj endian=little ;;
142      pj*)		cpu_type=pj endian=big ;;
143      powerpcle*)	cpu_type=ppc endian=little ;;
144      powerpc*)		cpu_type=ppc endian=big ;;
145      rs6000*)		cpu_type=ppc ;;
146      sparclite*)	cpu_type=sparc arch=sparclite ;;
147      sparclet*)	cpu_type=sparc arch=sparclet ;;
148      sparc64*)		cpu_type=sparc arch=v9-64 ;;
149      sparc86x*)	cpu_type=sparc arch=sparc86x  ;;
150      sparc*)		cpu_type=sparc arch=sparclite ;; # ??? See tc-sparc.c.
151      v850*)		cpu_type=v850 ;;
152      *)		cpu_type=${cpu} ;;
153    esac
154
155    if test ${this_target} = $target ; then
156      target_cpu_type=${cpu_type}
157    elif test ${target_cpu_type} != ${cpu_type} ; then
158      continue
159    fi
160
161    generic_target=${cpu_type}-$vendor-$os
162    dev=no
163    bfd_gas=no
164    em=generic
165
166    # assign object format
167    case ${generic_target} in
168      a29k-*-coff)          fmt=coff ;;
169      a29k-amd-udi)         fmt=coff ;;
170      a29k-amd-ebmon)       fmt=coff ;;
171      a29k-nyu-sym1)        fmt=coff ;;
172      a29k-*-rtems*)        fmt=coff ;;
173      a29k-*-vxworks*)      fmt=coff ;;
174
175      alpha*-*-*vms*)	    fmt=evax ;;
176      alpha*-*-netware*)    fmt=ecoff ;;
177      alpha*-*-openbsd*)    fmt=ecoff ;;
178      alpha*-*-osf*)        fmt=ecoff ;;
179      alpha*-*-linuxecoff*) fmt=ecoff ;;
180      alpha*-*-linux-gnu*)  fmt=elf em=linux ;;
181      alpha*-*-netbsd*)     fmt=elf em=nbsd ;;
182
183      arc-*-elf*)           fmt=elf bfd_gas=yes ;;
184
185      arm-*-aout)	                fmt=aout ;;
186      arm-*-coff | thumb-*-coff)        fmt=coff ;;
187      arm-*-rtems | thumb-*-rtems)      fmt=elf ;;
188      arm-*-elf | thumb-*-elf)          fmt=elf ;;
189      arm*-*-conix*)			fmt=elf ;;
190      arm-*-linux*aout*)	        fmt=aout em=linux ;;
191      arm*-*-linux-gnu* | arm*-*-uclinux*)	
192					fmt=elf  em=linux ;;
193      arm-*-netbsd*)	                fmt=aout em=nbsd ;;
194      arm-*-oabi | thumb-*-oabi)        fmt=elf ;;
195      arm-epoc-pe | thumb-epoc-pe)      fmt=coff em=epoc-pe ;;
196      arm-*-wince)			fmt=coff em=wince-pe ;;
197      arm-*-pe | thumb-*-pe)            fmt=coff em=pe ;;
198      arm-*-riscix*)	                fmt=aout em=riscix ;;
199      arm-*-vxworks)	                fmt=coff ;;
200
201      avr-*-*)		    fmt=elf bfd_gas=yes ;;
202
203      cris-*-*)		    fmt=multi bfd_gas=yes ;;
204
205      d10v-*-*)		    fmt=elf bfd_gas=yes ;;
206      d30v-*-*)		    fmt=elf bfd_gas=yes ;;
207
208
209      fr30-*-*)		    fmt=elf bfd_gas=yes ;;
210
211      hppa-*-linux-gnu*)    case ${cpu} in
212				hppa*64*)
213					fmt=elf em=hppalinux64;;
214				hppa*)
215					fmt=elf em=linux;;
216			    esac ;;
217      hppa-*-*elf*)         fmt=elf em=hppa ;;
218      hppa-*-lites*)        fmt=elf em=hppa ;;
219      hppa-*-osf*)          fmt=som em=hppa ;;
220      hppa-*-rtems*)        fmt=elf em=hppa ;;
221      hppa-*-hpux11*)	    case ${cpu} in
222				hppa*64*)
223					fmt=elf em=hppa64 ;;
224				hppa*)
225					fmt=som em=hppa ;;
226			    esac ;;
227      hppa-*-hpux*)         fmt=som em=hppa ;;
228      hppa-*-mpeix*)        fmt=som em=hppa ;;
229      hppa-*-bsd*)          fmt=som em=hppa ;;
230      hppa-*-hiux*)         fmt=som em=hppa ;;
231
232      h8300-*-rtems*)       fmt=coff ;;
233      h8300-*-coff)         fmt=coff ;;
234      h8500-*-rtems*)       fmt=coff ;;
235      h8500-*-coff)         fmt=coff ;;
236
237      i370-*-elf* | i370-*-linux*) fmt=elf ;;
238      i386-ibm-aix*)        fmt=coff em=i386aix ;;
239      i386-sequent-bsd*)    fmt=aout em=dynix bfd_gas=yes ;;
240      i386-*-beospe*)       fmt=coff em=pe bfd_gas=yes ;;
241      i386-*-beoself* | i386-*-beos*) fmt=elf bfd_gas=yes ;;
242      i386-*-bsd*)          fmt=aout em=386bsd ;;
243      i386-*-netbsd0.8)     fmt=aout em=386bsd ;;
244      i386-*-netbsdelf*)    fmt=elf em=nbsd bfd_gas=yes;;
245      i386-*-netbsd*)       fmt=aout em=nbsd bfd_gas=yes;;
246      i386-*-openbsd*)      fmt=aout em=nbsd bfd_gas=yes;;
247      i386-*-linux*aout* | i386-*-linux*oldld)   fmt=aout em=linux ;;
248      i386-*-linux*coff*)   fmt=coff em=linux ;;
249      i386-*-linux-gnu*)    fmt=elf em=linux bfd_gas=yes ;;
250      x86_64-*-linux-gnu*)  fmt=elf em=linux bfd_gas=yes ;;
251      i386-*-lynxos*)       fmt=coff em=lynx ;;
252changequote(,)dnl
253      i386-*-sysv[45]* | i386-*-solaris* | i386-*-elf)
254			    fmt=elf bfd_gas=yes ;;
255      i386-*-freebsdaout* | i386-*-freebsd[12].* | i386-*-freebsd[12])
256                            fmt=aout em=386bsd ;;
257changequote([,])dnl
258      i386-*-coff | i386-*-sysv* | i386-*-sco3.2v5*coff | i386-*-isc*)
259                          fmt=coff ;;
260      i386-*-sco3.2v5*)      fmt=elf
261			    if test ${this_target} = $target; then
262				AC_DEFINE(SCO_ELF, 1,
263				    [Define if defaulting to ELF on SCO 5.])
264			    fi
265			    ;;
266      i386-*-sco3.2*)       fmt=coff ;;
267      i386-*-vsta)          fmt=aout ;;
268      i386-*-msdosdjgpp* | i386-*-go32* | i386-go32-rtems*)
269			    fmt=coff em=go32 bfd_gas=yes
270			    AC_DEFINE(STRICTCOFF, 1, [Using strict COFF?])
271			    ;;
272      i386-*-rtemself*)     fmt=elf ;;
273      i386-*-rtems*)        fmt=coff ;;
274      i386-*-gnu*)          fmt=elf ;;
275      i386-*-mach*)
276			    fmt=aout em=mach bfd_gas=yes ;;
277      i386-*-msdos*)        fmt=aout ;;
278      i386-*-moss*)	    fmt=elf ;;
279      i386-*-pe)            fmt=coff em=pe bfd_gas=yes ;;
280      i386-*-cygwin*)       fmt=coff em=pe bfd_gas=yes ;;
281      i386-*-interix*)	    fmt=coff em=interix bfd_gas=yes ;;
282      i386-*-mingw32*)      fmt=coff em=pe bfd_gas=yes ;;
283      i386-*-*nt*)          fmt=coff em=pe bfd_gas=yes ;;
284      i386-*-vxworks*)      fmt=aout ;;
285      i386-*-chaos)         fmt=elf ;;
286      i860-stardent-sysv4* | i860-stardent-elf*)
287			    fmt=elf bfd_gas=yes endian=little
288			    AC_MSG_WARN(GAS support for ${generic_target} is preliminary and a work in progress) ;;
289      i960-*-bout)          fmt=bout ;;
290      i960-*-coff)          fmt=coff em=ic960 ;;
291      i960-*-rtems*)        fmt=coff em=ic960 ;;
292      i960-*-nindy*)        fmt=bout ;;
293      i960-*-vxworks4*)     fmt=bout ;;
294      i960-*-vxworks5.0)    fmt=bout ;;
295      i960-*-vxworks5.*)    fmt=coff em=ic960 ;;
296      i960-*-vxworks*)      fmt=bout ;;
297      i960-*-elf*)	    fmt=elf ;;
298
299      ia64-*-elf*)	    fmt=elf ;;
300      ia64-*-linux-gnu*)    fmt=elf em=linux ;;
301      ia64-*-hpux*)	    fmt=elf em=hpux ;;
302
303      m32r-*-*)		    fmt=elf bfd_gas=yes ;;
304
305      m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)fmt=elf bfd_gas=yes ;;
306
307      m68k-*-vxworks* | m68k-ericsson-ose | m68k-*-sunos*)
308			    fmt=aout em=sun3 ;;
309      m68k-motorola-sysv*)  fmt=coff em=delta ;;
310      m68k-bull-sysv3*)     fmt=coff em=dpx2 ;;
311      m68k-apollo-*)        fmt=coff em=apollo ;;
312      m68k-*-sysv4*) # must be before -sysv*
313			    fmt=elf em=svr4 ;;
314      m68k-*-elf*)	    fmt=elf ;;
315      m68k-*-coff | m68k-*-sysv* | m68k-*-rtems*)
316			    fmt=coff ;;
317      m68k-*-hpux*)         fmt=hp300 em=hp300 ;;
318      m68k-*-linux*aout*)   fmt=aout em=linux ;;
319      m68k-*-linux-gnu*)    fmt=elf em=linux ;;
320      m68k-*-gnu*)	    fmt=elf ;;
321      m68k-*-lynxos*)       fmt=coff em=lynx ;;
322      m68k-*-netbsd*)       fmt=aout em=nbsd bfd_gas=yes ;;
323      m68k-*-openbsd*)      fmt=aout em=nbsd bfd_gas=yes ;;
324      m68k-apple-aux*)      fmt=coff em=aux ;;
325      m68k-*-psos*)         fmt=elf em=psos;;
326
327      m88k-motorola-sysv3*) fmt=coff em=delt88 ;;
328      m88k-*-coff*)         fmt=coff ;;
329
330      mcore-*-elf)	    fmt=elf bfd_gas=yes ;;
331      mcore-*-pe)	    fmt=coff em=pe bfd_gas=yes ;;
332
333      # don't change em like *-*-bsd does
334      mips-dec-netbsd*)	    fmt=elf endian=little ;;
335      mips-dec-openbsd*)    fmt=elf endian=little ;;
336      mips-dec-bsd*)        fmt=aout endian=little ;;
337      mips-sony-bsd*)       fmt=ecoff ;;
338      mips-*-bsd*)          AC_MSG_ERROR(Unknown vendor for mips-bsd configuration.) ;;
339      mips-*-ultrix*)       fmt=ecoff endian=little ;;
340      mips-*-osf*)          fmt=ecoff endian=little ;;
341      mips-*-ecoff*)        fmt=ecoff ;;
342      mips-*-pe*)           fmt=coff endian=little em=pe ;;
343      mips-*-irix6*)	    fmt=elf ;;
344      mips-*-irix5*)        fmt=elf ;;
345      mips-*-irix*)         fmt=ecoff ;;
346      mips-*-lnews*)        fmt=ecoff em=lnews ;;
347      mips-*-riscos*)       fmt=ecoff ;;
348      mips-*-linux-gnu*)
349			    fmt=elf em=tmips
350			    AC_DEFINE(MIPS_STABS_ELF, 1,
351				[Use ELF stabs for MIPS, not ECOFF stabs])
352			    ;;
353      mips-*-sysv4*MP* | mips-*-gnu*)
354			    fmt=elf em=tmips ;;
355      mips-*-sysv*)         fmt=ecoff ;;
356      mips-*-elf* | mips-*-rtems* | mips-*-openbsd*)
357			    fmt=elf ;;
358      mips-*-vxworks*)      fmt=elf
359			    AC_DEFINE(MIPS_STABS_ELF, 1,
360				[Use ELF stabs for MIPS, not ECOFF stabs])
361			    ;;
362      mn10200-*-*)	    fmt=elf bfd_gas=yes ;;
363      mn10300-*-*)	    fmt=elf bfd_gas=yes ;;
364      pj*)		    fmt=elf ;;
365      ppc-*-pe | ppc-*-cygwin* | ppc-*-winnt*)
366		            fmt=coff em=pe ;;
367      ppc-*-aix*)           fmt=coff ;;
368      ppc-*-beos*)          fmt=coff ;;
369      ppc-*-*bsd* | ppc-*-elf* | ppc-*-eabi* | ppc-*-sysv4*)
370			    fmt=elf ;;
371      ppc-*-linux-gnu*)	    fmt=elf
372			    case "$endian" in
373			    big)  ;;
374			    *)    AC_MSG_ERROR(GNU/Linux must be configured big endian) ;;
375			    esac
376			    ;;
377      ppc-*-solaris*)	    fmt=elf
378			    if test ${this_target} = $target; then
379				AC_DEFINE(TARGET_SOLARIS_COMMENT, 1,
380				[Define if default target is PowerPC Solaris.])
381			    fi
382			    if test x${endian} = xbig; then
383				AC_MSG_ERROR(Solaris must be configured little endian)
384			    fi
385			    ;;
386      ppc-*-rtems*)	    fmt=elf ;;
387      ppc-*-macos* | ppc-*-mpw*)
388			    fmt=coff em=macos ;;
389      ppc-*-netware*)       fmt=elf em=ppcnw ;;
390      ppc-*-vxworks*)       fmt=elf ;;
391
392      sh-*-linux*)	    fmt=elf em=linux ;;
393      sh-*-elf*)	    fmt=elf ;;
394      sh-*-coff*)           fmt=coff ;;
395      sh-*-pe*)             fmt=coff em=pe bfd_gas=yes;;
396      sh-*-rtemself*)       fmt=elf ;;
397      sh-*-rtems*)	    fmt=coff ;;
398
399      ns32k-pc532-mach* | ns32k-pc532-ux*)    fmt=aout em=pc532mach ;;
400      ns32k-pc532-netbsd* | ns32k-pc532-lites*)  fmt=aout em=nbsd532 ;;
401      ns32k-pc532-openbsd*) fmt=aout em=nbsd532 ;;
402
403      sparc-*-rtemsaout*)   fmt=aout ;;
404      sparc-*-rtemself*)    fmt=elf ;;
405      sparc-*-rtems*)       fmt=elf ;;
406      sparc-*-sunos4*)      fmt=aout em=sun3 ;;
407      sparc-*-aout | sparc*-*-vxworks*)
408			    fmt=aout em=sparcaout ;;
409      sparc-*-coff)         fmt=coff ;;
410      sparc-*-linux*aout*)  fmt=aout em=linux ;;
411      sparc-*-linux-gnu*)   fmt=elf em=linux ;;
412      sparc-*-lynxos*)      fmt=coff em=lynx ;;
413      sparc-fujitsu-none)   fmt=aout ;;
414      sparc-*-elf | sparc-*-sysv4* | sparc-*-solaris*)
415			    fmt=elf ;;
416      sparc-*-netbsd*)      em=nbsd bfd_gas=yes
417                            case ${cpu} in
418                                sparc) case ${os} in
419                                           *elf*) fmt=elf ;;
420                                           *)     fmt=aout ;;
421                                       esac ;;
422                                sparc64) fmt=elf ;;
423                            esac
424                            ;;
425      sparc-*-openbsd*)     fmt=aout em=nbsd ;;
426
427      strongarm-*-coff)     fmt=coff ;;
428      strongarm-*-elf)      fmt=elf ;;
429      xscale-*-coff)     fmt=coff ;;
430      xscale-*-elf)      fmt=elf ;;
431
432      tic30-*-*aout*)	    fmt=aout bfd_gas=yes ;;
433      tic30-*-*coff*)       fmt=coff bfd_gas=yes ;;
434      tic54x-*-* | c54x*-*-*)
435			    fmt=coff bfd_gas=yes need_libm=yes;;
436      tic80-*-*)	    fmt=coff ;;
437
438      v850-*-*)		    fmt=elf bfd_gas=yes ;;
439      v850e-*-*)	    fmt=elf bfd_gas=yes ;;
440      v850ea-*-*)	    fmt=elf bfd_gas=yes ;;
441
442      vax-*-bsd* | vax-*-ultrix*)
443			    fmt=aout ;;
444      vax-*-vms)            fmt=vms ;;
445
446
447      z8k-*-coff | z8k-*-sim)
448			    fmt=coff ;;
449
450      w65-*-*)              fmt=coff ;;
451
452      *-*-aout | *-*-scout)
453			    fmt=aout ;;
454      *-*-freebsd*)	    fmt=elf em=freebsd bfd_gas=yes ;;
455      *-*-nindy*)
456			    fmt=bout ;;
457      *-*-bsd*)
458			    fmt=aout em=sun3 ;;
459      *-*-generic)          fmt=generic ;;
460      *-*-xray | *-*-hms)   fmt=coff ;;
461      *-*-sim)              fmt=coff ;;
462      *-*-elf | *-*-sysv4* | *-*-solaris*)
463			    AC_MSG_WARN(GAS support for ${generic_target} is incomplete.)
464			    fmt=elf dev=yes ;;
465      *-*-vxworks)          fmt=aout ;;
466      *-*-netware)          fmt=elf ;;
467    esac
468
469    if test ${this_target} = $target ; then
470      endian_def=
471      if test x${endian} = xbig; then
472	endian_def=1
473      elif test x${endian} = xlittle; then
474	endian_def=0
475      fi
476      if test x${endian_def} != x; then
477	AC_DEFINE_UNQUOTED(TARGET_BYTES_BIG_ENDIAN, $endian_def,
478			   [Define as 1 if big endian.])
479      fi
480    fi
481
482    case ${cpu_type}-${fmt} in
483      alpha*-*)	bfd_gas=yes ;;
484      arm-*)	bfd_gas=yes ;;
485    # not yet
486    # i386-aout)	bfd_gas=preferred ;;
487      ia64*-*)	bfd_gas=yes ;;
488      mips-*)	bfd_gas=yes ;;
489      ns32k-*)	bfd_gas=yes ;;
490      ppc-*)	bfd_gas=yes ;;
491      sparc-*)	bfd_gas=yes ;;
492      strongarm-*)	bfd_gas=yes ;;
493      xscale-*)	bfd_gas=yes ;;
494      *-elf)	bfd_gas=yes ;;
495      *-ecoff)	bfd_gas=yes ;;
496      *-som)	bfd_gas=yes ;;
497    #enable bfd for coff and aout to allow testing if a bfd target is
498    #the primary target, but not for coff or aout as the primary target
499      i386-coff)	if test x${primary_bfd_gas} = xyes; then bfd_gas=yes; fi ;;
500      i386-aout)	if test x${primary_bfd_gas} = xyes; then bfd_gas=yes; fi ;;
501      *)		;;
502    esac
503
504# Other random stuff.
505
506    # Do we need the opcodes library?
507    case ${cpu_type} in
508      vax | i386 | tic30)
509	;;
510
511      *)
512	need_opcodes=yes
513
514	case "${enable_shared}" in
515	yes) shared_opcodes=true ;;
516	*opcodes*) shared_opcodes=true ;;
517	*) shared_opcodes=false ;;
518	esac
519	if test "${shared_opcodes}" = "true"; then
520	  # A shared libopcodes must be linked against libbfd.
521	  need_bfd=yes
522	fi
523	;;
524    esac
525
526    # Any other special object files needed ?
527    case ${cpu_type} in
528      fr30 | m32r)
529	using_cgen=yes
530	;;
531
532      m68k)
533	case ${extra_objects} in
534	*m68k-parse.o*) ;;
535	*) extra_objects="$extra_objects m68k-parse.o" ;;
536	esac
537	;;
538
539      mips)
540	echo ${extra_objects} | grep -s "itbl-parse.o" 
541	if test $? -ne 0 ; then
542	  extra_objects="$extra_objects itbl-parse.o"
543	fi
544
545	echo ${extra_objects} | grep -s "itbl-lex.o" 
546	if test $? -ne 0 ; then
547	  extra_objects="$extra_objects itbl-lex.o"
548	fi
549
550	echo ${extra_objects} | grep -s "itbl-ops.o" 
551	if test $? -ne 0 ; then
552	  extra_objects="$extra_objects itbl-ops.o"
553	fi
554	;;
555
556      i386)
557	if test $this_target = $target ; then
558	  AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
559	fi
560	;;
561      sparc)
562	if test $this_target = $target ; then
563	  AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
564	fi
565	;;
566      *)
567	;;
568    esac
569
570    if test $using_cgen = yes ; then
571	case "x${extra_objects}" in
572	*cgen.o*) ;;
573	*) extra_objects="$extra_objects cgen.o" ;;
574	esac
575    fi
576
577# See if we really can support this configuration with the emulation code.
578
579    if test $this_target = $target ; then
580      primary_bfd_gas=$bfd_gas
581      obj_format=$fmt
582      te_file=$em
583
584      if test $bfd_gas = no ; then
585	# Can't support other configurations this way.
586	break
587      fi
588    elif test $bfd_gas = no ; then
589      # Can't support this configuration.
590      break
591    fi
592
593# From target name and format, produce a list of supported emulations.
594
595    case ${generic_target}-${fmt} in
596      mips-*-irix5*-*)	emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
597      mips-*-linux-gnu*-*) case "$endian" in
598			big)	emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
599			*)	emulation="mipslelf mipsbelf mipself mipslecoff mipsbecoff mipsecoff" ;;
600			esac ;;
601      mips-*-lnews*-ecoff) ;;
602      mips-*-*-ecoff)	case "$endian" in
603			big)	emulation="mipsbecoff mipslecoff mipsecoff" ;;
604			*)	emulation="mipslecoff mipsbecoff mipsecoff" ;;
605			esac ;;
606      mips-*-*-elf)	case "$endian" in
607			big)	emulation="mipsbelf mipslelf mipself" ;;
608			*)	emulation="mipslelf mipsbelf mipself" ;;
609			esac ;;
610      mips-*-sysv4*MP*-*) emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
611      # i386-pc-pe-coff != i386-pc-coff.
612      i386-*-pe-coff)	;;
613      # Uncommenting the next line will turn on support for i386 AOUT
614      # for the default linux configuration
615      # i386-*-linux*-elf) emulation="i386elf i386aout" ;;
616      #
617      i386-*-aout)	emulation="i386aout" ;;
618      i386-*-coff)	emulation="i386coff" ;;
619      i386-*-elf)	emulation="i386elf" ;;
620
621      # Always all formats.  The first stated emulation becomes the default.
622      cris-*-*aout*)	emulation="crisaout criself" ;;
623      cris-*-*)		emulation="criself crisaout" ;;
624    esac
625
626    emulations="$emulations $emulation"
627
628done
629
630# Turn on all targets if possible
631if test ${all_targets} = "yes"; then
632  case ${target_cpu_type} in
633  i386)
634    case ${obj_format} in
635    aout)
636      emulations="$emulations i386coff i386elf"
637      ;;
638    coff)
639      emulations="$emulations i386aout i386elf"
640    ;;
641    elf)
642      emulations="$emulations i386aout i386coff"
643      ;;
644    esac
645  ;;
646  esac
647fi
648
649# Assign floating point type.  Most processors with FP support
650# IEEE FP.  On those that don't support FP at all, usually IEEE
651# is emulated.
652case ${target_cpu} in
653  vax | tahoe )	atof=${target_cpu} ;;
654  *)		atof=ieee ;;
655esac
656
657case "${obj_format}" in
658  "") AC_MSG_ERROR(GAS does not know what format to use for target ${target}) ;;
659esac
660
661# Unfortunately the cpu in cpu-opc.h file isn't always $(TARGET_CPU).
662cgen_cpu_prefix=""
663if test $using_cgen = yes ; then
664  case ${target_cpu} in
665    *) cgen_cpu_prefix=${target_cpu} ;;
666  esac
667  AC_SUBST(cgen_cpu_prefix)
668  AC_DEFINE(USING_CGEN, 1, [Using cgen code?])
669fi
670
671dnl
672dnl Make sure the desired support files exist.
673dnl
674
675if test ! -r ${srcdir}/config/tc-${target_cpu_type}.c; then
676  AC_MSG_ERROR(GAS does not support target CPU ${target_cpu_type})
677fi
678
679if test ! -r ${srcdir}/config/obj-${obj_format}.c; then
680  AC_MSG_ERROR(GAS does not have support for object file format ${obj_format})
681fi
682
683case ${user_bfd_gas}-${primary_bfd_gas} in
684  yes-yes | no-no)
685    # We didn't override user's choice.
686    ;;
687  no-yes)
688    AC_MSG_WARN(Use of BFD is required for ${target}; overriding config options.)
689    ;;
690  no-preferred)
691    primary_bfd_gas=no
692    ;;
693  *-preferred)
694    primary_bfd_gas=yes
695    ;;
696  yes-*)
697    primary_bfd_gas=yes
698    ;;
699  -*)
700    # User specified nothing.
701    ;;
702esac
703
704# Some COFF configurations want these random other flags set.
705case ${obj_format} in
706  coff)
707    case ${target_cpu_type} in
708      i386) AC_DEFINE(I386COFF, 1, [Using i386 COFF?]) ;;
709      m68k) AC_DEFINE(M68KCOFF, 1, [Using m68k COFF?]) ;;
710      m88k) AC_DEFINE(M88KCOFF, 1, [Using m88k COFF?]) ;;
711    esac
712    ;;
713esac
714
715# Getting this done right is going to be a bitch.  Each configuration specified
716# with --enable-targets=... should be checked for environment, format, cpu, and
717# bfd_gas setting.
718#
719# For each configuration, the necessary object file support code must be linked
720# in.  This might be only one, it might be up to four.  The necessary emulation
721# code needs to be provided, too.
722#
723# And then there's "--enable-targets=all"....
724#
725# For now, just always do it for MIPS ELF or ECOFF configurations.  Sigh.
726
727formats="${obj_format}"
728emfiles=""
729EMULATIONS=""
730GAS_UNIQ(emulations)
731for em in . $emulations ; do
732  case $em in
733    .)	continue ;;
734    mipsbelf | mipslelf | mipself)
735	fmt=elf   file=mipself ;;
736    mipsbecoff | mipslecoff | mipsecoff)
737	fmt=ecoff file=mipsecoff ;;
738    *coff)
739	fmt=coff  file=$em ;;
740    *aout)
741	fmt=aout file=$em ;;
742    *elf)
743	fmt=elf file=$em ;;
744  esac
745  formats="$formats $fmt"
746  emfiles="$emfiles e-$file.o"
747  EMULATIONS="$EMULATIONS &$em,"
748done
749GAS_UNIQ(formats)
750GAS_UNIQ(emfiles)
751if test `set . $formats ; shift ; echo $#` -gt 1 ; then
752  for fmt in $formats ; do
753    case $fmt in
754      aout)	AC_DEFINE(OBJ_MAYBE_AOUT, 1,    [a.out support?])   ;;
755      bout)	AC_DEFINE(OBJ_MAYBE_BOUT, 1,    [b.out support?])   ;;
756      coff)	AC_DEFINE(OBJ_MAYBE_COFF, 1,    [COFF support?])    ;;
757      ecoff)	AC_DEFINE(OBJ_MAYBE_ECOFF, 1,   [ECOFF support?])   ;;
758      elf)	AC_DEFINE(OBJ_MAYBE_ELF, 1,     [ELF support?])     ;;
759      generic)	AC_DEFINE(OBJ_MAYBE_GENERIC, 1, [generic support?]) ;;
760      hp300)	AC_DEFINE(OBJ_MAYBE_HP300, 1,   [HP300 support?])   ;;
761      ieee)	AC_DEFINE(OBJ_MAYBE_IEEE, 1,    [IEEE support?])    ;;
762      som)	AC_DEFINE(OBJ_MAYBE_SOM, 1,     [SOM support?])     ;;
763      vms)	AC_DEFINE(OBJ_MAYBE_VMS, 1,     [VMS support?])     ;;
764    esac
765    extra_objects="$extra_objects obj-$fmt.o"
766  done
767  obj_format=multi
768fi
769if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then
770  DEFAULT_EMULATION=`set . $emulations ; echo $2`
771  # e-mips* has more than one emulation per file, e-i386* has just one at the
772  # moment.  If only one emulation is specified, then don't define
773  # USE_EMULATIONS or include any of the e-files as they will only be bloat.
774  case "${obj_format}${emfiles}" in
775    multi* | *mips*)
776      extra_objects="$extra_objects $emfiles"
777      AC_DEFINE(USE_EMULATIONS, 1, [Use emulation support?]) ;;
778  esac
779fi
780AC_SUBST(extra_objects)
781AC_DEFINE_UNQUOTED(EMULATIONS, $EMULATIONS, [Supported emulations.])
782AC_DEFINE_UNQUOTED(DEFAULT_EMULATION, "$DEFAULT_EMULATION",
783		   [Default emulation.])
784
785case ${primary_bfd_gas}-${target_cpu_type}-${obj_format} in
786  yes-*-coff)	need_bfd=yes ;;
787  no-*-coff)	need_bfd=yes
788		AC_DEFINE(MANY_SEGMENTS, 1, [old COFF support?]) ;;
789esac
790
791reject_dev_configs=yes
792
793case ${reject_dev_configs}-${dev} in
794  yes-yes) # Oops.
795    AC_MSG_ERROR(GAS does not support the ${generic_target} configuration.)
796    ;;
797esac
798
799AC_SUBST(target_cpu_type)
800AC_SUBST(obj_format)
801AC_SUBST(te_file)
802AC_SUBST(install_tooldir)
803AC_SUBST(atof)
804dnl AC_SUBST(emulation)
805
806case "${primary_bfd_gas}" in
807  yes)	AC_DEFINE(BFD_ASSEMBLER, 1, [Use BFD interface?])
808	need_bfd=yes ;;
809esac
810
811# do we need the opcodes library?
812case "${need_opcodes}" in
813yes)
814  OPCODES_LIB=../opcodes/libopcodes.la
815  ;;
816esac
817
818case "${need_bfd}" in
819yes)
820  BFDLIB=../bfd/libbfd.la
821  ALL_OBJ_DEPS="$ALL_OBJ_DEPS ../bfd/bfd.h"
822  ;;
823esac
824
825AC_SUBST(BFDLIB)
826AC_SUBST(OPCODES_LIB)
827
828AC_SUBST(ALL_OBJ_DEPS)
829
830AC_DEFINE_UNQUOTED(TARGET_ALIAS,	"${target_alias}", [Target alias.])
831AC_DEFINE_UNQUOTED(TARGET_CANONICAL,	"${target}",       [Canonical target.])
832AC_DEFINE_UNQUOTED(TARGET_CPU,		"${target_cpu}",   [Target CPU.])
833AC_DEFINE_UNQUOTED(TARGET_VENDOR,	"${target_vendor}", [Target vendor.])
834AC_DEFINE_UNQUOTED(TARGET_OS,		"${target_os}",    [Target OS.])
835
836AC_PROG_CC
837
838AC_PROG_YACC
839AM_PROG_LEX
840
841ALL_LINGUAS=
842CY_GNU_GETTEXT
843
844AM_MAINTAINER_MODE
845AC_EXEEXT
846
847AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h errno.h sys/types.h)
848
849# Put this here so that autoconf's "cross-compiling" message doesn't confuse
850# people who are not cross-compiling but are compiling cross-assemblers.
851AC_MSG_CHECKING(whether compiling a cross-assembler)
852if test "${host}" = "${target}"; then
853  cross_gas=no
854else
855  cross_gas=yes
856  AC_DEFINE(CROSS_COMPILE, 1, [Compiling cross-assembler?])
857fi
858AC_MSG_RESULT($cross_gas)
859
860dnl ansidecl.h will deal with const
861dnl AC_CONST
862AC_FUNC_ALLOCA
863AC_C_INLINE
864
865# VMS doesn't have unlink.
866AC_CHECK_FUNCS(unlink remove, break)
867
868# Some systems don't have sbrk().
869AC_CHECK_FUNCS(sbrk)
870
871# do we need the math library?
872case "${need_libm}" in
873yes) 
874  AC_CHECK_LIBM
875  AC_SUBST(LIBM)
876  ;;
877esac
878
879# Some non-ANSI preprocessors botch requoting inside strings.  That's bad
880# enough, but on some of those systems, the assert macro relies on requoting
881# working properly!
882GAS_WORKING_ASSERT
883
884# On some systems, the system header files may not declare malloc, realloc,
885# and free.  There are places where gas needs these functions to have been
886# declared -- such as when taking their addresses.
887gas_test_headers="
888#ifdef HAVE_MEMORY_H
889#include <memory.h>
890#endif
891#ifdef HAVE_STRING_H
892#include <string.h>
893#else
894#ifdef HAVE_STRINGS_H
895#include <strings.h>
896#endif
897#endif
898#ifdef HAVE_STDLIB_H
899#include <stdlib.h>
900#endif
901#ifdef HAVE_UNISTD_H
902#include <unistd.h>
903#endif
904"
905GAS_CHECK_DECL_NEEDED(strstr, f, char *(*f)(), $gas_test_headers)
906GAS_CHECK_DECL_NEEDED(malloc, f, char *(*f)(), $gas_test_headers)
907GAS_CHECK_DECL_NEEDED(free, f, void (*f)(), $gas_test_headers)
908GAS_CHECK_DECL_NEEDED(sbrk, f, char *(*f)(), $gas_test_headers)
909GAS_CHECK_DECL_NEEDED(environ, f, char **f, $gas_test_headers)
910
911# Does errno.h declare errno, or do we have to add a separate declaration
912# for it?
913GAS_CHECK_DECL_NEEDED(errno, f, int f, [
914#ifdef HAVE_ERRNO_H
915#include <errno.h>
916#endif
917])
918
919dnl This must come last.
920
921dnl We used to make symlinks to files in the source directory, but now
922dnl we just use the right name for .c files, and create .h files in
923dnl the build directory which include the right .h file.  Make sure
924dnl the old symlinks don't exist, so that a reconfigure in an existing
925dnl directory behaves reasonably.
926
927AC_OUTPUT(Makefile doc/Makefile ${GDBINIT}:gdbinit.in po/Makefile.in:po/Make-in,
928[rm -f targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c itbl-cpu.h
929 echo '#include "tc-'"${target_cpu_type}"'.h"' > targ-cpu.h
930 echo '#include "obj-'"${obj_format}"'.h"' > obj-format.h
931 echo '#include "te-'"${te_file}"'.h"' > targ-env.h
932 echo '#include "itbl-'"${target_cpu_type}"'.h"' > itbl-cpu.h
933 if test "x$cgen_cpu_prefix" != x ; then
934   echo '#include "opcodes/'"${cgen_cpu_prefix}"'-desc.h"' > cgen-desc.h
935 fi
936
937 sed -e '/POTFILES =/r po/POTFILES' po/Makefile.in > po/Makefile],
938[target_cpu_type=${target_cpu_type}
939 cgen_cpu_prefix=${cgen_cpu_prefix}
940 obj_format=${obj_format}
941 te_file=${te_file}])
942