* syscall.c (cb_syscall) <case CB_SYS_truncate>
[binutils-gdb.git] / sim / common / aclocal.m4
index b45261117826b43a3e1d146032dea3b467e9809c..578658ccaf5af09e8cd4145e35199f8e2af0c43c 100644 (file)
@@ -199,7 +199,7 @@ AC_ARG_ENABLE(sim-profile,
 esac
 if test x"$silent" != x"yes" && test x"$sim_profile" != x""; then
   echo "Setting sim profile = $sim_profile" 6>&1
-fi],[sim_profile=""])dnl
+fi],[sim_profile="-DPROFILE=1 -DWITH_PROFILE=-1"])dnl
 AC_SUBST(sim_profile)
 
 
@@ -529,7 +529,7 @@ AC_ARG_ENABLE(sim-scache,
 [case "${enableval}" in
   yes) sim_scache="-DWITH_SCACHE=${default_sim_scache}";;
   no)  sim_scache="-DWITH_SCACHE=0" ;;
-  [[0-9]]*) sim_cache=${enableval};;
+  [[0-9]]*) sim_scache="-DWITH_SCACHE=${enableval}";;
   *)   AC_MSG_ERROR("Bad value $enableval passed to --enable-sim-scache");
        sim_scache="";;
 esac
@@ -787,23 +787,68 @@ 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 -Wuninitialized"
+# 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"
 AC_ARG_ENABLE(build-warnings,
-[  --enable-build-warnings[=LIST]              Enable build-time compiler warnings],
-[build_warnings="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations"
-case "${enableval}" in
+[  --enable-build-warnings Enable build-time compiler warnings if gcc is used],
+[case "${enableval}" in
   yes) ;;
   no)  build_warnings="-w";;
   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
-       build_warnings="${build_warnings} ${t}";;
+        build_warnings="${build_warnings} ${t}";;
   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
-       build_warnings="${t} ${build_warnings}";;
-  *)   build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+        build_warnings="${t} ${build_warnings}";;
+  *)    build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
 esac
 if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
-  echo "Setting warning flags = $build_warnings" 6>&1
-fi],[build_warnings=""])dnl
+  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],
+[case "${enableval}" in
+  yes) ;;
+  no)  build_warnings="-w";;
+  ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+        build_warnings="${build_warnings} ${t}";;
+  *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
+        build_warnings="${t} ${build_warnings}";;
+  *)    build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+esac
+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)
+    # Separate out the -Werror flag as some files just cannot be
+    # compiled with it enabled.
+    for w in ${build_warnings}; do
+       case $w in
+       -Werr*) WERROR_CFLAGS=-Werror ;;
+       *) # Check that GCC accepts it
+           saved_CFLAGS="$CFLAGS"
+           CFLAGS="$CFLAGS $w"
+           AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
+           CFLAGS="$saved_CFLAGS"
+       esac
+    done
+    AC_MSG_RESULT(${WARN_CFLAGS}${WERROR_CFLAGS})
+fi
 ])
-AC_SUBST(build_warnings)
+AC_SUBST(WARN_CFLAGS)
+AC_SUBST(WERROR_CFLAGS)
 
 
 dnl Generate the Makefile in a target specific directory.
@@ -816,6 +861,12 @@ 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
+cgen_breaks="break cgen_rtx_error";
+fi
+AC_SUBST(cgen_breaks)
 AC_OUTPUT(Makefile.sim:Makefile.in Make-common.sim:../common/Make-common.in .gdbinit:../common/gdbinit.in,
 [case "x$CONFIG_FILES" in
  xMakefile*)
@@ -1182,7 +1233,7 @@ AC_DEFUN(SIM_AC_OPTION_CGEN_MAINT,
 [
 cgen_maint=no
 dnl Default is to use one in build tree.
-cgen=../../cgen/cgen
+cgen=guile
 cgendir='$(srcdir)/../../cgen'
 dnl Having --enable-maintainer-mode take arguments is another way to go.
 dnl ??? One can argue --with is more appropriate if one wants to specify
@@ -1199,7 +1250,7 @@ AC_ARG_ENABLE(cgen-maint,
        # Having a `share' directory might be more appropriate for the .scm,
        # .cpu, etc. files.
        cgendir=${cgen_maint}/lib/cgen
-       cgen=${cgendir}/bin/cgen
+       cgen=guile
        ;;
 esac])dnl
 dnl AM_CONDITIONAL(CGEN_MAINT, test x${cgen_maint} != xno)
@@ -1212,3 +1263,71 @@ AC_SUBST(CGEN_MAINT)
 AC_SUBST(cgendir)
 AC_SUBST(cgen)
 ])
