configure.in revision 78837
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 78837 2001-06-26 17:51:35Z 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-*-netbsd*)       fmt=aout em=nbsd bfd_gas=yes;;
245      i386-*-openbsd*)      fmt=aout em=nbsd bfd_gas=yes;;
246      i386-*-linux*aout* | i386-*-linux*oldld)   fmt=aout em=linux ;;
247      i386-*-linux*coff*)   fmt=coff em=linux ;;
248      i386-*-linux-gnu*)    fmt=elf em=linux bfd_gas=yes ;;
249      x86_64-*-linux-gnu*)  fmt=elf em=linux bfd_gas=yes ;;
250      i386-*-lynxos*)       fmt=coff em=lynx ;;
251changequote(,)dnl
252      i386-*-sysv[45]* | i386-*-solaris* | i386-*-elf)
253			    fmt=elf bfd_gas=yes ;;
254      i386-*-freebsdaout* | i386-*-freebsd[12].* | i386-*-freebsd[12])
255                            fmt=aout em=386bsd ;;
256changequote([,])dnl
257      i386-*-coff | i386-*-sysv* | i386-*-sco3.2v5*coff | i386-*-isc*)
258                          fmt=coff ;;
259      i386-*-sco3.2v5*)      fmt=elf
260			    if test ${this_target} = $target; then
261				AC_DEFINE(SCO_ELF, 1,
262				    [Define if defaulting to ELF on SCO 5.])
263			    fi
264			    ;;
265      i386-*-sco3.2*)       fmt=coff ;;
266      i386-*-vsta)          fmt=aout ;;
267      i386-*-msdosdjgpp* | i386-*-go32* | i386-go32-rtems*)
268			    fmt=coff em=go32 bfd_gas=yes
269			    AC_DEFINE(STRICTCOFF, 1, [Using strict COFF?])
270			    ;;
271      i386-*-rtemself*)     fmt=elf ;;
272      i386-*-rtems*)        fmt=coff ;;
273      i386-*-gnu*)          fmt=elf ;;
274      i386-*-mach*)
275			    fmt=aout em=mach bfd_gas=yes ;;
276      i386-*-msdos*)        fmt=aout ;;
277      i386-*-moss*)	    fmt=elf ;;
278      i386-*-pe)            fmt=coff em=pe bfd_gas=yes ;;
279      i386-*-cygwin*)       fmt=coff em=pe bfd_gas=yes ;;
280      i386-*-interix*)	    fmt=coff em=interix bfd_gas=yes ;;
281      i386-*-mingw32*)      fmt=coff em=pe bfd_gas=yes ;;
282      i386-*-*nt*)          fmt=coff em=pe bfd_gas=yes ;;
283      i386-*-vxworks*)      fmt=aout ;;
284      i386-*-chaos)         fmt=elf ;;
285      i860-stardent-sysv4* | i860-stardent-elf*)
286			    fmt=elf bfd_gas=yes endian=little
287			    AC_MSG_WARN(GAS support for ${generic_target} is preliminary and a work in progress) ;;
288      i960-*-bout)          fmt=bout ;;
289      i960-*-coff)          fmt=coff em=ic960 ;;
290      i960-*-rtems*)        fmt=coff em=ic960 ;;
291      i960-*-nindy*)        fmt=bout ;;
292      i960-*-vxworks4*)     fmt=bout ;;
293      i960-*-vxworks5.0)    fmt=bout ;;
294      i960-*-vxworks5.*)    fmt=coff em=ic960 ;;
295      i960-*-vxworks*)      fmt=bout ;;
296      i960-*-elf*)	    fmt=elf ;;
297
298      ia64-*-elf*)	    fmt=elf ;;
299      ia64-*-linux-gnu*)    fmt=elf em=linux ;;
300      ia64-*-hpux*)	    fmt=elf em=hpux ;;
301
302      m32r-*-*)		    fmt=elf bfd_gas=yes ;;
303
304      m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)fmt=elf bfd_gas=yes ;;
305
306      m68k-*-vxworks* | m68k-ericsson-ose | m68k-*-sunos*)
307			    fmt=aout em=sun3 ;;
308      m68k-motorola-sysv*)  fmt=coff em=delta ;;
309      m68k-bull-sysv3*)     fmt=coff em=dpx2 ;;
310      m68k-apollo-*)        fmt=coff em=apollo ;;
311      m68k-*-sysv4*) # must be before -sysv*
312			    fmt=elf em=svr4 ;;
313      m68k-*-elf*)	    fmt=elf ;;
314      m68k-*-coff | m68k-*-sysv* | m68k-*-rtems*)
315			    fmt=coff ;;
316      m68k-*-hpux*)         fmt=hp300 em=hp300 ;;
317      m68k-*-linux*aout*)   fmt=aout em=linux ;;
318      m68k-*-linux-gnu*)    fmt=elf em=linux ;;
319      m68k-*-gnu*)	    fmt=elf ;;
320      m68k-*-lynxos*)       fmt=coff em=lynx ;;
321      m68k-*-netbsd*)       fmt=aout em=nbsd bfd_gas=yes ;;
322      m68k-*-openbsd*)      fmt=aout em=nbsd bfd_gas=yes ;;
323      m68k-apple-aux*)      fmt=coff em=aux ;;
324      m68k-*-psos*)         fmt=elf em=psos;;
325
326      m88k-motorola-sysv3*) fmt=coff em=delt88 ;;
327      m88k-*-coff*)         fmt=coff ;;
328
329      mcore-*-elf)	    fmt=elf bfd_gas=yes ;;
330      mcore-*-pe)	    fmt=coff em=pe bfd_gas=yes ;;
331
332      # don't change em like *-*-bsd does
333      mips-dec-netbsd*)	    fmt=elf endian=little ;;
334      mips-dec-openbsd*)    fmt=elf endian=little ;;
335      mips-dec-bsd*)        fmt=aout endian=little ;;
336      mips-sony-bsd*)       fmt=ecoff ;;
337      mips-*-bsd*)          AC_MSG_ERROR(Unknown vendor for mips-bsd configuration.) ;;
338      mips-*-ultrix*)       fmt=ecoff endian=little ;;
339      mips-*-osf*)          fmt=ecoff endian=little ;;
340      mips-*-ecoff*)        fmt=ecoff ;;
341      mips-*-pe*)           fmt=coff endian=little em=pe ;;
342      mips-*-irix6*)	    fmt=elf ;;
343      mips-*-irix5*)        fmt=elf ;;
344      mips-*-irix*)         fmt=ecoff ;;
345      mips-*-lnews*)        fmt=ecoff em=lnews ;;
346      mips-*-riscos*)       fmt=ecoff ;;
347      mips-*-linux-gnu*)
348			    fmt=elf em=tmips
349			    AC_DEFINE(MIPS_STABS_ELF, 1,
350				[Use ELF stabs for MIPS, not ECOFF stabs])
351			    ;;
352      mips-*-sysv4*MP* | mips-*-gnu*)
353			    fmt=elf em=tmips ;;
354      mips-*-sysv*)         fmt=ecoff ;;
355      mips-*-elf* | mips-*-rtems* | mips-*-openbsd*)
356			    fmt=elf ;;
357      mips-*-vxworks*)      fmt=elf
358			    AC_DEFINE(MIPS_STABS_ELF, 1,
359				[Use ELF stabs for MIPS, not ECOFF stabs])
360			    ;;
361      mn10200-*-*)	    fmt=elf bfd_gas=yes ;;
362      mn10300-*-*)	    fmt=elf bfd_gas=yes ;;
363      pj*)		    fmt=elf ;;
364      ppc-*-pe | ppc-*-cygwin* | ppc-*-winnt*)
365		            fmt=coff em=pe ;;
366      ppc-*-aix*)           fmt=coff ;;
367      ppc-*-beos*)          fmt=coff ;;
368      ppc-*-*bsd* | ppc-*-elf* | ppc-*-eabi* | ppc-*-sysv4*)
369			    fmt=elf ;;
370      ppc-*-linux-gnu*)	    fmt=elf
371			    case "$endian" in
372			    big)  ;;
373			    *)    AC_MSG_ERROR(GNU/Linux must be configured big endian) ;;
374			    esac
375			    ;;
376      ppc-*-solaris*)	    fmt=elf
377			    if test ${this_target} = $target; then
378				AC_DEFINE(TARGET_SOLARIS_COMMENT, 1,
379				[Define if default target is PowerPC Solaris.])
380			    fi
381			    if test x${endian} = xbig; then
382				AC_MSG_ERROR(Solaris must be configured little endian)
383			    fi
384			    ;;
385      ppc-*-rtems*)	    fmt=elf ;;
386      ppc-*-macos* | ppc-*-mpw*)
387			    fmt=coff em=macos ;;
388      ppc-*-netware*)       fmt=elf em=ppcnw ;;
389      ppc-*-vxworks*)       fmt=elf ;;
390
391      sh-*-linux*)	    fmt=elf em=linux ;;
392      sh-*-elf*)	    fmt=elf ;;
393      sh-*-coff*)           fmt=coff ;;
394      sh-*-pe*)             fmt=coff em=pe bfd_gas=yes;;
395      sh-*-rtemself*)       fmt=elf ;;
396      sh-*-rtems*)	    fmt=coff ;;
397
398      ns32k-pc532-mach* | ns32k-pc532-ux*)    fmt=aout em=pc532mach ;;
399      ns32k-pc532-netbsd* | ns32k-pc532-lites*)  fmt=aout em=nbsd532 ;;
400      ns32k-pc532-openbsd*) fmt=aout em=nbsd532 ;;
401
402      sparc-*-rtemsaout*)   fmt=aout ;;
403      sparc-*-rtemself*)    fmt=elf ;;
404      sparc-*-rtems*)       fmt=elf ;;
405      sparc-*-sunos4*)      fmt=aout em=sun3 ;;
406      sparc-*-aout | sparc*-*-vxworks*)
407			    fmt=aout em=sparcaout ;;
408      sparc-*-coff)         fmt=coff ;;
409      sparc-*-linux*aout*)  fmt=aout em=linux ;;
410      sparc-*-linux-gnu*)   fmt=elf em=linux ;;
411      sparc-*-lynxos*)      fmt=coff em=lynx ;;
412      sparc-fujitsu-none)   fmt=aout ;;
413      sparc-*-elf | sparc-*-sysv4* | sparc-*-solaris*)
414			    fmt=elf ;;
415      sparc-*-netbsd*)      em=nbsd bfd_gas=yes
416                            case ${cpu} in
417                                sparc) case ${os} in
418                                           *elf*) fmt=elf ;;
419                                           *)     fmt=aout ;;
420                                       esac ;;
421                                sparc64) fmt=elf ;;
422                            esac
423                            ;;
424      sparc-*-openbsd*)     fmt=aout em=nbsd ;;
425
426      strongarm-*-coff)     fmt=coff ;;
427      strongarm-*-elf)      fmt=elf ;;
428      xscale-*-coff)     fmt=coff ;;
429      xscale-*-elf)      fmt=elf ;;
430
431      tic30-*-*aout*)	    fmt=aout bfd_gas=yes ;;
432      tic30-*-*coff*)       fmt=coff bfd_gas=yes ;;
433      tic54x-*-* | c54x*-*-*)
434			    fmt=coff bfd_gas=yes need_libm=yes;;
435      tic80-*-*)	    fmt=coff ;;
436
437      v850-*-*)		    fmt=elf bfd_gas=yes ;;
438      v850e-*-*)	    fmt=elf bfd_gas=yes ;;
439      v850ea-*-*)	    fmt=elf bfd_gas=yes ;;
440
441      vax-*-bsd* | vax-*-ultrix*)
442			    fmt=aout ;;
443      vax-*-vms)            fmt=vms ;;
444
445
446      z8k-*-coff | z8k-*-sim)
447			    fmt=coff ;;
448
449      w65-*-*)              fmt=coff ;;
450
451      *-*-aout | *-*-scout)
452			    fmt=aout ;;
453      *-*-freebsd*)	    fmt=elf em=freebsd bfd_gas=yes ;;
454      *-*-nindy*)
455			    fmt=bout ;;
456      *-*-bsd*)
457			    fmt=aout em=sun3 ;;
458      *-*-generic)          fmt=generic ;;
459      *-*-xray | *-*-hms)   fmt=coff ;;
460      *-*-sim)              fmt=coff ;;
461      *-*-elf | *-*-sysv4* | *-*-solaris*)
462			    AC_MSG_WARN(GAS support for ${generic_target} is incomplete.)
463			    fmt=elf dev=yes ;;
464      *-*-vxworks)          fmt=aout ;;
465      *-*-netware)          fmt=elf ;;
466    esac
467
468    if test ${this_target} = $target ; then
469      endian_def=
470      if test x${endian} = xbig; then
471	endian_def=1
472      elif test x${endian} = xlittle; then
473	endian_def=0
474      fi
475      if test x${endian_def} != x; then
476	AC_DEFINE_UNQUOTED(TARGET_BYTES_BIG_ENDIAN, $endian_def,
477			   [Define as 1 if big endian.])
478      fi
479    fi
480
481    case ${cpu_type}-${fmt} in
482      alpha*-*)	bfd_gas=yes ;;
483      arm-*)	bfd_gas=yes ;;
484    # not yet
485    # i386-aout)	bfd_gas=preferred ;;
486      ia64*-*)	bfd_gas=yes ;;
487      mips-*)	bfd_gas=yes ;;
488      ns32k-*)	bfd_gas=yes ;;
489      ppc-*)	bfd_gas=yes ;;
490      sparc-*)	bfd_gas=yes ;;
491      strongarm-*)	bfd_gas=yes ;;
492      xscale-*)	bfd_gas=yes ;;
493      *-elf)	bfd_gas=yes ;;
494      *-ecoff)	bfd_gas=yes ;;
495      *-som)	bfd_gas=yes ;;
496    #enable bfd for coff and aout to allow testing if a bfd target is
497    #the primary target, but not for coff or aout as the primary target
498      i386-coff)	if test x${primary_bfd_gas} = xyes; then bfd_gas=yes; fi ;;
499      i386-aout)	if test x${primary_bfd_gas} = xyes; then bfd_gas=yes; fi ;;
500      *)		;;
501    esac
502
503# Other random stuff.
504
505    # Do we need the opcodes library?
506    case ${cpu_type} in
507      vax | i386 | tic30)
508	;;
509
510      *)
511	need_opcodes=yes
512
513	case "${enable_shared}" in
514	yes) shared_opcodes=true ;;
515	*opcodes*) shared_opcodes=true ;;
516	*) shared_opcodes=false ;;
517	esac
518	if test "${shared_opcodes}" = "true"; then
519	  # A shared libopcodes must be linked against libbfd.
520	  need_bfd=yes
521	fi
522	;;
523    esac
524
525    # Any other special object files needed ?
526    case ${cpu_type} in
527      fr30 | m32r)
528	using_cgen=yes
529	;;
530
531      m68k)
532	case ${extra_objects} in
533	*m68k-parse.o*) ;;
534	*) extra_objects="$extra_objects m68k-parse.o" ;;
535	esac
536	;;
537
538      mips)
539	echo ${extra_objects} | grep -s "itbl-parse.o" 
540	if test $? -ne 0 ; then
541	  extra_objects="$extra_objects itbl-parse.o"
542	fi
543
544	echo ${extra_objects} | grep -s "itbl-lex.o" 
545	if test $? -ne 0 ; then
546	  extra_objects="$extra_objects itbl-lex.o"
547	fi
548
549	echo ${extra_objects} | grep -s "itbl-ops.o" 
550	if test $? -ne 0 ; then
551	  extra_objects="$extra_objects itbl-ops.o"
552	fi
553	;;
554
555      i386)
556	if test $this_target = $target ; then
557	  AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
558	fi
559	;;
560      sparc)
561	if test $this_target = $target ; then
562	  AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
563	fi
564	;;
565      *)
566	;;
567    esac
568
569    if test $using_cgen = yes ; then
570	case "x${extra_objects}" in
571	*cgen.o*) ;;
572	*) extra_objects="$extra_objects cgen.o" ;;
573	esac
574    fi
575
576# See if we really can support this configuration with the emulation code.
577
578    if test $this_target = $target ; then
579      primary_bfd_gas=$bfd_gas
580      obj_format=$fmt
581      te_file=$em
582
583      if test $bfd_gas = no ; then
584	# Can't support other configurations this way.
585	break
586      fi
587    elif test $bfd_gas = no ; then
588      # Can't support this configuration.
589      break
590    fi
591
592# From target name and format, produce a list of supported emulations.
593
594    case ${generic_target}-${fmt} in
595      mips-*-irix5*-*)	emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
596      mips-*-linux-gnu*-*) case "$endian" in
597			big)	emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
598			*)	emulation="mipslelf mipsbelf mipself mipslecoff mipsbecoff mipsecoff" ;;
599			esac ;;
600      mips-*-lnews*-ecoff) ;;
601      mips-*-*-ecoff)	case "$endian" in
602			big)	emulation="mipsbecoff mipslecoff mipsecoff" ;;
603			*)	emulation="mipslecoff mipsbecoff mipsecoff" ;;
604			esac ;;
605      mips-*-*-elf)	case "$endian" in
606			big)	emulation="mipsbelf mipslelf mipself" ;;
607			*)	emulation="mipslelf mipsbelf mipself" ;;
608			esac ;;
609      mips-*-sysv4*MP*-*) emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
610      # i386-pc-pe-coff != i386-pc-coff.
611      i386-*-pe-coff)	;;
612      # Uncommenting the next line will turn on support for i386 AOUT
613      # for the default linux configuration
614      # i386-*-linux*-elf) emulation="i386elf i386aout" ;;
615      #
616      i386-*-aout)	emulation="i386aout" ;;
617      i386-*-coff)	emulation="i386coff" ;;
618      i386-*-elf)	emulation="i386elf" ;;
619
620      # Always all formats.  The first stated emulation becomes the default.
621      cris-*-*aout*)	emulation="crisaout criself" ;;
622      cris-*-*)		emulation="criself crisaout" ;;
623    esac
624
625    emulations="$emulations $emulation"
626
627done
628
629# Turn on all targets if possible
630if test ${all_targets} = "yes"; then
631  case ${target_cpu_type} in
632  i386)
633    case ${obj_format} in
634    aout)
635      emulations="$emulations i386coff i386elf"
636      ;;
637    coff)
638      emulations="$emulations i386aout i386elf"
639    ;;
640    elf)
641      emulations="$emulations i386aout i386coff"
642      ;;
643    esac
644  ;;
645  esac
646fi
647
648# Assign floating point type.  Most processors with FP support
649# IEEE FP.  On those that don't support FP at all, usually IEEE
650# is emulated.
651case ${target_cpu} in
652  vax | tahoe )	atof=${target_cpu} ;;
653  *)		atof=ieee ;;
654esac
655
656case "${obj_format}" in
657  "") AC_MSG_ERROR(GAS does not know what format to use for target ${target}) ;;
658esac
659
660# Unfortunately the cpu in cpu-opc.h file isn't always $(TARGET_CPU).
661cgen_cpu_prefix=""
662if test $using_cgen = yes ; then
663  case ${target_cpu} in
664    *) cgen_cpu_prefix=${target_cpu} ;;
665  esac
666  AC_SUBST(cgen_cpu_prefix)
667  AC_DEFINE(USING_CGEN, 1, [Using cgen code?])
668fi
669
670dnl
671dnl Make sure the desired support files exist.
672dnl
673
674if test ! -r ${srcdir}/config/tc-${target_cpu_type}.c; then
675  AC_MSG_ERROR(GAS does not support target CPU ${target_cpu_type})
676fi
677
678if test ! -r ${srcdir}/config/obj-${obj_format}.c; then
679  AC_MSG_ERROR(GAS does not have support for object file format ${obj_format})
680fi
681
682case ${user_bfd_gas}-${primary_bfd_gas} in
683  yes-yes | no-no)
684    # We didn't override user's choice.
685    ;;
686  no-yes)
687    AC_MSG_WARN(Use of BFD is required for ${target}; overriding config options.)
688    ;;
689  no-preferred)
690    primary_bfd_gas=no
691    ;;
692  *-preferred)
693    primary_bfd_gas=yes
694    ;;
695  yes-*)
696    primary_bfd_gas=yes
697    ;;
698  -*)
699    # User specified nothing.
700    ;;
701esac
702
703# Some COFF configurations want these random other flags set.
704case ${obj_format} in
705  coff)
706    case ${target_cpu_type} in
707      i386) AC_DEFINE(I386COFF, 1, [Using i386 COFF?]) ;;
708      m68k) AC_DEFINE(M68KCOFF, 1, [Using m68k COFF?]) ;;
709      m88k) AC_DEFINE(M88KCOFF, 1, [Using m88k COFF?]) ;;
710    esac
711    ;;
712esac
713
714# Getting this done right is going to be a bitch.  Each configuration specified
715# with --enable-targets=... should be checked for environment, format, cpu, and
716# bfd_gas setting.
717#
718# For each configuration, the necessary object file support code must be linked
719# in.  This might be only one, it might be up to four.  The necessary emulation
720# code needs to be provided, too.
721#
722# And then there's "--enable-targets=all"....
723#
724# For now, just always do it for MIPS ELF or ECOFF configurations.  Sigh.
725
726formats="${obj_format}"
727emfiles=""
728EMULATIONS=""
729GAS_UNIQ(emulations)
730for em in . $emulations ; do
731  case $em in
732    .)	continue ;;
733    mipsbelf | mipslelf | mipself)
734	fmt=elf   file=mipself ;;
735    mipsbecoff | mipslecoff | mipsecoff)
736	fmt=ecoff file=mipsecoff ;;
737    *coff)
738	fmt=coff  file=$em ;;
739    *aout)
740	fmt=aout file=$em ;;
741    *elf)
742	fmt=elf file=$em ;;
743  esac
744  formats="$formats $fmt"
745  emfiles="$emfiles e-$file.o"
746  EMULATIONS="$EMULATIONS &$em,"
747done
748GAS_UNIQ(formats)
749GAS_UNIQ(emfiles)
750if test `set . $formats ; shift ; echo $#` -gt 1 ; then
751  for fmt in $formats ; do
752    case $fmt in
753      aout)	AC_DEFINE(OBJ_MAYBE_AOUT, 1,    [a.out support?])   ;;
754      bout)	AC_DEFINE(OBJ_MAYBE_BOUT, 1,    [b.out support?])   ;;
755      coff)	AC_DEFINE(OBJ_MAYBE_COFF, 1,    [COFF support?])    ;;
756      ecoff)	AC_DEFINE(OBJ_MAYBE_ECOFF, 1,   [ECOFF support?])   ;;
757      elf)	AC_DEFINE(OBJ_MAYBE_ELF, 1,     [ELF support?])     ;;
758      generic)	AC_DEFINE(OBJ_MAYBE_GENERIC, 1, [generic support?]) ;;
759      hp300)	AC_DEFINE(OBJ_MAYBE_HP300, 1,   [HP300 support?])   ;;
760      ieee)	AC_DEFINE(OBJ_MAYBE_IEEE, 1,    [IEEE support?])    ;;
761      som)	AC_DEFINE(OBJ_MAYBE_SOM, 1,     [SOM support?])     ;;
762      vms)	AC_DEFINE(OBJ_MAYBE_VMS, 1,     [VMS support?])     ;;
763    esac
764    extra_objects="$extra_objects obj-$fmt.o"
765  done
766  obj_format=multi
767fi
768if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then
769  DEFAULT_EMULATION=`set . $emulations ; echo $2`
770  # e-mips* has more than one emulation per file, e-i386* has just one at the
771  # moment.  If only one emulation is specified, then don't define
772  # USE_EMULATIONS or include any of the e-files as they will only be bloat.
773  case "${obj_format}${emfiles}" in
774    multi* | *mips*)
775      extra_objects="$extra_objects $emfiles"
776      AC_DEFINE(USE_EMULATIONS, 1, [Use emulation support?]) ;;
777  esac
778fi
779AC_SUBST(extra_objects)
780AC_DEFINE_UNQUOTED(EMULATIONS, $EMULATIONS, [Supported emulations.])
781AC_DEFINE_UNQUOTED(DEFAULT_EMULATION, "$DEFAULT_EMULATION",
782		   [Default emulation.])
783
784case ${primary_bfd_gas}-${target_cpu_type}-${obj_format} in
785  yes-*-coff)	need_bfd=yes ;;
786  no-*-coff)	need_bfd=yes
787		AC_DEFINE(MANY_SEGMENTS, 1, [old COFF support?]) ;;
788esac
789
790reject_dev_configs=yes
791
792case ${reject_dev_configs}-${dev} in
793  yes-yes) # Oops.
794    AC_MSG_ERROR(GAS does not support the ${generic_target} configuration.)
795    ;;
796esac
797
798AC_SUBST(target_cpu_type)
799AC_SUBST(obj_format)
800AC_SUBST(te_file)
801AC_SUBST(install_tooldir)
802AC_SUBST(atof)
803dnl AC_SUBST(emulation)
804
805case "${primary_bfd_gas}" in
806  yes)	AC_DEFINE(BFD_ASSEMBLER, 1, [Use BFD interface?])
807	need_bfd=yes ;;
808esac
809
810# do we need the opcodes library?
811case "${need_opcodes}" in
812yes)
813  OPCODES_LIB=../opcodes/libopcodes.la
814  ;;
815esac
816
817case "${need_bfd}" in
818yes)
819  BFDLIB=../bfd/libbfd.la
820  ALL_OBJ_DEPS="$ALL_OBJ_DEPS ../bfd/bfd.h"
821  ;;
822esac
823
824AC_SUBST(BFDLIB)
825AC_SUBST(OPCODES_LIB)
826
827AC_SUBST(ALL_OBJ_DEPS)
828
829AC_DEFINE_UNQUOTED(TARGET_ALIAS,	"${target_alias}", [Target alias.])
830AC_DEFINE_UNQUOTED(TARGET_CANONICAL,	"${target}",       [Canonical target.])
831AC_DEFINE_UNQUOTED(TARGET_CPU,		"${target_cpu}",   [Target CPU.])
832AC_DEFINE_UNQUOTED(TARGET_VENDOR,	"${target_vendor}", [Target vendor.])
833AC_DEFINE_UNQUOTED(TARGET_OS,		"${target_os}",    [Target OS.])
834
835AC_PROG_CC
836
837AC_PROG_YACC
838AM_PROG_LEX
839
840ALL_LINGUAS=
841CY_GNU_GETTEXT
842
843AM_MAINTAINER_MODE
844AC_EXEEXT
845
846AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h errno.h sys/types.h)
847
848# Put this here so that autoconf's "cross-compiling" message doesn't confuse
849# people who are not cross-compiling but are compiling cross-assemblers.
850AC_MSG_CHECKING(whether compiling a cross-assembler)
851if test "${host}" = "${target}"; then
852  cross_gas=no
853else
854  cross_gas=yes
855  AC_DEFINE(CROSS_COMPILE, 1, [Compiling cross-assembler?])
856fi
857AC_MSG_RESULT($cross_gas)
858
859dnl ansidecl.h will deal with const
860dnl AC_CONST
861AC_FUNC_ALLOCA
862AC_C_INLINE
863
864# VMS doesn't have unlink.
865AC_CHECK_FUNCS(unlink remove, break)
866
867# Some systems don't have sbrk().
868AC_CHECK_FUNCS(sbrk)
869
870# do we need the math library?
871case "${need_libm}" in
872yes) 
873  AC_CHECK_LIBM
874  AC_SUBST(LIBM)
875  ;;
876esac
877
878# Some non-ANSI preprocessors botch requoting inside strings.  That's bad
879# enough, but on some of those systems, the assert macro relies on requoting
880# working properly!
881GAS_WORKING_ASSERT
882
883# On some systems, the system header files may not declare malloc, realloc,
884# and free.  There are places where gas needs these functions to have been
885# declared -- such as when taking their addresses.
886gas_test_headers="
887#ifdef HAVE_MEMORY_H
888#include <memory.h>
889#endif
890#ifdef HAVE_STRING_H
891#include <string.h>
892#else
893#ifdef HAVE_STRINGS_H
894#include <strings.h>
895#endif
896#endif
897#ifdef HAVE_STDLIB_H
898#include <stdlib.h>
899#endif
900#ifdef HAVE_UNISTD_H
901#include <unistd.h>
902#endif
903"
904GAS_CHECK_DECL_NEEDED(strstr, f, char *(*f)(), $gas_test_headers)
905GAS_CHECK_DECL_NEEDED(malloc, f, char *(*f)(), $gas_test_headers)
906GAS_CHECK_DECL_NEEDED(free, f, void (*f)(), $gas_test_headers)
907GAS_CHECK_DECL_NEEDED(sbrk, f, char *(*f)(), $gas_test_headers)
908GAS_CHECK_DECL_NEEDED(environ, f, char **f, $gas_test_headers)
909
910# Does errno.h declare errno, or do we have to add a separate declaration
911# for it?
912GAS_CHECK_DECL_NEEDED(errno, f, int f, [
913#ifdef HAVE_ERRNO_H
914#include <errno.h>
915#endif
916])
917
918dnl This must come last.
919
920dnl We used to make symlinks to files in the source directory, but now
921dnl we just use the right name for .c files, and create .h files in
922dnl the build directory which include the right .h file.  Make sure
923dnl the old symlinks don't exist, so that a reconfigure in an existing
924dnl directory behaves reasonably.
925
926AC_OUTPUT(Makefile doc/Makefile ${GDBINIT}:gdbinit.in po/Makefile.in:po/Make-in,
927[rm -f targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c itbl-cpu.h
928 echo '#include "tc-'"${target_cpu_type}"'.h"' > targ-cpu.h
929 echo '#include "obj-'"${obj_format}"'.h"' > obj-format.h
930 echo '#include "te-'"${te_file}"'.h"' > targ-env.h
931 echo '#include "itbl-'"${target_cpu_type}"'.h"' > itbl-cpu.h
932 if test "x$cgen_cpu_prefix" != x ; then
933   echo '#include "opcodes/'"${cgen_cpu_prefix}"'-desc.h"' > cgen-desc.h
934 fi
935
936 sed -e '/POTFILES =/r po/POTFILES' po/Makefile.in > po/Makefile],
937[target_cpu_type=${target_cpu_type}
938 cgen_cpu_prefix=${cgen_cpu_prefix}
939 obj_format=${obj_format}
940 te_file=${te_file}])
941