]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/common/acinclude.m4
sim: allow the environment configure option everywhere
[thirdparty/binutils-gdb.git] / sim / common / acinclude.m4
index 20155ad11b1d6d2fe0b5f8c771f81a34c2cda924..9b62bcdd070b794f50f27d63fd5bd8a859766933 100644 (file)
@@ -5,7 +5,7 @@
 # SIM_AC_OUTPUT is a cover function to AC_OUTPUT to generate the Makefile.
 # It is intended to be invoked last.
 #
-# The simulator's configure.in should look like:
+# The simulator's configure.ac should look like:
 #
 # dnl Process this file with autoconf to produce a configure script.
 # AC_PREREQ(2.64)dnl
 # Include global overrides and fixes for Autoconf.
 m4_include(../../config/override.m4)
 sinclude([../../config/zlib.m4])
+m4_include([../../config/plugins.m4])
+m4_include([../../libtool.m4])
+m4_include([../../ltoptions.m4])
+m4_include([../../ltsugar.m4])
+m4_include([../../ltversion.m4])
+m4_include([../../lt~obsolete.m4])
 sinclude([../../config/depstand.m4])
 
 AC_DEFUN([SIM_AC_COMMON],
@@ -29,6 +35,8 @@ AC_REQUIRE([AC_PROG_CC])
 # autoconf.info says this should be called right after AC_INIT.
 AC_CONFIG_HEADER(ifelse([$1],,config.h,[$1]):config.in)
 AC_CANONICAL_SYSTEM
+AC_USE_SYSTEM_EXTENSIONS
+AC_C_BIGENDIAN
 AC_ARG_PROGRAM
 AC_PROG_INSTALL
 
@@ -46,6 +54,13 @@ AR=${AR-ar}
 AC_SUBST(AR)
 AC_PROG_RANLIB
 
+# Some of the common include files depend on bfd.h, and bfd.h checks
+# that config.h is included first by testing that the PACKAGE macro
+# is defined.
+PACKAGE=sim
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ])
+AC_SUBST(PACKAGE)
+
 # Dependency checking.
 ZW_CREATE_DEPDIR
 ZW_PROG_COMPILER_DEPENDENCIES([CC])
@@ -69,10 +84,26 @@ ZW_GNU_GETTEXT_SISTER_DIR(../../intl)
 # FIXME: Seems to me this can cause problems for i386-windows hosts.
 # At one point there were hardcoded AC_DEFINE's if ${host} = i386-*-windows*.
 AC_CHECK_HEADERS(stdlib.h string.h strings.h unistd.h time.h)
-AC_CHECK_HEADERS(sys/time.h sys/resource.h)
+AC_CHECK_HEADERS(sys/time.h sys/times.h sys/resource.h sys/mman.h)
 AC_CHECK_HEADERS(fcntl.h fpu_control.h)
 AC_CHECK_HEADERS(dlfcn.h errno.h sys/stat.h)
 AC_CHECK_FUNCS(getrusage time sigaction __setfpucw)
