245b84788d62425244df59c859088ca7cda0c2c3
[binutils-gdb.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 AC_PREREQ(2.3)dnl We only need 2.0, but pre-2.3 loses on some AIX version.
8 AC_INIT(as.h)dnl
9 dnl
10 user_bfd_gas=
11 AC_ARG_ENABLE(bfd-assembler,
12 [ 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) ;;
17 esac])dnl
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')
22 ;;
23 no) enable_targets= ;;
24 *) enable_targets=$enableval ;;
25 esac])dnl
26
27 # Generate a header file -- gets more post-processing by Makefile later.
28 AC_CONFIG_HEADER(conf)
29
30 dnl For recursion to work right, this must be an absolute pathname.
31 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
32 AC_CANONICAL_SYSTEM
33 AC_ARG_PROGRAM
34
35 te_file=generic
36
37 # assign cpu type
38
39 # check for architecture variants
40 case ${target_cpu} in
41 armeb) cpu_type=arm endian=big ;;
42 arm*) cpu_tpye=arm endian=little ;;
43 hppa*) cpu_type=hppa ;;
44 changequote(,)dnl
45 i[45]86) cpu_type=i386 ;;
46 m680[012346]0) cpu_type=m68k ;;
47 m68008) cpu_type=m68k ;;
48 m683??) cpu_type=m68k ;;
49 changequote([,])dnl
50 m8*) cpu_type=m88k ;;
51 mips*el) cpu_type=mips endian=little;;
52 mips*) cpu_type=mips endian=big ;;
53 powerpcle*) cpu_type=ppc endian=little ;;
54 powerpc*) cpu_type=ppc endian=big ;;
55 rs6000*) cpu_type=ppc ;;
56 sparc64) cpu_type=sparc obj_format=elf
57 AC_DEFINE(sparcv9) ;;
58 sparclite*) cpu_type=sparc ;;
59 *) cpu_type=${target_cpu} ;;
60 esac
61
62 # do we need the opcodes library?
63 case ${cpu_type} in
64 alpha | vax)
65 ;;
66 *)
67 OPCODES_LIB="../opcodes/libopcodes.a"
68 ;;
69 esac
70 AC_SUBST(OPCODES_LIB)
71
72 gas_target=${cpu_type}
73 this_target=${generic_target}
74
75 canon_targets=""
76 if test -n "$enable_targets" ; then
77 for t in `echo $enable_targets | sed 's/,/ /g'`; do
78 result=`$ac_config_sub $t 2>/dev/null`
79 if test -n "$result" ; then
80 canon_targets="$canon_targets $result"
81 # else
82 # # Permit "all", etc. We don't support it yet though.
83 # canon_targets="$canon_targets $t"
84 fi
85 done
86 GAS_UNIQ(canon_targets)
87 fi
88
89 emulations=""
90
91 for this_target in $target $canon_targets ; do
92
93 eval `echo $this_target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/'`
94
95 # check for architecture variants
96 case ${cpu} in
97 hppa*) cpu_type=hppa ;;
98 changequote(,)dnl
99 i[45]86) cpu_type=i386 ;;
100 m680[012346]0) cpu_type=m68k ;;
101 m68008) cpu_type=m68k ;;
102 m683??) cpu_type=m68k ;;
103 changequote([,])dnl
104 m8*) cpu_type=m88k ;;
105 mips*el) cpu_type=mips endian=little;;
106 mips*) cpu_type=mips endian=big ;;
107 powerpcle*) cpu_type=ppc endian=little ;;
108 powerpc*) cpu_type=ppc endian=big ;;
109 rs6000*) cpu_type=ppc ;;
110 sparc64) cpu_type=sparc obj_format=elf want_sparcv9=true ;;
111 sparclite*) cpu_type=sparc ;;
112 *) cpu_type=${target_cpu} ;;
113 esac
114
115 if test ${this_target} = $target ; then
116 target_cpu_type=${cpu_type}
117 elif test ${target_cpu_type} != ${cpu_type} ; then
118 continue
119 fi
120
121 targ=${cpu_type}
122 generic_target=${cpu_type}-$vendor-$os
123 dev=no
124 bfd_gas=no
125 em=generic
126
127 # assign object format
128 case ${generic_target} in
129 a29k-amd-udi) fmt=coff targ=ebmon29k ;;
130 a29k-amd-ebmon) fmt=coff targ=ebmon29k ;;
131 a29k-*-vxworks*) fmt=coff ;;
132
133 alpha-*-netware*) fmt=ecoff ;;
134 alpha-*-osf*) fmt=ecoff ;;
135
136 # start-sanitize-arc
137 arc-*-elf*) fmt=elf bfd_gas=yes ;;
138 # end-sanitize-arc
139
140 arm-*-riscix*) fmt=aout targ=arm-lit
141 emulation=riscix ;;
142 arm-*-aout) fmt=aout
143 case "$endian" in
144 big) targ=arm-big ;;
145 *) targ=arm-lit ;;
146 esac
147 ;;
148 arm-*-riscix*) fmt=aout ;;
149 arm-*-pe) fmt=coff targ=armcoff em=pe ;;
150
151 hppa-*-*elf*) fmt=elf em=hppa ;;
152 hppa-*-lites*) fmt=elf em=hppa ;;
153 hppa-*-osf*) fmt=som em=hppa ;;
154 hppa-*-hpux*) fmt=som em=hppa ;;
155 hppa-*-bsd*) fmt=som em=hppa ;;
156 hppa-*-hiux*) fmt=som em=hppa ;;
157
158 h8300-*-coff) fmt=coff ;;
159
160 i386-ibm-aix*) fmt=coff targ=i386coff
161 em=i386aix ;;
162 i386-*-bsd*) fmt=aout em=386bsd ;;
163 i386-*-netbsd0.8) fmt=aout em=386bsd ;;
164 i386-*-netbsd*) fmt=aout em=nbsd bfd_gas=yes;;
165 i386-*-linux*aout*) fmt=aout em=linux ;;
166 i386-*-linux*coff*) fmt=coff em=linux
167 targ=i386coff ;;
168 i386-*-linux*) fmt=elf em=linux ;;
169 i386-*-lynxos*) fmt=coff targ=i386coff
170 em=lynx ;;
171 i386-*-sysv4* | i386-*-solaris* | i386-*-elf)
172 fmt=elf ;;
173 i386-*-coff | i386-*-sysv* | i386-*-sco* | i386-*-isc*)
174 fmt=coff targ=i386coff ;;
175 i386-*-vsta) fmt=aout ;;
176 i386-*-go32) fmt=coff targ=i386coff ;;
177 i386-*-gnu*) fmt=elf ;;
178 i386-*-mach*)
179 fmt=aout em=mach bfd_gas=yes ;;
180 i386-*-msdos*) fmt=aout ;;
181 i386-*-moss*) fmt=elf ;;
182 i386-*-pe) fmt=coff targ=i386coff em=pe ;;
183 i386-*-win32) fmt=coff targ=i386coff em=pe ;;
184 i386-*-*nt) fmt=coff targ=i386coff em=pe ;;
185 i960-*-bout) fmt=bout ;;
186 i960-*-coff) fmt=coff em=ic960 targ=ic960coff ;;
187 i960-*-nindy*) fmt=bout ;;
188 i960-*-vxworks4*) fmt=bout ;;
189 i960-*-vxworks5.0) fmt=bout ;;
190 i960-*-vxworks5.*) fmt=coff em=ic960 targ=ic960coff ;;
191 i960-*-vxworks*) fmt=bout ;;
192
193 m68k-*-vxworks* | m68k-ericsson-ose | m68k-*-sunos*)
194 fmt=aout em=sun3 ;;
195 m68k-motorola-sysv) fmt=coff targ=m68kcoff em=delta ;;
196 m68k-bull-sysv3*) fmt=coff targ=m68kcoff em=dpx2 ;;
197 m68k-apollo-*) fmt=coff targ=apollo em=apollo ;;
198 m68k-*-coff | m68k-*-sysv*)
199 fmt=coff targ=m68kcoff ;;
200 m68k-*-elf) fmt=elf ;;
201 m68k-*-hpux*) fmt=hp300 em=hp300 ;;
202 m68k-*-lynxos*) fmt=coff targ=m68kcoff
203 em=lynx ;;
204 m68k-*-netbsd*) fmt=aout em=nbsd bfd_gas=yes ;;
205
206 m88k-*-coff*) fmt=coff targ=m88kcoff ;;
207
208 # don't change em like *-*-bsd does
209 mips-dec-bsd*) fmt=aout targ=mips-lit ;;
210 mips-sony-bsd*) fmt=ecoff targ=mips-big ;;
211 mips-*-bsd*) AC_MSG_ERROR(Unknown vendor for mips-bsd configuration.) ;;
212 mips-*-ultrix*) fmt=ecoff targ=mips-lit ;;
213 mips-*-ecoff*) fmt=ecoff
214 case "$endian" in
215 big) targ=mips-big ;;
216 *) targ=mips-lit ;;
217 esac
218 ;;
219 mips-*-ecoff*) fmt=ecoff targ=mips-big ;;
220 mips-*-gnu*) fmt=aout
221 case "$endian" in
222 big) targ=mips-big ;;
223 *) targ=mips-lit ;;
224 esac
225 ;;
226 mips-*-irix5*) fmt=elf targ=mips-big ;;
227 mips-*-irix*) fmt=ecoff targ=mips-big ;;
228 mips-*-riscos*) fmt=ecoff targ=mips-big ;;
229 mips-*-sysv*) fmt=ecoff targ=mips-big ;;
230 mips-*-elf*) fmt=elf
231 case "$endian" in
232 big) targ=mips-big ;;
233 *) targ=mips-lit ;;
234 esac
235 ;;
236 ppc-*-aix*) fmt=coff ;;
237 ppc-*-elf* | ppc-*-eabi* | ppc-*-sysv4*)
238 fmt=elf
239 case "$endian" in
240 big) targ=ppc-big ;;
241 *) targ=ppc-lit ;;
242 esac
243 ;;
244 ppc-*-netware*) fmt=elf em=ppcnw ;;
245
246 sh-*-coff) fmt=coff ;;
247
248 # start-sanitize-rce
249 rce-*-aout) fmt=aout ;;
250 # end-sanitize-rce
251
252 ns32k-pc532-mach*) fmt=aout em=pc532mach ;;
253 ns32k-pc532-netbsd*) fmt=aout em=nbsd532 ;;
254
255 sparc-*-sunos4*) fmt=aout em=sun3 ;;
256 sparc-*-aout | sparc*-*-vxworks)
257 fmt=aout ;;
258 sparc-*-coff) fmt=coff ;;
259 sparc-*-lynxos*) fmt=coff em=lynx ;;
260 sparc-fujitsu-none) fmt=aout ;;
261 sparc-*-elf | sparc*-*-solaris*)
262 fmt=elf ;;
263 sparc-*-netbsd*) fmt=aout em=nbsd bfd_gas=yes ;;
264
265 vax-*-bsd* | vax-*-ultrix*)
266 fmt=aout ;;
267 vax-*-vms) fmt=vms ;;
268
269 z8k-*-coff | z8k-*-sim)
270 fmt=coff ;;
271
272 w65-*-*) fmt=coff ;;
273
274 *-*-aout | *-*-scout)
275 fmt=aout ;;
276 *-*-nindy*)
277 fmt=bout ;;
278 *-*-bsd*)
279 fmt=aout em=sun3 ;;
280 *-*-generic) fmt=generic ;;
281 *-*-xray | *-*-hms) fmt=coff ;;
282 *-*-sim) fmt=coff ;;
283 *-*-elf | *-*-sysv4* | *-*-solaris*)
284 AC_MSG_WARN(GAS support for ELF format is incomplete.)
285 fmt=elf dev=yes ;;
286 *-*-vxworks) fmt=aout ;;
287 *-*-netware) fmt=elf ;;
288 esac
289
290 case ${cpu_type}-${fmt} in
291 arm-*) bfd_gas=yes ;;
292 # not yet
293 # i386-aout) bfd_gas=preferred ;;
294 mips-*) bfd_gas=yes ;;
295 ns32k-*) bfd_gas=yes ;;
296 ppc-*) bfd_gas=yes ;;
297 sparc-*) bfd_gas=yes ;;
298 *-elf) bfd_gas=yes ;;
299 *-ecoff) bfd_gas=yes ;;
300 *-som) bfd_gas=yes ;;
301 *) ;;
302 esac
303
304 # See if we really can support this configuration with the emulation code.
305
306 if test $this_target = $target ; then
307 primary_bfd_gas=$bfd_gas
308 obj_format=$fmt
309 gas_target=$targ
310 te_file=$em
311
312 if test $bfd_gas = no ; then
313 # Can't support other configurations this way.
314 break
315 fi
316 elif test $bfd_gas = no ; then
317 # Can't support this configuration.
318 break
319 fi
320
321 # From target name and format, produce a list of supported emulations.
322
323 case ${generic_target}-${fmt} in
324 mips-*-irix5*-*) emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
325 mips-*-*-ecoff) case "$endian" in
326 big) emulation="mipsbecoff mipslecoff mipsecoff" ;;
327 *) emulation="mipslecoff mipsbecoff mipsecoff" ;;
328 esac ;;
329 mips-*-*-elf) case "$endian" in
330 big) emulation="mipsbelf mipslelf mipself" ;;
331 *) emulation="mipslelf mipsbelf mipself" ;;
332 esac ;;
333 esac
334
335 emulations="$emulations $emulation"
336
337 # Other random stuff.
338
339 test -n "$want_sparcv9" && AC_DEFINE(sparcv9)
340
341 done
342
343 # Assign floating point type. Most processors with FP support
344 # IEEE FP. On those that don't support FP at all, usually IEEE
345 # is emulated.
346 case ${target_cpu} in
347 vax | tahoe ) atof=${target_cpu} ;;
348 *) atof=ieee ;;
349 esac
350
351 case "${obj_format}" in
352 "") AC_MSG_ERROR(GAS does not know what format to use for target ${target}) ;;
353 esac
354
355 dnl
356 dnl Make sure the desired support files exist.
357 dnl
358
359 if test ! -r ${srcdir}/config/tc-${cpu_type}.c; then
360 AC_MSG_ERROR(GAS does not support target CPU ${cpu_type})
361 fi
362
363 if test ! -r ${srcdir}/config/obj-${obj_format}.c; then
364 AC_MSG_ERROR(GAS does not have support for object file format ${obj_format})
365 fi
366
367 # and target makefile frag
368
369 target_frag=${srcdir}/config/${gas_target}.mt
370 if test ! -r ${target_frag}; then
371 target_frag=/dev/null # ick! but subst_file can't be conditionalized
372 fi
373 AC_SUBST_FILE(target_frag)
374
375 case ${user_bfd_gas}-${primary_bfd_gas} in
376 yes-yes | no-no)
377 # We didn't override user's choice.
378 ;;
379 no-yes)
380 AC_MSG_WARN(Use of BFD is required for ${target}; overriding config options.)
381 ;;
382 no-preferred)
383 primary_bfd_gas=no
384 ;;
385 *-preferred)
386 primary_bfd_gas=yes
387 ;;
388 yes-*)
389 primary_bfd_gas=yes
390 ;;
391 -*)
392 # User specified nothing.
393 ;;
394 esac
395
396 # Some COFF configurations want these random other flags set.
397 case ${obj_format} in
398 coff)
399 case ${target_cpu_type} in
400 i386) AC_DEFINE(I386COFF) ;;
401 m68k) AC_DEFINE(M68KCOFF) ;;
402 m88k) AC_DEFINE(M88KCOFF) ;;
403 esac
404 ;;
405 esac
406
407 # Getting this done right is going to be a bitch. Each configuration specified
408 # with --enable-targets=... should be checked for environment, format, cpu, and
409 # bfd_gas setting.
410 #
411 # For each configuration, the necessary object file support code must be linked
412 # in. This might be only one, it might be up to four. The necessary emulation
413 # code needs to be provided, too.
414 #
415 # And then there's "--enable-targets=all"....
416 #
417 # For now, just always do it for MIPS ELF or ECOFF configurations. Sigh.
418
419 formats="${obj_format}"
420 emfiles=""
421 EMULATIONS=""
422 GAS_UNIQ(emulations)
423 for em in . $emulations ; do
424 case $em in
425 .) continue ;;
426 mipsbelf | mipslelf)
427 fmt=elf file=mipself ;;
428 mipsbecoff | mipslecoff)
429 fmt=ecoff file=mipsecoff ;;
430 esac
431 formats="$formats $fmt"
432 emfiles="$emfiles e-$file.o"
433 EMULATIONS="$EMULATIONS &$em,"
434 done
435 GAS_UNIQ(formats)
436 GAS_UNIQ(emfiles)
437 if test `set . $formats ; shift ; echo $#` -gt 1 ; then
438 for fmt in $formats ; do
439 case $fmt in
440 aout) AC_DEFINE(OBJ_MAYBE_AOUT) ;;
441 bout) AC_DEFINE(OBJ_MAYBE_BOUT) ;;
442 coff) AC_DEFINE(OBJ_MAYBE_COFF) ;;
443 ecoff) AC_DEFINE(OBJ_MAYBE_ECOFF) ;;
444 elf) AC_DEFINE(OBJ_MAYBE_ELF) ;;
445 generic) AC_DEFINE(OBJ_MAYBE_GENERIC) ;;
446 hp300) AC_DEFINE(OBJ_MAYBE_HP300) ;;
447 ieee) AC_DEFINE(OBJ_MAYBE_IEEE) ;;
448 som) AC_DEFINE(OBJ_MAYBE_SOM) ;;
449 vms) AC_DEFINE(OBJ_MAYBE_VMS) ;;
450 esac
451 extra_objects="$extra_objects obj-$fmt.o"
452 done
453 obj_format=multi
454 fi
455 if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then
456 te_file=multi
457 extra_objects="$extra_objects $emfiles"
458 DEFAULT_EMULATION=`set . $emulations ; echo $2`
459 AC_DEFINE(USE_EMULATIONS)
460 fi
461 AC_SUBST(extra_objects)
462 AC_DEFINE_UNQUOTED(EMULATIONS, $EMULATIONS)
463 AC_DEFINE_UNQUOTED(DEFAULT_EMULATION, "$DEFAULT_EMULATION")
464
465 files="config/tc-${cpu_type}.c config/tc-${cpu_type}.h \
466 config/obj-${obj_format}.h config/obj-${obj_format}.c \
467 config/te-${te_file}.h config/atof-${atof}.c \
468 $extra_files"
469 links="targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c \
470 $extra_links"
471
472 case ${primary_bfd_gas}-${cpu_type}-${obj_format} in
473 yes-*-coff) need_bfd=yes ;;
474 no-*-coff) need_bfd=yes
475 AC_DEFINE(MANY_SEGMENTS) ;;
476 esac
477
478 reject_dev_configs=yes
479
480 case ${reject_dev_configs}-${dev} in
481 yes-yes) # Oops.
482 AC_MSG_ERROR(GAS does not support the ${generic_target} configuration.)
483 ;;
484 esac
485
486 AC_SUBST(cpu_type)
487 AC_SUBST(obj_format)
488 AC_SUBST(atof)
489 dnl AC_SUBST(emulation)
490
491 AC_LINK_FILES($files, $links)
492
493 case "${primary_bfd_gas}" in
494 yes) AC_DEFINE(BFD_ASSEMBLER)
495 need_bfd=yes ;;
496 esac
497
498 case "${need_bfd}" in
499 yes) BFDLIB=../bfd/libbfd.a
500 ALL_OBJ_DEPS="$ALL_OBJ_DEPS ../bfd/bfd.h"
501 ;;
502 esac
503 AC_SUBST(BFDLIB)
504 AC_SUBST(ALL_OBJ_DEPS)
505
506 AC_DEFINE_UNQUOTED(TARGET_ALIAS, "${target_alias}")
507 AC_DEFINE_UNQUOTED(TARGET_CANONICAL, "${target}")
508 AC_DEFINE_UNQUOTED(TARGET_CPU, "${target_cpu}")
509 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "${target_vendor}")
510 AC_DEFINE_UNQUOTED(TARGET_OS, "${target_os}")
511
512 AC_PROG_CC
513 AC_PROG_INSTALL
514
515 AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h errno.h sys/types.h)
516
517 # Put this here so that autoconf's "cross-compiling" message doesn't confuse
518 # people who are not cross-compiling but are compiling cross-assemblers.
519 AC_MSG_CHECKING(whether compiling a cross-assembler)
520 if test "${host}" = "${target}"; then
521 cross_gas=no
522 else
523 cross_gas=yes
524 AC_DEFINE(CROSS_COMPILE)
525 fi
526 AC_MSG_RESULT($cross_gas)
527
528 dnl ansidecl.h will deal with const
529 dnl AC_CONST
530 AC_FUNC_ALLOCA
531 AC_C_INLINE
532
533 # VMS doesn't have unlink.
534 AC_CHECK_FUNCS(unlink remove, break)
535
536 # Some systems don't have sbrk().
537 AC_CHECK_FUNCS(sbrk)
538
539 # Some non-ANSI preprocessors botch requoting inside strings. That's bad
540 # enough, but on some of those systems, the assert macro relies on requoting
541 # working properly!
542 GAS_WORKING_ASSERT
543
544 # On some systems, the system header files may not declare malloc, realloc,
545 # and free. There are places where gas needs these functions to have been
546 # declared -- such as when taking their addresses.
547 gas_test_headers="
548 #ifdef HAVE_MEMORY_H
549 #include <memory.h>
550 #endif
551 #ifdef HAVE_STRING_H
552 #include <string.h>
553 #endif
554 #ifdef HAVE_STDLIB_H
555 #include <stdlib.h>
556 #endif
557 #ifdef HAVE_UNISTD_H
558 #include <unistd.h>
559 #endif
560 "
561 GAS_CHECK_DECL_NEEDED(malloc, f, char *(*f)(), $gas_test_headers)
562 GAS_CHECK_DECL_NEEDED(free, f, int f, $gas_test_headers)
563
564 # Does errno.h declare errno, or do we have to add a separate declaration
565 # for it?
566 GAS_CHECK_DECL_NEEDED(errno, f, int f, [
567 #ifdef HAVE_ERRNO_H
568 #include <errno.h>
569 #endif
570 ])
571
572 AC_CONFIG_SUBDIRS(testsuite)
573
574 dnl This must come last.
575 AC_OUTPUT(Makefile doc/Makefile .gdbinit:gdbinit.in)