* run.c: #include ../common/config.h, tconfig.h.
(myname): New static global. (main): Recognize new options -a, -c. Also recognize -h if h8/300. Only process -c ifdef SIM_HAVE_SIMCACHE. Only process -p/-s ifdef SIM_HAVE_PROFILE. Parse program name from argv[0] and use in error messages. Pass sim_args to sim_open. Pass prog_args to sim_create_inferior. Add support for incomplete h8/300 termination indicators. (usage): Make more verbose. * aclocal.m4,config.in,tconfig.in,configure.in,configure: New files. * Makefile.in,Make-common.in,callback.c: New files. * nltvals.def,gentmap.c,gentvals.sh: New files.
This commit is contained in:
parent
e01714ccda
commit
58b72d7e20
|
@ -0,0 +1,172 @@
|
|||
# Makefile template for Configure for simulator common parts
|
||||
# Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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 2 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
default: all
|
||||
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
srcroot = $(srcdir)/../..
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
host_alias = @host_alias@
|
||||
target_alias = @target_alias@
|
||||
program_transform_name = @program_transform_name@
|
||||
bindir = @bindir@
|
||||
|
||||
libdir = @libdir@
|
||||
tooldir = $(libdir)/$(target_alias)
|
||||
|
||||
datadir = @datadir@
|
||||
mandir = @mandir@
|
||||
man1dir = $(mandir)/man1
|
||||
infodir = @infodir@
|
||||
includedir = @includedir@
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
INSTALL = $(srcroot)/install.sh -c
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_XFORM = $(INSTALL) -t='$(program_transform_name)'
|
||||
INSTALL_XFORM1= $(INSTALL_XFORM) -b=.1
|
||||
|
||||
CC = @CC@
|
||||
CC_FOR_BUILD = @CC_FOR_BUILD@
|
||||
CPP = @CPP@
|
||||
CPP_FOR_TARGET = @CPP_FOR_TARGET@
|
||||
TARGET_SUBDIR = @TARGET_SUBDIR@
|
||||
CFLAGS = @CFLAGS@
|
||||
SIM_CFLAGS = @sim_cflags@
|
||||
|
||||
HDEFINES = @HDEFINES@
|
||||
TDEFINES =
|
||||
|
||||
CONFIG_CFLAGS = @DEFS@ $(SIM_CFLAGS) $(HDEFINES) $(TDEFINES)
|
||||
CSEARCH = -I. -I$(srcdir) -I$(srcroot)/include
|
||||
ALL_CFLAGS = $(CFLAGS) $(CONFIG_CFLAGS) $(CSEARCH)
|
||||
BUILD_CFLAGS = -g -O $(CSEARCH)
|
||||
|
||||
AR = @AR@
|
||||
AR_FLAGS = rc
|
||||
RANLIB = @RANLIB@
|
||||
MAKEINFO = makeinfo
|
||||
|
||||
.NOEXPORT:
|
||||
MAKEOVERRIDES=
|
||||
|
||||
all: libcommon.a
|
||||
|
||||
LIB_OBJS = callback.o targ-map.o
|
||||
|
||||
# FIXME: Ideally, callback.o and friends live in a library outside of
|
||||
# both the gdb and simulator source trees (e.g. devo/remote. Not
|
||||
# devo/libremote because this directory would contain more than just
|
||||
# a library).
|
||||
|
||||
libcommon.a: $(LIB_OBJS)
|
||||
rm -f libcommon.a
|
||||
$(AR) $(ARFLAGS) libcommon.a $(LIB_OBJS)
|
||||
$(RANLIB) libcommon.a
|
||||
|
||||
callback.o: callback.c targ-vals.h $(srcroot)/include/callback.h
|
||||
|
||||
targ-map.o: targ-map.c targ-vals.h
|
||||
|
||||
# Generate TARG_VALS_H for newlib using devo and build tree.
|
||||
# This file is shipped with distributions so we build in the source dir.
|
||||
# This is built in srcdir so putting dependencies here is risky.
|
||||
# Use `make headers' to rebuild.
|
||||
headers: nltvals.def
|
||||
.PHONY: headers
|
||||
|
||||
# Note: If gdb releases begin to contain target header files, generate
|
||||
# targ-vals.def at build time.
|
||||
|
||||
nltvals.def: Makefile gentvals.sh
|
||||
rootme=`pwd` ; \
|
||||
cd $(srcdir) ; \
|
||||
rm -f nltvals.new ; \
|
||||
echo '/* Newlib macro values needed by simulator. */' >nltvals.new ; \
|
||||
echo '/* This file is machine generated by gentvalh.sh. */' >>nltvals.new ; \
|
||||
$(SHELL) $(srcdir)/gentvals.sh errno $(srcroot)/newlib/libc/include \
|
||||
"errno.h sys/errno.h" 'E[A-Z0-9]*' "$(CPP_FOR_TARGET)" >>nltvals.new ; \
|
||||
$(SHELL) $(srcdir)/gentvals.sh signal $(srcroot)/newlib/libc/include \
|
||||
"signal.h sys/signal.h" 'SIG[A-Z0-9]*' "$(CPP_FOR_TARGET)" >>nltvals.new ; \
|
||||
$(SHELL) $(srcdir)/gentvals.sh open $(srcroot)/newlib/libc/include \
|
||||
"fcntl.h sys/fcntl.h" 'O_[A-Z0-9]*' "$(CPP_FOR_TARGET)" >>nltvals.new ; \
|
||||
$(srcroot)/move-if-change nltvals.new nltvals.def
|
||||
|
||||
gentmap: Makefile gentmap.c
|
||||
$(CC_FOR_BUILD) $(srcdir)/gentmap.c -o gentmap $(BUILD_CFLAGS)
|
||||
|
||||
targ-vals.h: Makefile gentmap
|
||||
rm -f targ-vals.h
|
||||
./gentmap -h >targ-vals.h
|
||||
|
||||
targ-map.c: Makefile gentmap
|
||||
rm -f targ-map.c
|
||||
./gentmap -c >targ-map.c
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $< $(ALL_CFLAGS)
|
||||
|
||||
check:
|
||||
|
||||
info:
|
||||
clean-info:
|
||||
install-info:
|
||||
|
||||
tags etags: TAGS
|
||||
|
||||
TAGS: force
|
||||
etags *.c *.h
|
||||
|
||||
clean:
|
||||
rm -f *.[oa] *~ core gentmap
|
||||
rm -f $(ALL)
|
||||
|
||||
distclean mostlyclean maintainer-clean realclean: clean
|
||||
rm -f TAGS
|
||||
rm -f Makefile config.cache config.log config.status
|
||||
rm -f config.h stamp-h
|
||||
|
||||
# Dummy target to force execution of dependent targets.
|
||||
force:
|
||||
|
||||
# Copy the files into directories where they will be run.
|
||||
install:
|
||||
|
||||
install-man:
|
||||
$(INSTALL_XFORM1) $(srcdir)/run.1 $(man1dir)/run.1
|
||||
|
||||
Makefile: Makefile.in config.status
|
||||
$(SHELL) ./config.status
|
||||
|
||||
config.status: configure
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
# We can't add dependencies to configure because it causes too much trouble
|
||||
# to end users if configure's timestamp is out of sync.
|
||||
.PHONY: run-autoconf
|
||||
run-autoconf:
|
||||
cd $(srcdir) && autoconf
|
||||
|
||||
config.h: stamp-h ; @true
|
||||
stamp-h: config.in config.status
|
||||
CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
|
|
@ -0,0 +1,50 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.5)dnl
|
||||
AC_INIT(Makefile.in)
|
||||
|
||||
# This is intended for use by the target specific directories, and by us.
|
||||
SIM_AC_COMMON
|
||||
|
||||
# Put a useful copy of CPP_FOR_TARGET in Makefile.
|
||||
# This is only used to build the target values header files. These files are
|
||||
# shipped with distributions so CPP_FOR_TARGET only needs to work in
|
||||
# developer's trees. This value is borrowed from ../../Makefile.in.
|
||||
CPP_FOR_TARGET="\` \
|
||||
if test -f \$\${rootme}/../../gcc/Makefile ; then \
|
||||
if test -f \$\${rootme}/../../\$(TARGET_SUBDIR)/newlib/Makefile ; then \
|
||||
echo \$\${rootme}/../../gcc/xgcc -B\$\${rootme}/../../gcc/ -idirafter \$\${rootme}/../../\$(TARGET_SUBDIR)/newlib/targ-include -idirafter \$(srcroot)/newlib/libc/include -nostdinc; \
|
||||
else \
|
||||
echo \$\${rootme}/../../gcc/xgcc -B\$\${rootme}/../../gcc/; \
|
||||
fi; \
|
||||
else \
|
||||
if test '\$(host_canonical)' = '\$(target_canonical)' ; then \
|
||||
echo \$(CC); \
|
||||
else \
|
||||
t='\$(program_transform_name)'; echo gcc | sed -e 's/x/x/' \$\$t; \
|
||||
fi; \
|
||||
fi\` -E"
|
||||
AC_SUBST(CPP_FOR_TARGET)
|
||||
|
||||
# Set TARGET_SUBDIR, needed by CPP_FOR_TARGET.
|
||||
if test x"${host}" = x"${target}" ; then
|
||||
TARGET_SUBDIR="."
|
||||
else
|
||||
TARGET_SUBDIR=${target_alias}
|
||||
fi
|
||||
AC_SUBST(TARGET_SUBDIR)
|
||||
|
||||
case "${target}" in
|
||||
*-*-*) TARG_VALS_DEF=nltvals.def ;;
|
||||
esac
|
||||
|
||||
# Discard what SIM_AC_COMMON sets for these.
|
||||
sim_link_files="${TARG_VALS_DEF}"
|
||||
sim_link_links="targ-vals.def"
|
||||
|
||||
AC_LINK_FILES($sim_link_files, $sim_link_links)
|
||||
|
||||
# These aren't all needed yet, but will be eventually.
|
||||
AC_CHECK_HEADERS(stdlib.h string.h strings.h time.h sys/times.h)
|
||||
|
||||
AC_OUTPUT(Makefile,
|
||||
[case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac])
|
|
@ -0,0 +1,102 @@
|
|||
/* Generate targ-vals.h and targ-map.c. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
struct tdefs {
|
||||
char *symbol;
|
||||
int value;
|
||||
};
|
||||
|
||||
static struct tdefs errno_tdefs[] = {
|
||||
#define errno_defs
|
||||
#include "targ-vals.def"
|
||||
#undef errno_defs
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static struct tdefs open_tdefs[] = {
|
||||
#define open_defs
|
||||
#include "targ-vals.def"
|
||||
#undef open_defs
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static void
|
||||
gen_targ_vals_h ()
|
||||
{
|
||||
struct tdefs *t;
|
||||
|
||||
printf ("/* Target header values needed by the simulator and gdb. */\n");
|
||||
printf ("/* This file is machine generated by gentmap.c. */\n\n");
|
||||
|
||||
printf ("#ifndef TARG_VALS_H\n");
|
||||
printf ("#define TARG_VALS_H\n\n");
|
||||
|
||||
printf ("/* errno values */\n");
|
||||
for (t = &errno_tdefs[0]; t->symbol; ++t)
|
||||
printf ("#define TARGET_%s %d\n", t->symbol, t->value);
|
||||
printf ("\n");
|
||||
|
||||
printf ("/* open flag values */\n");
|
||||
for (t = &open_tdefs[0]; t->symbol; ++t)
|
||||
printf ("#define TARGET_%s 0x%x\n", t->symbol, t->value);
|
||||
printf ("\n");
|
||||
|
||||
printf ("#endif /* TARG_VALS_H */\n");
|
||||
}
|
||||
|
||||
static void
|
||||
gen_targ_map_c ()
|
||||
{
|
||||
struct tdefs *t;
|
||||
|
||||
printf ("/* Target value mapping utilities needed by the simulator and gdb. */\n");
|
||||
printf ("/* This file is machine generated by gentmap.c. */\n\n");
|
||||
|
||||
printf ("#include <errno.h>\n");
|
||||
printf ("#include <fcntl.h>\n");
|
||||
printf ("#include \"ansidecl.h\"\n");
|
||||
printf ("#include \"callback.h\"\n");
|
||||
printf ("#include \"targ-vals.h\"\n");
|
||||
printf ("\n");
|
||||
|
||||
printf ("/* errno mapping table */\n");
|
||||
printf ("target_defs_map errno_map[] = {\n");
|
||||
for (t = &errno_tdefs[0]; t->symbol; ++t)
|
||||
{
|
||||
printf ("#ifdef %s\n", t->symbol);
|
||||
printf (" { %s, TARGET_%s },\n", t->symbol, t->symbol);
|
||||
printf ("#endif\n");
|
||||
}
|
||||
printf (" { 0, 0 }\n");
|
||||
printf ("};\n\n");
|
||||
|
||||
printf ("/* open flags mapping table */\n");
|
||||
printf ("target_defs_map open_map[] = {\n");
|
||||
for (t = &open_tdefs[0]; t->symbol; ++t)
|
||||
{
|
||||
printf ("#ifdef %s\n", t->symbol);
|
||||
printf (" { %s, TARGET_%s },\n", t->symbol, t->symbol);
|
||||
printf ("#endif\n");
|
||||
}
|
||||
printf (" { -1, -1 }\n");
|
||||
printf ("};\n\n");
|
||||
}
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
if (argc != 2)
|
||||
abort ();
|
||||
|
||||
if (strcmp (argv[1], "-h") == 0)
|
||||
gen_targ_vals_h ();
|
||||
else if (strcmp (argv[1], "-c") == 0)
|
||||
gen_targ_map_c ();
|
||||
else
|
||||
abort ();
|
||||
|
||||
exit (0);
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/sh
|
||||
# Usage: gentvals.sh type dir files pattern cpp
|
||||
|
||||
type=$1
|
||||
dir=$2
|
||||
# FIXME: Would be nice to process #include's in these files.
|
||||
files=$3
|
||||
pattern=$4
|
||||
cpp=$5
|
||||
|
||||
# FIXME: need trap to remove tmp files.
|
||||
|
||||
rm -f tmpvals.list tmpvals.uniq
|
||||
for f in $files
|
||||
do
|
||||
if test -f $dir/$f ; then
|
||||
grep "#define[ ]$pattern" $dir/$f | sed -e "s/^.*#define[ ]\($pattern\)[ ]*\([^ ][^ ]*\).*$/\1/" >> tmpvals.list
|
||||
fi
|
||||
done
|
||||
|
||||
sort <tmpvals.list | uniq >tmpvals.uniq
|
||||
|
||||
rm -f tmpvals.h
|
||||
for f in $files
|
||||
do
|
||||
if test -f $dir/$f ; then
|
||||
echo "#include <$f>" >>tmpvals.h
|
||||
fi
|
||||
done
|
||||
|
||||
cat tmpvals.uniq |
|
||||
while read sym
|
||||
do
|
||||
echo "#ifdef $sym" >>tmpvals.h
|
||||
echo 'DEFVAL { "'$sym'", '$sym ' },' >>tmpvals.h
|
||||
echo "#endif" >>tmpvals.h
|
||||
done
|
||||
|
||||
echo "#ifdef ${type}_defs"
|
||||
for f in $files
|
||||
do
|
||||
if test -f $dir/$f ; then
|
||||
echo "/* from $f */"
|
||||
fi
|
||||
done
|
||||
echo "/* begin $type target macros */"
|
||||
$cpp tmpvals.h | grep DEFVAL | sed -e 's/DEFVAL//' -e 's/ / /'
|
||||
echo "/* end $type target macros */"
|
||||
echo "#endif"
|
||||
|
||||
rm -f tmpvals.list tmpvals.uniq tmpvals.h
|
|
@ -0,0 +1,20 @@
|
|||
/* Default target configuration file.
|
||||
To override this, create file `tconfig.in' in the simulator's
|
||||
source directory. */
|
||||
|
||||
/* Define this if the simulator supports profiling.
|
||||
See the mips simulator for an example.
|
||||
This enables the `-p foo' and `-s bar' options.
|
||||
The target is required to provide sim_set_profile{,_size}. */
|
||||
/* #define SIM_HAVE_PROFILE */
|
||||
|
||||
/* Define this if the simulator uses an instruction cache.
|
||||
See the h8/300 simulator for an example.
|
||||
This enables the `-c size' option to set the size of the cache.
|
||||
The target is required to provide sim_set_simcache_size. */
|
||||
/* #define SIM_HAVE_SIMCACHE */
|
||||
|
||||
/* C statement to call after argument parsing is done and executable file
|
||||
has been opened (with bfd_openr).
|
||||
See h8300/tconfig.in for an example. */
|
||||
/* #define SIM_PRE_LOAD(EXEC_BFD) */
|
Loading…
Reference in New Issue