+AC_CHECK_FUNCS(mmap munmap lstat truncate ftruncate posix_fallocate)
+AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino],
+[struct stat.st_mode], [struct stat.st_nlink], [struct stat.st_uid],
+[struct stat.st_gid], [struct stat.st_rdev], [struct stat.st_size],
+[struct stat.st_blksize], [struct stat.st_blocks], [struct stat.st_atime],
+[struct stat.st_mtime], [struct stat.st_ctime]], [], [],
+[[#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif]])
+AC_CHECK_TYPES(socklen_t, [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+])
 
 # Check for socket libraries
 AC_CHECK_LIB(socket, bind)
@@ -82,6 +113,12 @@ AC_CHECK_LIB(nsl, gethostbyname)
 # using the same condition.
 AM_ZLIB
 
+# BFD uses libdl when when plugins enabled.
+AC_PLUGINS
+AM_CONDITIONAL(PLUGINS, test "$plugins" = yes)
+LT_INIT([dlopen])
+AC_SUBST(lt_cv_dlopen_libs)
+
 . ${srcdir}/../../bfd/configure.host
 
 dnl Standard (and optional) simulator options.
@@ -93,53 +130,14 @@ dnl all shall eventually behave the same way.
 
 dnl We don't use automake, but we still want to support
 dnl --enable-maintainer-mode.
-USE_MAINTAINER_MODE=no
-AC_ARG_ENABLE(maintainer-mode,
-[  --enable-maintainer-mode            Enable developer functionality.],
-[case "${enableval}" in
-  yes) MAINT="" USE_MAINTAINER_MODE=yes ;;
-  no)  MAINT="#" ;;
-  *)   AC_MSG_ERROR("--enable-maintainer-mode does not take a value"); MAINT="#" ;;
-esac
-if test x"$silent" != x"yes" && test x"$MAINT" = x""; then
-  echo "Setting maintainer mode" 6>&1
-fi],[MAINT="#"])dnl
-AC_SUBST(MAINT)
-
-
-dnl This is a generic option to enable special byte swapping
-dnl insns on *any* cpu.
-AC_ARG_ENABLE(sim-bswap,
-[  --enable-sim-bswap                  Use Host specific BSWAP instruction.],
-[case "${enableval}" in
-  yes) sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
-  no)  sim_bswap="-DWITH_BSWAP=0";;
-  *)   AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
-esac
-if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
-  echo "Setting bswap flags = $sim_bswap" 6>&1
-fi],[sim_bswap=""])dnl
-AC_SUBST(sim_bswap)
-
-
-AC_ARG_ENABLE(sim-cflags,
-[  --enable-sim-cflags=opts            Extra CFLAGS for use in building simulator],
-[case "${enableval}" in
-  yes)  sim_cflags="-O2 -fomit-frame-pointer";;
-  trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
-  no)   sim_cflags="";;
-  *)    sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
-esac
-if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
-  echo "Setting sim cflags = $sim_cflags" 6>&1
-fi],[sim_cflags=""])dnl
-AC_SUBST(sim_cflags)
+AM_MAINTAINER_MODE
 
 
 dnl --enable-sim-debug is for developers of the simulator
 dnl the allowable values are work-in-progress
 AC_ARG_ENABLE(sim-debug,
-[  --enable-sim-debug=opts             Enable debugging flags],
+[AS_HELP_STRING([--enable-sim-debug=opts],
+               [Enable debugging flags (for developers of the sim itself)])],
 [case "${enableval}" in
   yes) sim_debug="-DDEBUG=7 -DWITH_DEBUG=7";;
   no)  sim_debug="-DDEBUG=0 -DWITH_DEBUG=0";;
@@ -154,7 +152,8 @@ AC_SUBST(sim_debug)
 dnl --enable-sim-stdio is for users of the simulator
 dnl It determines if IO from the program is routed through STDIO (buffered)
 AC_ARG_ENABLE(sim-stdio,
-[  --enable-sim-stdio                  Specify whether to use stdio for console input/output.],
+[AS_HELP_STRING([--enable-sim-stdio],
+               [Specify whether to use stdio for console input/output])],
 [case "${enableval}" in
   yes) sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
   no)  sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
@@ -172,12 +171,13 @@ dnl up to the simulator], or is a comma separated list of names of tracing
 dnl elements to enable.  The latter is only supported on simulators that
 dnl use WITH_TRACE.
 AC_ARG_ENABLE(sim-trace,
-[  --enable-sim-trace=opts             Enable tracing flags],
+[AS_HELP_STRING([--enable-sim-trace=opts],
+               [Enable tracing of simulated programs])],
 [case "${enableval}" in
-  yes) sim_trace="-DTRACE=1 -DWITH_TRACE=-1";;
-  no)  sim_trace="-DTRACE=0 -DWITH_TRACE=0";;
+  yes) sim_trace="-DWITH_TRACE=-1";;
+  no)  sim_trace="-DWITH_TRACE=0";;
   [[-0-9]]*)
-       sim_trace="-DTRACE='(${enableval})' -DWITH_TRACE='(${enableval})'";;
+       sim_trace="-DWITH_TRACE='(${enableval})'";;
   [[[:lower:]]]*)
        sim_trace=""
        for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
@@ -201,7 +201,7 @@ dnl up to the simulator], or is a comma separated list of names of profiling
 dnl elements to enable.  The latter is only supported on simulators that
 dnl use WITH_PROFILE.
 AC_ARG_ENABLE(sim-profile,
-[  --enable-sim-profile=opts           Enable profiling flags],
+[AS_HELP_STRING([--enable-sim-profile=opts], [Enable profiling flags])],
 [case "${enableval}" in
   yes) sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1";;
   no)  sim_profile="-DPROFILE=0 -DWITH_PROFILE=0";;
