2015-02-26 15:02:31 +00:00
|
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
|
|
# It is so hard getting the absolute path of the current script in bash
|
|
|
|
|
# so I converted CP back to perl. :)
|
|
|
|
|
|
|
|
|
|
use File::Basename ;
|
2015-03-23 22:06:41 +00:00
|
|
|
|
use Cwd ;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
use Cwd 'abs_path';
|
|
|
|
|
|
|
|
|
|
$trick_bin = dirname(abs_path($0)) ;
|
|
|
|
|
$trick_home = dirname($trick_bin) ;
|
|
|
|
|
|
2015-10-21 19:44:49 +00:00
|
|
|
|
#### Handle arguments ####
|
|
|
|
|
$numArgs = $#ARGV + 1;
|
|
|
|
|
$makefileAddArgs = ' ';
|
|
|
|
|
foreach $argnum (0 .. $#ARGV) {
|
|
|
|
|
$arg = $ARGV[$argnum];
|
|
|
|
|
if ($arg =~ /(\w+)=(\w+)/ ) {
|
|
|
|
|
$makefileAddArgs = $makefileAddArgs . $1 . "=" . $2 . " ";
|
|
|
|
|
} elsif ($arg =~ /-d/ ) {
|
|
|
|
|
$makefileAddArgs = $makefileAddArgs . " debug ";
|
|
|
|
|
} elsif ($arg =~ /-t/ ) {
|
|
|
|
|
$makefileAddArgs = $makefileAddArgs . " test ";
|
|
|
|
|
} else {
|
2016-08-02 14:56:43 +00:00
|
|
|
|
$ENV{TRICK_CPFLAGS} .= " $arg" ;
|
2015-10-21 19:44:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-26 15:02:31 +00:00
|
|
|
|
if ( -f "S_define" ) {
|
2015-03-23 22:06:41 +00:00
|
|
|
|
if ( not -w "." ) {
|
|
|
|
|
print getcwd() , " is not writable\n" ;
|
|
|
|
|
print "CP aborted\n" ;
|
|
|
|
|
exit 1 ;
|
|
|
|
|
}
|
2015-07-16 20:36:36 +00:00
|
|
|
|
unlink "build/Makefile_sim", "makefile" ;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
$makefile_text = do { local $/; <main::DATA> } ;
|
|
|
|
|
$makefile_text =~ s/SUB_TRICK_HOME/$trick_home/ ;
|
|
|
|
|
$makefile_text =~ s/SUB_TRICK_BIN/$trick_bin/ ;
|
|
|
|
|
open MAKEFILE, ">makefile" ;
|
|
|
|
|
print MAKEFILE $makefile_text ;
|
|
|
|
|
close MAKEFILE ;
|
2015-10-21 19:44:49 +00:00
|
|
|
|
system("make -f makefile " . $makefileAddArgs) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
exit $? >> 8;
|
|
|
|
|
} else {
|
|
|
|
|
print "S_define does not exist" ;
|
|
|
|
|
exit 1 ;
|
|
|
|
|
}
|
|
|
|
|
__END__
|
|
|
|
|
# CP found at SUB_TRICK_BIN
|
|
|
|
|
|
|
|
|
|
ifndef TRICK_HOME
|
|
|
|
|
export TRICK_HOME := SUB_TRICK_HOME
|
|
|
|
|
endif
|
|
|
|
|
|
2017-02-09 15:42:16 +00:00
|
|
|
|
ifneq ($(wildcard ${TRICK_HOME}/share/trick/makefiles/Makefile.common),)
|
|
|
|
|
include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
|
|
|
|
|
2017-02-14 14:34:02 +00:00
|
|
|
|
S_MAIN = S_main_${TRICK_HOST_CPU}.exe
|
|
|
|
|
ifeq ($(MAKECMDGOALS), test)
|
|
|
|
|
TRICK_HOST_CPU := $(shell $(TRICK_HOME)/bin/trick-gte TRICK_HOST_CPU)_test
|
|
|
|
|
S_MAIN = T_main_${TRICK_HOST_CPU}.exe
|
|
|
|
|
endif
|
|
|
|
|
|
2017-02-09 15:42:16 +00:00
|
|
|
|
ifndef TRICK_VERBOSE_BUILD
|
|
|
|
|
PRINT_CP = $(info $(call COLOR,Running) configuration_processor)
|
|
|
|
|
PRINT_ICG = $(info $(call COLOR,Running) ICG)
|
|
|
|
|
PRINT_S_DEF_DEPS = $(info $(call COLOR,Tracing) S_define)
|
|
|
|
|
PRINT_CONVERT_SWIG = $(info $(call COLOR,Running) convert_swig)
|
|
|
|
|
PRINT_MAKEFILE_SRC = $(info $(call COLOR,Writing) Makefile_src)
|
|
|
|
|
PRINT_MAKEFILE_SWIG = $(info $(call COLOR,Writing) Makefile_swig)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
all test: $(TRICK_STATIC_LIB) S_source.hh \
|
|
|
|
|
build/Makefile_io_src \
|
|
|
|
|
build/Makefile_src \
|
|
|
|
|
build/Makefile_swig \
|
|
|
|
|
build/convert_swig_last_run \
|
|
|
|
|
S_main
|
|
|
|
|
|
|
|
|
|
build:
|
|
|
|
|
@mkdir $@
|
|
|
|
|
|
|
|
|
|
debug: all
|
|
|
|
|
debug: TRICK_CPFLAGS += --debug
|
|
|
|
|
|
|
|
|
|
$(TRICK_STATIC_LIB):
|
|
|
|
|
$(info Cannot find $@. Please build Trick for this platform.)
|
|
|
|
|
@exit -1
|
|
|
|
|
|
|
|
|
|
# CP creates S_source.hh required for ICG and SWIG processing
|
2017-02-14 14:34:02 +00:00
|
|
|
|
S_source.hh: S_define | build
|
2017-02-09 15:42:16 +00:00
|
|
|
|
$(PRINT_CP)
|
|
|
|
|
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor $(TRICK_CPFLAGS)
|
|
|
|
|
$(PRINT_S_DEF_DEPS)
|
|
|
|
|
$(ECHO_CMD)$(TRICK_CPPC) $(TRICK_SFLAGS) $(TRICK_SYSTEM_SFLAGS) -M -MT S_source.hh -MF build/S_define.deps -x c++ S_define
|
|
|
|
|
|
|
|
|
|
# Automatic and manual ICG rules
|
2017-02-22 14:41:10 +00:00
|
|
|
|
build/Makefile_io_src: S_source.hh | build
|
2017-02-09 15:42:16 +00:00
|
|
|
|
$(PRINT_ICG)
|
|
|
|
|
$(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh
|
|
|
|
|
|
|
|
|
|
ICG:
|
|
|
|
|
$(PRINT_ICG)
|
|
|
|
|
$(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh
|
|
|
|
|
|
|
|
|
|
force_ICG:
|
|
|
|
|
$(PRINT_ICG)
|
|
|
|
|
$(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -f -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh
|
|
|
|
|
|
|
|
|
|
# Create makefile for source code
|
2017-02-22 14:41:10 +00:00
|
|
|
|
build/Makefile_src: build/Makefile_io_src S_source.hh
|
2017-02-09 15:42:16 +00:00
|
|
|
|
$(PRINT_MAKEFILE_SRC)
|
|
|
|
|
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_src $?
|
|
|
|
|
|
|
|
|
|
# Create makefile for SWIG code
|
2017-02-22 14:41:10 +00:00
|
|
|
|
build/Makefile_swig: build/Makefile_io_src
|
2017-02-09 15:42:16 +00:00
|
|
|
|
$(PRINT_MAKEFILE_SWIG)
|
|
|
|
|
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_swig $?
|
|
|
|
|
|
|
|
|
|
# Automatic and manual convert_swig rules
|
|
|
|
|
build/convert_swig_last_run: | build/Makefile_swig
|
|
|
|
|
$(PRINT_CONVERT_SWIG)
|
|
|
|
|
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/convert_swig ${TRICK_CONVERT_SWIG_FLAGS}
|
|
|
|
|
@touch $@
|
|
|
|
|
|
|
|
|
|
convert_swig:
|
|
|
|
|
$(PRINT_CONVERT_SWIG)
|
|
|
|
|
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/convert_swig ${TRICK_CONVERT_SWIG_FLAGS}
|
|
|
|
|
@touch build/convert_swig_last_run
|
|
|
|
|
|
|
|
|
|
# Force S_define_exp to be remade each time this rule runs
|
|
|
|
|
.PHONY: S_define_exp
|
|
|
|
|
|
|
|
|
|
S_define_exp:
|
|
|
|
|
$(TRICK_CC) -E -C -xc++ ${TRICK_SFLAGS} $(TRICK_SYSTEM_SFLAGS) S_define > $@
|
|
|
|
|
|
|
|
|
|
help:
|
|
|
|
|
@echo -e "\
|
|
|
|
|
Simulation make options:\n\
|
|
|
|
|
make [debug] [TRICK_VERBOSE_BUILD=1] - Makes everything: S_main and S_sie.resource\n\
|
|
|
|
|
make sie - Builds the S_sie.resource file.\n\
|
|
|
|
|
make clean - Removes all object files in simulation directory\n\
|
|
|
|
|
make spotless - Performs a clean\n\
|
|
|
|
|
make apocalypse - Performs a clean"
|
|
|
|
|
|
2017-02-17 21:47:23 +00:00
|
|
|
|
-include S_overrides.mk
|
2017-02-09 15:42:16 +00:00
|
|
|
|
CLEAN_TARGETS = tidy clean spotless distclean apocalypse
|
|
|
|
|
ifeq ($(findstring ${MAKECMDGOALS},$(CLEAN_TARGETS)),)
|
|
|
|
|
-include build/S_define.deps
|
|
|
|
|
-include build/Makefile_src
|
|
|
|
|
-include build/Makefile_src_deps
|
|
|
|
|
-include build/Makefile_io_src
|
|
|
|
|
-include build/Makefile_swig
|
|
|
|
|
-include build/Makefile_ICG
|
|
|
|
|
-include build/Makefile_convert_swig
|
|
|
|
|
-include build/Makefile_src_deps
|
|
|
|
|
endif
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
2017-02-09 15:42:16 +00:00
|
|
|
|
else
|
|
|
|
|
all:
|
|
|
|
|
$(error error with TRICK_HOME, cannot find ${TRICK_HOME}/share/trick/makefiles/Makefile.common)
|
|
|
|
|
endif
|
2016-08-19 14:57:13 +00:00
|
|
|
|
|
|
|
|
|
tidy:
|
|
|
|
|
-rm -f S_source.hh S_sie.resource
|
|
|
|
|
-rm -f S_main* T_main*
|
|
|
|
|
-rm -f build/Makefile_*
|
2016-08-23 13:58:16 +00:00
|
|
|
|
-rm -f S_default.dat
|
2016-08-19 14:57:13 +00:00
|
|
|
|
|
|
|
|
|
clean: tidy
|
|
|
|
|
-rm -f DP_Product/DP_rt_frame DP_Product/DP_rt_itimer
|
|
|
|
|
-rm -f DP_Product/DP_rt_jobs DP_Product/DP_rt_timeline DP_Product/DP_mem_stats
|
|
|
|
|
-rm -rf build trick
|
2017-02-14 14:34:02 +00:00
|
|
|
|
-rm -f makefile
|
2016-08-19 14:57:13 +00:00
|
|
|
|
|
|
|
|
|
spotless: clean
|
|
|
|
|
|
2016-11-03 20:20:05 +00:00
|
|
|
|
distclean: clean
|
|
|
|
|
|
2017-02-14 14:34:02 +00:00
|
|
|
|
apocalypse: clean
|
2016-08-19 14:57:13 +00:00
|
|
|
|
@echo "[31mI love the smell of napalm in the morning[0m"
|
2017-02-09 15:42:16 +00:00
|
|
|
|
|