1dnl $MirOS: src/gnu/usr.bin/binutils/gas/configure.in,v 1.5 2005/07/07 16:22:48 tg Exp $
2
3dnl Process this file with autoconf to produce a configure script.
4dnl
5dnl And be careful when changing it!  If you must add tests with square
6dnl brackets, be sure changequote invocations surround it.
7dnl
8dnl
9dnl v2.5 needed for --bindir et al
10AC_PREREQ(2.57)
11AC_INIT(as.h)
12
13dnl Autoconf 2.57 will find the aux dir without this.  However, unless
14dnl we specify this explicitly, automake-1.7 will assume that ylwrap is in
15dnl gas/ instead of gas/../.
16AC_CANONICAL_SYSTEM
17AC_ISC_POSIX
18
19changequote(,)dnl
20BFD_VERSION=`sed -n -e 's/^.._INIT_AUTOMAKE.*,[ 	]*\([^ 	]*\)[ 	]*).*/\1/p' < ${srcdir}/../bfd/configure.in`
21changequote([,])dnl
22AM_INIT_AUTOMAKE(gas, 050707)
23
24AM_PROG_LIBTOOL
25
26user_bfd_gas=
27AC_ARG_ENABLE(bfd-assembler,
28[  --enable-bfd-assembler  use BFD back end for writing object files],
29[case "${enableval}" in
30  yes) need_bfd=yes user_bfd_gas=yes ;;
31  no)  user_bfd_gas=no ;;
32  *)   AC_MSG_ERROR(bad value ${enableval} given for bfd-assembler option) ;;
33esac])dnl
34AC_ARG_ENABLE(targets,
35[    targets            alternative target configurations besides the primary],
36[case "${enableval}" in
37  yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
38	    ;;
39  no)	    enable_targets= ;;
40  *)	    enable_targets=$enableval ;;
41esac])dnl
42AC_ARG_ENABLE(commonbfdlib,
43[  --enable-commonbfdlib   build shared BFD/opcodes/libiberty library],
44[case "${enableval}" in
45  yes) commonbfdlib=true ;;
46  no)  commonbfdlib=false ;;
47  *)   AC_MSG_ERROR([bad value ${enableval} for BFD commonbfdlib option]) ;;
48esac])dnl
49
50using_cgen=no
51
52AM_BINUTILS_WARNINGS
53
54# Generate a header file
55AM_CONFIG_HEADER(config.h:config.in)
56
57# If we are on a DOS filesystem, we must use gdb.ini rather than
58# .gdbinit.
59case "${host}" in
60  *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-windows*)
61    GDBINIT="gdb.ini"
62    AC_CONFIG_FILES(gdb.ini:gdbinit.in)
63    ;;
64  *)
65    GDBINIT=".gdbinit"
66    AC_CONFIG_FILES(.gdbinit:gdbinit.in)
67    ;;
68esac
69AC_SUBST(GDBINIT)
70
71#We need this for the host.  BOUT header is in host order.
72AC_C_BIGENDIAN
73
74te_file=generic
75
76# Makefile target for installing gas in $(tooldir)/bin.
77install_tooldir=install-exec-tooldir
78
79canon_targets=""
80all_targets=no
81if test -n "$enable_targets" ; then
82  for t in `echo $enable_targets | sed 's/,/ /g'`; do
83    if test $t = "all"; then
84      all_targets=yes
85      continue
86    fi
87    result=`$ac_config_sub $t 2>/dev/null`
88    if test -n "$result" ; then
89      canon_targets="$canon_targets $result"
90#    else
91#      # Permit "all", etc.  We don't support it yet though.
92#      canon_targets="$canon_targets $t"
93    fi
94  done
95  GAS_UNIQ(canon_targets)
96fi
97
98emulations=""
99
100for this_target in $target $canon_targets ; do
101
102    targ=${this_target}
103    . ${srcdir}/configure.tgt
104
105    case ${target_cpu} in
106      crisv32)
107	AC_DEFINE_UNQUOTED(DEFAULT_CRIS_ARCH, $arch,
108			   [Default CRIS architecture.])
109	;;
110    esac
111
112    if test ${this_target} = $target ; then
113      target_cpu_type=${cpu_type}
114    elif test ${target_cpu_type} != ${cpu_type} ; then
115      continue
116    fi
117
118    generic_target=${cpu_type}-${target_vendor}-${target_os}
119    case ${generic_target} in
120      i386-*-sco3.2v5*)
121	if test ${this_target} = $target; then
122	  AC_DEFINE(SCO_ELF, 1, [Define if defaulting to ELF on SCO 5.])
123	fi
124	;;
125
126      i386-*-msdosdjgpp* \
127      | i386-*-go32* \
128      | i386-go32-rtems*)
129	AC_DEFINE(STRICTCOFF, 1, [Using strict COFF?])
130	;;
131
132      i860-*-*)
133	AC_MSG_WARN(GAS support for ${generic_target} is preliminary and a work in progress)
134	;;
135
136      mips-sony-bsd*)
137	;;
138      mips-*-bsd*)
139	AC_MSG_ERROR(Unknown vendor for mips-bsd configuration.)
140	;;
141
142      ppc-*-aix5.*)
143	AC_DEFINE(AIX_WEAK_SUPPORT, 1,
144		  [Define if using AIX 5.2 value for C_WEAKEXT.])
145	;;
146      ppc-*-linux-*)
147	case "$endian" in
148	  big)  ;;
149	  *)    AC_MSG_ERROR(GNU/Linux must be configured big endian) ;;
150	esac
151	;;
152      ppc-*-solaris*)
153	if test ${this_target} = $target; then
154	  AC_DEFINE(TARGET_SOLARIS_COMMENT, 1,
155		    [Define if default target is PowerPC Solaris.])
156	fi
157	if test x${endian} = xbig; then
158	  AC_MSG_ERROR(Solaris must be configured little endian)
159	fi
160	;;
161
162      sh*-*-symbianelf*)
163	AC_DEFINE(TARGET_SYMBIAN, 1, [Define if target is Symbian OS.])
164	;;
165    esac
166
167    if test ${this_target} = $target ; then
168      endian_def=
169      if test x${endian} = xbig; then
170	endian_def=1
171      elif test x${endian} = xlittle; then
172	endian_def=0
173      fi
174      if test x${endian_def} != x; then
175	AC_DEFINE_UNQUOTED(TARGET_BYTES_BIG_ENDIAN, $endian_def,
176			   [Define as 1 if big endian.])
177      fi
178    fi
179
180# Other random stuff.
181
182    case ${cpu_type} in
183      mips)
184	# Set mips_cpu to the name of the default CPU.
185	case ${target_cpu} in
186	  mips | mipsbe | mipseb | mipsle | mipsel | mips64 | mips64el)
187	    mips_cpu=from-abi
188	    ;;
189	  mipsisa32 | mipsisa32el)
190	    mips_cpu=mips32
191	    ;;
192	  mipsisa32r2 | mipsisa32r2el)
193	    mips_cpu=mips32r2
194	    ;;
195	  mipsisa64 | mipsisa64el)
196	    mips_cpu=mips64
197	    ;;
198	  mipsisa64r2 | mipsisa64r2el)
199	    mips_cpu=mips64r2
200	    ;;
201	  mipstx39 | mipstx39el)
202	    mips_cpu=r3900
203	    ;;
204	  mips64vr | mips64vrel)
205	    mips_cpu=vr4100
206	    ;;
207	  mipsisa32r2* | mipsisa64r2*)
208changequote(,)dnl
209	    mips_cpu=`echo $target_cpu | sed -e 's/[a-z]*..r2//' -e 's/el$//'`
210changequote([,])dnl
211	    ;;
212	  mips64* | mipsisa64* | mipsisa32*)
213changequote(,)dnl
214	    mips_cpu=`echo $target_cpu | sed -e 's/[a-z]*..//' -e 's/el$//'`
215changequote([,])dnl
216	    ;;
217	  *)
218	    AC_ERROR($target_cpu isn't a supported MIPS CPU name)
219	    ;;
220	esac
221	# See whether it's appropriate to set E_MIPS_ABI_O32 for o32
222	# binaries.  It's a GNU extension that some OSes don't understand.
223	# The value only matters on ELF targets.
224	case ${target} in
225	  *-*-irix*)
226	    use_e_mips_abi_o32=0
227	    ;;
228	  *)
229	    use_e_mips_abi_o32=1
230	    ;;
231	esac
232	# Decide whether to generate 32-bit or 64-bit code by default.
233	# Used to resolve -march=from-abi when an embedded ABI is selected.
234	case ${target} in
235	  mips64*-*-* | mipsisa64*-*-*)
236	    mips_default_64bit=1
237	    ;;
238	  *)
239	    mips_default_64bit=0
240	    ;;
241	esac
242	# Decide which ABI to target by default.
243	case ${target} in
244	  mips64*-linux* | mips-sgi-irix6*)
245	    mips_default_abi=N32_ABI
246	    ;;
247	  mips*-linux*)
248	    mips_default_abi=O32_ABI
249	    ;;
250	  mips64*-openbsd*)
251	    mips_default_abi=N64_ABI
252	    ;;
253	  *)
254	    mips_default_abi=NO_ABI
255	    ;;
256	esac
257	AC_DEFINE_UNQUOTED(MIPS_CPU_STRING_DEFAULT, "$mips_cpu",
258			   [Default CPU for MIPS targets. ])
259	AC_DEFINE_UNQUOTED(USE_E_MIPS_ABI_O32, $use_e_mips_abi_o32,
260			   [Allow use of E_MIPS_ABI_O32 on MIPS targets. ])
261	AC_DEFINE_UNQUOTED(MIPS_DEFAULT_64BIT, $mips_default_64bit,
262			   [Generate 64-bit code by default on MIPS targets. ])
263	AC_DEFINE_UNQUOTED(MIPS_DEFAULT_ABI, $mips_default_abi,
264			   [Choose a default ABI for MIPS targets. ])
265	;;
266    esac
267
268    # Do we need the opcodes library?
269    case ${cpu_type} in
270      vax | i386 | tic30)
271	;;
272
273      *)
274	need_opcodes=yes
275
276	case "${enable_shared}" in
277	yes) shared_opcodes=true ;;
278	*opcodes*) shared_opcodes=true ;;
279	*) shared_opcodes=false ;;
280	esac
281	if test "${shared_opcodes}" = "true"; then
282	  # A shared libopcodes must be linked against libbfd.
283	  need_bfd=yes
284	fi
285	;;
286    esac
287
288    # Any other special object files needed ?
289    case ${cpu_type} in
290      fr30 | ip2k | iq2000 | m32r | openrisc)
291	using_cgen=yes
292	;;
293
294      frv)
295	using_cgen=yes
296	;;
297      m68k)
298	case ${extra_objects} in
299	*m68k-parse.o*) ;;
300	*) extra_objects="$extra_objects m68k-parse.o" ;;
301	esac
302	;;
303
304      mips)
305	echo ${extra_objects} | grep -s "itbl-parse.o"
306	if test $? -ne 0 ; then
307	  extra_objects="$extra_objects itbl-parse.o"
308	fi
309
310	echo ${extra_objects} | grep -s "itbl-lex.o"
311	if test $? -ne 0 ; then
312	  extra_objects="$extra_objects itbl-lex.o"
313	fi
314
315	echo ${extra_objects} | grep -s "itbl-ops.o"
316	if test $? -ne 0 ; then
317	  extra_objects="$extra_objects itbl-ops.o"
318	fi
319	;;
320
321      ms1)
322        using_cgen=yes
323	;;
324
325      i386 | s390 | sparc)
326	if test $this_target = $target ; then
327	  AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
328	fi
329	;;
330
331      xstormy16)
332	using_cgen=yes
333	;;
334
335      xtensa)
336	echo ${extra_objects} | grep -s "xtensa-relax.o"
337	if test $? -ne 0 ; then
338	  extra_objects="$extra_objects xtensa-relax.o"
339	fi
340	;;
341
342      *)
343	;;
344    esac
345
346    if test $using_cgen = yes ; then
347	case "x${extra_objects}" in
348	*cgen.o*) ;;
349	*) extra_objects="$extra_objects cgen.o" ;;
350	esac
351    fi
352
353# See if we really can support this configuration with the emulation code.
354
355    if test $this_target = $target ; then
356      primary_bfd_gas=$bfd_gas
357      obj_format=$fmt
358      te_file=$em
359
360      if test $bfd_gas = no ; then
361	# Can't support other configurations this way.
362	break
363      fi
364    elif test $bfd_gas = no ; then
365      # Can't support this configuration.
366      break
367    fi
368
369# From target name and format, produce a list of supported emulations.
370
371    case ${generic_target}-${fmt} in
372      mips-*-irix5*-*)	emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
373      mips*-*-linux*-*) case "$endian" in
374			big)	emulation="mipsbelf mipslelf mipself" ;;
375			*)	emulation="mipslelf mipsbelf mipself" ;;
376			esac ;;
377      mips-*-lnews*-ecoff) ;;
378      mips-*-*-ecoff)	case "$endian" in
379			big)	emulation="mipsbecoff mipslecoff mipsecoff" ;;
380			*)	emulation="mipslecoff mipsbecoff mipsecoff" ;;
381			esac ;;
382      mips-*-*-elf)	case "$endian" in
383			big)	emulation="mipsbelf mipslelf mipself" ;;
384			*)	emulation="mipslelf mipsbelf mipself" ;;
385			esac ;;
386      mips-*-sysv4*MP*-*) emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
387      # i386-pc-pe-coff != i386-pc-coff.
388      i386-*-pe-coff)	;;
389      # Uncommenting the next line will turn on support for i386 AOUT
390      # for the default linux configuration
391      # i386-*-linux*-elf) emulation="i386elf i386aout" ;;
392      #
393      i386-*-aout)	emulation="i386aout" ;;
394      i386-*-coff)	emulation="i386coff" ;;
395      i386-*-elf)	emulation="i386elf" ;;
396
397      # Always all formats.  The first stated emulation becomes the default.
398      cris-*-*aout*)	emulation="crisaout criself" ;;
399      cris-*-*)		emulation="criself crisaout" ;;
400    esac
401
402    emulations="$emulations $emulation"
403
404done
405
406# Turn on all targets if possible
407if test ${all_targets} = "yes"; then
408  case ${target_cpu_type} in
409  i386)
410    case ${obj_format} in
411    aout)
412      emulations="$emulations i386coff i386elf"
413      ;;
414    coff)
415      emulations="$emulations i386aout i386elf"
416    ;;
417    elf)
418      emulations="$emulations i386aout i386coff"
419      ;;
420    esac
421  ;;
422  esac
423fi
424
425# Assign floating point type.  Most processors with FP support
426# IEEE FP.  On those that don't support FP at all, usually IEEE
427# is emulated.
428case ${target_cpu} in
429  vax | tahoe )	atof=${target_cpu} ;;
430  pdp11)	atof=vax ;;
431  *)		atof=ieee ;;
432esac
433
434case "${obj_format}" in
435  "") AC_MSG_ERROR(GAS does not know what format to use for target ${target}) ;;
436esac
437
438# Unfortunately the cpu in cpu-opc.h file isn't always $(TARGET_CPU).
439cgen_cpu_prefix=""
440if test $using_cgen = yes ; then
441  case ${target_cpu} in
442    *) cgen_cpu_prefix=${target_cpu} ;;
443  esac
444  AC_SUBST(cgen_cpu_prefix)
445  AC_DEFINE(USING_CGEN, 1, [Using cgen code?])
446fi
447
448dnl
449dnl Make sure the desired support files exist.
450dnl
451
452if test ! -r ${srcdir}/config/tc-${target_cpu_type}.c; then
453  AC_MSG_ERROR(GAS does not support target CPU ${target_cpu_type})
454fi
455
456if test ! -r ${srcdir}/config/obj-${obj_format}.c; then
457  AC_MSG_ERROR(GAS does not have support for object file format ${obj_format})
458fi
459
460case ${user_bfd_gas}-${primary_bfd_gas} in
461  yes-yes | no-no)
462    # We didn't override user's choice.
463    ;;
464  no-yes)
465    AC_MSG_WARN(Use of BFD is required for ${target}; overriding config options.)
466    ;;
467  no-preferred)
468    primary_bfd_gas=no
469    ;;
470  *-preferred)
471    primary_bfd_gas=yes
472    ;;
473  yes-*)
474    primary_bfd_gas=yes
475    ;;
476  -*)
477    # User specified nothing.
478    ;;
479esac
480
481# Some COFF configurations want these random other flags set.
482case ${obj_format} in
483  coff)
484    case ${target_cpu_type} in
485      i386) AC_DEFINE(I386COFF, 1, [Using i386 COFF?]) ;;
486      m68k) AC_DEFINE(M68KCOFF, 1, [Using m68k COFF?]) ;;
487      m88k) AC_DEFINE(M88KCOFF, 1, [Using m88k COFF?]) ;;
488    esac
489    ;;
490esac
491
492# Getting this done right is going to be a bitch.  Each configuration specified
493# with --enable-targets=... should be checked for environment, format, cpu, and
494# bfd_gas setting.
495#
496# For each configuration, the necessary object file support code must be linked
497# in.  This might be only one, it might be up to four.  The necessary emulation
498# code needs to be provided, too.
499#
500# And then there's "--enable-targets=all"....
501#
502# For now, just always do it for MIPS ELF or ECOFF configurations.  Sigh.
503
504formats="${obj_format}"
505emfiles=""
506EMULATIONS=""
507GAS_UNIQ(emulations)
508for em in . $emulations ; do
509  case $em in
510    .)	continue ;;
511    mipsbelf | mipslelf | mipself)
512	fmt=elf   file=mipself ;;
513    mipsbecoff | mipslecoff | mipsecoff)
514	fmt=ecoff file=mipsecoff ;;
515    *coff)
516	fmt=coff  file=$em ;;
517    *aout)
518	fmt=aout file=$em ;;
519    *elf)
520	fmt=elf file=$em ;;
521  esac
522  formats="$formats $fmt"
523  emfiles="$emfiles e-$file.o"
524  EMULATIONS="$EMULATIONS &$em,"
525done
526GAS_UNIQ(formats)
527GAS_UNIQ(emfiles)
528if test `set . $formats ; shift ; echo $#` -gt 1 ; then
529  for fmt in $formats ; do
530    case $fmt in
531      aout)	AC_DEFINE(OBJ_MAYBE_AOUT, 1,    [a.out support?])   ;;
532      bout)	AC_DEFINE(OBJ_MAYBE_BOUT, 1,    [b.out support?])   ;;
533      coff)	AC_DEFINE(OBJ_MAYBE_COFF, 1,    [COFF support?])    ;;
534      ecoff)	AC_DEFINE(OBJ_MAYBE_ECOFF, 1,   [ECOFF support?])   ;;
535      elf)	AC_DEFINE(OBJ_MAYBE_ELF, 1,     [ELF support?])     ;;
536      generic)	AC_DEFINE(OBJ_MAYBE_GENERIC, 1, [generic support?]) ;;
537      hp300)	AC_DEFINE(OBJ_MAYBE_HP300, 1,   [HP300 support?])   ;;
538      ieee)	AC_DEFINE(OBJ_MAYBE_IEEE, 1,    [IEEE support?])    ;;
539      som)	AC_DEFINE(OBJ_MAYBE_SOM, 1,     [SOM support?])     ;;
540    esac
541    extra_objects="$extra_objects obj-$fmt.o"
542  done
543  obj_format=multi
544fi
545if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then
546  DEFAULT_EMULATION=`set . $emulations ; echo $2`
547  # e-mips* has more than one emulation per file, e-i386* has just one at the
548  # moment.  If only one emulation is specified, then don't define
549  # USE_EMULATIONS or include any of the e-files as they will only be bloat.
550  case "${obj_format}${emfiles}" in
551    multi* | *mips*)
552      extra_objects="$extra_objects $emfiles"
553      AC_DEFINE(USE_EMULATIONS, 1, [Use emulation support?]) ;;
554  esac
555fi
556AC_SUBST(extra_objects)
557AC_DEFINE_UNQUOTED(EMULATIONS, $EMULATIONS, [Supported emulations.])
558AC_DEFINE_UNQUOTED(DEFAULT_EMULATION, "$DEFAULT_EMULATION",
559		   [Default emulation.])
560
561case ${primary_bfd_gas}-${target_cpu_type}-${obj_format} in
562  yes-*-coff)	need_bfd=yes ;;
563  no-*-coff)	need_bfd=yes
564		AC_DEFINE(MANY_SEGMENTS, 1, [old COFF support?]) ;;
565esac
566
567reject_dev_configs=yes
568
569case ${reject_dev_configs}-${dev} in
570  yes-yes) # Oops.
571    AC_MSG_ERROR(GAS does not support the ${generic_target} configuration.)
572    ;;
573esac
574
575AC_SUBST(target_cpu_type)
576AC_SUBST(obj_format)
577AC_SUBST(te_file)
578AC_SUBST(install_tooldir)
579AC_SUBST(atof)
580dnl AC_SUBST(emulation)
581
582case "${primary_bfd_gas}" in
583  yes)	AC_DEFINE(BFD_ASSEMBLER, 1, [Use BFD interface?])
584	need_bfd=yes ;;
585esac
586
587# do we need the opcodes library?
588case "${need_opcodes}" in
589yes)
590  OPCODES_LIB=../opcodes/libopcodes.la
591  ;;
592esac
593
594case "${need_bfd}" in
595yes)
596  BFDLIB=../bfd/libbfd.la
597  BFDVER_H=../bfd/bfdver.h
598  ALL_OBJ_DEPS="$ALL_OBJ_DEPS"' ../bfd/bfd.h $(INCDIR)/symcat.h'
599  ;;
600esac
601
602AC_SUBST(BFDLIB)
603AC_SUBST(OPCODES_LIB)
604
605AC_SUBST(BFDVER_H)
606AC_SUBST(ALL_OBJ_DEPS)
607
608AC_DEFINE_UNQUOTED(TARGET_ALIAS,	"${target_alias}", [Target alias.])
609AC_DEFINE_UNQUOTED(TARGET_CANONICAL,	"${target}",       [Canonical target.])
610AC_DEFINE_UNQUOTED(TARGET_CPU,		"${target_cpu}",   [Target CPU.])
611AC_DEFINE_UNQUOTED(TARGET_VENDOR,	"${target_vendor}", [Target vendor.])
612AC_DEFINE_UNQUOTED(TARGET_OS,		"${target_os}",    [Target OS.])
613
614AC_PROG_CC
615
616AC_PROG_YACC
617AM_PROG_LEX
618
619AM_MAINTAINER_MODE
620AC_EXEEXT
621
622AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h errno.h sys/types.h)
623
624# Put this here so that autoconf's "cross-compiling" message doesn't confuse
625# people who are not cross-compiling but are compiling cross-assemblers.
626AC_MSG_CHECKING(whether compiling a cross-assembler)
627if test "${host}" = "${target}"; then
628  cross_gas=no
629else
630  cross_gas=yes
631  AC_DEFINE(CROSS_COMPILE, 1, [Compiling cross-assembler?])
632fi
633AC_MSG_RESULT($cross_gas)
634
635dnl ansidecl.h will deal with const
636dnl AC_CONST
637AC_FUNC_ALLOCA
638AC_C_INLINE
639
640# VMS doesn't have unlink.
641AC_CHECK_FUNCS(unlink remove, break)
642
643# Some systems don't have sbrk().
644AC_CHECK_FUNCS(sbrk)
645
646# do we need the math library?
647case "${need_libm}" in
648yes)
649  AC_CHECK_LIBM
650  AC_SUBST(LIBM)
651  ;;
652esac
653
654# Some non-ANSI preprocessors botch requoting inside strings.  That's bad
655# enough, but on some of those systems, the assert macro relies on requoting
656# working properly!
657GAS_WORKING_ASSERT
658
659# On some systems, the system header files may not declare malloc, realloc,
660# and free.  There are places where gas needs these functions to have been
661# declared -- such as when taking their addresses.
662gas_test_headers="
663#ifdef HAVE_MEMORY_H
664#include <memory.h>
665#endif
666#ifdef HAVE_STRING_H
667#include <string.h>
668#else
669#ifdef HAVE_STRINGS_H
670#include <strings.h>
671#endif
672#endif
673#ifdef HAVE_STDLIB_H
674#include <stdlib.h>
675#endif
676#ifdef HAVE_UNISTD_H
677#include <unistd.h>
678#endif
679"
680
681# Does errno.h declare errno, or do we have to add a separate declaration
682# for it?
683GAS_CHECK_DECL_NEEDED(errno, f, int f, [
684#ifdef HAVE_ERRNO_H
685#include <errno.h>
686#endif
687])
688
689AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
690AC_CACHE_VAL(gas_cv_decl_getopt_unistd_h,
691[AC_TRY_COMPILE([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);],
692gas_cv_decl_getopt_unistd_h=yes, gas_cv_decl_getopt_unistd_h=no)])
693AC_MSG_RESULT($gas_cv_decl_getopt_unistd_h)
694if test $gas_cv_decl_getopt_unistd_h = yes; then
695  AC_DEFINE([HAVE_DECL_GETOPT], 1,
696	    [Is the prototype for getopt in <unistd.h> in the expected format?])
697fi
698
699GAS_CHECK_DECL_NEEDED(environ, f, char **f, $gas_test_headers)
700GAS_CHECK_DECL_NEEDED(ffs, f, int (*f)(int), $gas_test_headers)
701GAS_CHECK_DECL_NEEDED(free, f, void (*f)(), $gas_test_headers)
702GAS_CHECK_DECL_NEEDED(malloc, f, char *(*f)(), $gas_test_headers)
703GAS_CHECK_DECL_NEEDED(sbrk, f, char *(*f)(), $gas_test_headers)
704GAS_CHECK_DECL_NEEDED(strstr, f, char *(*f)(), $gas_test_headers)
705
706dnl This must come last.
707
708dnl We used to make symlinks to files in the source directory, but now
709dnl we just use the right name for .c files, and create .h files in
710dnl the build directory which include the right .h file.  Make sure
711dnl the old symlinks don't exist, so that a reconfigure in an existing
712dnl directory behaves reasonably.
713
714AC_CONFIG_FILES(Makefile doc/Makefile)
715AC_CONFIG_COMMANDS([default],
716[rm -f targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c itbl-cpu.h
717 echo '#include "tc-'"${target_cpu_type}"'.h"' > targ-cpu.h
718 echo '#include "obj-'"${obj_format}"'.h"' > obj-format.h
719 echo '#include "te-'"${te_file}"'.h"' > targ-env.h
720 echo '#include "itbl-'"${target_cpu_type}"'.h"' > itbl-cpu.h
721 if test "x$cgen_cpu_prefix" != x ; then
722   echo '#include "opcodes/'"${cgen_cpu_prefix}"'-desc.h"' > cgen-desc.h
723 fi],
724[target_cpu_type=${target_cpu_type}
725 cgen_cpu_prefix=${cgen_cpu_prefix}
726 obj_format=${obj_format}
727 te_file=${te_file}])
728
729AC_OUTPUT
730