@@ -223,7 +223,11 @@ if test x"$silent" != x"yes" && test x"$sim_profile" != x""; then
 fi],[sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1"])dnl
 AC_SUBST(sim_profile)
 
-ACX_PKGVERSION([GDB])
+SIM_AC_OPTION_ASSERT
+SIM_AC_OPTION_ENVIRONMENT
+SIM_AC_OPTION_INLINE
+
+ACX_PKGVERSION([SIM])
 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
@@ -234,39 +238,18 @@ AC_TYPE_SIGNAL
 dnl Detect exe extension
 AC_EXEEXT
 
-dnl These are available to append to as desired.
-sim_link_files=
-sim_link_links=
-
-dnl Create tconfig.h either from simulator's tconfig.in or default one
-dnl in common.
-sim_link_links=tconfig.h
-if test -f ${srcdir}/tconfig.in
-then
-  sim_link_files=tconfig.in
-else
-  sim_link_files=../common/tconfig.in
-fi
-
-# targ-vals.def points to the libc macro description file.
-case "${target}" in
-*-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
-esac
-sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
-sim_link_links="${sim_link_links} targ-vals.def"
-
 ]) dnl End of SIM_AC_COMMON
 
 
 dnl Additional SIM options that can (optionally) be configured
 dnl For optional simulator options, a macro SIM_AC_OPTION_* is defined.
 dnl Simulators that wish to use the relevant option specify the macro
-dnl in the simulator specific configure.in file between the SIM_AC_COMMON
+dnl in the simulator specific configure.ac file between the SIM_AC_COMMON
 dnl and SIM_AC_OUTPUT lines.
 
 
 dnl Specify the running environment.
-dnl If the simulator invokes this in its configure.in then without this option
+dnl If the simulator invokes this in its configure.ac then without this option
 dnl the default is the user environment and all are runtime selectable.
 dnl If the simulator doesn't invoke this, only the user environment is
 dnl supported.
