aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/ChangeLog17
-rw-r--r--sim/common/Make-common.in10
-rw-r--r--sim/common/aclocal.m41
-rw-r--r--sim/common/common.m44
-rw-r--r--sim/common/config.in6
-rwxr-xr-xsim/common/configure70
-rw-r--r--sim/common/run-sim.h2
-rw-r--r--sim/common/run.c69
-rw-r--r--sim/common/version.h25
9 files changed, 180 insertions, 24 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index de70dfe..c482dfd 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,20 @@
+2008-06-06 Vladimir Prus <vladimir@codesourcery.com>
+ Daniel Jacobowitz <dan@codesourcery.com>
+ Joseph Myers <joseph@codesourcery.com>
+
+ * aclocal.m4: Include ../../config/acx.m4.
+ * common.m4: Use ACX_PKGVERSION and ACX_BUGURL.
+ * configure, config.in: Regenerate.
+ * Make-common.in (LIB_OBJS): Add version.o.
+ (version.c, version.o): New rules.
+ * run.c: Include version.h.
+ (usage): Add help parameter. Print output either to stdout or
+ stderr depending on that parameter.
+ (print_version): New.
+ (main): Check for --help and --version.
+ * run-sim.h (sim_target_display_usage): Add help parameter.
+ * version.h: New.
+
2008-04-14 Hans Kester <kester.hans@gmail.com>
* sim-signal.c: Define missing signals for _WIN32.
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index bda7c40..e516583 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -245,7 +245,7 @@ LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL_DEP) $(LIBIBERTY_LIB) \
EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL) $(LIBIBERTY_LIB) \
$(CONFIG_LIBS) $(SIM_EXTRA_LIBS)
-LIB_OBJS = callback.o syscall.o targ-map.o $(SIM_OBJS)
+LIB_OBJS = callback.o syscall.o targ-map.o version.o $(SIM_OBJS)
RUNTESTFLAGS =
@@ -291,6 +291,14 @@ stamp-tvals: gentmap
$(SHELL) $(srcroot)/move-if-change tmp-tmap.c targ-map.c
touch stamp-tvals
+version.c: Makefile ../../gdb/version.in
+ rm -f version.c-tmp version.c
+ echo '#include "version.h"' >> version.c-tmp
+ echo 'const char version[] = "'"`sed q ${srcdir}/../../gdb/version.in`"'";' >> version.c-tmp
+ mv version.c-tmp version.c
+version.o: version.c $(version_h)
+
+
#
# Rules for building sim-* components. Triggered by listing the corresponding
# .o file in the list of simulator targets.
diff --git a/sim/common/aclocal.m4 b/sim/common/aclocal.m4
index 615f330..d916e62 100644
--- a/sim/common/aclocal.m4
+++ b/sim/common/aclocal.m4
@@ -893,6 +893,7 @@ AC_OUTPUT
])
sinclude(../../config/gettext-sister.m4)
+sinclude(../../config/acx.m4)
dnl --enable-cgen-maint support
AC_DEFUN(SIM_AC_OPTION_CGEN_MAINT,
diff --git a/sim/common/common.m4 b/sim/common/common.m4
index 8daf08e..f587754 100644
--- a/sim/common/common.m4
+++ b/sim/common/common.m4
@@ -195,6 +195,10 @@ 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])
+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])
dnl Types used by common code
AC_TYPE_SIGNAL
diff --git a/sim/common/config.in b/sim/common/config.in
index e2c2494..5df0854 100644
--- a/sim/common/config.in
+++ b/sim/common/config.in
@@ -145,6 +145,12 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
+/* Additional package description */
+#undef PKGVERSION
+
+/* Bug reporting address */
+#undef REPORT_BUGS_TO
+
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
diff --git a/sim/common/configure b/sim/common/configure
index d4bd3f8..b302f6c 100755
--- a/sim/common/configure
+++ b/sim/common/configure
@@ -309,7 +309,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
-ac_subst_vars='sim_environment sim_alignment sim_assert sim_bitsize sim_endian sim_hostendian sim_float sim_scache sim_default_model sim_hw_cflags sim_hw_objs sim_hw sim_inline sim_packages sim_regparm sim_reserved_bits sim_smp sim_stdcall sim_xor_endian WARN_CFLAGS WERROR_CFLAGS SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC_FOR_BUILD HDEFINES AR RANLIB ac_ct_RANLIB USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT CPP EGREP MAINT sim_bswap sim_cflags sim_debug sim_stdio sim_trace sim_profile CPP_FOR_TARGET TARGET_SUBDIR LIBOBJS LTLIBOBJS'
+ac_subst_vars='sim_environment sim_alignment sim_assert sim_bitsize sim_endian sim_hostendian sim_float sim_scache sim_default_model sim_hw_cflags sim_hw_objs sim_hw sim_inline sim_packages sim_regparm sim_reserved_bits sim_smp sim_stdcall sim_xor_endian WARN_CFLAGS WERROR_CFLAGS SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC_FOR_BUILD HDEFINES AR RANLIB ac_ct_RANLIB USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT CPP EGREP MAINT sim_bswap sim_cflags sim_debug sim_stdio sim_trace sim_profile PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI CPP_FOR_TARGET TARGET_SUBDIR LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -858,6 +858,12 @@ Optional Features:
--enable-sim-trace=opts Enable tracing flags
--enable-sim-profile=opts Enable profiling flags
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-pkgversion=PKG Use PKG in the version string in place of "GDB"
+ --with-bugurl=URL Direct users to URL to report a bug
+
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
@@ -4130,6 +4136,65 @@ else
fi;
+
+# Check whether --with-pkgversion or --without-pkgversion was given.
+if test "${with_pkgversion+set}" = set; then
+ withval="$with_pkgversion"
+ case "$withval" in
+ yes) { { echo "$as_me:$LINENO: error: package version not specified" >&5
+echo "$as_me: error: package version not specified" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ no) PKGVERSION= ;;
+ *) PKGVERSION="($withval) " ;;
+ esac
+else
+ PKGVERSION="(GDB) "
+
+fi;
+
+
+
+
+# Check whether --with-bugurl or --without-bugurl was given.
+if test "${with_bugurl+set}" = set; then
+ withval="$with_bugurl"
+ case "$withval" in
+ yes) { { echo "$as_me:$LINENO: error: bug URL not specified" >&5
+echo "$as_me: error: bug URL not specified" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ no) BUGURL=
+ ;;
+ *) BUGURL="$withval"
+ ;;
+ esac
+else
+ BUGURL="http://www.gnu.org/software/gdb/bugs/"
+
+fi;
+ case ${BUGURL} in
+ "")
+ REPORT_BUGS_TO=
+ REPORT_BUGS_TEXI=
+ ;;
+ *)
+ REPORT_BUGS_TO="<$BUGURL>"
+ REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
+ ;;
+ esac;
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define PKGVERSION "$PKGVERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define REPORT_BUGS_TO "$REPORT_BUGS_TO"
+_ACEOF
+
+
echo "$as_me:$LINENO: checking return type of signal handlers" >&5
echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6
if test "${ac_cv_type_signal+set}" = set; then
@@ -6785,6 +6850,9 @@ s,@sim_debug@,$sim_debug,;t t
s,@sim_stdio@,$sim_stdio,;t t
s,@sim_trace@,$sim_trace,;t t
s,@sim_profile@,$sim_profile,;t t
+s,@PKGVERSION@,$PKGVERSION,;t t
+s,@REPORT_BUGS_TO@,$REPORT_BUGS_TO,;t t
+s,@REPORT_BUGS_TEXI@,$REPORT_BUGS_TEXI,;t t
s,@CPP_FOR_TARGET@,$CPP_FOR_TARGET,;t t
s,@TARGET_SUBDIR@,$TARGET_SUBDIR,;t t
s,@LIBOBJS@,$LIBOBJS,;t t
diff --git a/sim/common/run-sim.h b/sim/common/run-sim.h
index 58023a9..aacae88 100644
--- a/sim/common/run-sim.h
+++ b/sim/common/run-sim.h
@@ -30,7 +30,7 @@ int sim_target_parse_command_line PARAMS ((int, char **));
/* Display a list of target specific switches supported by this
target. */
-void sim_target_display_usage PARAMS ((void));
+void sim_target_display_usage PARAMS ((int help));
#endif
diff --git a/sim/common/run.c b/sim/common/run.c
index f2b6fb0..233b17a 100644
--- a/sim/common/run.c
+++ b/sim/common/run.c
@@ -49,8 +49,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "gdb/remote-sim.h"
#include "ansidecl.h"
#include "run-sim.h"
+#include "version.h"
-static void usage PARAMS ((void));
+static void usage PARAMS ((int help));
+static void print_version PARAMS ((void));
extern int optind;
extern char *optarg;
@@ -118,6 +120,19 @@ main (ac, av)
ac = sim_target_parse_command_line (ac, av);
#endif
+ for (i = 1; av[i]; ++i)
+ {
+ if (strcmp (av[i], "--help") == 0)
+ {
+ usage (1);
+ }
+ else if (strcmp (av[i], "--version") == 0)
+ {
+ print_version ();
+ return 0;
+ }
+ }
+
/* FIXME: This is currently being rewritten to have each simulator
do all argv processing. */
@@ -175,13 +190,13 @@ main (ac, av)
break;
/* FIXME: Quick hack, to be replaced by more general facility. */
default:
- usage ();
+ usage (0);
}
ac -= optind;
av += optind;
if (ac <= 0)
- usage ();
+ usage (0);
name = *av;
prog_args = av;
@@ -301,31 +316,43 @@ main (ac, av)
}
static void
-usage ()
+usage (int help)
{
- fprintf (stderr, "Usage: %s [options] program [program args]\n", myname);
- fprintf (stderr, "Options:\n");
- fprintf (stderr, "-a args Pass `args' to simulator.\n");
+ FILE *stream = help ? stdout : stderr;
+
+ fprintf (stream, "Usage: %s [options] program [program args]\n", myname);
+ fprintf (stream, "Options:\n");
+ fprintf (stream, "-a args Pass `args' to simulator.\n");
#ifdef SIM_HAVE_SIMCACHE
- fprintf (stderr, "-c size Set simulator cache size to `size'.\n");
+ fprintf (stream, "-c size Set simulator cache size to `size'.\n");
#endif
- fprintf (stderr, "-m size Set memory size of simulator, in bytes.\n");
+ fprintf (stream, "-m size Set memory size of simulator, in bytes.\n");
#ifdef SIM_HAVE_ENVIRONMENT
- fprintf (stderr, "-o Select operating (kernel) environment.\n");
+ fprintf (stream, "-o Select operating (kernel) environment.\n");
#endif
#ifdef SIM_HAVE_PROFILE
- fprintf (stderr, "-p freq Set profiling frequency.\n");
- fprintf (stderr, "-s size Set profiling size.\n");
+ fprintf (stream, "-p freq Set profiling frequency.\n");
+ fprintf (stream, "-s size Set profiling size.\n");
#endif
- fprintf (stderr, "-t Perform instruction tracing.\n");
- fprintf (stderr, " Note: Very few simulators support tracing.\n");
- fprintf (stderr, "-v Verbose output.\n");
- fprintf (stderr, "\n");
- fprintf (stderr, "program args Arguments to pass to simulated program.\n");
- fprintf (stderr, " Note: Very few simulators support this.\n");
+ fprintf (stream, "-t Perform instruction tracing.\n");
+ fprintf (stream, " Note: Very few simulators support tracing.\n");
+ fprintf (stream, "-v Verbose output.\n");
+ fprintf (stream, "\n");
+ fprintf (stream, "program args Arguments to pass to simulated program.\n");
+ fprintf (stream, " Note: Very few simulators support this.\n");
#ifdef SIM_TARGET_SWITCHES
- fprintf (stderr, "\nTarget specific options:\n");
- sim_target_display_usage ();
+ fprintf (stream, "\nTarget specific options:\n");
+ sim_target_display_usage (help);
#endif
- exit (1);
+
+ if (help && REPORT_BUGS_TO[0])
+ printf ("Report bugs to %s\n", REPORT_BUGS_TO);
+
+ exit (help ? 0 : 1);
+}
+
+static void
+print_version ()
+{
+ printf ("GNU simulator %s%s\n", PKGVERSION, version);
}
diff --git a/sim/common/version.h b/sim/common/version.h
new file mode 100644
index 0000000..97c092b
--- /dev/null
+++ b/sim/common/version.h
@@ -0,0 +1,25 @@
+/* Version information for GDB.
+ Copyright (C) 1999, 2007, 2008 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+/* Version number of GDB, as a string. */
+extern const char version[];
+
+#endif /* #ifndef VERSION_H */