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
|
|
|
|
|
|
2016-08-19 14:57:13 +00:00
|
|
|
|
-include ${TRICK_HOME}/share/trick/makefiles/Makefile.sim
|
2015-02-26 15:02:31 +00:00
|
|
|
|
-include S_overrides.mk
|
|
|
|
|
|
2016-08-23 13:58:16 +00:00
|
|
|
|
ifndef CLEAN_RULES_DEFINED
|
2016-08-19 14:57:13 +00:00
|
|
|
|
no_makefile_sim:
|
|
|
|
|
@echo ${TRICK_HOME}/share/trick/makefiles/Makefile.sim not found
|
|
|
|
|
exit -1
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
@ echo "Removed build directory"
|
|
|
|
|
|
|
|
|
|
spotless: clean
|
|
|
|
|
|
2016-11-03 20:20:05 +00:00
|
|
|
|
distclean: clean
|
|
|
|
|
-rm -f makefile
|
|
|
|
|
|
|
|
|
|
apocalypse: distclean
|
2016-08-19 14:57:13 +00:00
|
|
|
|
@echo "[31mI love the smell of napalm in the morning[0m"
|
2016-08-23 13:58:16 +00:00
|
|
|
|
endif
|