1 dnl Process this file with autoconf to produce a configure script.
3 dnl And be careful when changing it! If you must add tests with square
4 dnl brackets, be sure changequote invocations surround it.
7 AC_PREREQ(2.3)dnl We only need 2.0, but pre-2.3 loses on some AIX version.
11 AC_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) ;;
18 AC_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')
23 no) enable_targets= ;;
24 *) enable_targets=$enableval ;;
27 [ --enable-shared build shared BFD library],
28 [case "${enableval}" in
31 *) AC_MSG_ERROR([bad value ${enableval} for BFD shared option]) ;;
34 # Generate a header file -- gets more post-processing by Makefile later.
35 AC_CONFIG_HEADER(conf)
37 dnl For recursion to work right, this must be an absolute pathname.
38 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
45 if test -n "$enable_targets" ; then
46 for t in `echo $enable_targets | sed 's/,/ /g'`; do
47 result=`$ac_config_sub $t 2>/dev/null`
48 if test -n "$result" ; then
49 canon_targets="$canon_targets $result"
51 # # Permit "all", etc. We don't support it yet though.
52 # canon_targets="$canon_targets $t"
55 GAS_UNIQ(canon_targets)
60 for this_target in $target $canon_targets ; do
62 eval `echo $this_target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/'`
64 # check for architecture variants
66 armeb) cpu_type=arm endian=big ;;
67 arm*) cpu_type=arm endian=little ;;
68 hppa*) cpu_type=hppa ;;
70 i[456]86) cpu_type=i386 ;;
71 m680[012346]0) cpu_type=m68k ;;
72 m68008) cpu_type=m68k ;;
73 m683??) cpu_type=m68k ;;
76 mips*el) cpu_type=mips endian=little;;
77 mips*) cpu_type=mips endian=big ;;
78 powerpcle*) cpu_type=ppc endian=little ;;
79 powerpc*) cpu_type=ppc endian=big ;;
80 rs6000*) cpu_type=ppc ;;
81 sparc64) cpu_type=sparc want_sparc_v9=true ;;
82 sparc*) cpu_type=sparc ;;
86 if test ${this_target} = $target ; then
87 target_cpu_type=${cpu_type}
88 elif test ${target_cpu_type} != ${cpu_type} ; then
93 generic_target=${cpu_type}-$vendor-$os
98 # assign object format
99 case ${generic_target} in
100 a29k-*-coff) fmt=coff targ=ebmon29k ;;
101 a29k-amd-udi) fmt=coff targ=ebmon29k ;;
102 a29k-amd-ebmon) fmt=coff targ=ebmon29k ;;
103 a29k-nyu-sym1) fmt=coff targ=ebmon29k ;;
104 a29k-*-vxworks*) fmt=coff ;;
106 alpha-*-netware*) fmt=ecoff ;;
107 alpha-*-osf*) fmt=ecoff ;;
108 alpha-*-linux*) fmt=ecoff ;;
111 arc-*-elf*) fmt=elf bfd_gas=yes ;;
114 arm-*-riscix*) fmt=aout targ=arm-lit ;;
121 arm-*-coff) fmt=coff ;;
122 arm-*-riscix*) fmt=aout ;;
123 arm-*-pe) fmt=coff targ=armcoff em=pe ;;
125 hppa-*-*elf*) fmt=elf em=hppa ;;
126 hppa-*-lites*) fmt=elf em=hppa ;;
127 hppa-*-osf*) fmt=som em=hppa ;;
128 hppa-*-hpux*) fmt=som em=hppa ;;
129 hppa-*-bsd*) fmt=som em=hppa ;;
130 hppa-*-hiux*) fmt=som em=hppa ;;
132 h8300-*-coff) fmt=coff ;;
134 i386-ibm-aix*) fmt=coff targ=i386coff
136 i386-*-bsd*) fmt=aout em=386bsd ;;
137 i386-*-netbsd0.8) fmt=aout em=386bsd ;;
138 i386-*-netbsd*) fmt=aout em=nbsd bfd_gas=yes;;
139 i386-*-linux*aout* | i386-*-linuxoldld) fmt=aout em=linux ;;
140 i386-*-linux*coff*) fmt=coff em=linux
142 i386-*-linux*) fmt=elf em=linux ;;
143 i386-*-lynxos*) fmt=coff targ=i386coff
145 i386-*-sysv4* | i386-*-solaris* | i386-*-elf)
147 i386-*-sco*elf*) fmt=elf targ=sco5 ;;
148 i386-*-coff | i386-*-sysv* | i386-*-sco* | i386-*-isc*)
149 fmt=coff targ=i386coff ;;
150 i386-*-vsta) fmt=aout ;;
151 i386-*-go32) fmt=coff targ=i386coff ;;
152 i386-*-gnu*) fmt=elf ;;
154 fmt=aout em=mach bfd_gas=yes ;;
155 i386-*-msdos*) fmt=aout ;;
156 i386-*-moss*) fmt=elf ;;
157 i386-*-pe) fmt=coff targ=i386coff em=pe ;;
158 i386-*-cygwin32) fmt=coff targ=i386coff em=pe ;;
159 i386-*-*nt) fmt=coff targ=i386coff em=pe ;;
160 i960-*-bout) fmt=bout ;;
161 i960-*-coff) fmt=coff em=ic960 targ=ic960coff ;;
162 i960-*-nindy*) fmt=bout ;;
163 i960-*-vxworks4*) fmt=bout ;;
164 i960-*-vxworks5.0) fmt=bout ;;
165 i960-*-vxworks5.*) fmt=coff em=ic960 targ=ic960coff ;;
166 i960-*-vxworks*) fmt=bout ;;
168 m68k-*-vxworks* | m68k-ericsson-ose | m68k-*-sunos*)
170 m68k-motorola-sysv*) fmt=coff targ=m68kcoff em=delta ;;
171 m68k-bull-sysv3*) fmt=coff targ=m68kcoff em=dpx2 ;;
172 m68k-apollo-*) fmt=coff targ=apollo em=apollo ;;
173 m68k-*-sysv4 | m68k-*-elf) # must be before -sysv*
175 m68k-*-coff | m68k-*-sysv*)
176 fmt=coff targ=m68kcoff ;;
177 m68k-*-hpux*) fmt=hp300 em=hp300 ;;
178 m68k-*-linux*aout*) fmt=aout em=linux ;;
179 m68k-*-linux*) fmt=elf em=linux ;;
180 m68k-*-lynxos*) fmt=coff targ=m68kcoff
182 m68k-*-netbsd*) fmt=aout em=nbsd bfd_gas=yes ;;
183 m68k-apple-aux*) fmt=coff targ=m68kcoff em=aux ;;
184 m68k-*-psos*) fmt=elf em=psos;;
186 m88k-motorola-sysv3*) fmt=coff targ=m88kcoff em=delt88 ;;
187 m88k-*-coff*) fmt=coff targ=m88kcoff ;;
189 # don't change em like *-*-bsd does
190 mips-dec-netbsd*) fmt=elf targ=mips-lit endian=little ;;
191 mips-dec-bsd*) fmt=aout targ=mips-lit ;;
192 mips-sony-bsd*) fmt=ecoff targ=mips-big ;;
193 mips-*-bsd*) AC_MSG_ERROR(Unknown vendor for mips-bsd configuration.) ;;
194 mips-*-ultrix*) fmt=ecoff targ=mips-lit endian=little ;;
195 mips-*-ecoff*) fmt=ecoff
197 big) targ=mips-big ;;
201 mips-*-ecoff*) fmt=ecoff targ=mips-big ;;
202 mips-*-gnu*) fmt=aout
204 big) targ=mips-big ;;
208 mips-*-irix5*) fmt=elf targ=mips-big ;;
209 mips-*-irix*) fmt=ecoff targ=mips-big ;;
210 mips-*-riscos*) fmt=ecoff targ=mips-big ;;
211 mips-*-sysv*) fmt=ecoff targ=mips-big ;;
214 big) targ=mips-big ;;
218 ppc-*-pe | ppc-*-cygwin32 | ppc-*-winnt*)
225 ppc-*-aix*) fmt=coff ;;
226 ppc-*-elf* | ppc-*-eabi* | ppc-*-sysv4*)
233 ppc-*-macos* | ppc-*-mpw*)
235 ppc-*-netware*) fmt=elf em=ppcnw ;;
237 sh-*-coff) fmt=coff ;;
240 rce-*-aout) fmt=aout ;;
243 ns32k-pc532-mach* | ns32k-pc532-ux*) fmt=aout em=pc532mach ;;
244 ns32k-pc532-netbsd* | ns32k-pc532-lites*) fmt=aout em=nbsd532 ;;
246 sparc-*-sunos4*) fmt=aout em=sun3 ;;
247 sparc-*-aout | sparc*-*-vxworks)
249 sparc-*-coff) fmt=coff ;;
250 sparc-*-lynxos*) fmt=coff em=lynx ;;
251 sparc-fujitsu-none) fmt=aout ;;
252 sparc-*-elf | sparc-*-solaris*)
254 sparc-*-netbsd*) fmt=aout em=nbsd bfd_gas=yes ;;
256 vax-*-bsd* | vax-*-ultrix*)
258 vax-*-vms) fmt=vms ;;
260 z8k-*-coff | z8k-*-sim)
265 *-*-aout | *-*-scout)
271 *-*-generic) fmt=generic ;;
272 *-*-xray | *-*-hms) fmt=coff ;;
274 *-*-elf | *-*-sysv4* | *-*-solaris*)
275 AC_MSG_WARN(GAS support for ${generic_target} is incomplete.)
277 *-*-vxworks) fmt=aout ;;
278 *-*-netware) fmt=elf ;;
281 case ${cpu_type}-${fmt} in
282 arm-*) bfd_gas=yes ;;
284 # i386-aout) bfd_gas=preferred ;;
285 mips-*) bfd_gas=yes ;;
286 ns32k-*) bfd_gas=yes ;;
287 ppc-*) bfd_gas=yes ;;
288 sparc-*) bfd_gas=yes ;;
289 *-elf) bfd_gas=yes ;;
290 *-ecoff) bfd_gas=yes ;;
291 *-som) bfd_gas=yes ;;
295 # Other random stuff.
297 # do we need the opcodes library?
303 if test "${shared}" = "true"; then
304 # A shared libopcodes must be linked against libbfd.
310 test -n "$want_sparc_v9" && AC_DEFINE(SPARC_V9)
312 case ${cpu}-${vendor}-${os} in
313 sparc64-*-elf*) AC_DEFINE(SPARC_ARCH64) ;;
318 case ${extra_objects} in
320 *) extra_objects="$extra_objects m68k-parse.o" ;;
325 # See if we really can support this configuration with the emulation code.
327 if test $this_target = $target ; then
328 primary_bfd_gas=$bfd_gas
333 if test $bfd_gas = no ; then
334 # Can't support other configurations this way.
337 elif test $bfd_gas = no ; then
338 # Can't support this configuration.
342 # From target name and format, produce a list of supported emulations.
344 case ${generic_target}-${fmt} in
345 mips-*-irix5*-*) emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
346 mips-*-*-ecoff) case "$endian" in
347 big) emulation="mipsbecoff mipslecoff mipsecoff" ;;
348 *) emulation="mipslecoff mipsbecoff mipsecoff" ;;
350 mips-*-*-elf) case "$endian" in
351 big) emulation="mipsbelf mipslelf mipself" ;;
352 *) emulation="mipslelf mipsbelf mipself" ;;
356 emulations="$emulations $emulation"
360 # Assign floating point type. Most processors with FP support
361 # IEEE FP. On those that don't support FP at all, usually IEEE
363 case ${target_cpu} in
364 vax | tahoe ) atof=${target_cpu} ;;
368 case "${obj_format}" in
369 "") AC_MSG_ERROR(GAS does not know what format to use for target ${target}) ;;
373 dnl Make sure the desired support files exist.
376 if test ! -r ${srcdir}/config/tc-${target_cpu_type}.c; then
377 AC_MSG_ERROR(GAS does not support target CPU ${target_cpu_type})
380 if test ! -r ${srcdir}/config/obj-${obj_format}.c; then
381 AC_MSG_ERROR(GAS does not have support for object file format ${obj_format})
384 # and target makefile frag
386 target_frag=${srcdir}/config/${gas_target}.mt
387 if test ! -r ${target_frag}; then
388 target_frag=/dev/null # ick! but subst_file can't be conditionalized
390 AC_SUBST_FILE(target_frag)
392 case ${user_bfd_gas}-${primary_bfd_gas} in
394 # We didn't override user's choice.
397 AC_MSG_WARN(Use of BFD is required for ${target}; overriding config options.)
409 # User specified nothing.
413 # Some COFF configurations want these random other flags set.
414 case ${obj_format} in
416 case ${target_cpu_type} in
417 i386) AC_DEFINE(I386COFF) ;;
418 m68k) AC_DEFINE(M68KCOFF) ;;
419 m88k) AC_DEFINE(M88KCOFF) ;;
424 # Getting this done right is going to be a bitch. Each configuration specified
425 # with --enable-targets=... should be checked for environment, format, cpu, and
428 # For each configuration, the necessary object file support code must be linked
429 # in. This might be only one, it might be up to four. The necessary emulation
430 # code needs to be provided, too.
432 # And then there's "--enable-targets=all"....
434 # For now, just always do it for MIPS ELF or ECOFF configurations. Sigh.
436 formats="${obj_format}"
440 for em in . $emulations ; do
444 fmt=elf file=mipself ;;
445 mipsbecoff | mipslecoff)
446 fmt=ecoff file=mipsecoff ;;
448 formats="$formats $fmt"
449 emfiles="$emfiles e-$file.o"
450 EMULATIONS="$EMULATIONS &$em,"
454 if test `set . $formats ; shift ; echo $#` -gt 1 ; then
455 for fmt in $formats ; do
457 aout) AC_DEFINE(OBJ_MAYBE_AOUT) ;;
458 bout) AC_DEFINE(OBJ_MAYBE_BOUT) ;;
459 coff) AC_DEFINE(OBJ_MAYBE_COFF) ;;
460 ecoff) AC_DEFINE(OBJ_MAYBE_ECOFF) ;;
461 elf) AC_DEFINE(OBJ_MAYBE_ELF) ;;
462 generic) AC_DEFINE(OBJ_MAYBE_GENERIC) ;;
463 hp300) AC_DEFINE(OBJ_MAYBE_HP300) ;;
464 ieee) AC_DEFINE(OBJ_MAYBE_IEEE) ;;
465 som) AC_DEFINE(OBJ_MAYBE_SOM) ;;
466 vms) AC_DEFINE(OBJ_MAYBE_VMS) ;;
468 extra_objects="$extra_objects obj-$fmt.o"
472 if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then
474 extra_objects="$extra_objects $emfiles"
475 DEFAULT_EMULATION=`set . $emulations ; echo $2`
476 AC_DEFINE(USE_EMULATIONS)
478 AC_SUBST(extra_objects)
479 AC_DEFINE_UNQUOTED(EMULATIONS, $EMULATIONS)
480 AC_DEFINE_UNQUOTED(DEFAULT_EMULATION, "$DEFAULT_EMULATION")
482 files="config/tc-${target_cpu_type}.c config/tc-${target_cpu_type}.h \
483 config/obj-${obj_format}.h config/obj-${obj_format}.c \
484 config/te-${te_file}.h config/atof-${atof}.c \
486 links="targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c \
489 case ${primary_bfd_gas}-${target_cpu_type}-${obj_format} in
490 yes-*-coff) need_bfd=yes ;;
491 no-*-coff) need_bfd=yes
492 AC_DEFINE(MANY_SEGMENTS) ;;
495 reject_dev_configs=yes
497 case ${reject_dev_configs}-${dev} in
499 AC_MSG_ERROR(GAS does not support the ${generic_target} configuration.)
503 AC_SUBST(target_cpu_type)
506 dnl AC_SUBST(emulation)
508 AC_LINK_FILES($files, $links)
510 case "${primary_bfd_gas}" in
511 yes) AC_DEFINE(BFD_ASSEMBLER)
515 # do we need the opcodes library?
516 case "${need_opcodes}" in
518 OPCODES_DEP=../opcodes/libopcodes.a
519 OPCODES_LIB='-L../opcodes -lopcodes'
521 # We need to handle some special cases if opcodes was built shared.
522 if test "${shared}" = "true"; then
525 # On SunOS, we must link against the name we are going to install,
526 # not -lbfd, since SunOS does not support SONAME.
527 OPCODES_LIB='-L../opcodes -l`echo opcodes | sed '"'"'$(program_transform_name)'"'"'`'
533 AC_SUBST(OPCODES_DEP)
534 AC_SUBST(OPCODES_LIB)
536 case "${need_bfd}" in
538 BFDDEP=../bfd/libbfd.a
539 BFDLIB='-L../bfd -lbfd'
540 ALL_OBJ_DEPS="$ALL_OBJ_DEPS ../bfd/bfd.h"
542 # We need to handle some special cases if BFD was built shared.
543 if test "${shared}" = "true"; then
546 # On SunOS, we must link against the name we are going to install,
547 # not -lbfd, since SunOS does not support SONAME.
548 BFDLIB='-L../bfd -l`echo bfd | sed '"'"'$(program_transform_name)'"'"'`'
556 AC_SUBST(ALL_OBJ_DEPS)
558 AC_DEFINE_UNQUOTED(TARGET_ALIAS, "${target_alias}")
559 AC_DEFINE_UNQUOTED(TARGET_CANONICAL, "${target}")
560 AC_DEFINE_UNQUOTED(TARGET_CPU, "${target_cpu}")
561 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "${target_vendor}")
562 AC_DEFINE_UNQUOTED(TARGET_OS, "${target_os}")
567 AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h errno.h sys/types.h)
569 # Put this here so that autoconf's "cross-compiling" message doesn't confuse
570 # people who are not cross-compiling but are compiling cross-assemblers.
571 AC_MSG_CHECKING(whether compiling a cross-assembler)
572 if test "${host}" = "${target}"; then
576 AC_DEFINE(CROSS_COMPILE)
578 AC_MSG_RESULT($cross_gas)
580 dnl ansidecl.h will deal with const
585 # VMS doesn't have unlink.
586 AC_CHECK_FUNCS(unlink remove, break)
588 # Some systems don't have sbrk().
591 # Some non-ANSI preprocessors botch requoting inside strings. That's bad
592 # enough, but on some of those systems, the assert macro relies on requoting
596 # On some systems, the system header files may not declare malloc, realloc,
597 # and free. There are places where gas needs these functions to have been
598 # declared -- such as when taking their addresses.
613 GAS_CHECK_DECL_NEEDED(malloc, f, char *(*f)(), $gas_test_headers)
614 GAS_CHECK_DECL_NEEDED(free, f, void (*f)(), $gas_test_headers)
616 # Does errno.h declare errno, or do we have to add a separate declaration
618 GAS_CHECK_DECL_NEEDED(errno, f, int f, [
625 RPATH_ENVVAR=LD_LIBRARY_PATH
626 # If we have shared libraries, try to set rpath reasonably.
627 if test "${shared}" = "true"; then
630 HLDFLAGS='-Wl,+s,+b,$(libdir)'
631 RPATH_ENVVAR=SHLIB_PATH
634 HLDFLAGS='-Wl,-rpath,$(libdir)'
639 HLDFLAGS='-Wl,-rpath,$(libdir)'
641 *-*-sysv4* | *-*-solaris*)
642 HLDFLAGS='-R $(libdir)'
647 # On SunOS, if the linker supports the -rpath option, use it to
648 # prevent ../bfd and ../opcodes from being included in the run time
652 echo 'main () { }' > conftest.c
653 ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
654 if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
656 elif grep 'No such file' conftest.t >/dev/null 2>&1; then
658 elif grep 'do not mix' conftest.t >/dev/null 2>&1; then
660 elif test "${shared}" = "true"; then
661 HLDFLAGS='-Wl,-rpath=$(libdir)'
663 HLDFLAGS='-Wl,-rpath='
665 rm -f conftest.t conftest.c conftest
669 AC_SUBST(RPATH_ENVVAR)
671 dnl This must come last.
672 AC_OUTPUT(Makefile doc/Makefile .gdbinit:gdbinit.in)