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   Copyright (C) 2012-2024 Free Software Foundation, Inc.
7dnl
8dnl This file is free software; you can redistribute it and/or modify
9dnl it under the terms of the GNU General Public License as published by
10dnl the Free Software Foundation; either version 3 of the License, or
11dnl (at your option) any later version.
12dnl
13dnl This program is distributed in the hope that it will be useful,
14dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16dnl GNU General Public License for more details.
17dnl
18dnl You should have received a copy of the GNU General Public License
19dnl along with this program; see the file COPYING3.  If not see
20dnl <http://www.gnu.org/licenses/>.
21dnl
22dnl v2.5 needed for --bindir et al
23m4_include([../bfd/version.m4])
24AC_INIT([gas], BFD_VERSION)
25AC_CONFIG_SRCDIR(as.h)
26
27dnl Autoconf 2.57 will find the aux dir without this.  However, unless
28dnl we specify this explicitly, automake-1.7 will assume that ylwrap is in
29dnl gas/ instead of gas/../.
30AC_CONFIG_AUX_DIR(..)
31AC_CANONICAL_TARGET
32
33AM_INIT_AUTOMAKE
34AM_SILENT_RULES([yes])
35
36AC_PROG_CC
37AC_GNU_SOURCE
38AC_USE_SYSTEM_EXTENSIONS
39
40LT_INIT
41ACX_LARGEFILE
42ACX_PROG_CMP_IGNORE_INITIAL
43
44AC_ARG_ENABLE(targets,
45[  --enable-targets        alternative target configurations besides the primary],
46[case "${enableval}" in
47  yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all')
48              ;;
49  no)         enable_targets= ;;
50  *)          enable_targets=$enableval ;;
51esac])dnl
52
53ac_checking=
54. ${srcdir}/../bfd/development.sh
55test "$development" = true && ac_checking=yes
56AC_ARG_ENABLE(checking,
57[  --enable-checking       enable run-time checks],
58[case "${enableval}" in
59  no|none)  ac_checking= ;;
60  *)          ac_checking=yes ;;
61esac])dnl
62if test x$ac_checking != x ; then
63  AC_DEFINE(ENABLE_CHECKING, 1, [Define if you want run-time sanity checks.])
64fi
65
66# PR gas/19109
67# Decide the default method for compressing debug sections.
68ac_default_compressed_debug_sections=unset
69# Provide a configure time option to override our default.
70AC_ARG_ENABLE(compressed_debug_sections,
71                AS_HELP_STRING([--enable-compressed-debug-sections={all,gas,none}],
72                [compress debug sections by default]),
73[case ,"${enableval}", in
74  ,yes, | ,all, | *,gas,*) ac_default_compressed_debug_sections=yes ;;
75  ,no, | ,none,)  ac_default_compressed_debug_sections=no ;;
76  *)   ac_default_compressed_debug_sections=unset ;;
77esac])dnl
78
79# Select default compression algorithm.
80ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_GABI_ZLIB
81AC_ARG_ENABLE(default_compressed_debug_sections_algorithm,
82                AS_HELP_STRING([--enable-default-compressed-debug-sections-algorithm={zlib,zstd}],
83                [Default compression algorithm for --enable-compressed-debug-sections.]),
84[case "${enableval}" in
85   zstd) ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_ZSTD ;;
86esac])dnl
87
88# PR gas/19520
89# Decide if x86 assembler should generate relax relocations.
90ac_default_x86_relax_relocations=unset
91# Provide a configure time option to override our default.
92AC_ARG_ENABLE(x86_relax_relocations,
93                AS_HELP_STRING([--enable-x86-relax-relocations],
94                [generate x86 relax relocations by default]),
95[case "${enableval}" in
96  no)  ac_default_x86_relax_relocations=0 ;;
97esac])dnl
98
99# Decide if ELF assembler should generate common symbols with the
100# STT_COMMON type.
101ac_default_elf_stt_common=unset
102# Provide a configure time option to override our default.
103AC_ARG_ENABLE(elf_stt_common,
104                AS_HELP_STRING([--enable-elf-stt-common],
105                [generate ELF common symbols with STT_COMMON type by default]),
106[case "${enableval}" in
107  yes)  ac_default_elf_stt_common=1 ;;
108esac])dnl
109
110
111# Decide if the ELF assembler should default to generating
112# GNU Build notes if none are provided by the input.
113ac_default_generate_build_notes=0
114# Provide a configuration option to override the default.
115AC_ARG_ENABLE(generate_build_notes,
116                AS_HELP_STRING([--enable-generate-build-notes],
117                [generate GNU Build notes if none are provided by the input]),
118[case "${enableval}" in
119  yes)  ac_default_generate_build_notes=1 ;;
120  no)   ac_default_generate_build_notes=0 ;;
121esac])dnl
122
123# Decide if the MIPS assembler should default to enable MIPS fix Loongson3
124# LLSC errata.
125ac_default_mips_fix_loongson3_llsc=unset
126# Provide a configuration option to override the default.
127AC_ARG_ENABLE(mips-fix-loongson3-llsc,
128             AS_HELP_STRING([--enable-mips-fix-loongson3-llsc],
129             [enable MIPS fix Loongson3 LLSC errata]),
130[case "${enableval}" in
131  yes)  ac_default_mips_fix_loongson3_llsc=1 ;;
132  no)   ac_default_mips_fix_loongson3_llsc=0 ;;
133esac])dnl
134
135# Decide if the x86 ELF assembler should default to generating GNU x86
136# used ISA and feature properties.
137ac_default_generate_x86_used_note=unset
138# Provide a configuration option to override the default.
139AC_ARG_ENABLE(x86-used-note,
140                AS_HELP_STRING([--enable-x86-used-note],
141                [generate GNU x86 used ISA and feature properties]),
142[case "${enableval}" in
143  yes)  ac_default_generate_x86_used_note=1 ;;
144  no)   ac_default_generate_x86_used_note=0 ;;
145esac])dnl
146
147# Decide if the RISC-V ELF assembler should default to generating attribute.
148ac_default_generate_riscv_attr=unset
149# Provide a configuration option to override the default.
150AC_ARG_ENABLE(default-riscv-attribute,
151                AS_HELP_STRING([--enable-default-riscv-attribute],
152                [generate RISC-V arch attribute by default]),
153[case "${enableval}" in
154  yes)  ac_default_generate_riscv_attr=1 ;;
155  no)   ac_default_generate_riscv_attr=0 ;;
156esac])dnl
157
158using_cgen=no
159
160AM_BINUTILS_WARNINGS
161
162# Generate a header file
163AC_CONFIG_HEADERS(config.h:config.in)
164
165dnl Option --with-cpu=TYPE allows configure type control of the default
166dnl cpu type within the assembler.  Currently only the ARC target
167dnl supports this feature, but others may be added in the future.
168AC_ARG_WITH(cpu,
169            AS_HELP_STRING([--with-cpu=CPU],
170            [default cpu variant is CPU (currently only supported on ARC)]),
171            [AC_DEFINE_UNQUOTED(TARGET_WITH_CPU,
172                                "${with_cpu}",
173                                [Target specific CPU.])],
174            [])
175
176# PR 14072
177AH_VERBATIM([00_CONFIG_H_CHECK],
178[/* Check that config.h is #included before system headers
179   (this works only for glibc, but that should be enough).  */
180#if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
181#  error config.h must be #included before system headers
182#endif
183#define __CONFIG_H__ 1])
184
185# If we are on a DOS filesystem, we must use gdb.ini rather than
186# .gdbinit.
187case "${host}" in
188  *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-windows*)
189    GDBINIT="gdb.ini"
190    AC_CONFIG_FILES(gdb.ini:gdbinit.in)
191    ;;
192  *)
193    GDBINIT=".gdbinit"
194    AC_CONFIG_FILES(.gdbinit:gdbinit.in)
195    ;;
196esac
197AC_SUBST(GDBINIT)
198
199#We need this for the host.
200AC_C_BIGENDIAN
201
202te_file=generic
203
204# Makefile target for installing gas in $(tooldir)/bin.
205install_tooldir=install-exec-tooldir
206
207canon_targets=""
208all_targets=no
209if test -n "$enable_targets" ; then
210  for t in `echo $enable_targets | sed 's/,/ /g'`; do
211    if test $t = "all"; then
212      all_targets=yes
213      continue
214    fi
215    result=`$ac_config_sub $t 2>/dev/null`
216    if test -n "$result" ; then
217      canon_targets="$canon_targets $result"
218#    else
219#      # Permit "all", etc.  We don't support it yet though.
220#      canon_targets="$canon_targets $t"
221    fi
222  done
223  GAS_UNIQ(canon_targets)
224fi
225
226emulations=""
227
228for this_target in $target $canon_targets ; do
229
230    targ=${this_target}
231    . ${srcdir}/configure.tgt
232
233    case ${target_cpu} in
234      crisv32)
235          AC_DEFINE_UNQUOTED(DEFAULT_CRIS_ARCH, $arch,
236                                 [Default CRIS architecture.])
237          ;;
238    esac
239
240    if test ${this_target} = $target ; then
241      target_cpu_type=${cpu_type}
242    elif test ${target_cpu_type} != ${cpu_type} ; then
243      continue
244    fi
245
246    generic_target=${cpu_type}-${target_vendor}-${target_os}
247    case ${generic_target} in
248      i386-*-msdosdjgpp* \
249      | i386-*-go32*)
250          AC_DEFINE(STRICTCOFF, 1, [Using strict COFF?])
251          ;;
252
253      i386-*-linux-* | x86_64-*-linux-*)
254          if test ${this_target} = $target \
255             && test ${ac_default_generate_x86_used_note} = unset; then
256            ac_default_generate_x86_used_note=1
257          fi
258          ;;
259
260      i386-*-solaris2 \
261      | x86_64-*-solaris2 \
262      | i386-*-solaris2.[[0-9]] \
263      | i386-*-solaris2.1[[01]] \
264      | x86_64-*-solaris2.1[[01]])
265          if test ${this_target} = $target \
266             && test ${ac_default_x86_relax_relocations} = unset; then
267            ac_default_x86_relax_relocations=0
268          fi
269          ;;
270
271      microblaze*)
272        ;;
273
274changequote(,)dnl
275      ppc-*-aix5.[01]*)
276          ;;
277      ppc-*-aix[5-9].*)
278changequote([,])dnl
279          AC_DEFINE(AIX_WEAK_SUPPORT, 1,
280                      [Define if using AIX 5.2 value for C_WEAKEXT.])
281          ;;
282      ppc-*-solaris*)
283          if test ${this_target} = $target; then
284            AC_DEFINE(TARGET_SOLARIS_COMMENT, 1,
285                        [Define if default target is PowerPC Solaris.])
286          fi
287          if test x${endian} = xbig; then
288            AC_MSG_ERROR(Solaris must be configured little endian)
289          fi
290          ;;
291    esac
292
293    if test ${this_target} = $target ; then
294      endian_def=
295      if test x${endian} = xbig; then
296          endian_def=1
297      elif test x${endian} = xlittle; then
298          endian_def=0
299      fi
300      if test x${endian_def} != x; then
301          AC_DEFINE_UNQUOTED(TARGET_BYTES_BIG_ENDIAN, $endian_def,
302                                 [Define as 1 if big endian.])
303      fi
304    fi
305
306# Other random stuff.
307
308    case ${cpu_type} in
309      mips)
310          # Set mips_cpu to the name of the default CPU.
311          case ${target_cpu} in
312            mips | mipsbe | mipseb | mipsle | mipsel | mips64 | mips64el | mips64eb | mipsn64el | mipsn64eb )
313              mips_cpu=from-abi
314              ;;
315            mipsisa32 | mipsisa32el)
316              mips_cpu=mips32
317              ;;
318            mipsisa32r2 | mipsisa32r2el)
319              mips_cpu=mips32r2
320              ;;
321            mipsisa32r3 | mipsisa32r3el)
322              mips_cpu=mips32r3
323              ;;
324            mipsisa32r5 | mipsisa32r5el)
325              mips_cpu=mips32r5
326              ;;
327            mipsisa32r6 | mipsisa32r6el)
328              mips_cpu=mips32r6
329              ;;
330            mipsisa64 | mipsisa64el)
331              mips_cpu=mips64
332              ;;
333            mipsisa64r2 | mipsisa64r2el)
334              mips_cpu=mips64r2
335              ;;
336            mipsisa64r3 | mipsisa64r3el)
337              mips_cpu=mips64r3
338              ;;
339            mipsisa64r5 | mipsisa64r5el)
340              mips_cpu=mips64r5
341              ;;
342            mipsisa64r6 | mipsisa64r6el)
343              mips_cpu=mips64r6
344              ;;
345            mipstx39 | mipstx39el)
346              mips_cpu=r3900
347              ;;
348            mips64vr | mips64vrel)
349              mips_cpu=vr4100
350              ;;
351            mipsisa32r2* | mipsisa64r2*)
352changequote(,)dnl
353              mips_cpu=`echo $target_cpu | sed -e 's/[a-z]*..r2//' -e 's/el$//'`
354changequote([,])dnl
355              ;;
356            mipsisa32r6* | mipsisa64r6*)
357changequote(,)dnl
358              mips_cpu=`echo $target_cpu | sed -e 's/[a-z]*..r6//' -e 's/el$//'`
359changequote([,])dnl
360              ;;
361            mips64* | mipsisa64* | mipsisa32*)
362changequote(,)dnl
363              mips_cpu=`echo $target_cpu | sed -e 's/[a-z]*..//' -e 's/el$//'`
364changequote([,])dnl
365              ;;
366            mips*)
367changequote(,)dnl
368              mips_cpu=`echo $target_cpu | sed -e 's/^mips//' -e 's/el$//'`
369changequote([,])dnl
370              ;;
371            *)
372              AC_MSG_ERROR($target_cpu isn't a supported MIPS CPU name)
373              ;;
374          esac
375          # See whether it's appropriate to set EF_MIPS_ABI_O32 for o32
376          # binaries.  It's a GNU extension that some OSes don't understand.
377          case ${target} in
378            *-*-irix*)
379              use_ef_mips_abi_o32=0
380              ;;
381            *)
382              use_ef_mips_abi_o32=1
383              ;;
384          esac
385          # If Vendor is IMG, then MIPSr6 is used
386          case ${target} in
387            mips*-img-*)
388              mips_cpu=mips32r6
389              ;;
390          esac
391          # Decide whether to generate 32-bit or 64-bit code by default.
392          # Used to resolve -march=from-abi when an embedded ABI is selected.
393          case ${target} in
394            mips64*-*-* | mipsisa64*-*-*)
395              mips_default_64bit=1
396              ;;
397            *)
398              mips_default_64bit=0
399              ;;
400          esac
401          # Decide which ABI to target by default.
402          case ${target} in
403            mips64*-openbsd* | mips64*-linux-gnuabi64)
404              mips_default_abi=N64_ABI
405              ;;
406            mips64*-linux* | mips-sgi-irix6* | mips64*-freebsd* \
407            | mips64*-kfreebsd*-gnu | mips64*-ps2-elf*)
408              mips_default_abi=N32_ABI
409              ;;
410            mips*-linux* | mips*-freebsd* | mips*-kfreebsd*-gnu)
411              mips_default_abi=O32_ABI
412              ;;
413            *)
414              mips_default_abi=NO_ABI
415              ;;
416          esac
417          AC_DEFINE_UNQUOTED(MIPS_CPU_STRING_DEFAULT, "$mips_cpu",
418                                 [Default CPU for MIPS targets. ])
419          AC_DEFINE_UNQUOTED(USE_EF_MIPS_ABI_O32, $use_ef_mips_abi_o32,
420                                 [Allow use of EF_MIPS_ABI_O32 on MIPS targets. ])
421          AC_DEFINE_UNQUOTED(MIPS_DEFAULT_64BIT, $mips_default_64bit,
422                                 [Generate 64-bit code by default on MIPS targets. ])
423          AC_DEFINE_UNQUOTED(MIPS_DEFAULT_ABI, $mips_default_abi,
424                                 [Choose a default ABI for MIPS targets. ])
425          ;;
426    esac
427
428    # Do we need the opcodes library?
429    case ${cpu_type} in
430      vax | tic30 | i386 | arm)
431          ;;
432
433      *)
434          need_opcodes=yes
435
436          case "${enable_shared}" in
437          yes) shared_opcodes=true ;;
438          *opcodes*) shared_opcodes=true ;;
439          *) shared_opcodes=false ;;
440          esac
441          ;;
442    esac
443
444    # Any other special object files needed ?
445    case ${cpu_type} in
446
447      bfin)
448          for f in config/bfin-parse.o config/bfin-lex-wrapper.o; do
449            case " $extra_objects " in
450              *" $f "*) ;;
451              *) extra_objects="$extra_objects $f" ;;
452            esac
453          done
454          ;;
455
456      bpf)
457          if test $this_target = $target ; then
458            AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
459          fi
460        ;;
461      epiphany | fr30 | ip2k | iq2000 | lm32 | m32r | or1k)
462          using_cgen=yes
463          ;;
464
465      loongarch)
466          for f in config/loongarch-parse.o config/loongarch-lex-wrapper.o; do
467            case " $extra_objects " in
468              *" $f "*) ;;
469              *) extra_objects="$extra_objects $f" ;;
470            esac
471          done
472        # --target=loongarch[32|64]-*-*.  */
473        if test $this_target = $target ; then
474          AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
475        fi
476          ;;
477
478      m32c)
479          using_cgen=yes
480          ;;
481      frv)
482          using_cgen=yes
483          ;;
484      kvx)
485          for f in config/kvx-parse.o; do
486            case " $extra_objects " in
487              *" $f "*) ;;
488              *) extra_objects="$extra_objects $f" ;;
489            esac
490          done
491          ;;
492      m68k)
493          f=config/m68k-parse.o
494          case " $extra_objects " in
495            *" $f "*) ;;
496            *) extra_objects="$extra_objects $f" ;;
497          esac
498          ;;
499
500      mep)
501          using_cgen=yes
502          ;;
503
504      mips)
505          for f in itbl-parse.o itbl-lex-wrapper.o itbl-ops.o; do
506            case " $extra_objects " in
507              *" $f "*) ;;
508              *) extra_objects="$extra_objects $f" ;;
509            esac
510          done
511          ;;
512
513      mt)
514          using_cgen=yes
515          ;;
516
517      nds32)
518          # setup NDS32_LINUX_TOOLCHAIN definition
519          if test "linux" = $em; then
520            AC_DEFINE(NDS32_LINUX_TOOLCHAIN, 1,
521              [Define value for nds32_linux_toolchain])
522          else
523            AC_DEFINE(NDS32_LINUX_TOOLCHAIN, 0,
524              [Define default value for nds32_linux_toolchain])
525          fi
526
527          # Decide BASELINE, REDUCED_REGS, FPU_DP_EXT, FPU_SP_EXT features
528          # based on arch_name.
529          AC_MSG_CHECKING(for default configuration of --with-arch)
530          if test "x${with_arch}" != x; then
531            case ${with_arch} in
532              v2j | v2s | v2f | v2 | v3m | v3j | v3s | v3f | v3 )
533                AC_DEFINE_UNQUOTED(NDS32_DEFAULT_ARCH_NAME, "$with_arch",
534                                         [Define value for nds32_arch_name])
535                ;;
536              *)
537                AC_MSG_ERROR(This kind of arch name does *NOT* exist!)
538                ;;
539            esac
540          fi
541          AC_MSG_RESULT($with_arch)
542
543          # Decide features one by one.
544          AC_MSG_CHECKING(for default configuration of --enable-dx-regs)
545          if test "x${enable_dx_regs}" = xyes; then
546            AC_DEFINE(NDS32_DEFAULT_DX_REGS, 1,
547                        [Define value for nds32_dx_regs])
548          else
549            AC_DEFINE(NDS32_DEFAULT_DX_REGS, 0,
550                        [Define default value for nds32_dx_regs])
551          fi
552          AC_MSG_RESULT($enable_dx_regs)
553
554          AC_MSG_CHECKING(for default configuration of --enable-perf-ext)
555          if test "x${enable_perf_ext}" = xno; then
556            AC_DEFINE(NDS32_DEFAULT_PERF_EXT, 0,
557                        [Define value for nds32_perf_ext])
558          else
559            AC_DEFINE(NDS32_DEFAULT_PERF_EXT, 1,
560                        [Define default value for nds32_perf_ext])
561          fi
562          AC_MSG_RESULT($enable_perf_ext)
563
564          AC_MSG_CHECKING(for default configuration of --enable-perf-ext2)
565          if test "x${enable_perf_ext2}" = xno; then
566            AC_DEFINE(NDS32_DEFAULT_PERF_EXT2, 0,
567                        [Define value for nds32_perf_ext2])
568          else
569            AC_DEFINE(NDS32_DEFAULT_PERF_EXT2, 1,
570                        [Define default value for nds32_perf_ext2])
571          fi
572          AC_MSG_RESULT($enable_perf_ext2)
573
574          AC_MSG_CHECKING(for default configuration of --enable-string-ext)
575          if test "x${enable_string_ext}" = xno; then
576            AC_DEFINE(NDS32_DEFAULT_STRING_EXT, 0,
577                        [Define value for nds32_string_ext])
578          else
579            AC_DEFINE(NDS32_DEFAULT_STRING_EXT, 1,
580                        [Define default value for nds32_string_ext])
581          fi
582          AC_MSG_RESULT($enable_string_ext)
583
584          AC_MSG_CHECKING(for default configuration of --enable-audio-ext)
585          if test "x${enable_audio_ext}" = xno; then
586            AC_DEFINE(NDS32_DEFAULT_AUDIO_EXT, 0,
587                        [Define value for nds32_audio_ext])
588          else
589            AC_DEFINE(NDS32_DEFAULT_AUDIO_EXT, 1,
590                        [Define default value for nds32_audio_ext])
591          fi
592          AC_MSG_RESULT($enable_audio_ext)
593
594          AC_MSG_CHECKING(for default configuration of --enable-dsp-ext)
595          if test "x${enable_dsp_ext}" = xno; then
596            AC_DEFINE(NDS32_DEFAULT_DSP_EXT, 0,
597                        [Define value for nds32_dsp_ext])
598          else
599            AC_DEFINE(NDS32_DEFAULT_DSP_EXT, 1,
600                        [Define default value for nds32_dsp_ext])
601          fi
602          AC_MSG_RESULT($enable_dsp_ext)
603
604          AC_MSG_CHECKING(for default configuration of --enable-zol-ext)
605          if test "x${enable_zol_ext}" = xno; then
606            AC_DEFINE(NDS32_DEFAULT_ZOL_EXT, 0,
607                        [Define value for nds32_zol_ext])
608          else
609            AC_DEFINE(NDS32_DEFAULT_ZOL_EXT, 1,
610                        [Define default value for nds32_zol_ext])
611          fi
612          AC_MSG_RESULT($enable_zol_ext)
613          ;;
614
615      aarch64 | i386 | s390 | sparc)
616          if test $this_target = $target ; then
617            AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
618          fi
619          ;;
620
621      riscv)
622        # --target=riscv[32|64]-*-*.  */
623        if test $this_target = $target ; then
624          AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
625        fi
626
627        # --with-arch=<value>.  The syntax of <value> is same as Gas option -march.
628        AC_MSG_CHECKING(for default configuration of --with-arch)
629        if test "x${with_arch}" != x; then
630        AC_DEFINE_UNQUOTED(DEFAULT_RISCV_ARCH_WITH_EXT, "$with_arch",
631                           [Define default value for RISC-V -march.])
632        fi
633        AC_MSG_RESULT($with_arch)
634
635        # --with-isa-spec=[2.2|20190608|20191213].
636        AC_MSG_CHECKING(for default configuration of --with-isa-spec)
637        if test "x${with_isa_spec}" != x; then
638          AC_DEFINE_UNQUOTED(DEFAULT_RISCV_ISA_SPEC, "$with_isa_spec",
639                             [Define default value for RISC-V -misa-spec.])
640        fi
641        AC_MSG_RESULT($with_isa_spec)
642
643        # --with-priv-spec=[1.9.1|1.10|1.11|1.12].
644        AC_MSG_CHECKING(for default configuration of --with-priv-spec)
645        if test "x${with_priv_spec}" != x; then
646          AC_DEFINE_UNQUOTED(DEFAULT_RISCV_PRIV_SPEC, "$with_priv_spec",
647                             [Define default value for RISC-V -mpriv-spec])
648        fi
649        AC_MSG_RESULT($with_priv_spec)
650        ;;
651
652      rl78)
653          f=config/rl78-parse.o
654          case " $extra_objects " in
655            *" $f "*) ;;
656            *) extra_objects="$extra_objects $f" ;;
657          esac
658          ;;
659
660      rx)
661          f=config/rx-parse.o
662          case " $extra_objects " in
663            *" $f "*) ;;
664            *) extra_objects="$extra_objects $f" ;;
665          esac
666          ;;
667
668      xstormy16)
669          using_cgen=yes
670          ;;
671
672      xtensa)
673          f=config/xtensa-relax.o
674          case " $extra_objects " in
675            *" $f "*) ;;
676            *) extra_objects="$extra_objects $f" ;;
677          esac
678          ;;
679
680      *)
681          ;;
682    esac
683
684    if test $using_cgen = yes ; then
685          f=cgen.o
686          case " $extra_objects " in
687            *" $f "*) ;;
688            *) extra_objects="$extra_objects $f" ;;
689          esac
690    fi
691
692# See if we really can support this configuration with the emulation code.
693
694    if test $this_target = $target ; then
695      obj_format=$fmt
696      te_file=$em
697    fi
698
699    case ${te_file} in
700      vms)
701          f=config/te-vms.o
702          case " $extra_objects " in
703            *" $f "*) ;;
704            *) extra_objects="$extra_objects $f" ;;
705          esac ;;
706    esac
707
708# From target name and format, produce a list of supported emulations.
709
710    case ${generic_target}-${fmt} in
711      mips-*-*-*)   case "$endian" in
712                              big)      emulation="mipsbelf mipslelf mipself" ;;
713                              *)        emulation="mipslelf mipsbelf mipself" ;;
714                              esac ;;
715      # i386-pc-pe-coff != i386-pc-coff.
716      i386-*-pe-coff)         ;;
717      # Uncommenting the next line will turn on support for i386 AOUT
718      # for the default linux configuration
719      # i386-*-linux*-elf) emulation="i386elf i386aout" ;;
720      #
721      i386-*-aout)  emulation="i386aout" ;;
722      i386-*-coff)  emulation="i386coff" ;;
723      i386-*-elf)   emulation="i386elf" ;;
724
725      # Always all formats.  The first stated emulation becomes the default.
726      cris-*-*aout*)          emulation="crisaout criself" ;;
727      cris-*-*)               emulation="criself crisaout" ;;
728    esac
729
730    emulations="$emulations $emulation"
731
732done
733
734if test ${ac_default_x86_relax_relocations} = unset; then
735  ac_default_x86_relax_relocations=1
736fi
737AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_X86_RELAX_RELOCATIONS,
738  $ac_default_x86_relax_relocations,
739  [Define to 1 if you want to generate x86 relax relocations by default.])
740
741if test ${ac_default_elf_stt_common} = unset; then
742  ac_default_elf_stt_common=0
743fi
744AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_ELF_STT_COMMON,
745  $ac_default_elf_stt_common,
746  [Define to 1 if you want to generate ELF common symbols with the
747   STT_COMMON type by default.])
748
749AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_BUILD_NOTES,
750  $ac_default_generate_build_notes,
751  [Define to 1 if you want to generate GNU Build attribute notes
752   by default, if none are contained in the input.])
753
754if test ${ac_default_generate_x86_used_note} = unset; then
755  ac_default_generate_x86_used_note=0
756fi
757AC_DEFINE_UNQUOTED(DEFAULT_X86_USED_NOTE,
758  $ac_default_generate_x86_used_note,
759  [Define to 1 if you want to generate GNU x86 used ISA and feature
760   properties by default.])
761
762if test ${ac_default_generate_riscv_attr} = unset; then
763  ac_default_generate_riscv_attr=1
764fi
765
766AC_DEFINE_UNQUOTED(DEFAULT_RISCV_ATTR,
767  $ac_default_generate_riscv_attr,
768  [Define to 1 if you want to generate RISC-V arch attribute by default.])
769
770if test ${ac_default_mips_fix_loongson3_llsc} = unset; then
771  ac_default_mips_fix_loongson3_llsc=0
772fi
773AC_DEFINE_UNQUOTED(DEFAULT_MIPS_FIX_LOONGSON3_LLSC,
774  $ac_default_mips_fix_loongson3_llsc,
775  [Define to 1 if you want to fix Loongson3 LLSC Errata by default.])
776
777if test x$ac_default_compressed_debug_sections = xyes ; then
778  AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.])
779fi
780
781AC_DEFINE_UNQUOTED(DEFAULT_COMPRESSED_DEBUG_ALGORITHM, $ac_default_compressed_debug_sections_algorithm,
782                       [Default compression algorithm for --enable-compressed-debug-sections.])
783
784# Turn on all targets if possible
785if test ${all_targets} = "yes"; then
786  case ${target_cpu_type} in
787  i386)
788    case ${obj_format} in
789    aout)
790      emulations="$emulations i386coff i386elf"
791      ;;
792    coff)
793      emulations="$emulations i386aout i386elf"
794    ;;
795    elf)
796      emulations="$emulations i386aout i386coff"
797      ;;
798    esac
799  ;;
800  x86_64)
801    case ${obj_format} in
802    aout)
803      emulations="$emulations i386coff i386elf"
804      ;;
805    coff)
806      emulations="$emulations i386aout i386elf"
807    ;;
808    elf)
809      emulations="$emulations i386aout i386coff"
810      ;;
811    esac
812  ;;
813  esac
814fi
815
816# PE code has way too many macros tweaking behaviour
817case ${te_file} in
818  pe*) emulations="" ;;
819esac
820
821# Assign floating point type.  Most processors with FP support
822# IEEE FP.  On those that don't support FP at all, usually IEEE
823# is emulated.
824case ${target_cpu} in
825  vax | pdp11 )     atof=vax ;;
826  *)                atof=ieee ;;
827esac
828
829case "${obj_format}" in
830  "") AC_MSG_ERROR(GAS does not know what format to use for target ${target}) ;;
831esac
832
833# Unfortunately the cpu in cpu-opc.h file isn't always $(TARGET_CPU).
834cgen_cpu_prefix=""
835if test $using_cgen = yes ; then
836  case ${target_cpu} in
837    or1knd)
838       cgen_cpu_prefix=or1k ;;
839    *) cgen_cpu_prefix=${target_cpu} ;;
840  esac
841  AC_SUBST(cgen_cpu_prefix)
842  AC_DEFINE(USING_CGEN, 1, [Using cgen code?])
843fi
844
845dnl
846dnl Make sure the desired support files exist.
847dnl
848
849if test ! -r ${srcdir}/config/tc-${target_cpu_type}.c; then
850  AC_MSG_ERROR(GAS does not support target CPU ${target_cpu_type})
851fi
852
853if test ! -r ${srcdir}/config/obj-${obj_format}.c; then
854  AC_MSG_ERROR(GAS does not have support for object file format ${obj_format})
855fi
856
857# Some COFF configurations want these random other flags set.
858case ${obj_format} in
859  coff)
860    case ${target_cpu_type} in
861      i386) AC_DEFINE(I386COFF, 1, [Using i386 COFF?]) ;;
862      x86_64) AC_DEFINE(I386COFF, 1, [Using i386 COFF?]) ;;
863    esac
864    ;;
865esac
866
867# Getting this done right is going to be a bitch.  Each configuration specified
868# with --enable-targets=... should be checked for environment, format, cpu
869# setting.
870#
871# For each configuration, the necessary object file support code must be linked
872# in.  This might be only one, it might be up to four.  The necessary emulation
873# code needs to be provided, too.
874#
875# And then there's "--enable-targets=all"....
876#
877# For now, just always do it for MIPS ELF configurations.  Sigh.
878
879formats="${obj_format}"
880emfiles=""
881EMULATIONS=""
882GAS_UNIQ(emulations)
883for em in . $emulations ; do
884  case $em in
885    .)    continue ;;
886    mipsbelf | mipslelf | mipself)
887          fmt=elf   file=mipself ;;
888    *coff)
889          fmt=coff  file=$em ;;
890    *aout)
891          fmt=aout file=$em ;;
892    *elf)
893          fmt=elf file=$em ;;
894  esac
895  formats="$formats $fmt"
896  emfiles="$emfiles config/e-$file.o"
897  EMULATIONS="$EMULATIONS &$em,"
898done
899GAS_UNIQ(formats)
900GAS_UNIQ(emfiles)
901if test `set . $formats ; shift ; echo $#` -gt 1 ; then
902  for fmt in $formats ; do
903    case $fmt in
904      aout)         AC_DEFINE(OBJ_MAYBE_AOUT, 1,    [a.out support?])   ;;
905      coff)         AC_DEFINE(OBJ_MAYBE_COFF, 1,    [COFF support?])    ;;
906      ecoff)        AC_DEFINE(OBJ_MAYBE_ECOFF, 1,   [ECOFF support?])   ;;
907      elf)          AC_DEFINE(OBJ_MAYBE_ELF, 1,     [ELF support?])     ;;
908      generic)      AC_DEFINE(OBJ_MAYBE_GENERIC, 1, [generic support?]) ;;
909      som)          AC_DEFINE(OBJ_MAYBE_SOM, 1,     [SOM support?])     ;;
910    esac
911    extra_objects="$extra_objects config/obj-$fmt.o"
912  done
913  obj_format=multi
914fi
915if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then
916  DEFAULT_EMULATION=`set . $emulations ; echo $2`
917  # e-mipself has more than one emulation per file, e-i386* has just one at the
918  # moment.  If only one emulation is specified, then don't define
919  # USE_EMULATIONS or include any of the e-files as they will only be bloat.
920  case "${obj_format}${emfiles}" in
921    multi* | *mipself*)
922      extra_objects="$extra_objects $emfiles"
923      AC_DEFINE(USE_EMULATIONS, 1, [Use emulation support?]) ;;
924  esac
925fi
926AC_SUBST(extra_objects)
927AC_DEFINE_UNQUOTED(EMULATIONS, $EMULATIONS, [Supported emulations.])
928AC_DEFINE_UNQUOTED(DEFAULT_EMULATION, "$DEFAULT_EMULATION",
929                       [Default emulation.])
930
931reject_dev_configs=yes
932
933case ${reject_dev_configs}-${dev} in
934  yes-yes) # Oops.
935    AC_MSG_ERROR(GAS does not support the ${generic_target} configuration.)
936    ;;
937esac
938
939AC_SUBST(target_cpu_type)
940AC_SUBST(obj_format)
941AC_SUBST(te_file)
942AC_SUBST(install_tooldir)
943AC_SUBST(atof)
944dnl AC_SUBST(emulation)
945
946# do we need the opcodes library?
947case "${need_opcodes}" in
948yes)
949  OPCODES_LIB=../opcodes/libopcodes.la
950  ;;
951esac
952
953AC_SUBST(OPCODES_LIB)
954
955AC_DEFINE_UNQUOTED(TARGET_ALIAS,        "${target_alias}", [Target alias.])
956AC_DEFINE_UNQUOTED(TARGET_CANONICAL,    "${target}",       [Canonical target.])
957AC_DEFINE_UNQUOTED(TARGET_CPU,                    "${target_cpu}",   [Target CPU.])
958AC_DEFINE_UNQUOTED(TARGET_VENDOR,       "${target_vendor}", [Target vendor.])
959AC_DEFINE_UNQUOTED(TARGET_OS,           "${target_os}",    [Target OS.])
960
961AC_PROG_YACC
962AM_PROG_LEX
963
964ALL_LINGUAS="es fi fr id ja ru rw sv tr uk zh_CN"
965ZW_GNU_GETTEXT_SISTER_DIR
966AM_PO_SUBDIRS
967
968AM_MAINTAINER_MODE
969AM_CONDITIONAL(GENINSRC_NEVER, false)
970AC_EXEEXT
971
972AC_CHECK_HEADERS(memory.h sys/stat.h sys/types.h unistd.h)
973
974# Put this here so that autoconf's "cross-compiling" message doesn't confuse
975# people who are not cross-compiling but are compiling cross-assemblers.
976AC_MSG_CHECKING(whether compiling a cross-assembler)
977if test "${host}" = "${target}"; then
978  cross_gas=no
979else
980  cross_gas=yes
981  AC_DEFINE(CROSS_COMPILE, 1, [Compiling cross-assembler?])
982fi
983AC_MSG_RESULT($cross_gas)
984
985AC_CHECK_FUNCS(strsignal)
986
987AM_LC_MESSAGES
988
989# do we need the math library?
990case "${need_libm}" in
991yes)
992  LT_LIB_M
993  AC_SUBST(LIBM)
994  ;;
995esac
996
997# Some non-ANSI preprocessors botch requoting inside strings.  That's bad
998# enough, but on some of those systems, the assert macro relies on requoting
999# working properly!
1000GAS_WORKING_ASSERT
1001
1002# On some systems, the system header files may not declare malloc, realloc,
1003# and free.  There are places where gas needs these functions to have been
1004# declared -- such as when taking their addresses.
1005gas_test_headers="
1006#ifdef HAVE_MEMORY_H
1007#include <memory.h>
1008#endif
1009#include <string.h>
1010#include <stdlib.h>
1011#ifdef HAVE_UNISTD_H
1012#include <unistd.h>
1013#endif
1014"
1015
1016AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
1017AC_CACHE_VAL(gas_cv_decl_getopt_unistd_h,
1018[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
1019gas_cv_decl_getopt_unistd_h=yes, gas_cv_decl_getopt_unistd_h=no)])
1020AC_MSG_RESULT($gas_cv_decl_getopt_unistd_h)
1021if test $gas_cv_decl_getopt_unistd_h = yes; then
1022  AC_DEFINE([HAVE_DECL_GETOPT], 1,
1023              [Is the prototype for getopt in <unistd.h> in the expected format?])
1024fi
1025
1026GAS_CHECK_DECL_NEEDED(environ, f, char **f, $gas_test_headers)
1027GAS_CHECK_DECL_NEEDED(ffs, f, int (*f)(int), $gas_test_headers)
1028
1029AC_CHECK_DECLS([asprintf, mempcpy, stpcpy])
1030
1031BFD_BINARY_FOPEN
1032
1033# Link in zlib/zstd if we can.  This allows us to write compressed debug sections.
1034AM_ZLIB
1035AC_ZSTD
1036
1037# Support for VMS timestamps via cross compile
1038
1039if test "$ac_cv_header_time_h" = yes; then
1040  GAS_HAVE_TIME_TYPE_MEMBER(struct tm, tm_gmtoff)
1041fi
1042
1043if test "$ac_cv_header_sys_stat_h" = yes; then
1044    GAS_HAVE_SYS_STAT_TYPE_MEMBER(struct stat, st_mtim, tv_sec)
1045    GAS_HAVE_SYS_STAT_TYPE_MEMBER(struct stat, st_mtim, tv_nsec)
1046fi
1047
1048
1049dnl Required for html, pdf, install-pdf and install-html targets.
1050AC_SUBST(datarootdir)
1051AC_SUBST(docdir)
1052AC_SUBST(htmldir)
1053AC_SUBST(pdfdir)
1054
1055dnl This must come last.
1056
1057dnl We used to make symlinks to files in the source directory, but now
1058dnl we just use the right name for .c files, and create .h files in
1059dnl the build directory which include the right .h file.  Make sure
1060dnl the old symlinks don't exist, so that a reconfigure in an existing
1061dnl directory behaves reasonably.
1062
1063AC_CONFIG_FILES(Makefile po/Makefile.in:po/Make-in)
1064AC_CONFIG_COMMANDS([default],
1065[rm -f targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c itbl-cpu.h
1066 echo '#include "tc-'"${target_cpu_type}"'.h"' > targ-cpu.h
1067 echo '#include "obj-'"${obj_format}"'.h"' > obj-format.h
1068 echo '#include "te-'"${te_file}"'.h"' > targ-env.h
1069 echo '#include "itbl-'"${target_cpu_type}"'.h"' > itbl-cpu.h
1070 if test "x$cgen_cpu_prefix" != x ; then
1071   echo '#include "opcodes/'"${cgen_cpu_prefix}"'-desc.h"' > cgen-desc.h
1072 fi],
1073[target_cpu_type=${target_cpu_type}
1074 cgen_cpu_prefix=${cgen_cpu_prefix}
1075 obj_format=${obj_format}
1076 te_file=${te_file}])
1077
1078AC_OUTPUT
1079
1080GNU_MAKE_JOBSERVER
1081