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