@@ -275,7 +258,8 @@ dnl let's not.
 AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT],
 [
 AC_ARG_ENABLE(sim-environment,
-[  --enable-sim-environment=environment        Specify mixed, user, virtual or operating environment.],
+[AS_HELP_STRING([--enable-sim-environment=environment],
+               [Specify mixed, user, virtual or operating environment])],
 [case "${enableval}" in
   all | ALL)             sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT";;
   user | USER)           sim_environment="-DWITH_ENVIRONMENT=USER_ENVIRONMENT";;
@@ -301,7 +285,8 @@ wire_alignment="[$1]"
 default_alignment="[$2]"
 [
 AC_ARG_ENABLE(sim-alignment,
-[  --enable-sim-alignment=align                Specify strict,  nonstrict or forced alignment of memory accesses.],
+[AS_HELP_STRING([--enable-sim-alignment=align],
+               [Specify strict, nonstrict or forced alignment of memory accesses])],
 [case "${enableval}" in
   strict | STRICT)       sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
   nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
@@ -348,7 +333,8 @@ dnl Conditionally compile in assertion statements.
 AC_DEFUN([SIM_AC_OPTION_ASSERT],
 [
 AC_ARG_ENABLE(sim-assert,
-[  --enable-sim-assert                 Specify whether to perform random assertions.],
+[AS_HELP_STRING([--enable-sim-assert],
+               [Specify whether to perform random assertions])],
 [case "${enableval}" in
   yes) sim_assert="-DWITH_ASSERT=1";;
   no)  sim_assert="-DWITH_ASSERT=0";;
@@ -375,7 +361,7 @@ wire_word_msb="[$2]"
 wire_address_bitsize="[$3]"
 wire_cell_bitsize="[$4]"
 [AC_ARG_ENABLE(sim-bitsize,
-[  --enable-sim-bitsize=N              Specify target bitsize (32 or 64).],
+[AS_HELP_STRING([--enable-sim-bitsize=N], [Specify target bitsize (32 or 64)])],
 [sim_bitsize=
 case "${enableval}" in
   64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";;
@@ -440,28 +426,29 @@ AC_DEFUN([SIM_AC_OPTION_ENDIAN],
 wire_endian="[$1]"
 default_endian="[$2]"
 AC_ARG_ENABLE(sim-endian,
-[  --enable-sim-endian=endian          Specify target byte endian orientation.],
+[AS_HELP_STRING([--enable-sim-endian=endian],
+               [Specify target byte endian orientation])],
 [case "${enableval}" in
-  b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
-  l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
+  b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG";;
+  l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_LITTLE";;
   yes)  if test x"$wire_endian" != x; then
-          sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
+          sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
         else
-           if test x"$default_endian" != x; then
-            sim_endian="-DWITH_TARGET_BYTE_ORDER=${default_endian}"
+         if test x"$default_endian" != x; then
+            sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
           else
             echo "No hard-wired endian for target $target" 1>&6
-            sim_endian="-DWITH_TARGET_BYTE_ORDER=0"
+            sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
           fi
         fi;;
   no)   if test x"$default_endian" != x; then
-          sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
+          sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
         else
           if test x"$wire_endian" != x; then
-            sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${wire_endian}"
+            sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
           else
             echo "No default endian for target $target" 1>&6
-            sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=0"
+            sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
           fi
         fi;;
   *)    AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
@@ -470,10 +457,10 @@ if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
   echo "Setting endian flags = $sim_endian" 6>&1
 fi],
 [if test x"$default_endian" != x; then
-  sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
+  sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
 else
   if test x"$wire_endian" != x; then
-    sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
+    sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
   else
     sim_endian=
   fi
@@ -482,36 +469,6 @@ fi])dnl
 AC_SUBST(sim_endian)
 
 
-dnl --enable-sim-hostendian is for users of the simulator when
-dnl they find that AC_C_BIGENDIAN does not function correctly
-dnl (for instance in a canadian cross)
-AC_DEFUN([SIM_AC_OPTION_HOSTENDIAN],
-[
-AC_ARG_ENABLE(sim-hostendian,
-[  --enable-sim-hostendian=end         Specify host byte endian orientation.],
-[case "${enableval}" in
-  no)   sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
-  b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
-  l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
-  *)    AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
-esac
-if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
-  echo "Setting hostendian flags = $sim_hostendian" 6>&1
-fi],[
-if test "x$cross_compiling" = "xno"; then
-  AC_C_BIGENDIAN
-  if test $ac_cv_c_bigendian = yes; then
-    sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
-  else
-    sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
-  fi
-else
-  sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
-fi])dnl
-])
-AC_SUBST(sim_hostendian)
-
-
 dnl --enable-sim-float is for developers of the simulator
 dnl It specifies the presence of hardware floating point
 dnl And optionally the bitsize of the floating point register.
@@ -522,7 +479,8 @@ AC_DEFUN([SIM_AC_OPTION_FLOAT],
 default_sim_float="[$1]"
 default_sim_float_bitsize="[$2]"
 AC_ARG_ENABLE(sim-float,
-[  --enable-sim-float                  Specify that the target processor has floating point hardware.],
+[AS_HELP_STRING([--enable-sim-float],
+               [Specify that the target processor has floating point hardware])],
 [case "${enableval}" in
   yes | hard)  sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
   no | soft)   sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
@@ -550,7 +508,8 @@ AC_DEFUN([SIM_AC_OPTION_SCACHE],
 [
 default_sim_scache="ifelse([$1],,0,[$1])"
 AC_ARG_ENABLE(sim-scache,
-[  --enable-sim-scache=size            Specify simulator execution cache size.],
+[AS_HELP_STRING([--enable-sim-scache=size],
+               [Specify simulator execution cache size])],
 [case "${enableval}" in
   yes) sim_scache="-DWITH_SCACHE=${default_sim_scache}";;
   no)  sim_scache="-DWITH_SCACHE=0" ;;
@@ -570,7 +529,8 @@ AC_DEFUN([SIM_AC_OPTION_DEFAULT_MODEL],
 [
 default_sim_default_model="ifelse([$1],,0,[$1])"
 AC_ARG_ENABLE(sim-default-model,
-[  --enable-sim-default-model=model    Specify default model to simulate.],
+[AS_HELP_STRING([--enable-sim-default-model=model],
+               [Specify default model to simulate])],
 [case "${enableval}" in
   yes|no) AC_MSG_ERROR("Missing argument to --enable-sim-default-model");;
   *)   sim_default_model="-DWITH_DEFAULT_MODEL='\"${enableval}\"'";;
@@ -588,31 +548,29 @@ dnl arg[2] is a space separated list of devices that override the defaults
 dnl arg[3] is a space separated list of extra target specific devices.
 AC_DEFUN([SIM_AC_OPTION_HARDWARE],
 [
-if test x"[$1]" = x"yes"; then
-  sim_hw_p=yes
-else
-  sim_hw_p=no
-fi
 if test "[$2]"; then
   hardware="[$2]"
 else
   hardware="cfi core pal glue"
 fi
 hardware="$hardware [$3]"
+
 sim_hw_cflags="-DWITH_HW=1"
 sim_hw="$hardware"
 sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
+
 AC_ARG_ENABLE(sim-hardware,
-[  --enable-sim-hardware=LIST          Specify the hardware to be included in the build.],
-[
-case "${enableval}" in
-  yes) sim_hw_p=yes;;
-  no)  sim_hw_p=no;;
-  ,*)   sim_hw_p=yes; hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
-  *,)   sim_hw_p=yes; hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
-  *)   sim_hw_p=yes; hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
+  [AS_HELP_STRING([--enable-sim-hardware=LIST],
+                  [Specify the hardware to be included in the build.])],
+  ,[enable_sim_hardware="[$1]"])
+case ${enable_sim_hardware} in
+  yes|no) ;;
+  ,*) hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
+  *,) hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
+  *)  hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
 esac
-if test "$sim_hw_p" != yes; then
+
+if test "$enable_sim_hardware" = no; then
   sim_hw_objs=
   sim_hw_cflags="-DWITH_HW=0"
   sim_hw=
@@ -627,22 +585,25 @@ else
       *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";;
     esac
   done
+  # mingw does not support sockser
+  case ${host} in
+    *mingw*) ;;
+    *) # TODO: We don't add dv-sockser to sim_hw as it is not a "real" device
+       # that you instatiate.  Instead, other code will call into it directly.
+       # At some point, we should convert it over.
+       sim_hw_objs="$sim_hw_objs dv-sockser.o"
+       AC_DEFINE_UNQUOTED(
+         [HAVE_DV_SOCKSER], 1, [Define if dv-sockser is usable.])
+       ;;
+  esac
+  if test x"$silent" != x"yes"; then
+    echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
+  fi
+  dnl Some devices require extra libraries.
+  case " $hardware " in
+    *" cfi "*) AC_CHECK_LIB(m, log2);;
+  esac
 fi
