914e8d1521466895bf5b8f6f613b828d3bf86720
[external/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 Remember to use "dnl" in each line before the AC_INIT call...
7 dnl
8 dnl
9 AC_INIT(as.h)
10 dnl
11 bfd_gas=no
12 AC_ARG_ENABLE(bfd-assembler,
13 [    bfd-assembler      use BFD back end for writing object files],
14 [case "${enableval}" in
15   yes) need_bfd=yes bfd_gas=yes ;;
16   no)  ;;
17   *)   AC_MSG_ERROR(bad value ${enableval} given for bfd-assembler option) ;;
18 esac])dnl
19
20 # Generate a header file -- gets more post-processing by Makefile later.
21 AC_CONFIG_HEADER(conf)
22
23 dnl For recursion to work right, this must be an absolute pathname.
24 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
25 AC_CANONICAL_SYSTEM
26
27 emulation=generic
28
29 # assign cpu type
30
31 # check for architecture variants
32 case ${target_cpu} in
33   hppa*)        cpu_type=hppa ;;
34 changequote(,)dnl
35   i[45]86)      cpu_type=i386 ;;
36   m680[012346]0) cpu_type=m68k ;;
37   m68008)       cpu_type=m68k ;;
38   m683??)       cpu_type=m68k ;;
39 changequote([,])dnl
40   m8*)          cpu_type=m88k ;;
41   mips*el)      cpu_type=mips endian=little;;
42   mips*)        cpu_type=mips endian=big ;;
43   powerpc*)     cpu_type=ppc ;;
44   rs6000*)      cpu_type=ppc ;;
45   sparc64)      cpu_type=sparc obj_format=elf AC_DEFINE(sparcv9) ;;
46   sparclite*)   cpu_type=sparc ;;
47   *)            cpu_type=${target_cpu} ;;
48 esac
49
50 # do we need the opcodes library?
51 case ${cpu_type} in
52   alpha | vax)
53     ;;
54   *)
55     OPCODES_LIB="../opcodes/libopcodes.a"
56     ;;
57 esac
58 AC_SUBST(OPCODES_LIB)
59
60 gas_target=${cpu_type}
61 generic_target=${cpu_type}-${target_vendor}-${target_os}
62 dev=no
63
64 # assign object format
65 case ${generic_target} in
66   a29k-amd-udi)         obj_format=coff gas_target=ebmon29k ;;
67   a29k-amd-ebmon)       obj_format=coff gas_target=ebmon29k ;;
68
69   alpha-*-netware*)     obj_format=ecoff ;;
70   alpha-*-osf*)         obj_format=ecoff ;;
71
72   hppa-*-*elf*)         obj_format=elf emulation=hppa ;;
73   hppa-*-osf*)          obj_format=som emulation=hppa ;;
74   hppa-*-hpux*)         obj_format=som emulation=hppa ;;
75   hppa-*-bsd*)          obj_format=som emulation=hppa ;;
76   hppa-*-hiux*)         obj_format=som emulation=hppa ;;
77
78   h8300-*-coff)         obj_format=coff ;;
79
80   i386-ibm-aix*)        obj_format=coff gas_target=i386coff
81                          emulation=i386aix ;;
82   i386-*-bsd*)          obj_format=aout emulation=386bsd ;;
83   i386-*-netbsd0.8)     obj_format=aout emulation=386bsd ;;
84   i386-*-netbsd*)       obj_format=aout emulation=netbsd ;;
85   i386-*-linux*elf*)    obj_format=elf  emulation=linux ;;
86   i386-*-linux*coff*)   obj_format=coff emulation=linux
87                          gas_target=i386coff ;;
88   i386-*-linux*)        obj_format=aout emulation=linux ;;
89   i386-*-lynxos*)       obj_format=coff gas_target=i386coff
90                          emulation=lynx ;;
91   i386-*-sysv4* | i386-*-solaris* | i386-*-elf)
92                         obj_format=elf ;;
93   i386-*-coff | i386-*-sysv* | i386-*-sco* | i386-*-isc*)
94                         obj_format=coff gas_target=i386coff ;;
95   i386-*-vsta)          obj_format=aout ;;
96   i386-*-go32)          obj_format=coff gas_target=i386coff ;;
97   i386-*-mach* | i386-*-gnu*)
98                         obj_format=aout emulation=mach bfd_gas=yes ;;
99
100   i960-*-bout)          obj_format=bout ;;
101   i960-*-coff)          obj_format=coff emulation=ic960 gas_target=ic960coff ;;
102   i960-*-nindy*)        obj_format=bout ;;
103   i960-*-vxworks4*)     obj_format=bout ;;
104   i960-*-vxworks5.0)    obj_format=bout ;;
105   i960-*-vxworks5.*)    obj_format=coff emulation=ic960 gas_target=ic960coff ;;
106   i960-*-vxworks*)      obj_format=bout ;;
107
108   m68k-wrs-vxworks | m68k-ericsson-ose | m68k-*-sunos*)
109                         obj_format=aout emulation=sun3 ;;
110   m68k-motorola-sysv)   obj_format=coff gas_target=m68kcoff emulation=delta ;;
111   m68k-bull-sysv3*)     obj_format=coff gas_target=m68kcoff emulation=dpx2 ;;
112   m68k-apollo-*)        obj_format=coff gas_target=apollo emulation=apollo ;;
113   m68k-*-coff | m68k-*-sysv*)
114                         obj_format=coff gas_target=m68kcoff ;;
115   m68k-*-hpux)          obj_format=hp300 emulation=hp300 ;;
116   m68k-*-lynxos*)       obj_format=coff gas_target=m68kcoff
117                          emulation=lynx ;;
118
119   m88k-*-coff*)         obj_format=coff gas_target=m88kcoff ;;
120
121   # don't change emulation like *-*-bsd does
122   mips-*-bsd*)          bfd_gas=yes obj_format=aout gas_target=mips-lit ;;
123   mips-*-ultrix*)       obj_format=ecoff gas_target=mips-lit ;;
124   mips-*-ecoff*)        obj_format=ecoff 
125                         case "$endian" in
126                         big) gas_target=mips-big ;;
127                         *)   gas_target=mips-lit ;;
128                         esac
129                         ;;
130   mips-*-ecoff*)        obj_format=ecoff gas_target=mips-big ;;
131   mips-*-irix5*)        obj_format=elf gas_target=mips-big ;;
132   mips-*-irix*)         obj_format=ecoff gas_target=mips-big ;;
133   mips-*-riscos*)       obj_format=ecoff gas_target=mips-big ;;
134   mips-*-sysv*)         obj_format=ecoff gas_target=mips-big ;;
135   mips-*-elf*)          obj_format=elf 
136                         case "$endian" in
137                         big) gas_target=mips-big ;;
138                         *)   gas_target=mips-lit ;;
139                         esac
140                         ;;
141   ppc-*-aix*)           obj_format=coff bfd_gas=yes ;;
142   ppc-*-elf*)           obj_format=elf bfd_gas=yes ;;
143   ppc-*-netware*)       obj_format=elf emulation=ppcnw ;;
144   ppc-*-sysv4*)         obj_format=elf bfd_gas=yes ;;
145
146   sh-*-coff)            obj_format=coff ;;
147
148   ns32k-pc532-mach*)    obj_format=aout emulation=pc532 bfd_gas=yes ;;
149   ns32k-pc532-netbsd*)  obj_format=aout emulation=netbsd532 bfd_gas=yes ;;
150
151   sparc*-*-sunos4*)     obj_format=aout emulation=sun3 bfd_gas=yes ;;
152   sparc*-*-aout | sparc*-*-vxworks)
153                         obj_format=aout bfd_gas=yes ;;
154   sparc*-*-coff)        obj_format=coff bfd_gas=yes ;;
155   sparc*-*-lynxos*)     obj_format=coff bfd_gas=yes emulation=lynx ;;
156   sparc*-fujitsu-none)  obj_format=aout bfd_gas=yes ;;
157   sparc*-*-elf | sparc*-*-solaris*)
158                         obj_format=elf ;;
159
160   vax-*-bsd* | vax-*-ultrix*)
161                         obj_format=aout ;;
162   vax-*-vms)            obj_format=vms ;;
163
164   z8k-*-coff | z8k-*-sim)
165                         obj_format=coff ;;
166
167   *-*-aout | *-*-scout)
168                         obj_format=aout ;;
169   *-*-nindy*)
170                         obj_format=bout ;;
171   *-*-bsd*)
172                         obj_format=aout emulation=sun3 ;;
173   *-*-generic)          obj_format=generic ;;
174   *-*-xray | *-*-hms)   obj_format=coff ;;
175   *-*-sim)              obj_format=coff ;;
176   *-*-elf | *-*-sysv4* | *-*-solaris*)
177                         AC_MSG_WARN(GAS support for ELF format is incomplete)
178                         obj_format=elf dev=yes ;;
179   *-*-vxworks)          obj_format=aout ;;
180   *-*-netware)          obj_format=elf ;;
181 esac
182
183 # Assign floating point type.  Most processors with FP support
184 # IEEE FP.  On those that don't support FP at all, usually IEEE
185 # is emulated.
186 case ${target_cpu} in
187   vax | tahoe ) atof=${target_cpu} ;;
188   *)                    atof=ieee ;;
189 esac
190
191 case "${obj_format}" in
192   "") AC_MSG_ERROR(GAS does not know what format to use for target ${target}) ;;
193 esac
194
195 dnl
196 dnl Make sure the desired support files exist.
197 dnl
198
199 if test ! -r ${srcdir}/config/tc-${cpu_type}.c; then
200   AC_MSG_ERROR(GAS does not support target CPU ${cpu_type})
201 fi
202
203 if test ! -r ${srcdir}/config/obj-${obj_format}.c; then
204   AC_MSG_ERROR(GAS does not have support for object file format ${obj_format})
205 fi
206
207 # and target makefile frag
208
209 target_frag=${srcdir}/config/${gas_target}.mt
210 AC_SUBST_FILE(target_frag)
211
212 case ${bfd_gas}-${obj_format} in
213   yes-coff)     need_bfd=yes ;;
214   no-coff)      need_bfd=yes
215                 AC_DEFINE(MANY_SEGMENTS) ;;
216   *-elf)        bfd_gas=yes ;;
217   *-ecoff)      bfd_gas=yes ;;
218   *-som)        bfd_gas=yes ;;
219   *)            ;;
220 esac
221
222 case ${with_bfd_assembler}-${bfd_gas} in
223   yes-yes | no-no)
224     # We didn't override user's choice.
225     ;;
226   no-yes)
227     AC_MSG_WARN(Use of BFD is required for ${target}; overriding config options.)
228     ;;
229   no-preferred)
230     bfd_gas=no
231     ;;
232   *-preferred)
233     bfd_gas=yes
234     ;;
235   -*)
236     # User specified nothing.
237     ;;
238 esac
239
240 reject_dev_configs=yes
241
242 case ${reject_dev_configs}-${dev} in
243   yes-yes) # Oops.
244     AC_MSG_ERROR(GAS does not support the ${generic_target} configuration.)
245     ;;
246 esac
247
248 dnl Looks like the AC_MAKE_LINKS string is taken literally and put into the
249 dnl  config.status file.  So the necessary variables also have to be
250 dnl  exported.
251 AC_SUBST(cpu_type) AC_SUBST(obj_format) AC_SUBST(emulation) AC_SUBST(atof)
252 AC_LINK_FILES(targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c,
253         config/tc-${cpu_type}.c config/tc-${cpu_type}.h \
254         config/obj-${obj_format}.h config/obj-${obj_format}.c \
255         config/te-${emulation}.h config/atof-${atof}.c)
256
257 case "${bfd_gas}" in
258   yes)  AC_DEFINE(BFD_ASSEMBLER)
259         need_bfd=yes ;;
260 esac
261
262 case "${need_bfd}" in
263   yes)  BFDLIB=../bfd/libbfd.a
264         ALL_OBJ_DEPS="$ALL_OBJ_DEPS ../bfd/bfd.h"
265         ;;
266 esac
267 AC_SUBST(BFDLIB)
268 AC_SUBST(ALL_OBJ_DEPS)
269
270 case "x${host_canon}" in
271   x${target_canon})                     ;;
272   *)            AC_DEFINE(CROSS_COMPILE);;
273 esac
274
275 AC_DEFINE_UNQUOTED(TARGET_ALIAS,        "${target_alias}")
276 AC_DEFINE_UNQUOTED(TARGET_CANONICAL,    "${target}")
277 AC_DEFINE_UNQUOTED(TARGET_CPU,          "${target_cpu}")
278 AC_DEFINE_UNQUOTED(TARGET_VENDOR,       "${target_vendor}")
279 AC_DEFINE_UNQUOTED(TARGET_OS,           "${target_os}")
280
281 case ${host} in
282   rs6000-*-*)
283         # The IBM compiler mis-compiles some expressions used in gas.
284         # This will tell gas to work around this lossage.
285         AC_DEFINE(IBM_COMPILER_SUX) ;;
286   i386-*-go32)
287         # Using fopen(..., "w") for a binary file breaks under DOS.
288         AC_DEFINE(WANT_FOPEN_BIN)   ;;
289 esac
290
291 AC_PROG_CC
292 AC_PROG_INSTALL
293
294 AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h errno.h sys/types.h)
295
296 dnl ansidecl.h will deal with const
297 dnl AC_CONST
298 AC_FUNC_ALLOCA
299 AC_C_INLINE
300
301 # Some non-ANSI preprocessors botch requoting inside strings.  That's bad
302 # enough, but on some of those systems, the assert macro relies on requoting
303 # working properly!
304 AC_MSG_CHECKING([for working assert macro])
305 AC_CACHE_VAL(gas_cv_assert_ok,
306 AC_TRY_LINK([#include <assert.h>
307 #include <stdio.h>], [
308 /* check for requoting problems */
309 static int a, b, c, d;
310 static char *s;
311 assert (!strcmp(s, "foo bar baz quux"));
312 /* check for newline handling */
313 assert (a == b
314         || c == d);
315 ], gas_cv_assert_ok=yes, gas_cv_assert_ok=no))dnl
316 AC_MSG_RESULT($gas_cv_assert_ok)
317 test $gas_cv_assert_ok = yes || AC_DEFINE(BROKEN_ASSERT)
318
319 # On some systems, the system header files may not declare malloc, realloc,
320 # and free.  There are places where gas needs these functions to have been
321 # declared -- such as when taking their addresses.
322 AC_MSG_CHECKING([whether a malloc declaration is required])
323 AC_CACHE_VAL(gas_cv_malloc_decl_needed,
324 AC_TRY_LINK([
325 #ifdef HAVE_MEMORY_H
326 #include <memory.h>
327 #endif
328 #ifdef HAVE_STRING_H
329 #include <string.h>
330 #endif
331 #ifdef HAVE_STDLIB_H
332 #include <stdlib.h>
333 #endif
334 #ifdef HAVE_UNISTD_H
335 #include <unistd.h>
336 #endif
337 ], [
338 char *(*f) ();
339 f = (char *(*)()) malloc;
340 ], gas_cv_malloc_decl_needed=no, gas_cv_malloc_decl_needed=yes))dnl
341 AC_MSG_RESULT($gas_cv_malloc_decl_needed)
342 test $gas_cv_malloc_decl_needed = no || AC_DEFINE(NEED_MALLOC_DECLARATION)
343
344 AC_MSG_CHECKING([whether a free declaration is required])
345 AC_CACHE_VAL(gas_cv_free_decl_needed,
346 AC_TRY_LINK([
347 #ifdef HAVE_MEMORY_H
348 #include <memory.h>
349 #endif
350 #ifdef HAVE_STRING_H
351 #include <string.h>
352 #endif
353 #ifdef HAVE_STDLIB_H
354 #include <stdlib.h>
355 #endif
356 #ifdef HAVE_UNISTD_H
357 #include <unistd.h>
358 #endif
359 ], [
360 int (*f) ();
361 f = (int (*)()) free;
362 ], gas_cv_free_decl_needed=no, gas_cv_free_decl_needed=yes))
363 AC_MSG_RESULT($gas_cv_free_decl_needed)
364 test $gas_cv_free_decl_needed = no || AC_DEFINE(NEED_FREE_DECLARATION)
365
366 # Does errno.h declare errno, or do we have to add a separate declaration
367 # for it?
368 AC_MSG_CHECKING([whether an errno declaration is required])
369 AC_CACHE_VAL(gas_cv_errno_decl_needed,
370 AC_TRY_LINK([
371 #ifdef HAVE_ERRNO_H
372 #include <errno.h>
373 #endif
374 ], [
375 int x;
376 x = errno;
377 ], gas_cv_errno_decl_needed=no, gas_cv_errno_decl_needed=yes))
378 AC_MSG_RESULT($gas_cv_errno_decl_needed)
379 test $gas_cv_errno_decl_needed = no || AC_DEFINE(NEED_ERRNO_DECLARATION)
380
381 AC_CONFIG_SUBDIRS(testsuite)
382
383 dnl This must come last.
384 dnl Apparently symlinks are checked for in the directory containing
385 dnl  the last Makefile.  Thus the order used here...
386 AC_OUTPUT(doc/Makefile Makefile)