1dnl Process this file with autoconf to produce a configure script. 2dnl NB: The version here is not used. If gdb ever changes from generating its 3dnl version at build time to autoconf time (like bfd et al do), we can switch. 4AC_INIT([sim], [0], 5 [https://sourceware.org/bugzilla/enter_bug.cgi?product=gdb&component=sim], 6 [], [https://sourceware.org/gdb/wiki/Sim/]) 7 8dnl Probably should unify PKGVERSION with PACKAGE_* settings from AC_INIT. 9ACX_PKGVERSION([SIM]) 10AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description]) 11dnl PACKAGE_BUGREPORT is provided by AC_INIT. 12ACX_BUGURL([$PACKAGE_BUGREPORT]) 13AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address]) 14 15AC_CONFIG_HEADERS([config.h]) 16 17SIM_AC_TOOLCHAIN 18SIM_AC_PLATFORM 19 20AM_MAINTAINER_MODE 21AM_INIT_AUTOMAKE 22AM_SILENT_RULES([yes]) 23 24# If a cpu ever has more than one simulator to choose from, use 25# --enable-sim=... to choose. 26AC_ARG_ENABLE(sim, 27[AS_HELP_STRING([--enable-sim], [Enable the GNU simulator])], 28[case "${enableval}" in 29yes | no) ;; 30*) AC_MSG_ERROR(bad value ${enableval} given for --enable-sim option) ;; 31esac]) 32 33AC_ARG_ENABLE([example-sims], 34 [AC_HELP_STRING([--enable-example-sims], 35 [enable example GNU simulators])]) 36 37AC_ARG_ENABLE(targets, 38[ --enable-targets alternative target configurations], 39[case "${enableval}" in 40 yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all') 41 ;; 42 no) enable_targets= ;; 43 *) enable_targets=$enableval ;; 44esac]) 45 46dnl Used to keep track of which target (if any) is the default one. This is 47dnl used when installing files to see if they need to be suffixed. 48SIM_PRIMARY_TARGET= 49AC_SUBST(SIM_PRIMARY_TARGET) 50 51dnl Directories that we need to recurse into (i.e. add to $SUBDIRS). 52SIM_SUBDIRS= 53AC_SUBST(SIM_SUBDIRS) 54 55dnl List of enabled arch backends. 56SIM_ENABLED_ARCHES= 57AC_SUBST(SIM_ENABLED_ARCHES) 58 59dnl Used by common/Make-common.in to see which configure script created it. 60SIM_COMMON_BUILD_TRUE= 61SIM_COMMON_BUILD_FALSE='#' 62AC_SUBST(SIM_COMMON_BUILD_TRUE) 63AC_SUBST(SIM_COMMON_BUILD_FALSE) 64 65AC_CONFIG_FILES(Make-common.sim:common/Make-common.in) 66dnl Build a particular arch subdir. 67dnl arg[1] is the arch subdir name. 68dnl arg[2] is whether the arch has a dedicated configure script. 69m4_define([SIM_BUILD_TARGET], [dnl 70 AS_VAR_APPEND([SIM_ENABLED_ARCHES], [" $1"]) 71 m4_if($2, [true], [dnl 72 AC_CONFIG_SUBDIRS($1) 73 ], [dnl 74 AC_CONFIG_FILES($1/Makefile.sim:$1/Makefile.in) 75 AC_CONFIG_COMMANDS([$1/Makefile], 76[sed -n \ 77 -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ { 78 /^srcdir = / s:$:/$1: 79 p 80 }' \ 81 <Make-common.sim >$1/Makesim1.tmp 82 sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >$1/Makesim2.tmp 83 sed -e '/^## COMMON_PRE_/ r $1/Makesim1.tmp' \ 84 -e '/^## COMMON_POST_/ r $1/Makesim2.tmp' \ 85 <$1/Makefile.sim >$1/Makefile 86 rm -f $1/Makesim1.tmp $1/Makesim2.tmp 87]) 88 AS_VAR_APPEND([SIM_SUBDIRS], [" $1"]) 89 ]) 90 AC_CONFIG_FILES($1/.gdbinit:common/gdbinit.in) 91 dnl Create the depdirs for ports until we can convert them to automake. 92 AC_CONFIG_COMMANDS([depdir-$1], 93 [$SHELL $ac_aux_dir/mkinstalldirs $1/$DEPDIR], 94 [ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR]) 95]) 96dnl Enable a particular arch subdir. 97dnl arg[1] is the matching target triple. 98dnl arg[2] is the arch subdir name. 99dnl arg[3] is whether the arch has a dedicated configure script. 100dnl arg[4] is any additional shell code to run for this arch. 101m4_define([SIM_TARGET], [dnl 102 sim_enable_arch_$2=false 103 case "${targ}" in 104 all|$1) 105 if test "${targ}" = "${target}"; then 106 SIM_PRIMARY_TARGET=$2 107 fi 108 SIM_BUILD_TARGET($2, $3) 109 sim_enable_arch_$2=true 110 $4 111 ;; 112 esac 113 SIM_AC_TOOLCHAIN_FOR_TARGET($2) 114 AM_CONDITIONAL([SIM_ENABLE_ARCH_$2], [${sim_enable_arch_$2}]) 115]) 116 117dnl WHEN ADDING ENTRIES TO THIS MATRIX: 118dnl Make sure that the left side always has two dashes. Otherwise you can get 119dnl spurious matches. Even for unambiguous cases, do this as a convention, else 120dnl the table becomes a real mess to understand and maintain. 121dnl 122dnl NB: Target matching is aligned with gdb/configure.tgt. Changes must be kept 123dnl in sync with that file. 124if test "${enable_sim}" != no; then 125 sim_igen=no 126 for targ in `echo $target $enable_targets | sed 's/,/ /g'` 127 do 128 SIM_TARGET([aarch64*-*-*], [aarch64]) 129 SIM_TARGET([arm*-*-*], [arm]) 130 SIM_TARGET([avr*-*-*], [avr]) 131 SIM_TARGET([bfin-*-*], [bfin]) 132 SIM_TARGET([bpf-*-*], [bpf]) 133 SIM_TARGET([cr16*-*-*], [cr16]) 134 SIM_TARGET([cris-*-* | crisv32-*-*], [cris]) 135 SIM_TARGET([d10v-*-*], [d10v]) 136 SIM_TARGET([frv-*-*], [frv]) 137 SIM_TARGET([ft32-*-*], [ft32]) 138 SIM_TARGET([h8300*-*-*], [h8300]) 139 SIM_TARGET([iq2000-*-*], [iq2000]) 140 SIM_TARGET([lm32-*-*], [lm32]) 141 SIM_TARGET([m32c-*-*], [m32c]) 142 SIM_TARGET([m32r-*-*], [m32r]) 143 SIM_TARGET([m68hc11-*-*|m6811-*-*], [m68hc11]) 144 SIM_TARGET([mcore-*-*], [mcore]) 145 SIM_TARGET([microblaze*-*-*], [microblaze]) 146 SIM_TARGET([mips*-*-*], [mips], [true], [sim_igen=yes]) 147 SIM_TARGET([mn10300*-*-*], [mn10300], [], [sim_igen=yes]) 148 SIM_TARGET([moxie-*-*], [moxie]) 149 SIM_TARGET([msp430*-*-*], [msp430]) 150 SIM_TARGET([or1k*-*-*], [or1k]) 151 SIM_TARGET([powerpc*-*-*], [ppc], [true]) 152 SIM_TARGET([pru*-*-*], [pru]) 153 SIM_TARGET([riscv*-*-*], [riscv]) 154 SIM_TARGET([rl78-*-*], [rl78]) 155 SIM_TARGET([rx-*-*], [rx]) 156 SIM_TARGET([sh*-*-*], [sh]) 157 SIM_TARGET([sparc-*-*], [erc32]) 158 SIM_TARGET([v850*-*-*], [v850], [], [sim_igen=yes]) 159 done 160 161 if test "x${enable_example_sims}" = xyes; then 162 SIM_AC_TOOLCHAIN_FOR_TARGET(example-synacor) 163 SIM_BUILD_TARGET([example-synacor]) 164 fi 165 AM_CONDITIONAL([SIM_ENABLE_ARCH_examples], [test "${enable_example_sims}" = "yes"]) 166fi 167AM_CONDITIONAL([SIM_ENABLE_IGEN], [test "$sim_igen" = "yes"]) 168AM_CONDITIONAL([ENABLE_SIM], [test -n "$SIM_SUBDIRS"]) 169 170dnl Standard (and optional) simulator options. 171dnl Eventually all simulators will support these. 172SIM_AC_OPTION_ALIGNMENT 173SIM_AC_OPTION_ASSERT 174SIM_AC_OPTION_CGEN_MAINT 175SIM_AC_OPTION_DEBUG 176SIM_AC_OPTION_ENDIAN 177SIM_AC_OPTION_ENVIRONMENT 178SIM_AC_OPTION_HARDWARE 179SIM_AC_OPTION_INLINE 180SIM_AC_OPTION_PROFILE 181SIM_AC_OPTION_RESERVED_BITS 182SIM_AC_OPTION_SCACHE 183SIM_AC_OPTION_STDIO 184SIM_AC_OPTION_TRACE 185SIM_AC_OPTION_WARNINGS 186 187AC_MSG_CHECKING(for a known getopt prototype in unistd.h) 188AC_CACHE_VAL(sim_cv_decl_getopt_unistd_h, 189[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])], 190sim_cv_decl_getopt_unistd_h=yes, sim_cv_decl_getopt_unistd_h=no)]) 191AC_MSG_RESULT($sim_cv_decl_getopt_unistd_h) 192if test $sim_cv_decl_getopt_unistd_h = yes; then 193 AC_DEFINE([HAVE_DECL_GETOPT], 1, 194 [Is the prototype for getopt in <unistd.h> in the expected format?]) 195fi 196 197dnl These are unfortunate. They are conditionally called by other sim macros 198dnl but always used by common/Make-common.in. So we have to subst here even 199dnl when the rest of the code is in the respective macros. Once we merge the 200dnl respective SIM_AC_OPTION_xxx call above, we can drop these. 201AC_SUBST(sim_bitsize) 202AC_SUBST(sim_float) 203 204dnl Some arches have unique configure flags. 205m4_include([frv/acinclude.m4]) 206m4_include([riscv/acinclude.m4]) 207m4_include([rx/acinclude.m4]) 208 209dnl Hack to output an "include" statement in the Makefile so automake doesn't 210dnl try to follow it itself while processing Makefile.am. 211include_makefile="include" 212AC_SUBST(include_makefile) 213 214AC_CONFIG_FILES([arch-subdir.mk Makefile .gdbinit:gdbinit.in]) 215AC_OUTPUT 216