-if test x"$silent" != x"yes" && test "$sim_hw_p" = "yes"; then
-  echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
-fi],[
-if test "$sim_hw_p" != yes; then
-  sim_hw_objs=
-  sim_hw_cflags="-DWITH_HW=0"
-  sim_hw=
-fi
-if test x"$silent" != x"yes"; then
-  echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
-fi])
-dnl Some devices require extra libraries.
-case " $hardware " in
-  *" cfi "*) AC_CHECK_LIB(m, log2);;
-esac
 ])
 AC_SUBST(sim_hw_cflags)
 AC_SUBST(sim_hw_objs)
@@ -651,13 +612,13 @@ AC_SUBST(sim_hw)
 
 dnl --enable-sim-inline is for users that wish to ramp up the simulator's
 dnl performance by inlining functions.
-dnl Guarantee that unconfigured simulators do not do any inlining
-sim_inline="-DDEFAULT_INLINE=0"
+dnl Default sims to no inlining.
 AC_DEFUN([SIM_AC_OPTION_INLINE],
 [
-default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
+sim_inline="-DDEFAULT_INLINE=m4_ifblank([$1],[0],[$1])"
 AC_ARG_ENABLE(sim-inline,
-[  --enable-sim-inline=inlines         Specify which functions should be inlined.],
+[AS_HELP_STRING([--enable-sim-inline=inlines],
+               [Specify which functions should be inlined])],
 [sim_inline=""
 case "$enableval" in
   no)          sim_inline="-DDEFAULT_INLINE=0";;
@@ -681,18 +642,6 @@ case "$enableval" in
 esac
 if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
   echo "Setting inline flags = $sim_inline" 6>&1
-fi],[
-if test "x$cross_compiling" = "xno"; then
-  if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then
-    sim_inline="${default_sim_inline}"
-    if test x"$silent" != x"yes"; then
-      echo "Setting inline flags = $sim_inline" 6>&1
-    fi
-  else
-    sim_inline=""
-  fi
-else
-  sim_inline="-DDEFAULT_INLINE=0"
 fi])dnl
 ])
 AC_SUBST(sim_inline)
