Create a separate directory for simulation compilation.

Functioning build directory on Linux.  Everything is going into the build directory.
All files for all steps use the full path.  this change removes the need for us to
call depend_objs to fix makefile dependencies.  Changed the makefile rules to use
more pattern rules reducing the size of make_makefile.pm and the makefile too.
Changed the output of make to show short commands for each compile line.  Setting
the variable TRICK_VERBOSE_BUILD in the environement, command line, or in S_overrides.mk
will change the output to the full printout.

refs #80
This commit is contained in:
Alex Lin 2015-07-07 14:42:58 -05:00
parent 469be90e32
commit 5a77824638
10 changed files with 245 additions and 325 deletions

View File

@ -388,6 +388,7 @@ sub process_file($$) {
last ;
}
}
$file_name =~ s/^"// ;
$file_name = "\"build" . $file_name . "\"" ;
if ( $exclude == 0 ) {

View File

@ -4,53 +4,33 @@ use Exporter ();
@ISA = qw(Exporter);
@EXPORT = qw(make_makefile);
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
use lib $ENV{"TRICK_HOME"} . "/libexec/trick/pm" ;
use Cwd ;
use Cwd 'abs_path';
use File::Basename ;
use strict ;
use gte ;
use trick_print ;
use trick_version ;
# bm_build , bm_and and bm_or taken from www.perl.com
sub _bm_build {
my $condition = shift;
my $sub_pat = shift;
my @regexp = @_; # this MUST not be local(); need my()
my $expr = join $condition => map { "s/\$regexp[$_]/$sub_pat/o" } (0..$#regexp);
my $match_func = eval "sub { $expr }";
die if $@; # propagate $@; this shouldn't happen!
return $match_func;
}
sub bm_and { _bm_build('&&', @_) }
sub bm_or { _bm_build('||', @_) }
sub make_makefile($$$) {
my ($h_ref , $sim_ref , $make_cwd ) = @_ ;
my ($n , $f , $k , $i , $j, $m);
my ($n , $f , $k , $i , $m);
my $num_inc_objs ;
my %all_mis_depends ;
my %temp_hash ;
my @all_h_files ;
my @all_cfly_files ;
my @all_read_only_libs ;
my @all_compile_libs ;
my %compile_libs ;
my %files_by_dir ;
my ( $sp_dir , $src_dir , $sp_file , $base_name , $suffix) ;
my $num_src_files ;
my (@temp_array , @temp_array2) ;
my $sub_multiple ;
my %real_extension_h ;
my %real_extension_cpp ;
my @temp_array ;
if ( exists $$sim_ref{all_mis_depends} ) {
%all_mis_depends = %{$$sim_ref{all_mis_depends}} ;
}
my @exclude_dirs ;
@exclude_dirs = split /:/ , $ENV{"TRICK_EXCLUDE"};
# See if there are any elements in the exclude_dirs array
if (scalar @exclude_dirs) {
@ -80,7 +60,6 @@ sub make_makefile($$$) {
@all_compile_libs = sort (grep !/trick_source/ , @all_compile_libs) ;
@all_cfly_files = sort (grep !/^-|trick_source|a$/ , @all_cfly_files) ;
# split off files by directory
foreach ( @all_cfly_files ) {
$sp_file = basename($_) ;
@ -95,6 +74,7 @@ sub make_makefile($$$) {
}
# get all of the files required by compiled libraries
# compile all files as normal files, we're not going to make a library anymore.
foreach $n ( @all_compile_libs ) {
my @local_files ;
$sp_file = basename($n) ;
@ -102,24 +82,12 @@ sub make_makefile($$$) {
$sp_dir =~ s/\/object_\$\{TRICK_HOST_CPU\}?$// ;
$sp_dir = abs_path($sp_dir) ;
$src_dir = ( -e "$sp_dir/src" ) ? "src/" : "" ;
($base_name) = $sp_file =~ /lib(.*?)\.a$/ ;
$files_by_dir{$sp_dir}{base_name} = $base_name ;
$files_by_dir{$sp_dir}{dir_num} = $base_name ;
$files_by_dir{$sp_dir}{full_name} = "$sp_dir/object_\${TRICK_HOST_CPU}/$sp_file" ;
$files_by_dir{$sp_dir}{src_dir} = $src_dir ;
opendir THISDIR, "$sp_dir/$src_dir" or die "Could not open the directory $sp_dir/$src_dir";
@local_files = grep !/^\.\.\./ , readdir THISDIR;
@local_files = grep /\.[cfly]$|C$|cc$|cxx$|cpp$|c\+\+$/ , @local_files;
foreach $k ( @local_files ) {
#if ( $k =~ /(C$|cc$|cxx$|cpp$|c\+\+$)/ ) {
# ($base_name) = $k =~ /(.*?)(C$|cc$|cxx$|cpp$|c\+\+$)/ ;
# $real_extension_cpp{"$sp_dir/$src_dir$base_name"} = $2 ;
# $suffix = "cpp" ;
#}
#else {
# ($base_name , $suffix) = $k =~ /(.*?)([cfly])$/ ;
#}
($base_name , $suffix) = $sp_file =~ /(.*?)([cfly]$|C$|cc$|cxx$|cpp$|c\+\+$)/ ;
($base_name , $suffix) = $k =~ /(.*?)([cfly]$|C$|cc$|cxx$|cpp$|c\+\+$)/ ;
push @{$files_by_dir{$sp_dir}{$suffix}} , $base_name ;
}
closedir THISDIR ;
@ -133,12 +101,9 @@ sub make_makefile($$$) {
}
}
$i = 0 ;
$num_src_files = 0;
foreach $k ( sort keys %files_by_dir ) {
foreach my $ie ( @exclude_dirs ) {
# if file location begins with $ie (an IGC exclude dir)
# if file location begins with $ie (an ICG exclude dir)
if ( $k =~ /^\Q$ie/ ) {
delete $files_by_dir{$k} ;
print "excluding $k from build\n" ;
@ -147,9 +112,9 @@ sub make_makefile($$$) {
}
}
# check to see if each directory is writable and count the number of source files
# count the number of source files and set the "dir_num" of each directory.
$num_src_files = 0;
foreach $k ( sort keys %files_by_dir ) {
$files_by_dir{$k}{writable} = ( -w $k ) ? 1 : 0 ;
$_ = $k ;
($files_by_dir{$k}{dir_num} = $_) =~ s#^/## ;
$files_by_dir{$k}{dir_num} =~ s/[\/.]/_/g ;
@ -191,13 +156,14 @@ sub make_makefile($$$) {
my ($trick_ver) = get_trick_version() ;
chomp $trick_ver ;
open MAKEFILE , ">Makefile_sim" or return ;
open MAKEFILE , ">build/Makefile_sim" or return ;
print MAKEFILE "#############################################################################
print MAKEFILE "\
#############################################################################
# Makefile:
# This is a makefile for maintaining the
# '$wd'
# simulation directory. This make file was automatically generated by CP
# simulation directory. This make file was automatically generated by trick-CP
#
#############################################################################
# Creation:
@ -205,29 +171,45 @@ sub make_makefile($$$) {
# Date: $dt
#
#############################################################################
#
# To get a list of make options, type 'make help'
#
#############################################################################
include \${TRICK_HOME}/share/trick/makefiles/Makefile.common" ;
include \${TRICK_HOME}/share/trick/makefiles/Makefile.common
print MAKEFILE "
S_MAIN = \$(CURDIR)/S_main_\${TRICK_HOST_CPU}.exe
ifeq (\$(MAKECMDGOALS), test_all)
TRICK_HOST_CPU := \$(shell \$(TRICK_HOME)/bin/trick-gte TRICK_HOST_CPU)_test
S_MAIN = \$(CURDIR)/T_main_\${TRICK_HOST_CPU}.exe
endif" ;
endif
print MAKEFILE "
LIB_DIR = \$(CURDIR)/lib_\${TRICK_HOST_CPU}
LIB_DIR = \$(CURDIR)/build/lib
SIM_LIB = \$(LIB_DIR)/lib_${sim_dir_name}.a
S_OBJECT_FILES = build/S_source.o
ifdef TRICK_VERBOSE_BUILD
PRINT_ICG =
PRINT_COMPILE =
PRINT_INC_LINK =
PRINT_EXE_LINK =
PRINT_S_DEF_DEPS =
ECHO_CMD =
else
PRINT_ICG = \@echo \"Running ICG\"
PRINT_COMPILE = \@echo \"Compiling \$(subst \$(CURDIR)/build,build,\$<)\"
PRINT_INC_LINK = \@echo \"Partial linking \$(subst \$(CURDIR)/build,build,\${<D})\"
PRINT_EXE_LINK = \@echo \"Final linking \$(subst \$(CURDIR)/,,\$(S_MAIN))\"
PRINT_S_DEF_DEPS = \@echo \"Generating dependencies for S_define\"
ECHO_CMD = \@
ifeq (\$(MAKECMDGOALS), all)
\$(info Performing build with these compilation flags)
\$(info TRICK_CFLAGS = \$(TRICK_CFLAGS))
\$(info TRICK_CXXFLAGS = \$(TRICK_CXXFLAGS))
endif
endif
S_OBJECT_FILES = \$(CURDIR)/build/S_source.o
\$(S_OBJECT_FILES) : | \$(LIB_DIR)\n\n" ;
my %object_files_by_type ;
$num_inc_objs = 0 ;
# list out all of the source and object files
foreach $k ( sort keys %files_by_dir ) {
foreach my $ext ( qw{ c C cc cxx cpp c++ l y} ) {
@ -240,25 +222,30 @@ S_OBJECT_FILES = build/S_source.o
if ( scalar @{$files_by_dir{$k}{$ext}} ne 0 ) {
print MAKEFILE "MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num} =" ;
foreach $f ( @{$files_by_dir{$k}{$ext}} ) {
print MAKEFILE " \\\n build$k/$files_by_dir{$k}{src_dir}$f" . "o" ;
print MAKEFILE " \\\n \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f" . "o" ;
}
push @{$object_files_by_type{$ext}}, "MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num}" ;
print MAKEFILE "\n\n\$(MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num}) : | build$k/$files_by_dir{$k}{src_dir}$f\n" ;
print MAKEFILE "build$k/$files_by_dir{$k}{src_dir}$f :\n" ;
print MAKEFILE "\tmkdir -p \$\@\n" ;
print MAKEFILE "\n\n\$(MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num}) : | \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f\n" ;
print MAKEFILE "\$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f :\n" ;
print MAKEFILE "\t@ mkdir -p \$\@\n\n" ;
print MAKEFILE "\$(CURDIR)/build/lib/o${num_inc_objs}.o : \$(MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num})\n" ;
print MAKEFILE "\t\$(PRINT_INC_LINK)\n" ;
print MAKEFILE "\t\$(ECHO_CMD)cd \${<D} ; ld -Ur -o \$\@ \$(notdir \$^)\n\n" ;
$num_inc_objs++ ;
}
}
if ( scalar @{$files_by_dir{$k}{l}} ne 0 ) {
print MAKEFILE "MODEL_clex_SRC_$files_by_dir{$k}{dir_num} =" ;
foreach $f ( @{$files_by_dir{$k}{l}} ) {
print MAKEFILE " \\\n build$k/$files_by_dir{$k}{src_dir}$f" . "clex" ;
print MAKEFILE " \\\n \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f" . "clex" ;
}
}
if ( scalar @{$files_by_dir{$k}{y}} ne 0 ) {
print MAKEFILE "MODEL_y_c_SRC_$files_by_dir{$k}{dir_num} =" ;
foreach $f ( @{$files_by_dir{$k}{y}} ) {
print MAKEFILE " \\\n build$k/$files_by_dir{$k}{src_dir}$f" . "y.c" ;
print MAKEFILE " \\\n \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f" . "y.c" ;
}
}
}
@ -275,36 +262,51 @@ S_OBJECT_FILES = build/S_source.o
foreach $f ( @{$object_files_by_type{$print_ext}} ) {
print MAKEFILE " \\\n \$($f)" ;
}
print MAKEFILE "\n\n" ;
}
print MAKEFILE "\n\n" ;
# Write out the compile rules for each type of file.
print MAKEFILE "\${MODEL_c_OBJ} : build\%.o : \%.c\n" ;
print MAKEFILE "\tcd \$(<D) ; \$(TRICK_CC) \$(TRICK_CXXFLAGS) -MMD -MP -c \${<F} -o \$(CURDIR)/\$\@\n\n" ;
print MAKEFILE "\${MODEL_c_OBJ} : \$(CURDIR)/build\%.o : \%.c\n" ;
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CC) \$(TRICK_CFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
print MAKEFILE "\${MODEL_C_OBJ} : build\%.o : \%.C\n" ;
print MAKEFILE "\tcd \$(<D) ; \$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -MMD -MP -c \${<F} -o \$(CURDIR)/\$\@\n\n" ;
print MAKEFILE "\${MODEL_C_OBJ} : \$(CURDIR)/build\%.o : \%.C\n" ;
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
print MAKEFILE "\${MODEL_cc_OBJ} : build\%.o : \%.cc\n" ;
print MAKEFILE "\tcd \$(<D) ; \$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -MMD -MP -c \${<F} -o \$(CURDIR)/\$\@\n\n" ;
print MAKEFILE "\${MODEL_cc_OBJ} : \$(CURDIR)/build\%.o : \%.cc\n" ;
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
print MAKEFILE "\${MODEL_cpp_OBJ} : build\%.o : \%.cpp\n" ;
print MAKEFILE "\tcd \$(<D) ; \$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -MMD -MP -c \${<F} -o \$(CURDIR)/\$\@\n\n" ;
print MAKEFILE "\${MODEL_cpp_OBJ} : \$(CURDIR)/build\%.o : \%.cpp\n" ;
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
print MAKEFILE "\${MODEL_cxx_OBJ} : build\%.o : \%.cxx\n" ;
print MAKEFILE "\tcd \$(<D) ; \$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -MMD -MP -c \${<F} -o \$(CURDIR)/\$\@\n\n" ;
print MAKEFILE "\${MODEL_cxx_OBJ} : \$(CURDIR)/build\%.o : \%.cxx\n" ;
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
print MAKEFILE "\${MODEL_CPLUSPLUS_OBJ} : build\%.o : \%.c++\n" ;
print MAKEFILE "\tcd \$(<D) ; \$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -MMD -MP -c \${<F} -o \$(CURDIR)/\$\@\n\n" ;
print MAKEFILE "\${MODEL_CPLUSPLUS_OBJ} : \$(CURDIR)/build\%.o : \%.c++\n" ;
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
print MAKEFILE "\${MODEL_clex_SRC} : build\%.clex : \%.l\n" ;
print MAKEFILE "\t\$(LEX) -o\$\@ \$\<\n\n" ;
print MAKEFILE "\${MODEL_clex_SRC} : \$(CURDIR)/build\%.clex : \%.l\n" ;
print MAKEFILE "\t\$(LEX) -o\$\@ \$<\n\n" ;
print MAKEFILE "\${MODEL_y_c_SRC} : build\%.y.c : \%.y\n" ;
print MAKEFILE "\t\$(YACC) -o\$\@ \$\?\n\n" ;
print MAKEFILE "\${MODEL_y_c_SRC} : \$(CURDIR)/build\%.y.c : \%.y\n" ;
print MAKEFILE "\t\$(YACC) -o\$\@ \$<\n\n" ;
print MAKEFILE "\${MODEL_y_OBJ} : build\%.o : \%.y.c\n" ;
print MAKEFILE "\tcd \$(<D) ; \$(TRICK_CC) \$(TRICK_CXXFLAGS) -MMD -MP -c \${<F} -o \$(CURDIR)/\$\@\n\n" ;
print MAKEFILE "\${MODEL_y_OBJ} : \$(CURDIR)/build\%.o : \%.y.c\n" ;
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
print MAKEFILE "\t\$(ECHO_CMD)cd \$(<D) ; \$(TRICK_CC) \$(TRICK_CXXFLAGS) -MMD -MP -c \${<F} -o \$\@\n\n" ;
# Include all of the dependency files for each object code file
print MAKEFILE "-include \$(MODEL_c_OBJ:.o=.d)\n" ;
print MAKEFILE "-include \$(MODEL_C_OBJ:.o=.d)\n" ;
print MAKEFILE "-include \$(MODEL_cc_OBJ:.o=.d)\n" ;
print MAKEFILE "-include \$(MODEL_cpp_OBJ:.o=.d)\n" ;
print MAKEFILE "-include \$(MODEL_cxx_OBJ:.o=.d)\n" ;
print MAKEFILE "-include \$(MODEL_CPLUSPLUS_OBJ:.o=.d)\n\n" ;
print MAKEFILE "\nDEFAULT_DATA_C_OBJ =" ;
if ( exists $$sim_ref{def_data_c} ) {
@ -322,20 +324,10 @@ S_OBJECT_FILES = build/S_source.o
print MAKEFILE "\n\nDEFAULT_DATA_OBJECTS = \$(DEFAULT_DATA_C_OBJ) \$(DEFAULT_DATA_CPP_OBJ)\n\n" ;
printf MAKEFILE "\n\nOBJECTS =" ;
for( $i = 0 ; $i < $num_src_files ; $i++ ) {
for( $i = 0 ; $i < $num_inc_objs ; $i++ ) {
print MAKEFILE " \\\n\t\$(LIB_DIR)/o$i.o" ;
}
# print out the libraries we build
print MAKEFILE "\n\nBUILD_USER_LIBS = ";
foreach ( sort keys %files_by_dir ) {
if ( exists $files_by_dir{$_}{full_name} ) {
my $temp_str = $files_by_dir{$_}->{full_name} ;
$temp_str =~ s/object_\${TRICK_HOST_CPU}/lib_\${TRICK_HOST_CPU}/ ;
print MAKEFILE " \\\n\t$temp_str" ;
}
}
# print out the libraries we link
print MAKEFILE "\n\nREAD_ONLY_LIBS = ";
foreach ( @all_read_only_libs ) {
@ -344,97 +336,66 @@ S_OBJECT_FILES = build/S_source.o
print MAKEFILE "\n\n
test_all: TRICK_CXXFLAGS += -DTRICK_UNIT_TEST
test_all: TRICK_CFLAGS += -DTRICK_UNIT_TEST\n\n" ;
test_all: TRICK_CFLAGS += -DTRICK_UNIT_TEST
print MAKEFILE "all: S_main\n\n" ;
all: S_main
print MAKEFILE "test_all: all\n\n" ;
test_all: all
print MAKEFILE "ICG:\n" ;
print MAKEFILE "\t\${TRICK_HOME}/bin/trick-ICG -m \${TRICK_CXXFLAGS} S_source.hh\n" ;
print MAKEFILE "force_ICG:\n" ;
print MAKEFILE "\t\${TRICK_HOME}/bin/trick-ICG -f -m \${TRICK_CXXFLAGS} S_source.hh\n" ;
ICG:
\t\$(PRINT_ICG)
\t\$(ECHO_CMD)\${TRICK_HOME}/bin/trick-ICG -m \${TRICK_CXXFLAGS} S_source.hh
print MAKEFILE "
S_main : objects \$(LIB_DIR) \$(S_MAIN) build/S_define.deps S_sie.resource
force_ICG:
\t\$(PRINT_ICG)
\t\$(ECHO_CMD)\${TRICK_HOME}/bin/trick-ICG -f -m \${TRICK_CXXFLAGS} S_source.hh
S_main : \$(S_MAIN) build/S_define.deps S_sie.resource
\t@ echo \"\"
\t@ echo \"=== Simulation make complete ===\"
objects : \$(OBJECTS) build_user_lib
\$(S_MAIN): \${TRICK_STATIC_LIB} \$(OBJECTS) \$(S_OBJECT_FILES)
\t\$(PRINT_EXE_LINK)
\t\$(ECHO_CMD)\$(TRICK_LD) \$(TRICK_LDFLAGS) -o \$@ \\
\t\t\$(S_OBJECT_FILES) build/lib/*.o \\
\t\t\${TRICK_USER_LINK_LIBS} \${READ_ONLY_LIBS} \\
\t\t\$(LD_WHOLE_ARCHIVE) \${TRICK_LIBS} \$(LD_NO_WHOLE_ARCHIVE)\\
\t\t\${TRICK_EXEC_LINK_LIBS}
build_user_lib : \$(BUILD_USER_OBJ_DIRS) \$(BUILD_USER_LIBS)
#\t\t\$(S_OBJECT_FILES) \@build/link_objs \\
#\t\t\$(LD_WHOLE_ARCHIVE) \$(SIM_LIB) \$(LD_NO_WHOLE_ARCHIVE)\\
" ;
if ( $num_src_files > 1 ) {
print MAKEFILE "\
\$(S_MAIN): \$(BUILD_USER_LIBS) \${TRICK_STATIC_LIB} \$(SIM_LIB) \$(S_OBJECT_FILES) \$(SIM_LIBS)
\t\$(TRICK_LD) \$(TRICK_LDFLAGS) -o \$@ \\
\t\t\$(S_OBJECT_FILES)\\
\t\t\$(LD_WHOLE_ARCHIVE) \$(SIM_LIB) \$(LD_NO_WHOLE_ARCHIVE)\\
\t\t\${BUILD_USER_LIBS} \${TRICK_USER_LINK_LIBS} \${READ_ONLY_LIBS} \\
\t\t\$(LD_WHOLE_ARCHIVE) \$(SIM_LIBS) \${TRICK_LIBS} \$(LD_NO_WHOLE_ARCHIVE)\\
\t\t\$(HDF5_LIB) \${TRICK_EXEC_LINK_LIBS}" ;
} else {
print MAKEFILE "\
\$(S_MAIN): \$(BUILD_USER_LIBS) \${TRICK_STATIC_LIB} \$(S_OBJECT_FILES) \$(SIM_LIBS)
\t\$(TRICK_LD) \$(TRICK_LDFLAGS) -o \$@ \\
\t\tbuild/*.o\\
\t\t\${BUILD_USER_LIBS} \${TRICK_USER_LINK_LIBS} \${READ_ONLY_LIBS} \\
\t\t\$(LD_WHOLE_ARCHIVE) \$(SIM_LIBS) \${TRICK_LIBS} \$(LD_NO_WHOLE_ARCHIVE)\\
\t\t\$(HDF5_LIB) \${TRICK_EXEC_LINK_LIBS}" ;
}
print MAKEFILE "\n
\$(OBJECTS) : | \$(LIB_DIR)
\$(LIB_DIR) :
\t@ mkdir -p \$@
" ;
print MAKEFILE "
build/S_source.o: S_source.cpp
\t\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -MMD -MP -c \$\< -o \$\@
#\t\@\${TRICK_HOME}/\$(LIBEXEC)/trick/depend_objs S_source.cpp
\$(CURDIR)/build/S_source.o: \$(CURDIR)/build/S_source.cpp
\t\$(PRINT_COMPILE)
\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -MMD -MP -c \$\< -o \$\@
-include build/S_source.dep
-include build/S_source.d
build/S_define.deps:
\t\$(TRICK_CPPC) \$(TRICK_SFLAGS) -M -MT Makefile_sim -MF build/S_define.deps -x c++ S_define
" ;
\t\$(PRINT_S_DEF_DEPS)
\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_SFLAGS) -M -MT Makefile_sim -MF build/S_define.deps -x c++ S_define
print MAKEFILE "
S_source.cpp S_default.dat: S_define
\$(CURDIR)/build/S_source.cpp S_default.dat: S_define
\t\$(PERL) \${TRICK_HOME}/bin/trick-CP -s -d
sie: S_sie.resource
S_sie.resource: \$(S_MAIN)
\t@ echo \"Generating S_sie.resource...\"
\t\$(S_MAIN) sie
\t@ echo \"Generating S_sie.resource...\"
\t\$(ECHO_CMD)\$(S_MAIN) sie
S_define_exp:
\t\$(TRICK_CC) -E -C -xc++ \${TRICK_SFLAGS} S_define > \$@\n\n" ;
\t\$(TRICK_CC) -E -C -xc++ \${TRICK_SFLAGS} S_define > \$@
# write out the the rules to make the libraries
print MAKEFILE "\n#LIBS\n\n" ;
print MAKEFILE "\$(SIM_LIB) : \$(OBJECTS) \$(DEFAULT_DATA_OBJECTS)\n" ;
print MAKEFILE "\t@ echo \"Creating libraries...\"\n" ;
print MAKEFILE "\t\@ rm -rf \$\@\n" ;
print MAKEFILE "\tar crs \$\@ \$(LIB_DIR)/*.o || touch \$\@\n\n" ;
$m = 0 ;
foreach $k ( sort keys %files_by_dir ) {
foreach my $ext ( qw{ c C cc cxx cpp c++ y l } ) {
if ( scalar @{$files_by_dir{$k}{$ext}} ne 0 ) {
foreach $f ( @{$files_by_dir{$k}{$ext}} ) {
print MAKEFILE "\$(LIB_DIR)/o$m.o : build$k/$files_by_dir{$k}{src_dir}${f}o\n" ;
print MAKEFILE "\tln -f -s ../\$< \$@\n" ;
$m++;
}
}
}
}
\$(SIM_LIB) : \$(DEFAULT_DATA_OBJECTS)
\t@ echo \"Creating libraries...\"
\t\@ rm -rf \$\@
\t\@ ar crs \$\@ \$^ || touch \$\@\n\n" ;
print MAKEFILE "\n\n#DEFAULT_DATA_C_OBJ\n\n" ;
foreach my $d ( sort keys %{$$sim_ref{def_data_c}} ) {
@ -458,15 +419,17 @@ S_define_exp:
}
}
print MAKEFILE "\n-include Makefile_io_src\n" ;
print MAKEFILE "\ninclude Makefile_swig\n" ;
print MAKEFILE "\n-include build/Makefile_io_src\n" ;
print MAKEFILE "\ninclude build/Makefile_swig\n" ;
print MAKEFILE "\n-include S_overrides.mk\n" ;
close MAKEFILE ;
if ( ! -e "build" ) {
mkdir "build", 0775 ;
open SIM_INC_OBJS , ">build/link_objs" or return ;
for( $i = 0 ; $i < $num_inc_objs ; $i++ ) {
print SIM_INC_OBJS "build/lib/o$i.o\n" ;
}
close SIM_INC_OBJS ;
# write out all of the files we used to S_library_list
open LIB_LIST, ">build/S_library_list" or die "Could not open build/S_library_list" ;

View File

@ -19,11 +19,11 @@ use strict ;
sub make_swig_makefile($$$) {
my ($h_ref , $sim_ref , $make_cwd ) = @_ ;
my ($n , $f , $k , $i , $j, $m);
my ($n , $f , $k , $m);
my (%all_icg_depends) = %{$$sim_ref{all_icg_depends}} ;
my %temp_hash ;
my @all_h_files ;
my (@temp_array , @temp_array2) ;
my (@temp_array , @temp_array2) ;
my ($ii) ;
my ($swig_sim_dir, $swig_src_dir) ;
my (%py_module_map) ;
@ -34,11 +34,8 @@ sub make_swig_makefile($$$) {
my (@s_inc_paths) ;
my (@defines) ;
my ($version, $thread, $year) ;
my ($swig_module_i, $swig_module_source, $py_wrappers) ;
my $s_source_full_path = abs_path("S_source.hh") ;
my $s_source_md5 = md5_hex($s_source_full_path) ;
my $s_library_swig = "build/.S_library_swig" ;
my $s_library_swig_ext = "build/.S_library_swig_ext" ;
($version, $thread) = get_trick_version() ;
($year) = $version =~ /^(\d+)/ ;
@ -97,23 +94,6 @@ sub make_swig_makefile($$$) {
@s_inc_paths = $ENV{"TRICK_SFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
# The sim_libraries are full paths at this point
if ( exists $$sim_ref{sim_libraries} ) {
for ($i = 0 ; $i < scalar @{$$sim_ref{sim_libraries}} ; $i++ ) {
open SLIB , "@{$$sim_ref{sim_libraries}}[$i]/$s_library_swig" ;
while ( <SLIB> ) {
chomp ;
$$sim_ref{sim_lib_swig_files}{$_} = 1 ;
}
}
}
open SLIB_EXT, ">$s_library_swig_ext" ;
foreach my $f ( sort keys %{$$sim_ref{sim_lib_swig_files}} ) {
print SLIB_EXT "$f\n" ;
}
close SLIB_EXT ;
# make a list of all the header files required by this sim
foreach $n ( @$h_ref ) {
push @all_h_files , $n ;
@ -128,16 +108,15 @@ sub make_swig_makefile($$$) {
@all_h_files = grep ++$temp_hash{$_} < 2, @all_h_files ;
@all_h_files = sort (grep !/trick_source/ , @all_h_files) ;
$swig_sim_dir = abs_path("trick") ;
$swig_sim_dir = "\$(CURDIR)/trick" ;
$swig_src_dir = "\$(CURDIR)/build" ;
if ( ! -e $swig_sim_dir ) {
mkdir $swig_sim_dir, 0775 ;
# create output directories if they don't exist
if ( ! -e "trick" ) {
mkdir "trick", 0775 ;
}
$swig_src_dir = abs_path("build") ;
if ( ! -e $swig_src_dir ) {
mkdir $swig_src_dir, 0775 ;
if ( ! -e "build" ) {
mkdir "build", 0775 ;
}
undef @temp_array2 ;
@ -216,44 +195,34 @@ sub make_swig_makefile($$$) {
# remove headers found in trick_source and ${TRICK_HOME}/include/trick
@temp_array2 = sort (grep !/$ENV{"TRICK_HOME"}\/include\/trick\// , @temp_array2) ;
open MAKEFILE , ">Makefile_swig" or return ;
open MAKEFILE , ">build/Makefile_swig" or return ;
open LINK_PY_OBJS , ">build/link_py_objs" or return ;
print LINK_PY_OBJS "build/init_swig_modules.o\n" ;
print LINK_PY_OBJS "build/py_top.o\n" ;
print MAKEFILE "# SWIG rules\n" ;
print MAKEFILE "SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers\n" ;
print MAKEFILE "ifeq (\$(IS_CC_CLANG), 1)\n" ;
print MAKEFILE " SWIG_CFLAGS += -Wno-self-assign -Wno-sometimes-uninitialized\n" ;
print MAKEFILE "endif\n" ;
print MAKEFILE "SWIG_MODULE_OBJECTS = " ;
for ( $ii = 0 ; $ii < scalar @temp_array2 ; $ii++ ) {
print MAKEFILE "\
# SWIG rule
SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers
ifeq (\$(IS_CC_CLANG), 1)
SWIG_CFLAGS += -Wno-self-assign -Wno-sometimes-uninitialized
endif
my ($continue) = 1 ;
foreach my $ie ( @exclude_dirs ) {
# if file location begins with $ie (an IGC exclude dir)
if ( @temp_array2[$ii] =~ /^\Q$ie/ ) {
$continue = 0 ;
last ; # break out of loop
}
}
next if ( $continue == 0 ) ;
ifdef TRICK_VERBOSE_BUILD
PRINT_SWIG =
PRINT_COMPILE_SWIG =
PRINT_SWIG_INC_LINK =
PRINT_CONVERT_SWIG =
else
PRINT_SWIG = \@echo \"Swig \$(subst \$(CURDIR)/build,build,\$<)\"
PRINT_COMPILE_SWIG = \@echo \"Compiling swig \$(subst .o,.cpp,\$(subst \$(CURDIR)/build,build,\$@))\"
PRINT_SWIG_INC_LINK = \@echo \"Partial linking swig objects\"
PRINT_CONVERT_SWIG = \@echo \"Running convert_swig\"
endif
if ( ! exists $$sim_ref{sim_lib_swig_files}{@temp_array2[$ii]} ) {
print MAKEFILE "\\\n\t\$(LIB_DIR)/p${ii}.o" ;
}
}
SWIG_MODULE_OBJECTS = \$(LIB_DIR)/swig_python.o
print MAKEFILE "\n\n" ;
print MAKEFILE "SIM_SWIG_OBJECTS = \\\n" ;
print MAKEFILE " $swig_src_dir/init_swig_modules.o\\\n" ;
print MAKEFILE " $swig_src_dir/py_top.o\n" ;
print MAKEFILE "S_OBJECT_FILES += \$(SIM_SWIG_OBJECTS)\n\n" ;
print MAKEFILE "ALL_SWIG_OBJECTS = \\\n" ;
print MAKEFILE "\t\$(SWIG_MODULE_OBJECTS)\\\n" ;
print MAKEFILE "\t\$(SIM_SWIG_OBJECTS)\n\n" ;
SWIG_PY_OBJECTS =" ;
print MAKEFILE "\$(ALL_SWIG_OBJECTS) : | \$(LIB_DIR)\n\n" ;
print MAKEFILE "# SWIG_PY_OBJECTS is a convienince list to modify rules for compilation\n" ;
print MAKEFILE "SWIG_PY_OBJECTS =" ;
foreach my $f ( @temp_array2 ) {
my ($continue) = 1 ;
foreach my $ie ( @exclude_dirs ) {
@ -270,12 +239,14 @@ sub make_swig_makefile($$$) {
my ($swig_f) = $f ;
$swig_object_dir = dirname($f) ;
($swig_file_only) = ($f =~ /([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx)$/) ;
print MAKEFILE" \\\n\tbuild$swig_object_dir/py_${swig_file_only}.o" ;
print MAKEFILE" \\\n \$(CURDIR)/build$swig_object_dir/py_${swig_file_only}.o" ;
}
print MAKEFILE"\n\n" ;
print MAKEFILE "\\\n $swig_src_dir/init_swig_modules.o" ;
print MAKEFILE "\\\n $swig_src_dir/py_top.o\n\n" ;
print MAKEFILE "convert_swig:\n" ;
print MAKEFILE "\t\${TRICK_HOME}/\$(LIBEXEC)/trick/convert_swig \${TRICK_CONVERT_SWIG_FLAGS} S_source.hh\n" ;
print MAKEFILE "\t\$(PRINT_CONVERT_SWIG)\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\${TRICK_HOME}/\$(LIBEXEC)/trick/convert_swig \${TRICK_CONVERT_SWIG_FLAGS} S_source.hh\n" ;
print MAKEFILE "\n\n" ;
my %swig_dirs ;
@ -318,23 +289,18 @@ sub make_swig_makefile($$$) {
}
$swig_f =~ s/([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx)$/$1.i/ ;
$swig_file_only = $1 ;
$swig_f = "build" . $swig_f ;
my $link_py_obj = "build" . dirname($swig_f) . "/py_${swig_file_only}.o";
$swig_f = "\$(CURDIR)/build" . $swig_f ;
$swig_dir = dirname($swig_f) ;
$swig_object_dir = dirname($swig_f) ;
$swig_dirs{$swig_dir} = 1 ;
$swig_module_i .= "\\\n $swig_f" ;
$swig_module_source .= "\\\n $swig_dir/py_${swig_file_only}.cpp\\\n $swig_dir/m${md5_sum}.py" ;
$py_wrappers .= " \\\n $swig_sim_dir/${swig_module_dir}m${md5_sum}.py" ;
if ( ! exists $$sim_ref{sim_lib_swig_files}{$f} ) {
print MAKEFILE "$swig_object_dir/py_${swig_file_only}.o : $swig_f\n" ;
print MAKEFILE "\t\$(SWIG) \$(TRICK_INCLUDE) \$(TRICK_DEFINES) \$(TRICK_VERSIONS) -c++ -python -includeall -ignoremissing -w201,303,362,389,401,451 -outdir trick -o $swig_dir/py_${swig_file_only}.cpp \$<\n" ;
print MAKEFILE "\t\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(TRICK_IO_CXXFLAGS) \$(SWIG_CFLAGS) -c $swig_dir/py_${swig_file_only}.cpp -o \$@\n\n" ;
print MAKEFILE "\$(LIB_DIR)/p${ii}.o : $swig_object_dir/py_${swig_file_only}.o\n" ;
print MAKEFILE "\tln -s -f ../\$< \$@\n\n" ;
}
print MAKEFILE "$swig_object_dir/py_${swig_file_only}.o : $swig_f\n" ;
print MAKEFILE "\t\$(PRINT_SWIG)\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(SWIG) \$(TRICK_INCLUDE) \$(TRICK_DEFINES) \$(TRICK_VERSIONS) -c++ -python -includeall -ignoremissing -w201,303,362,389,401,451 -outdir trick -o $swig_dir/py_${swig_file_only}.cpp \$<\n" ;
print MAKEFILE "\t\$(PRINT_COMPILE_SWIG)\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(TRICK_IO_CXXFLAGS) \$(SWIG_CFLAGS) -c $swig_dir/py_${swig_file_only}.cpp -o \$@\n\n" ;
print LINK_PY_OBJS "$link_py_obj\n" ;
$ii++ ;
}
@ -347,28 +313,29 @@ sub make_swig_makefile($$$) {
print MAKEFILE "\tmkdir -p \$@\n\n" ;
}
print MAKEFILE "PY_WRAPPERS = $py_wrappers\n\n" ;
my $wd = abs_path(cwd()) ;
my $sim_dir_name = basename($wd) ;
$sim_dir_name =~ s/SIM_// ;
print MAKEFILE "
\$(ALL_SWIG_OBJECTS) : TRICK_CXXFLAGS += -Wno-unused-parameter -Wno-redundant-decls
\$(SWIG_MODULE_OBJECTS) : TRICK_CXXFLAGS += -Wno-unused-parameter -Wno-redundant-decls
.PHONY: swig_objects
\$(S_MAIN): \$(SWIG_MODULE_OBJECTS)
\$(S_MAIN) : $swig_src_dir/py_top.o $swig_src_dir/init_swig_modules.o\n
\$(SIM_LIB): \$(SWIG_MODULE_OBJECTS)\n\n" ;
\$(SWIG_MODULE_OBJECTS) : \$(SWIG_PY_OBJECTS) | \$(LIB_DIR)
\t\$(PRINT_SWIG_INC_LINK)
\t\$(ECHO_CMD)ld -Ur -o \$\@ \@build/link_py_objs
\n\n" ;
print MAKEFILE "$swig_src_dir/py_top.cpp : $swig_src_dir/top.i\n" ;
print MAKEFILE "\t\$(SWIG) \$(TRICK_INCLUDE) \$(TRICK_DEFINES) \$(TRICK_VERSIONS) -c++ -python -includeall -ignoremissing -w201,303,362,389,401,451 -outdir $swig_sim_dir -o \$@ \$<\n\n" ;
print MAKEFILE "\t\$(PRINT_SWIG)\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(SWIG) \$(TRICK_INCLUDE) \$(TRICK_DEFINES) \$(TRICK_VERSIONS) -c++ -python -includeall -ignoremissing -w201,303,362,389,401,451 -outdir $swig_sim_dir -o \$@ \$<\n\n" ;
print MAKEFILE "$swig_src_dir/py_top.o : $swig_src_dir/py_top.cpp\n" ;
print MAKEFILE "\t\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(SWIG_CFLAGS) -c \$< -o \$@\n\n" ;
print MAKEFILE "\t\$(PRINT_COMPILE_SWIG)\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(SWIG_CFLAGS) -c \$< -o \$@\n\n" ;
print MAKEFILE "$swig_src_dir/init_swig_modules.o : $swig_src_dir/init_swig_modules.cpp\n" ;
print MAKEFILE "\t\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(SWIG_CFLAGS) -c \$< -o \$@\n\n" ;
print MAKEFILE "\t\$(PRINT_COMPILE_SWIG)\n" ;
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(SWIG_CFLAGS) -c \$< -o \$@\n\n" ;
print MAKEFILE "TRICK_FIXED_PYTHON = \\
$swig_sim_dir/swig_double.py \\
@ -381,7 +348,7 @@ sub make_swig_makefile($$$) {
print MAKEFILE "S_main: \$(TRICK_FIXED_PYTHON)\n\n" ;
print MAKEFILE "\$(TRICK_FIXED_PYTHON) : $swig_sim_dir/\% : \${TRICK_HOME}/share/trick/swig/\%\n" ;
print MAKEFILE "\t/bin/cp \$< \$@\n\n" ;
print MAKEFILE "\t\$(ECHO_CMD)/bin/cp \$< \$@\n\n" ;
foreach (keys %swig_dirs) {
print MAKEFILE "$_:\n" ;
@ -390,14 +357,9 @@ sub make_swig_makefile($$$) {
print MAKEFILE "\n" ;
close MAKEFILE ;
close LINK_PY_OBJS ;
open SWIGLIB , ">$s_library_swig" or return ;
foreach my $f ( @temp_array2 ) {
print SWIGLIB "$f\n" ;
}
close SWIGLIB ;
open TOPFILE , ">$swig_src_dir/top.i" or return ;
open TOPFILE , ">build/top.i" or return ;
print TOPFILE "\%module top\n\n" ;
print TOPFILE "\%{\n#include \"../S_source.hh\"\n\n" ;
foreach my $inst ( @{$$sim_ref{instances}} ) {
@ -417,7 +379,7 @@ sub make_swig_makefile($$$) {
}
close TOPFILE ;
open INITSWIGFILE , ">$swig_src_dir/init_swig_modules.cpp" or return ;
open INITSWIGFILE , ">build/init_swig_modules.cpp" or return ;
print INITSWIGFILE "extern \"C\" {\n\n" ;
foreach $f ( @temp_array2 ) {
@ -447,7 +409,7 @@ sub make_swig_makefile($$$) {
print INITSWIGFILE " return ;\n}\n\n}\n" ;
close INITSWIGFILE ;
open INITFILE , ">$swig_sim_dir/__init__.py" or return ;
open INITFILE , ">trick/__init__.py" or return ;
print INITFILE "import sys\n" ;
print INITFILE "import os\n" ;
@ -506,11 +468,10 @@ sub make_swig_makefile($$$) {
next if ( $m eq "root") ;
my ($temp_str) = $m ;
$temp_str =~ s/\./\//g ;
if ( ! -e "$swig_sim_dir/$temp_str" ) {
#make_path("$swig_sim_dir/$temp_str", {mode=>0775}) ;
mkpath("$swig_sim_dir/$temp_str", {mode=>0775}) ;
if ( ! -e "trick/$temp_str" ) {
mkpath("trick/$temp_str", {mode=>0775}) ;
}
open INITFILE , ">$swig_sim_dir/$temp_str/__init__.py" or return ;
open INITFILE , ">trick/$temp_str/__init__.py" or return ;
foreach $f ( @{$python_modules{$m}} ) {
next if ( $f =~ /S_source.hh/ ) ;
my $md5_sum = md5_hex($f) ;
@ -521,7 +482,7 @@ sub make_swig_makefile($$$) {
close INITFILE ;
while ( $temp_str =~ s/\/.*?$// ) {
open INITFILE , ">$swig_sim_dir/$temp_str/__init__.py" or return ;
open INITFILE , ">trick/$temp_str/__init__.py" or return ;
close INITFILE ;
}
}

View File

@ -255,9 +255,6 @@ sub parse_s_define ($) {
#print " look for object $object_file\n" ;
if ( $object_file =~ /^\// ) {
push @{$$sim_ref{mis_entry_files}}, $object_file ;
} elsif ( $object_file =~ /^sim_lib(\S+)/i ) {
push @{$$sim_ref{sim_libraries}}, $1 ;
#print "found a sim_library $1\n" ;
} else {
my $found = 0 ;
foreach my $inc_path ( @valid_inc_paths ) {

View File

@ -15,7 +15,7 @@ sub s_source($) {
#--------------------------------------------------------------
# Generate S_source.c
open S_SOURCE, ">S_source.cpp" or die "Couldn't open S_source.cpp!\n";
open S_SOURCE, ">build/S_source.cpp" or die "Couldn't open build/S_source.cpp!\n";
open S_SOURCE_H, ">S_source.hh" or die "Couldn't open S_source.hh!\n";
# Get Trick version
@ -146,7 +146,7 @@ PURPOSE:
close S_SOURCE_H ;
print S_SOURCE "#include \"S_source.hh\"\n" ;
print S_SOURCE "#include \"../S_source.hh\"\n" ;
print S_SOURCE "$$sim_ref{user_code}\n" ;

View File

@ -61,7 +61,7 @@ endif
# Do this section only once
ifeq ($(MAKELEVEL),0)
export TRICK_INCLUDES := -I${TRICK_HOME}/trick_source -I../include -I${TRICK_HOME}/include -I${TRICK_HOME}/include/trick/compat
export TRICK_INCLUDES := -I${TRICK_HOME}/trick_source -I${TRICK_HOME}/include -I${TRICK_HOME}/include/trick/compat
export TRICK_VERSIONS := -DTRICK_VER=$(TRICK_MAJOR) -DTRICK_MINOR=$(TRICK_MINOR)
TRICK_CFLAGS += $(TRICK_INCLUDES) $(TRICK_VERSIONS) -fpic
ifdef TRICK_CXXFLAGS
@ -123,6 +123,7 @@ ifneq ($(HDF5),/usr)
else
HDF5_LIB = -lhdf5_hl -lhdf5
endif
TRICK_EXEC_LINK_LIBS += ${HDF5_LIB}
endif
HAVE_GSL := $(shell test -e ${GSL_HOME}/include/gsl && echo "1")

View File

@ -12,17 +12,17 @@ ifeq ($(MAKECMDGOALS), debug)
TRICK_CPFLAGS += --debug
endif
all : ${TRICK_LIB_DIR}/libtrick.a Makefile_sim build
all : ${TRICK_LIB_DIR}/libtrick.a build/Makefile_sim
@/bin/cp ${TRICK_HOME}/share/trick/MAKE_out_header.txt build/MAKE_out
@$(MAKE) --no-print-directory -f Makefile_sim ICG 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
@$(MAKE) --no-print-directory -f Makefile_sim convert_swig 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
@$(MAKE) --no-print-directory -f Makefile_sim all 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
@$(MAKE) --no-print-directory -f build/Makefile_sim ICG 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
@$(MAKE) --no-print-directory -f build/Makefile_sim convert_swig 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
@$(MAKE) --no-print-directory -f build/Makefile_sim all 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
test : ${TRICK_LIB_DIR}/libtrick.a Makefile_sim build
test : ${TRICK_LIB_DIR}/libtrick.a build/Makefile_sim
@/bin/cp ${TRICK_HOME}/share/trick/MAKE_out_header.txt build/MAKE_out
@$(MAKE) --no-print-directory -f Makefile_sim ICG 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
@$(MAKE) --no-print-directory -f Makefile_sim convert_swig 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
@$(MAKE) --no-print-directory -f Makefile_sim test_all 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
@$(MAKE) --no-print-directory -f build/Makefile_sim ICG 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
@$(MAKE) --no-print-directory -f build/Makefile_sim convert_swig 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
@$(MAKE) --no-print-directory -f build/Makefile_sim test_all 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
build:
mkdir $@
@ -33,41 +33,34 @@ ${TRICK_LIB_DIR}/libtrick.a:
@echo "Cannot find $@. Please build Trick for this platfrom"
@exit -1
Makefile_sim: S_define
@/bin/rm -rf lib_${TRICK_HOST_CPU} object_${TRICK_HOST_CPU}
build/Makefile_sim: S_define | build
@${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor $(TRICK_CPFLAGS)
model_dirs:
@${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor -z
sie ICG force_ICG convert_swig S_define_exp:
@if [ -f Makefile_sim ] ; then $(MAKE) --no-print-directory -f Makefile_sim $@ ; else echo "No Makefile_sim found" ; fi
@if [ -f build/Makefile_sim ] ; then $(MAKE) --no-print-directory -f build/Makefile_sim $@ ; else echo "No build/Makefile_sim found" ; fi
help:
@ echo -e "\n\
Simulation make options:\n\
make - Makes everything: S_main, S_sie.resource,\n\
\t\t\tand S_default.dat\n\
make - Makes everything: S_main and S_sie.resource\n\
make S_sie.resource - Rebuilds the S_sie.resource file.\n\
make S_source.cpp - Rebuilds the S_source.cpp file.\n\
make clean - Removes all auto-generated files in\n\
\t\t\tsimulation directory\n\
make clean - Removes all object files in simulation directory\n\
make real_clean - Performs a clean\n\
make spotless - Performs a clean\n\
make apocalypse - Performs a clean"
tidy:
-rm -rf Default_data S_default.dat
-rm -f S_sie.resource
-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 -f S_source.cpp S_source.hh
-rm -rf lib_* S_main* T_main*
-rm -f Makefile_sim
-rm -f Makefile_io_src
-rm -f Makefile_swig
-rm -f S_main* T_main*
clean: tidy
-rm -rf Default_data S_default.dat
rm -f S_source.hh
rm -rf build
-rm -rf trick
@ echo "Removed build directory"

View File

@ -1,7 +1,6 @@
INSTALL = /bin/install
# if we are on a Rehat system, the lib directory is lib64 on 64 bit machines
ifneq ("$(wildcard /etc/redhat-release)","")
UNAME_M := $(shell uname -m)

View File

@ -23,3 +23,4 @@ S_source.hh
T_main_*
trick
jitlib
build

View File

@ -362,6 +362,7 @@ void PrintAttributes::closeMapFiles() {
//TODO: Move this into PrintFileContents10.
void PrintAttributes::printIOMakefile() {
std::ofstream makefile ;
std::ofstream link_io_objs ;
unsigned int ii ;
// Don't create a makefile if we didn't process any files.
@ -369,7 +370,7 @@ void PrintAttributes::printIOMakefile() {
return ;
}
makefile.open("Makefile_io_src") ;
makefile.open("build/Makefile_io_src") ;
makefile << "TRICK_IO_CXXFLAGS := \\" << std::endl ;
makefile << " -Wno-invalid-offsetof \\" << std::endl ;
@ -384,6 +385,13 @@ void PrintAttributes::printIOMakefile() {
makefile << " endif" << std::endl ;
makefile << "endif" << std::endl ;
makefile << std::endl ;
makefile << "ifdef TRICK_VERBOSE_BUILD" << std::endl ;
makefile << "PRINT_IO_COMPILE =" << std::endl ;
makefile << "PRINT_IO_INC_LINK =" << std::endl ;
makefile << "else" << std::endl ;
makefile << "PRINT_IO_COMPILE = @echo \"Compiling io $(subst $(CURDIR)/build,build,$<)\"" << std::endl ;
makefile << "PRINT_IO_INC_LINK = @echo \"Partial linking io objects\"" << std::endl ;
makefile << "endif" << std::endl ;
//TODO: create the io_file name if it doesn't exist
makefile << "IO_OBJ_FILES =" ;
@ -393,43 +401,39 @@ void PrintAttributes::printIOMakefile() {
if ( mit != all_io_files.end() ) {
size_t found ;
found = (*mit).second.find_last_of(".") ;
makefile << " \\\n " << (*mit).second.substr(0,found) << ".o" ;
makefile << " \\\n $(CURDIR)/" << (*mit).second.substr(0,found) << ".o" ;
}
}
makefile << " \\\n build/class_map.o" ;
makefile << " \\\n build/enum_map.o" ;
makefile << std::endl << std::endl ;
makefile << " \\\n $(CURDIR)/build/class_map.o" ;
makefile << " \\\n $(CURDIR)/build/enum_map.o" << std::endl ;
makefile << std::endl ;
makefile << "$(IO_OBJ_FILES) : \%.o : \%.cpp" << std::endl ;
makefile << "\t$(PRINT_IO_COMPILE)" << std::endl ;
makefile << "\t$(ECHO_CMD)$(TRICK_CPPC) $(TRICK_CXXFLAGS) $(TRICK_IO_CXXFLAGS) -MMD -MP -c $< -o $@" << std::endl ;
makefile << std::endl ;
makefile << "-include $(IO_OBJ_FILES:.o=.d)" << std::endl ;
makefile << std::endl ;
makefile << "IO_OBJECTS =" ;
for ( ii = 0 ; ii < visited_files.size() + 2 ; ii++ ) {
makefile << " \\\n $(LIB_DIR)/i" << ii << ".o" ;
}
makefile << std::endl << std::endl ;
makefile << "$(S_MAIN) : $(LIB_DIR)/io_src.o" << std::endl ;
makefile << std::endl ;
makefile << "$(LIB_DIR)/io_src.o : $(IO_OBJ_FILES) | $(LIB_DIR)" << std::endl ;
makefile << "\t$(PRINT_IO_INC_LINK)" << std::endl ;
makefile << "\t$(ECHO_CMD)ld -Ur -o $@ @build/link_io_objs" << std::endl ;
for ( sit = visited_files.begin() , ii = 0 ; sit != visited_files.end() ; sit++ , ii++ ) {
makefile.close() ;
link_io_objs.open("build/link_io_objs") ;
for ( sit = visited_files.begin() ; sit != visited_files.end() ; sit++ ) {
std::map< std::string , std::string >::iterator mit = all_io_files.find(*sit) ;
if ( mit != all_io_files.end() ) {
size_t found ;
found = (*mit).second.find_last_of(".") ;
makefile << "$(LIB_DIR)/i" << ii << ".o : " << (*mit).second.substr(0,found) << ".o" << std::endl ;
makefile << "\tln -f -s ../$< $@" << std::endl ;
link_io_objs << (*mit).second.substr(0,found) << ".o" << std::endl ;
}
}
makefile << "$(LIB_DIR)/i" << ii++ << ".o : " << "build/class_map.o" << std::endl ;
makefile << "\tln -f -s ../$< $@" << std::endl ;
makefile << "$(LIB_DIR)/i" << ii << ".o : " << "build/enum_map.o" << std::endl ;
makefile << "\tln -f -s ../$< $@" << std::endl ;
makefile << "$(IO_OBJECTS) : | $(LIB_DIR)" << std::endl ;
makefile << std::endl ;
makefile << "$(IO_OBJ_FILES) : \%.o : \%.cpp" << std::endl ;
makefile << "\tcd $(<D) ; $(TRICK_CPPC) $(TRICK_CXXFLAGS) $(TRICK_IO_CXXFLAGS) -MMD -MP -c ${<F} -o ${@F}" << std::endl ;
makefile << std::endl ;
makefile << "$(SIM_LIB) : $(IO_OBJECTS)" << std::endl ;
makefile << "$(IO_OBJECTS) : | $(LIB_DIR)" << std::endl ;
makefile << std::endl ;
makefile.close() ;
link_io_objs << "build/class_map.o" << std::endl ;
link_io_objs << "build/enum_map.o" << std::endl ;
link_io_objs.close() ;
}
void PrintAttributes::printEmptyFiles() {
@ -491,7 +495,7 @@ void PrintAttributes::printEmptyFiles() {
void PrintAttributes::printICGNoFiles() {
if ( ! sim_services_flag ) {
std::vector< std::string >::iterator it ;
std::ofstream icg_no_outfile(".icg_no_found") ;
std::ofstream icg_no_outfile("build/icg_no_found") ;
for ( it = icg_no_files.begin() ; it != icg_no_files.end() ; it++ ) {
icg_no_outfile << (*it) << std::endl ;
}