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