@@ -701,7 +650,8 @@ AC_SUBST(sim_inline)
 AC_DEFUN([SIM_AC_OPTION_PACKAGES],
 [
 AC_ARG_ENABLE(sim-packages,
-[  --enable-sim-packages=list          Specify the packages to be included in the build.],
+[AS_HELP_STRING([--enable-sim-packages=list],
+               [Specify the packages to be included in the build])],
 [packages=disklabel
 case "${enableval}" in
   yes) ;;
@@ -724,28 +674,12 @@ fi])dnl
 AC_SUBST(sim_packages)
 
 
-AC_DEFUN([SIM_AC_OPTION_REGPARM],
-[
-AC_ARG_ENABLE(sim-regparm,
-[  --enable-sim-regparm=nr-parm                Pass parameters in registers instead of on the stack - x86/GCC specific.],
-[case "${enableval}" in
-  0*|1*|2*|3*|4*|5*|6*|7*|8*|9*) sim_regparm="-DWITH_REGPARM=${enableval}";;
-  no)                            sim_regparm="" ;;
-  yes)                           sim_regparm="-DWITH_REGPARM=3";;
-  *)   AC_MSG_ERROR("Unknown value $enableval for --enable-sim-regparm"); sim_regparm="";;
-esac
-if test x"$silent" != x"yes" && test x"$sim_regparm" != x""; then
-  echo "Setting regparm flags = $sim_regparm" 6>&1
-fi],[sim_regparm=""])dnl
-])
-AC_SUBST(sim_regparm)
-
-
 AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS],
 [
 default_sim_reserved_bits="ifelse([$1],,1,[$1])"
 AC_ARG_ENABLE(sim-reserved-bits,
-[  --enable-sim-reserved-bits          Specify whether to check reserved bits in instruction.],
+[AS_HELP_STRING([--enable-sim-reserved-bits],
+               [Specify whether to check reserved bits in instruction])],
 [case "${enableval}" in
   yes) sim_reserved_bits="-DWITH_RESERVED_BITS=1";;
   no)  sim_reserved_bits="-DWITH_RESERVED_BITS=0";;
@@ -762,7 +696,8 @@ AC_DEFUN([SIM_AC_OPTION_SMP],
 [
 default_sim_smp="ifelse([$1],,5,[$1])"
 AC_ARG_ENABLE(sim-smp,
-[  --enable-sim-smp=n                  Specify number of processors to configure for (default ${default_sim_smp}).],
+[AS_HELP_STRING([--enable-sim-smp=n],
+               [Specify number of processors to configure for (default ${default_sim_smp})])],
 [case "${enableval}" in
   yes) sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5";;
   no)  sim_smp="-DWITH_SMP=0" ; sim_igen_smp="-N 0";;
@@ -778,28 +713,12 @@ fi])dnl
 AC_SUBST(sim_smp)
 
 
-AC_DEFUN([SIM_AC_OPTION_STDCALL],
-[
-AC_ARG_ENABLE(sim-stdcall,
-[  --enable-sim-stdcall=type           Use an alternative function call/return mechanism - x86/GCC specific.],
-[case "${enableval}" in
-  no)          sim_stdcall="" ;;
-  std*)                sim_stdcall="-DWITH_STDCALL=1";;
-  yes)         sim_stdcall="-DWITH_STDCALL=1";;
-  *)   AC_MSG_ERROR("Unknown value $enableval for --enable-sim-stdcall"); sim_stdcall="";;
-esac
-if test x"$silent" != x"yes" && test x"$sim_stdcall" != x""; then
-  echo "Setting function call flags = $sim_stdcall" 6>&1
-fi],[sim_stdcall=""])dnl
-])
-AC_SUBST(sim_stdcall)
-
-
 AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN],
 [
 default_sim_xor_endian="ifelse([$1],,8,[$1])"
 AC_ARG_ENABLE(sim-xor-endian,
-[  --enable-sim-xor-endian=n           Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian}).],
+[AS_HELP_STRING([--enable-sim-xor-endian=n],
+               [Specify number bytes involved in XOR bi-endian mode (default ${default_sim_xor_endian})])],
 [case "${enableval}" in
   yes) sim_xor_endian="-DWITH_XOR_ENDIAN=8";;
   no)  sim_xor_endian="-DWITH_XOR_ENDIAN=0";;
