# Makefile fragment for common parts of all simulators.
# Copyright 1997-2022 Free Software Foundation, Inc.
# Contributed by Cygnus Support.
# 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 .
# This Makefile fragment consists of two separate parts.
# They are merged into the final Makefile at points denoted by
# "## COMMON_PRE_CONFIG_FRAG" and "## COMMON_POST_CONFIG_FRAG".
#
# The target Makefile should look like:
#
#># Copyright blah blah
#>
#>## COMMON_PRE_CONFIG_FRAG
#>
#># Any overrides necessary for the SIM_FOO config vars.
#>SIM_FOO = ...
#>
#>## COMMON_POST_CONFIG_FRAG
#>
#># Rules to build target specific .o's.
## COMMON_PRE_CONFIG_FRAG
srcdir = /home/seti/riscv-gnu-toolchain/gdb/sim
VPATH = $(srcdir):$(srccom)
srccom = $(srcdir)/../common
srcroot = $(srcdir)/../..
srcsim = $(srcdir)/..
#config.status = config.status
config.status = ../config.status
include $(srcroot)/gdb/silent-rules.mk
ifeq ($(V),0)
ECHO_STAMP = @echo " GEN "
ECHO_IGEN = @echo " IGEN $( tmp-hw.h
$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-hw.h hw-config.h
$(SILENCE) touch $@
test-hw-events: $(srccom)/hw-events.c libsim.a
$(CC) $(ALL_CFLAGS) -DMAIN -o test-hw-events$(EXEEXT) \
$(srccom)/hw-events.c libsim.a $(EXTRA_LIBS)
# See sim_pre_argv_init and sim_module_install in sim-module.c for more details.
modules.c: stamp-modules ; @true
stamp-modules: Makefile $(SIM_OBJS:.o=.c)
$(ECHO_STAMP) modules.c
$(SILENCE) LANG=C ; export LANG ; \
LC_ALL=C ; export LC_ALL ; \
sed -n -e '/^sim_install_/{s/^\(sim_install_[a-z_0-9A-Z]*\).*/\1/;p}' $^ | sort >$@.l-tmp
@set -e; (\
echo '/* Do not modify this file. */'; \
echo '/* It is created automatically by the Makefile. */'; \
echo '#include "libiberty.h"'; \
echo '#include "sim-module.h"'; \
sed -e 's:\(.*\):extern MODULE_INIT_FN \1;:' $@.l-tmp; \
echo 'MODULE_INSTALL_FN * const sim_modules_detected[] = {'; \
sed -e 's:\(.*\): \1,:' $@.l-tmp; \
echo '};'; \
echo 'const int sim_modules_detected_len = ARRAY_SIZE (sim_modules_detected);'; \
) >$@.tmp
$(SILENCE) $(SHELL) $(srcroot)/move-if-change $@.tmp modules.c
$(SILENCE) rm -f $@.l-tmp $@.tmp
$(SILENCE) touch $@
# CGEN support.
# For use in Makefile.in for cpu-specific files.
CGEN_MAIN_CPU_DEPS = \
$(SIM_MAIN_DEPS) \
$(srccom)/cgen-ops.h \
$(srccom)/cgen-mem.h
# Support targets.
install: install-common $(SIM_EXTRA_INSTALL)
install-common: installdirs
a=`basename "$$(pwd)"`; \
n=`echo run | sed '$(program_transform_name)'`; \
[ "$(SIM_PRIMARY_TARGET)" = "$$a" ] || n="$$n-$$a"; \
$(INSTALL_PROGRAM) run$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
n=`echo sim | sed '$(program_transform_name)'`; \
a=`basename "$$(pwd)"`; \
[ "$(SIM_PRIMARY_TARGET)" = "$$a" ] || n="$$n-$$a"; \
n="lib$$n.a"; \
$(INSTALL_DATA) libsim.a $(DESTDIR)$(libdir)/$$n ; \
( cd $(DESTDIR)$(libdir) ; $(RANLIB) $$n )
installdirs:
$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(bindir)
$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(libdir)
check:
html:
clean-html:
install-html:
info:
clean-info:
install-info:
pdf:
clean-pdf:
install-pdf:
.NOEXPORT:
MAKEOVERRIDES=
tags etags: TAGS
# Macros like EXTERN_SIM_CORE confuse tags.
# And the sim-n-foo.h files create functions that can't be found either.
TAGS: force
cd $(srcdir) && \
etags --regex '/^\([[:lower:]_]+\) (/\1/' --regex '/^\/[*] TAGS: .*/' \
*.[ch] ../common/*.[ch]
mostlyclean clean: $(SIM_EXTRA_CLEAN)
rm -f *.[oa] *~ core \
run$(EXEEXT) libsim.a \
hw-config.h stamp-hw \
modules.c stamp-modules \
tmp-mloop.hin tmp-mloop.h tmp-mloop.cin tmp-mloop.c
distclean maintainer-clean realclean: clean $(SIM_EXTRA_DISTCLEAN)
rm -f TAGS
rm -f Makefile config.cache config.log config.status
.c.o:
$(COMPILE) $<
$(POSTCOMPILE)
# Dummy target to force execution of dependent targets.
force:
Makefile: Makefile.in $(srccom)/Make-common.in $(config.status)
# $(ECHO_GEN) CONFIG_HEADERS= $(SHELL) ./config.status
$(ECHO_GEN) pwd=`pwd` && subdir=`basename "$$pwd"` && cd .. && \
$(SHELL) ./config.status Make-common.sim $$subdir/Makefile.sim $$subdir/Makefile
#config.status: configure
# $(ECHO_GEN) $(SHELL) ./config.status --recheck
# CGEN support
GUILE = `if [ -f ../../guile/libguile/guile ]; then echo ../../guile/libguile/guile; else echo guile ; fi`
CGEN = "$(GUILE) -l $(CGENDIR)/guile.scm -s"
CGENFLAGS = -v
CGEN_CPU_DIR = $(CGENDIR)/cpu
# Most ports use the files here instead of cgen/cpu.
CPU_DIR = $(srcroot)/cpu
CGEN_READ_SCM = $(CGENDIR)/sim.scm
CGEN_ARCH_SCM = $(CGENDIR)/sim-arch.scm
CGEN_CPU_SCM = $(CGENDIR)/sim-cpu.scm $(CGENDIR)/sim-model.scm
CGEN_DECODE_SCM = $(CGENDIR)/sim-decode.scm
CGEN_DESC_SCM = $(CGENDIR)/desc.scm $(CGENDIR)/desc-cpu.scm
# Various choices for which cpu specific files to generate.
# These are passed to cgen.sh in the "extrafiles" argument.
CGEN_CPU_EXTR = /extr/
CGEN_CPU_READ = /read/
CGEN_CPU_WRITE = /write/
CGEN_CPU_SEM = /sem/
CGEN_CPU_SEMSW = /semsw/
CGEN_FLAGS_TO_PASS = \
CGEN='$(CGEN)' \
CGENFLAGS="$(CGENFLAGS)"
# We store the generated files in the source directory until we decide to
# ship a Scheme interpreter with gdb/binutils. Maybe we never will.
cgen-arch: force
$(SHELL) $(srccom)/cgen.sh arch $(srcdir) \
$(CGEN) $(CGENDIR) "$(CGENFLAGS)" \
$(arch) "$(FLAGS)" ignored "$(isa)" $(mach) ignored \
$(archfile) ignored
cgen-cpu: force
$(SHELL) $(srccom)/cgen.sh cpu $(srcdir) \
$(CGEN) $(CGENDIR) "$(CGENFLAGS)" \
$(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \
$(archfile) "$(EXTRAFILES)"
cgen-defs: force
$(SHELL) $(srccom)/cgen.sh defs $(srcdir) \
$(CGEN) $(CGENDIR) "$(CGENFLAGS)" \
$(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \
$(archfile) ignored
cgen-decode: force
$(SHELL) $(srccom)/cgen.sh decode $(srcdir) \
$(CGEN) $(CGENDIR) "$(CGENFLAGS)" \
$(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \
$(archfile) "$(EXTRAFILES)"
cgen-cpu-decode: force
$(SHELL) $(srccom)/cgen.sh cpu-decode $(srcdir) \
$(CGEN) $(CGENDIR) "$(CGENFLAGS)" \
$(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \
$(archfile) "$(EXTRAFILES)"
cgen-desc: force
$(SHELL) $(srccom)/cgen.sh desc $(srcdir) \
$(CGEN) $(CGENDIR) "$(CGENFLAGS)" \
$(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \
$(archfile) ignored $(opcfile)
## End COMMON_POST_CONFIG_FRAG