+dnl FIXME: When upgrading to modern autoconf, remove
+dnl        SIM_CHECK_MEMBER and SIM_CHECK_MEMBERS et al and use
+dnl        AC_CHECK_MEMBERS from autoconf.
+dnl
+dnl Translated from a FC2 autoconf-2.59-3 installation.
+dnl  AC_CHECK_MEMBER(AGGREGATE.MEMBER,
+dnl                  [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl                  [INCLUDES])
+dnl
+dnl  ---------------------------------------------------------
+dnl  AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
+dnl  variables are not a valid argument.
+AC_DEFUN([SIM_CHECK_MEMBER],
+dnl Extract the aggregate name, and the member name
+[AC_CACHE_CHECK([for $1], [ac_]patsubst([$1], [[\. ]], [_]),
+[ac_]patsubst([$1], [[\. ]], [_])[=no;]
+AC_TRY_COMPILE([$4],[
+dnl AGGREGATE ac_aggr;
+static ]patsubst([$1], [\..*])[ ac_aggr;
+dnl ac_aggr.MEMBER;
+if (ac_aggr.]patsubst([$1], [^[^.]*\.])[)
+return 0;],[ac_]patsubst([$1], [[\. ]], [_])[=yes;],
+AC_TRY_COMPILE([$4],[
+dnl AGGREGATE ac_aggr;
+static ]patsubst([$1], [\..*])[ ac_aggr;
+dnl ac_aggr.MEMBER;
+if (sizeof ac_aggr.]patsubst([$1], [^[^.]*\.])[)
+return 0;],
+[ac_]patsubst([$1], [[\. ]], [_])[=yes;],
+[ac_]patsubst([$1], [[\. ]], [_])[=no;]))
+[if test [$]ac_]patsubst([$1], [[\. ]], [_])[ = yes; then :; [$2]
+else :; [$3]
+fi])
+])dnl SIM_CHECK_MEMBER
+dnl
+dnl Translated from a FC2 autoconf-2.59-3 installation.
+dnl  SIM_CHECK_MEMBERS([AGGREGATE.MEMBER, ...])
+dnl except we just work with a limited set of fixed includes.
+dnl
+AC_DEFUN([SIM_CHECK_MEMBERS_1],
+[ifelse($#, 1,
+[SIM_CHECK_MEMBER([$1],
+AC_DEFINE_UNQUOTED([HAVE_]translit([$1], [a-z .], [A-Z__]), 1,
+[Define to 1 if ]patsubst([$1],
+[^[^.]*\.])[ is a member of ]patsubst([$1], [\..*])[. ]),,
+[#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif])],
+[SIM_CHECK_MEMBER([$1],
+AC_DEFINE_UNQUOTED([HAVE_]translit([$1], [a-z .], [A-Z__]), 1,
+[Define to 1 if ]patsubst([$1],
+[^[^.]*\.])[ is a member of ]patsubst([$1], [\..*])[. ]),,
+[#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif])
+SIM_CHECK_MEMBERS_1(builtin(shift,$@))])])dnl SIM_CHECK_MEMBERS
+dnl
+AC_DEFUN([SIM_CHECK_MEMBERS],
+[ifelse($#, 1, [SIM_CHECK_MEMBERS_1($1)],
+[errprint(__file__:__line__:
+[This SIM_CHECK_MEMBERS only supports one argument,]
+[the list of struct tests])])])dnl SIM_CHECK_MEMBERS