@@ -816,31 +735,42 @@ dnl --enable-build-warnings is for developers of the simulator.
 dnl it enables extra GCC specific warnings.
 AC_DEFUN([SIM_AC_OPTION_WARNINGS],
 [
-# NOTE: Don't add -Wall or -Wunused, they both include
-# -Wunused-parameter which reports bogus warnings.
-# NOTE: If you add to this list, remember to update
-# gdb/doc/gdbint.texinfo.
-build_warnings="-Wimplicit -Wreturn-type -Wcomment -Wtrigraphs \
--Wformat -Wparentheses -Wpointer-arith"
-# GCC supports -Wuninitialized only with -O or -On, n != 0.
-if test x${CFLAGS+set} = xset; then
-  case "${CFLAGS}" in
-    *"-O0"* ) ;;
-    *"-O"* )
-      build_warnings="${build_warnings} -Wuninitialized"
-    ;;
-  esac
-else
-  build_warnings="${build_warnings} -Wuninitialized"
+AC_ARG_ENABLE(werror,
+  AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
+  [case "${enableval}" in
+     yes | y) ERROR_ON_WARNING="yes" ;;
+     no | n)  ERROR_ON_WARNING="no" ;;
+     *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
+   esac])
+
+# Enable -Werror by default when using gcc
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+    ERROR_ON_WARNING=yes
+fi
+
+WERROR_CFLAGS=""
+if test "${ERROR_ON_WARNING}" = yes ; then
+# NOTE: Disabled in the sim dir due to most sims generating warnings.
+#    WERROR_CFLAGS="-Werror"
+     true
 fi
-# Up for debate: -Wswitch -Wcomment -trigraphs -Wtrigraphs
-# -Wunused-function -Wunused-label -Wunused-variable -Wunused-value
-# -Wchar-subscripts -Wtraditional -Wshadow -Wcast-qual
-# -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes
-# -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls
-# -Woverloaded-virtual -Winline -Werror"
+
+build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
+-Wpointer-sign \
+-Wno-unused -Wunused-value -Wunused-function \
+-Wno-switch -Wno-char-subscripts -Wmissing-prototypes
+-Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
+-Wold-style-declaration -Wold-style-definition"
+
+# Enable -Wno-format by default when using gcc on mingw since many
+# GCC versions complain about %I64.
+case "${host}" in
+  *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
+  *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
+esac
+
 AC_ARG_ENABLE(build-warnings,
-[  --enable-build-warnings Enable build-time compiler warnings if gcc is used],
+AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
 [case "${enableval}" in
   yes) ;;
   no)  build_warnings="-w";;
@@ -854,7 +784,7 @@ if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
   echo "Setting compiler warning flags = $build_warnings" 6>&1
 fi])dnl
 AC_ARG_ENABLE(sim-build-warnings,
-[  --enable-gdb-build-warnings Enable SIM specific build-time compiler warnings if gcc is used],
+AS_HELP_STRING([--enable-sim-build-warnings], [enable SIM specific build-time compiler warnings if gcc is used]),
 [case "${enableval}" in
   yes) ;;
   no)  build_warnings="-w";;
@@ -868,7 +798,6 @@ if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
   echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
 fi])dnl
 WARN_CFLAGS=""
-WERROR_CFLAGS=""
 if test "x${build_warnings}" != x -a "x$GCC" = xyes
 then
     AC_MSG_CHECKING(compiler warning flags)
@@ -884,7 +813,7 @@ then
            CFLAGS="$saved_CFLAGS"
        esac
     done
-    AC_MSG_RESULT(${WARN_CFLAGS}${WERROR_CFLAGS})
+    AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
 fi
 ])
 AC_SUBST(WARN_CFLAGS)
@@ -900,7 +829,6 @@ dnl the target's fragment at the appropriate points.
 
 AC_DEFUN([SIM_AC_OUTPUT],
 [
-AC_LINK_FILES($sim_link_files, $sim_link_links)
 dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
 cgen_breaks=""
 if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
@@ -940,7 +868,7 @@ dnl a directory name, but what we're doing here is an enable/disable kind
 dnl of thing and specifying both --enable and --with is klunky.
 dnl If you reeely want this to be --with, go ahead and change it.
 AC_ARG_ENABLE(cgen-maint,
-[  --enable-cgen-maint[=DIR]    build cgen generated files],
+[AS_HELP_STRING([--enable-cgen-maint[=DIR]], [build cgen generated files])],
 [case "${enableval}" in
   yes) cgen_maint=yes ;;
   no)  cgen_maint=no ;;