diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..ee08820a --- /dev/null +++ b/Makefile @@ -0,0 +1,506 @@ + +# Makefile to build Trick + +# Make Targets +#------------------------------------------------------------------------------- +# default - Compile Trick-core and Trick Data-products Libraries and Applications. +# 'no_dp' - Compile Trick-core only. +# 'dp' - Compile Data-products only. +# 'java' - Compile Java GUI Applications +# 'javadoc' - Generate Java Documentation. +# 'doxygen' - Generate HTML User's Guide. +# 'test' - Run Unit-tests and Simulation Tests. + +# $Id: Makefile 3796 2015-02-11 19:53:36Z alin $ + +export TRICK_HOME = $(CURDIR) + +# Include the build configuration information. +include $(TRICK_HOME)/makefiles/Makefile.common + +#------------------------------------------------------------------------------- +# Specify the contents of: libtrick.a +#------------------------------------------------------------------------------- +TRICK_LIB = $(TRICK_LIB_DIR)/libtrick.a +SIM_SERV_DIRS = \ + ${TRICK_HOME}/trick_source/sim_services/ExternalApplications \ + ${TRICK_HOME}/trick_source/sim_services/Clock \ + ${TRICK_HOME}/trick_source/sim_services/CheckPointAgent \ + ${TRICK_HOME}/trick_source/sim_services/CheckPointRestart \ + ${TRICK_HOME}/trick_source/sim_services/Collect \ + ${TRICK_HOME}/trick_source/sim_services/CommandLineArguments \ + ${TRICK_HOME}/trick_source/sim_services/DataRecord \ + ${TRICK_HOME}/trick_source/sim_services/DebugPause \ + ${TRICK_HOME}/trick_source/sim_services/DMTCP \ + ${TRICK_HOME}/trick_source/sim_services/EchoJobs \ + ${TRICK_HOME}/trick_source/sim_services/Environment \ + ${TRICK_HOME}/trick_source/sim_services/EventManager \ + ${TRICK_HOME}/trick_source/sim_services/Executive \ + ${TRICK_HOME}/trick_source/sim_services/FrameLog \ + ${TRICK_HOME}/trick_source/sim_services/JITInputFile \ + ${TRICK_HOME}/trick_source/sim_services/JSONVariableServer \ + ${TRICK_HOME}/trick_source/sim_services/Integrator \ + ${TRICK_HOME}/trick_source/sim_services/UnitTest \ + ${TRICK_HOME}/trick_source/sim_services/MasterSlave \ + ${TRICK_HOME}/trick_source/sim_services/MemoryManager \ + ${TRICK_HOME}/trick_source/sim_services/Message \ + ${TRICK_HOME}/trick_source/sim_services/MonteCarlo \ + ${TRICK_HOME}/trick_source/sim_services/RealtimeInjector \ + ${TRICK_HOME}/trick_source/sim_services/RealtimeSync \ + ${TRICK_HOME}/trick_source/sim_services/STL \ + ${TRICK_HOME}/trick_source/sim_services/ScheduledJobQueue \ + ${TRICK_HOME}/trick_source/sim_services/Scheduler \ + ${TRICK_HOME}/trick_source/sim_services/Sie \ + ${TRICK_HOME}/trick_source/sim_services/SimObject \ + ${TRICK_HOME}/trick_source/sim_services/SimTime \ + ${TRICK_HOME}/trick_source/sim_services/ThreadBase \ + ${TRICK_HOME}/trick_source/sim_services/Timer \ + ${TRICK_HOME}/trick_source/sim_services/Units \ + ${TRICK_HOME}/trick_source/sim_services/VariableServer \ + ${TRICK_HOME}/trick_source/sim_services/Zeroconf \ + ${TRICK_HOME}/trick_source/sim_services/include +SIM_SERV_OBJS = $(addsuffix /object_$(TRICK_HOST_CPU)/*.o ,$(SIM_SERV_DIRS)) + +ER7_UTILS_DIRS = \ + ${ER7_UTILS_HOME}/integration/abm4 \ + ${ER7_UTILS_HOME}/integration/beeman \ + ${ER7_UTILS_HOME}/integration/core \ + ${ER7_UTILS_HOME}/integration/euler \ + ${ER7_UTILS_HOME}/integration/mm4 \ + ${ER7_UTILS_HOME}/integration/nl2 \ + ${ER7_UTILS_HOME}/integration/position_verlet \ + ${ER7_UTILS_HOME}/integration/rk2_heun \ + ${ER7_UTILS_HOME}/integration/rk2_midpoint \ + ${ER7_UTILS_HOME}/integration/rk4 \ + ${ER7_UTILS_HOME}/integration/rkf45 \ + ${ER7_UTILS_HOME}/integration/rkf78 \ + ${ER7_UTILS_HOME}/integration/rkg4 \ + ${ER7_UTILS_HOME}/integration/symplectic_euler \ + ${ER7_UTILS_HOME}/integration/velocity_verlet \ + ${ER7_UTILS_HOME}/interface \ + ${ER7_UTILS_HOME}/math \ + ${ER7_UTILS_HOME}/trick/integration +ER7_UTILS_OBJS = $(addsuffix /object_$(TRICK_HOST_CPU)/*.o ,$(ER7_UTILS_DIRS)) + +UTILS_DIRS = \ + ${TRICK_HOME}/trick_source/trick_utils/interpolator \ + ${TRICK_HOME}/trick_source/trick_utils/trick_adt \ + ${TRICK_HOME}/trick_source/trick_utils/comm \ + ${TRICK_HOME}/trick_source/trick_utils/shm \ + ${TRICK_HOME}/trick_source/trick_utils/math \ + ${TRICK_HOME}/trick_source/trick_utils/units +UTILS_OBJS = $(addsuffix /object_$(TRICK_HOST_CPU)/*.o ,$(UTILS_DIRS)) + +#------------------------------------------------------------------------------- +# Specify the contents of: libtrick_pyip.a +# This library contains the SWIG generated interface-code between Trick and Python. +#------------------------------------------------------------------------------- +TRICK_SWIG_LIB = $(TRICK_LIB_DIR)/libtrick_pyip.a + +SWIG_DIRS = \ + ${TRICK_HOME}/trick_source/sim_services/InputProcessor \ + ${TRICK_HOME}/trick_source/trick_swig + +SWIG_OBJS = $(addsuffix /object_$(TRICK_HOST_CPU)/*.o ,$(SWIG_DIRS)) + +#------------------------------------------------------------------------------- +# Specify where to find units tests. +#------------------------------------------------------------------------------- +UNIT_TEST_DIRS = \ + $(wildcard ${TRICK_HOME}/trick_source/sim_services/*/test) \ + $(wildcard ${TRICK_HOME}/trick_source/trick_utils/*/test) \ + ${TRICK_HOME}/trick_source/data_products/DPX/test/unit_test + +#------------------------------------------------------------------------------- +# FIXME: +# This is only used by the 'clean_test' target below. Seems to me that it really +# doesn't belong here. Instead, the 'clean' target in +# $TRICK_HOME/trick_sims/makefile define this. +#------------------------------------------------------------------------------- +MODEL_DIRS = \ + ${TRICK_HOME}/trick_models/Ball++/L1 \ + ${TRICK_HOME}/trick_models/ball/L1 \ + ${TRICK_HOME}/trick_models/ball/L2 \ + ${TRICK_HOME}/trick_models/baseball/aero \ + ${TRICK_HOME}/trick_models/baseball/optim \ + ${TRICK_HOME}/trick_models/cannon/aero \ + ${TRICK_HOME}/trick_models/cannon/graphics \ + ${TRICK_HOME}/trick_models/cannon/gravity \ + ${TRICK_HOME}/trick_models/cannon/optim \ + ${TRICK_HOME}/trick_models/exclude_me \ + ${TRICK_HOME}/trick_models/helios \ + ${TRICK_HOME}/trick_models/stl_checkpoint \ + ${TRICK_HOME}/trick_models/target \ + ${TRICK_HOME}/trick_models/test/dp \ + ${TRICK_HOME}/trick_models/test/impexp \ + ${TRICK_HOME}/trick_models/test/ip \ + ${TRICK_HOME}/trick_models/test/ip2 \ + ${TRICK_HOME}/trick_models/test/sched \ + ${TRICK_HOME}/trick_models/test_ip \ + ${TRICK_HOME}/trick_models/threads + +# The name of the ICG executable indicates the operating system, and the machine +# hardware on which it is built. This allows pre-build ICG binaries to be +# distributed in the installation package. The reason for distributing pre-built +# ICG binaries is because the user's machine may not have the requisite clang +# libraries. +ICG_EXE := ${TRICK_HOME}/trick_source/codegen/Interface_Code_Gen/ICG_$(shell uname -s)_$(shell uname -m) + +################################################################################ +# RULES +################################################################################ +# DEFAULT TARGET +# 1 Build Trick-core and Trick Data-products. +all: no_dp dp + @ echo ; echo "Trick compilation complete:" ; date + +#------------------------------------------------------------------------------- +# 1.1 Build Trick-core +no_dp: $(TRICK_LIB) $(TRICK_SWIG_LIB) $(TRICK_LIB_DIR)/master.o + @ echo ; echo "Trick libs compiled:" ; date + +# 1.1.1 Build libTrick.a +ifeq ($(USE_ER7_UTILS_INTEGRATORS), 1) +$(TRICK_LIB): $(SIM_SERV_DIRS) $(ER7_UTILS_DIRS) $(UTILS_DIRS) | $(TRICK_LIB_DIR) + ar crs $@ $(SIM_SERV_OBJS) $(ER7_UTILS_OBJS) $(UTILS_OBJS) +else +$(TRICK_LIB): $(SIM_SERV_DIRS) $(UTILS_DIRS) | $(TRICK_LIB_DIR) + ar crs $@ $(SIM_SERV_OBJS) $(UTILS_OBJS) +endif + +# 1.1.1.1 Compile the objects in the specified sim_services directories. +.PHONY: $(SIM_SERV_DIRS) +$(SIM_SERV_DIRS): icg_sim_serv $(TRICK_LIB_DIR) + @ $(MAKE) -C $@ trick + +# 1.1.1.2 Compile the objects in the specified utils directories. +.PHONY: $(UTILS_DIRS) +$(UTILS_DIRS): icg_sim_serv + @ $(MAKE) -C $@ trick + +# 1.1.1.3 Compile the objects in the specified er7_utils directories. +.PHONY: $(ER7_UTILS_DIRS) +$(ER7_UTILS_DIRS): TRICK_CXXFLAGS += -Wno-unused-parameter +$(ER7_UTILS_DIRS): make_er7_makefiles icg_sim_serv + @ $(MAKE) -C $@ trick + +.PHONY: make_er7_makefiles +make_er7_makefiles: + @for i in $(ER7_UTILS_DIRS) ; do \ + $(CP) ${TRICK_HOME}/trick_source/sim_services/Executive/Makefile $$i; \ + done + +# 1.1.1.4 Generate interface code (using ICG) for the specified sim_services +# header files. +.PHONY: icg_sim_serv +icg_sim_serv: $(ICG_EXE) | make_er7_makefiles + ${TRICK_HOME}/bin/ICG -s ${TRICK_CXXFLAGS} ${TRICK_HOME}/trick_source/sim_services/include/files_to_ICG.hh + +# 1.1.1.4.1 Build the Interface Code Generator (ICG) executable. +$(ICG_EXE) : + $(MAKE) -C ${@D} + +# 1.1.1.5 Create Trick Library directory. +$(TRICK_LIB_DIR): + @ mkdir $@ + +# 1.1.2 Build libTrick_pyip.a (Swig Lib) +$(TRICK_SWIG_LIB): $(SWIG_DIRS) | $(TRICK_LIB_DIR) + ar crs $@ $(SWIG_OBJS) + +.PHONY: $(SWIG_DIRS) +$(SWIG_DIRS): icg_sim_serv $(TRICK_LIB_DIR) + @ $(MAKE) -C $@ trick + +# 1.1.3 Build master.o. This object contains the main() function for Trick-based +# simulations. +$(TRICK_LIB_DIR)/master.o: | $(TRICK_LIB_DIR) + @ $(MAKE) -C ${TRICK_HOME}/trick_source/sim_services/mains trick + +#------------------------------------------------------------------------------- +# 1.2 Build Trick's Data-products Applications. +.PHONY: dp +dp: ${TRICK_HOME}/trick_source/trick_utils/units + @ $(MAKE) -C ${TRICK_HOME}/trick_source/data_products + +#------------------------------------------------------------------------------- +# 1.3 Build Trick's Java Tools +java: + @ $(MAKE) -C ${TRICK_HOME}/trick_source/java + +.PHONY: javadoc +javadoc: + @ $(MAKE) -C ${TRICK_HOME}/trick_source/java $@ + +#------------------------------------------------------------------------------- +# 1.4 This target builds the Trick Documentation. +.PHONY: doxygen +doxygen: + @ $(MAKE) -C $@ + +#------------------------------------------------------------------------------- +# 1.5 Some Trick source is auto-generated as part of the Trick's build process. When +# Trick is distributed to the user community, we can't be certain that everyone's +# machine will have the approriate versions of the code generations tool. So rather +# than just hope, we go ahead and pre-generate the necessary source files, and +# include those in the distribution package. +# This target pre-generates these source files, that are necessary for creating +# a distribution package. +premade: + @ $(MAKE) -C ${TRICK_HOME}/trick_source/sim_services/MemoryManager premade + @ $(MAKE) -C ${TRICK_HOME}/trick_source/sim_services/CheckPointAgent premade + @ $(MAKE) -C ${TRICK_HOME}/trick_source/java + +################################################################################ +# TESTING +################################################################################ +# This target runs Trick's Unit-tests and simulation-tests. +test: unit_test sim_test requirements + @ echo "All tests completed sucessfully" + +.PHONY: $(UNIT_TEST_DIRS) +$(UNIT_TEST_DIRS): + @ $(MAKE) -C $@ test + +unit_test: $(UNIT_TEST_DIRS) + +sim_test: + @ $(MAKE) -C trick_sims test + +requirements: + @ $(MAKE) -C trick_test/requirements_docs install + +################################################################################ +# CLEAN Targets +################################################################################ + + +clean: clean_sim_serv clean_utils clean_swig clean_dp clean_ICG + @/bin/rm -rf $(TRICK_BIN_DIR) + @/bin/rm -rf $(TRICK_LIB_DIR) + +ifeq ($(USE_ER7_UTILS_INTEGRATORS), 1) +clean: clean_er7_utils +endif + +clean_sim_serv: + @for i in $(SIM_SERV_DIRS) ; do \ + $(MAKE) -C $$i real_clean ; \ + done + @ $(MAKE) -C ${TRICK_HOME}/trick_source/sim_services/mains real_clean + +clean_er7_utils: make_er7_makefiles + @for i in $(ER7_UTILS_DIRS) ; do \ + $(MAKE) -C $$i real_clean ; \ + rm $$i/Makefile; \ + done + +clean_utils: + @ $(MAKE) -C ${TRICK_HOME}/trick_source/trick_utils real_clean + +clean_swig: make_er7_makefiles + @for i in $(SWIG_DIRS) ; do \ + $(MAKE) -C $$i real_clean ; \ + done + +ifeq ($(USE_ER7_UTILS_INTEGRATORS), 1) +clean_swig: make_er7_makefiles +endif + +ifeq ($(DEVELOPER),1) +clean_ICG : + $(MAKE) -C ${TRICK_HOME}/trick_source/codegen/Interface_Code_Gen clean +else +clean_ICG : +endif + +clean_unit_test: + @/bin/rm -rf ${TRICK_HOME}/trick_test/*.xml + @ for i in $(UNIT_TEST_DIRS) ; do \ + $(MAKE) -C $$i clean ; \ + done + +clean_doxygen: + @ $(MAKE) -C ${TRICK_HOME}/doxygen clean + + +clean_dp: + @ $(MAKE) clean -C ${TRICK_HOME}/trick_source/data_products + +clean_java: + @ $(MAKE) -C ${TRICK_HOME}/trick_source/java clean + + +# FIXME: Seems to me that the for loop below should be removed and that the +# 'clean' target in trick_sims/makefile should be doing this. --Penn +clean_test: clean_unit_test clean_requirements + -@ $(MAKE) -C trick_sims clean + @for i in $(MODEL_DIRS) ; do \ + cd $$i ; /bin/rm -rf io_src object_* swig xml ; \ + done + +clean_requirements: + @ $(MAKE) -C trick_test/requirements_docs clean + +clean_stand_alone_utils: + @ $(MAKE) -C ${TRICK_HOME}/trick_source/trick_utils clean_stand_alone + +clean_stand_alone: clean_stand_alone_utils + +clean_objs_for_rpm: clean_sim_serv clean_er7_utils clean_utils + +clean_gui: clean_java + +################################################################################ +# INSTALL Targets +################################################################################ + +install: copy_files + +.PHONY: copy_files +copy_files: ${PREFIX}/trick/trick-$(TRICK_VERSION) copy_trick_source + @ cp -r ${TRICK_HOME}/bin ${PREFIX}/trick/trick-$(TRICK_VERSION) + @ cp ${TRICK_HOME}/config_Linux.mk ${PREFIX}/trick/trick-$(TRICK_VERSION) + @ cp -r ${TRICK_HOME}/docs ${PREFIX}/trick/trick-$(TRICK_VERSION) + @ cp -r ${TRICK_HOME}/lib_${TRICK_HOST_CPU} ${PREFIX}/trick/trick-$(TRICK_VERSION) + @ cp -r ${TRICK_HOME}/makefiles ${PREFIX}/trick/trick-$(TRICK_VERSION) + @ cp -r ${TRICK_HOME}/man ${PREFIX}/trick/trick-$(TRICK_VERSION) + +${PREFIX}/trick/trick-$(TRICK_VERSION) : + @ mkdir -p $@ + +########### + +copy_trick_source: copy_codegen copy_er7_utils_dirs copy_sim_objects copy_sim_serv_dirs copy_utils_dirs copy_swig + +${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source : ${PREFIX}/trick/trick-$(TRICK_VERSION) + @ mkdir -p $@ + +########### + +copy_codegen: ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/codegen/Interface_Code_Gen + @ cp ${TRICK_HOME}/trick_source/codegen/Interface_Code_Gen/ICG_* ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/codegen/Interface_Code_Gen + @ cp -r ${TRICK_HOME}/trick_source/codegen/Interface_Code_Gen/lib ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/codegen/Interface_Code_Gen + +${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/codegen/Interface_Code_Gen : ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source + @ mkdir -p $@ + +########### + +copy_sim_objects: ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source + @ cp -r ${TRICK_HOME}/trick_source/sim_objects ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source + +########### + +BARE_ER7_UTILS_DIRS = $(patsubst ${TRICK_HOME}/trick_source/er7_utils/%,%,$(ER7_UTILS_DIRS)) +TARGET_ER7_UTILS_DIRS = $(addprefix ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/er7_utils/,$(BARE_ER7_UTILS_DIRS)) + +${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/er7_utils : ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source + @ mkdir -p $@ + +$(TARGET_ER7_UTILS_DIRS): ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/er7_utils + @ mkdir -p $@ + +copy_er7_utils_dirs: $(TARGET_ER7_UTILS_DIRS) + @for i in $(BARE_ER7_UTILS_DIRS) ; do \ + cp -r ${TRICK_HOME}/trick_source/er7_utils/$$i/include ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/er7_utils/$$i ; \ + done + +########### + +BARE_SIM_SERV_DIRS = $(filter-out include,$(notdir $(SIM_SERV_DIRS))) +BARE_SIM_SERV_DIRS += InputProcessor +TARGET_SIM_SERV_DIRS = $(addprefix ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services/,$(BARE_SIM_SERV_DIRS)) +TARGET_SIM_SERV_DIRS += ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services/include + +${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services : ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source + @ mkdir -p $@ + +$(TARGET_SIM_SERV_DIRS): ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services + @ mkdir -p $@ + +copy_sim_serv_dirs: $(TARGET_SIM_SERV_DIRS) + @ cp ${TRICK_HOME}/trick_source/sim_services/include/*.h ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services/include + @ cp ${TRICK_HOME}/trick_source/sim_services/include/*.hh ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services/include + @for i in $(BARE_SIM_SERV_DIRS) ; do \ + cp -r ${TRICK_HOME}/trick_source/sim_services/$$i/include ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services/$$i ; \ + done + +########### + +BARE_UTILS_DIRS = $(notdir $(UTILS_DIRS)) +TARGET_UTILS_DIRS = $(addprefix ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_utils/,$(BARE_UTILS_DIRS)) + +${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_utils : ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source + @ mkdir -p $@ + +$(TARGET_UTILS_DIRS): ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_utils + @ mkdir -p $@ + +copy_utils_dirs: $(TARGET_UTILS_DIRS) + @for i in $(BARE_UTILS_DIRS) ; do \ + cp -r ${TRICK_HOME}/trick_source/trick_utils/$$i/include ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_utils/$$i ; \ + done + +########### + +TARGET_SWIG_DIRS = \ + ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_swig \ + ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_swig/swig_${TRICK_HOST_CPU} + +$(TARGET_SWIG_DIRS): ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source + @ mkdir -p $@ + +copy_swig: $(TARGET_SWIG_DIRS) + @ cp ${TRICK_HOME}/trick_source/trick_swig/*.py ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_swig + @ cp ${TRICK_HOME}/trick_source/trick_swig/swig_${TRICK_HOST_CPU}/*.py ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_swig/swig_${TRICK_HOST_CPU} + +########### + +uninstall: + rm -rf ${PREFIX}/trick/trick-$(TRICK_VERSION) + +########### + +# These rules run the alternatives command in linux to create links in /usr/local/bin for Trick. +ifeq ($(TRICK_HOST_TYPE),Linux) +ALTERNATIVES := $(shell which alternatives || which update-alternatives) + +#install: set_alternatives +.PHONY: set_alternatives +set_alternatives: copy_files + - ${ALTERNATIVES} --install /usr/local/bin/CP trick ${PREFIX}/trick/trick-$(TRICK_VERSION)/bin/CP 10 \ + --slave /usr/local/bin/ICG ICG /usr/local/trick/trick-$(TRICK_VERSION)/bin/ICG \ + --slave /usr/local/bin/gte gte /usr/local/trick/trick-$(TRICK_VERSION)/bin/gte \ + --slave /usr/local/bin/kill_sim kill_sim /usr/local/trick/trick-$(TRICK_VERSION)/bin/kill_sim \ + --slave /usr/local/bin/sie sie /usr/local/trick/trick-$(TRICK_VERSION)/bin/sie \ + --slave /usr/local/bin/sim_control sim_control /usr/local/trick/trick-$(TRICK_VERSION)/bin/sim_control \ + --slave /usr/local/bin/sniffer sniffer /usr/local/trick/trick-$(TRICK_VERSION)/bin/sniffer \ + --slave /usr/local/bin/trick_dp trick_dp /usr/local/trick/trick-$(TRICK_VERSION)/bin/trick_dp \ + --slave /usr/local/bin/trick_version trick_version /usr/local/trick/trick-$(TRICK_VERSION)/bin/trick_version \ + --slave /usr/local/bin/tv tv /usr/local/trick/trick-$(TRICK_VERSION)/bin/tv + +#uninstall: remove_alternatives +.PHONY: remove_alternatives +remove_alternatives: + - ${ALTERNATIVES} --remove trick ${PREFIX}/trick/trick-$(TRICK_VERSION)/bin/CP +endif + +################################################################################ +# MISCELLANEOUS DEVELOPER UTILITY TARGETS # +################################################################################ +stand_alone: stand_alone_utils +stand_alone_utils: + @ $(MAKE) -C ${TRICK_HOME}/trick_source/trick_utils stand_alone + +# The below rules are used by Debian based .deb file creating. + +# ICG all sim_services files (for testing and debugging ICG). +# The -f flag forces io_src files to be regenerated whether or not they need to be. +ICG: $(ICG_EXE) + ${TRICK_HOME}/bin/ICG -f -s ${TRICK_CXXFLAGS} ${TRICK_HOME}/trick_source/sim_services/include/files_to_ICG.hh + +# This builds a tricklib share library. +trick_lib: + ${TRICK_CPPC} $(SHARED_LIB_OPT) -o $(TRICK_LIB) $(SIM_SERV_OBJS) $(ER7_UTILS_OBJS) $(UTILS_OBJS) $(SWIG_OBJS) + diff --git a/bin/C3PO b/bin/C3PO new file mode 100755 index 00000000..09a05deb --- /dev/null +++ b/bin/C3PO @@ -0,0 +1,367 @@ +#! /usr/bin/perl + +# $Id: CP 1740 2011-07-07 18:38:25Z lin $ + +use File::Basename ; +use Cwd ; +use strict ; +use Data::Dumper ; +use Getopt::Long ; +use Pod::Usage ; +use Pod::Text ; +use Cwd 'abs_path'; + +use FindBin qw($Bin); +use lib "$Bin/pm" ; + +use parse_s_define ; +use get_headers ; +use ICG ; +use MIS ; +use mis_dep ; +use make_makefile ; +use make_swig_makefile ; +use make_no_swig_makefile ; +use gte ; +use s_source ; +use auto_doc ; +use default_data ; +use trick_print ; +use trick_version ; + +my %sim ; +my $cwd = cwd(); +my $saved_cflags ; +my (@paths , $cc , $cc_found) ; +my $make_cmd; + +# override the print format for help message +*Pod::Text::seq_i = sub { return "" . $_[1] . "" } ; + +# set stdout to unbuffered so we see printout immediately. +$| = 1 ; + +# set default verbose level +$sim{args}{v} = 2 ; +$sim{args}{o} = "CP_out" ; +$sim{args}{p} = 1 ; + +#-------------------------------------------------------------- +# Process command line arguments +Getopt::Long::Configure ("bundling"); +GetOptions ( "d" => \$sim{args}{d} , + "e" => \$sim{args}{e} , + "f" => \$sim{args}{f} , + "model_dirs|z" => \$sim{args}{z} , + "no_python|p" => sub { $sim{args}{p} = 0 } , + "debug|g" => sub { $sim{args}{v} = 3 ; } , + "help|h|?" => \$sim{args}{h} , + "m" => \$sim{args}{m} , + "outfile|o=s" => \$sim{args}{o} , + "r" => \$sim{args}{r} , + "s" => \$sim{args}{s} , + "t" => \$sim{args}{t} , + "verbose|v=i" => \$sim{args}{v} + ) or pod2usage(1) ; + +pod2usage(1) if $sim{args}{h} ; + +$ENV{TRICK_HOST_CPU} = gte("TRICK_HOST_CPU") ; +chomp $ENV{TRICK_HOST_CPU} ; + +# look to see if TRICK_CC set properly +@paths = split /:/ , $ENV{PATH} ; +$cc = gte("TRICK_CC") ; +chomp $cc ; +$cc =~ s/.*?ccache\s+// ; +$cc_found = 0 ; +foreach my $p ( @paths ) { + if ( -x "$p/$cc" or -x $cc ) { + $cc_found = 1 ; + last ; + } +} + +if ( $cc_found == 0 ) { + trick_print( $sim{fh}, "CP can't find TRICK_CC = $cc.\n", "title_red", $sim{args}{v} ) ; + exit ; +} + +# Get Trick version +my ($version, $thread) = get_trick_version() ; +$thread =~ s/\d+\.// ; + +local *OUTFILE ; +open OUTFILE , ">$sim{args}{o}" or warn "CP cannot open $sim{args}{o} for writing\n" ; +$sim{fh} = *OUTFILE ; +print OUTFILE "Output for $0 version $version-$thread at " . localtime() . "\n\n" ; + + +if ( !( $sim{args}{e} || $sim{args}{s} || $sim{args}{m} || $sim{args}{d} ) ) { + $sim{args}{e} = $sim{args}{s} = $sim{args}{m} = $sim{args}{d} = 1 ; +} + +# if no python is specified, turn off the python InputProcessor sim_object in S_define. +if ( $sim{args}{p} == 0 ) { + $ENV{TRICK_SFLAGS} .= " -DTRICK_NO_INPUTPROCESSOR" ; +} + +#-------------------------------------------------------------- +# Parse the S_define file + +trick_print($sim{fh}, "Parsing S_define..." , "title_cyan" , $sim{args}{v}) ; +trick_print($sim{fh}, "\n" , "title_white" , $sim{args}{v}) if ( $sim{args}{v} != 1 ) ; + +parse_s_define(\%sim) ; + +trick_print( $sim{fh}, "\nCompleted parsing S_define\n\n" , "normal_green" , $ sim{args}{v} ) ; + +#-------------------------------------------------------------- +# If this is CP -z|model_dirs, print model dirs and exit +if ( $sim{args}{z} ) { + my %model_dirs ; + foreach ( keys %{$sim{headers_full_path}} ) { + $model_dirs{dirname($_)} = 1 ; + } + foreach ( @{$sim{mis_entry_files}} ) { + $model_dirs{dirname($_)} = 1 ; + } + trick_print($sim{fh}, "Model directory listing\n", "title_cyan", $sim{args}{v}); + foreach ( sort keys %model_dirs ) { + trick_print($sim{fh}, "$_\n", "normal_white", $sim{args}{v}); + } + exit ; +} + +#-------------------------------------------------------------- +# Make S_source.c + +if ($sim{args}{s}) { + trick_print($sim{fh}, "Creating S_source.c...", "title_cyan", $sim{args}{v}); + s_source( \%sim ) ; + trick_print($sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ; +} + +#-------------------------------------------------------------- +# Get all headers used by the sim and their modification dates +get_headers(\%sim, abs_path("S_source.hh")) ; + +#-------------------------------------------------------------- +# ICG all headers that S_define references +# ICG will return: +# -> Hash of types (used to create S_source.c) +# %types{type_name} -> {name,value,xml} +# value == 102 means enumerated type +# value == 103 means struct type +# -> Hash of dependencies (used to create Makefile) +my @files_to_mis ; +my ($new_mis_depends_ref , $rcs_tags_ref) ; +my @mis_entry_files ; +my @headers_to_ICG ; +my @all_headers_to_ICG ; + +chdir ($cwd) ; + +trick_print($sim{fh}, "Determining structure dependencies.\n" , "normal_cyan" , $sim{args}{v}) ; + +@all_headers_to_ICG = (sort keys %{$sim{headers_full_path}}) ; +foreach ( @all_headers_to_ICG ) { + if ( !/trick_source/ ) { + push @headers_to_ICG , $_ ; + } +} +if ( scalar @headers_to_ICG ) { + trick_print( $sim{fh}, "ICG'ing header files to get all header file dependencies..." , "title_cyan" , $sim{args}{v} ) ; + trick_print( $sim{fh}, "\n" , "title_white" , $sim{args}{v} ) if ( $sim{args}{v} != 1 ) ; +} + +my @defs ; +my @temp_array = ( abs_path("S_source.hh")) ; +ICG ( @temp_array , "CP" , \@defs, \%sim ) ; +if ( $sim{args}{v} == 1 ) { + print " Complete\n" ; +} + +if ( scalar @headers_to_ICG ) { + trick_print( $sim{fh}, "\nAll header file dependencies found.\n" , "normal_green" , $sim{args}{v} ) ; +} + +foreach my $h ( @all_headers_to_ICG ) { + # push the header dependencies for c++ files onto the lists for mis processing + foreach ( keys %{$sim{all_icg_depends}{$h}} ) { + if ( exists $sim{head_deps}{$_} and defined $sim{head_deps}{$_}{files} ) { + push @mis_entry_files , @{$sim{head_deps}{$_}{files}} ; + push @{$sim{mis_entry_files}} , @{$sim{head_deps}{$_}{files}} ; + } + } +} + +trick_print( $sim{fh}, "Determining module dependencies.\n", "normal_cyan" , $sim{args}{v}) ; + +push @mis_entry_files , (grep !/trick_source/ , @{$sim{mis_entry_files}}) ; +foreach ( @mis_entry_files ) { + if ( ! exists $sim{src_only}{$_} ) { + if ( !/trick_source/ ) { + push @files_to_mis , $_ ; + } + } +} + +my %temp_hash ; +@files_to_mis = grep ++$temp_hash{$_} < 2, @files_to_mis ; + +$new_mis_depends_ref = mis_dep(\%sim , @files_to_mis) ; + +# Add the object only listings +mis_catalog_dep(\%sim , $new_mis_depends_ref) ; + +foreach my $k ( keys %$new_mis_depends_ref ) { + $sim{all_mis_depends}{$k} = $$new_mis_depends_ref{$k} ; +} + +my @all_src_files ; +foreach my $n ( @{$sim{mis_entry_files}} ) { + foreach my $k ( grep !/last_look/ , + (keys %{$sim{all_mis_depends}{$n}}) ) { + + push @all_src_files , + @{$sim{all_mis_depends}{$n}{$k}} ; + } +} +undef %temp_hash ; +@all_src_files = grep ++$temp_hash{$_} < 2, @all_src_files ; +@all_src_files = grep !/trick_source|\.a$|^\-/ , @all_src_files ; + +# TODO: Add back at some time before release +#trick_print($sim{fh}, "MIS-ing all src files... ", "title_cyan" , $sim{args}{v}) ; +#trick_print($sim{fh}, "\n" , "title_white" , $sim{args}{v}) if ( $sim{args}{v} != 1 ) ; +#mis_all_c(\@all_src_files , \%sim ) ; + +if ( $sim{args}{v} == 1 ) { + print " Complete\n" ; +} +trick_print($sim{fh}, "\nMIS complete\n\n" , "normal_green" , $sim{args}{v}) ; + +if ( $sim{args}{v} > 3 ) { + chdir ($cwd) ; + $Data::Dumper::Indent = 1 ; + open FILE, ">sim_info" or die "Couldn't open sim_info\n"; + print FILE Data::Dumper->Dump([\%sim], ["*sim_info"]) , "\n" ; + close FILE ; +} + +#-------------------------------------------------------------- +# Make Default Data + +if ($sim{args}{d}) { + chdir ($cwd) ; + trick_print($sim{fh}, "Creating Default_data...", "title_cyan" , $sim{args}{v}) ; + make_default_data( \%sim ) ; + trick_print($sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ; + + chdir ($cwd) ; + trick_print($sim{fh}, "Creating S_document.xml...", "title_cyan", $sim{args}{v}) ; + print_xml_CP( \%sim ) ; + trick_print( $sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ; +} + +#-------------------------------------------------------------- +# Make Makefile + +if ($sim{args}{m}) { + trick_print($sim{fh}, "Creating New Makefile... ", "title_cyan" , $sim{args}{v}) ; + make_makefile( \@temp_array , \%sim , $cwd) ; + trick_print($sim{fh}, " Complete\n" , "title_green" , $sim{args}{v}) ; + + if ( $sim{args}{p} == 1 ) { + trick_print($sim{fh}, "Creating SWIG Makefile... ", "title_cyan" , $sim{args}{v}) ; + make_swig_makefile( \@temp_array , \%sim , $cwd) ; + trick_print($sim{fh}, " Complete\n" , "title_green" , $sim{args}{v}) ; + } else { + trick_print($sim{fh}, "Creating No-python Makefile... ", "title_cyan" , $sim{args}{v}) ; + make_no_swig_makefile() ; + trick_print($sim{fh}, " Complete\n" , "title_green" , $sim{args}{v}) ; + } +} + +close OUTFILE ; + +################################################################################ +# END MAIN +################################################################################ + +__END__ + +=head1 NAME + +CP - Trick Configuration Processor + +=head1 SYNOPSIS + +CP [-defghmprsz?] [--debug] [--help] [-o I] [--outfile=I] +[-v I] [--verbose=I] [--model_dirs] + +=head1 DESCRIPTION + +See the Trick User's guide for B + +=head1 OPTIONS + +=over 8 + +=item B<-d> + +S_default.dat and Default_data (Default data files) + +=item B<-e> + +S_main_\${TRICK_HOST_CPU}.exe (Master executable) + +=item B<-f> + +Force CP to process S_define without catalog/cache + +=item B<-g> | B<--debug> + +Set the verbose level to 3 + +=item B<-h> | B<-?> | B<--help> + +Print this help message + +=item B<-m> + +Makefile (Simulation make file) + +=item B<-o> I | B<--outfile>=I + +output all CP output to an external file + +=item B<-p> + +Create a simulation without python input processor. + +=item B<-s> + +S_source.c (Simulation specific executive source code) + +=item B<-r> + +S_sie.resource (Smart Input Editor data base) + +=item B<-v> I | B<--verbose>=I + +Set the verbose level. Valid entries are 0-3. + +=item B<-z> | B<--model_dirs> + +Print out the model directories this S_define depends on. + +=item B<-DTRICK_VER=x.x> + +Note: -DTRICK_VER=x.x is automatically used when parsing header files and the S_define file + +=back + +=cut + diff --git a/bin/CP b/bin/CP new file mode 100755 index 00000000..6b800e5c --- /dev/null +++ b/bin/CP @@ -0,0 +1,41 @@ +#!/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 ; +use Cwd 'abs_path'; + +$trick_bin = dirname(abs_path($0)) ; +$trick_home = dirname($trick_bin) ; + +if ( -f "S_define" ) { + unlink "Makefile_sim", "makefile" ; + $makefile_text = do { local $/; } ; + $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 ; + if (@ARGV[0] eq "-t" ) { + system("make -f makefile test") ; + } elsif ( @ARGV[0] eq "-d" or @ARGV[0] eq "--debug" ) { + system("make -f makefile debug") ; + } else { + system("make -f makefile") ; + } + 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 + +include ${TRICK_HOME}/makefiles/Makefile.sim +-include S_overrides.mk + diff --git a/bin/ICG b/bin/ICG new file mode 100755 index 00000000..66551dba --- /dev/null +++ b/bin/ICG @@ -0,0 +1,20 @@ +#!/usr/bin/perl + +use File::Basename ; +use Cwd 'abs_path'; + +if ( ! exists $ENV{TRICK_HOME} ) { + $trick_bin = dirname(abs_path($0)) ; + $trick_home = dirname($trick_bin) ; + + # set TRICK_HOME based on the value of trick_home + $ENV{TRICK_HOME} = $trick_home ; +} + +$kernel = `uname -s` ; +chomp $kernel ; +$machine = `uname -m` ; +chomp $machine ; + +system ("$ENV{TRICK_HOME}/trick_source/codegen/Interface_Code_Gen/ICG_${kernel}_${machine}", @ARGV) ; +exit $? >> 8 ; diff --git a/bin/ICG_10 b/bin/ICG_10 new file mode 100755 index 00000000..80f0ecf2 --- /dev/null +++ b/bin/ICG_10 @@ -0,0 +1,266 @@ +#!/usr/bin/perl + +# +# $Id: ICG_10 3006 2013-06-07 21:10:59Z dstrauss $ +# Revision 7.3 2006-09-20 14:50:44-05 hua +# Update ICG -u to include dual system units and prefix list +# +# Revision 7.2 2006-07-26 10:00:46-05 hua +# ICG -u Measurement Units Summary Incomplete +# +# Revision 7.1 2006-06-22 14:15:34-05 lin +# Bump version number for 07 +# +# Revision 5.3 2006-03-29 16:09:54-06 lin +# add -DTRICK_VER=x to ICG -help +# +# Revision 5.2 2005-11-08 14:53:28-06 vetter +# 8 space indent bin directory +# +# Revision 5.1 2004-08-05 11:29:12-05 lin +# Bump +# +# Revision 4.6 2004/03/09 22:36:44 lin +# trick_version -v is messed up. +# +# Revision 4.5 2004/02/10 21:59:35 lin +# make the CP, ICG, MIS help messages prettier +# +# Revision 4.4 2004/01/28 17:13:06 lin +# Cut error message out of CP down to 1 line. +# +# Revision 4.3 2004/01/16 21:34:33 lin +# Can't Compile 04 With g++3 +# +# + +use FindBin qw($Bin); +use strict ; +use Getopt::Long; +use Pod::Usage; +use Pod::Text; +use lib "$Bin/pm" ; +use ICG ; +use trick_print ; +use trick_version ; +use get_headers ; +use Cwd 'abs_path'; + +############################################################################## +# Main program +############################################################################## + +my $icg_operation ; +my @icg_h_files ; +my %sim ; +my $ret ; +my $help ; +my @defs ; +my ($valid_types_ref,$icg_depends_ref, $mis_entries_ref,$mis_depends_ref) ; +my ($head_depends_ref,$rcs_tags_ref) ; + +# override the print format for help message +*Pod::Text::seq_i = sub { return "" . $_[1] . "" } ; + +# set stdout to unbuffered so we see printout immediately. +$| = 1 ; + +# set the default verbose level to 2 +$sim{args}{v} = 2 ; +$sim{args}{force} = 0 ; + +# default operation +$icg_operation = "full" ; +$ICG::arg_lang = 0 ; + +Getopt::Long::Configure ("bundling"); +GetOptions ( "D=s" => sub { my $temp = join "" , @_ ; push @defs , "-$temp" ; } , + "U=s" => sub { my $temp = join "" , @_ ; push @defs , "-$temp" ; } , + "cpp|p" => sub { $ICG::arg_lang = "CPP" } , + "debug|d|g" => sub { $sim{args}{v} = 3 } , + "help|h|?" => \$help , + "force|f" => sub { $sim{args}{force} = 1} , + "outfile|o=s" => \$sim{args}{o} , + "sim_services|s" => sub { $icg_operation = "sim_services" } , + "single" => sub { $icg_operation = "single" } , + "s_source" => sub { $icg_operation = "s_source" } , + "tree|t" => sub { $icg_operation = "tree" } , + "unit_summary|u" => \&unit_summary , + "verbose|v=i" => \$sim{args}{v} + ) or pod2usage(1) ; + +pod2usage(1) if $help ; + +#if ( -e "S_overrides.mk" ) { +# +# open CFLAGS, "make -p -n -f S_overrides.mk fake_target 2>&1 |" ; +# +# while ( ) { +# +# if ( /^TRICK_CFLAGS\s*\:?=\s*(.*)/ ) { +# $ENV{TRICK_CFLAGS} = $1 ; +# } +# elsif ( /^TRICK_ICG_EXCLUDE\s*\:?=\s*(.*)/ ) { +# $ENV{TRICK_ICG_EXCLUDE} = $1 ; +# $ENV{TRICK_ICG_EXCLUDE} =~ s/\$[{(]([^})]+)[})]/$ENV{$1}/ge ; +# } +# } +# close CFLAGS ; +#} + +$ENV{TRICK_CFLAGS} =~ s/\$[{(](\w+)[})]/$ENV{$1}/g ; +$ENV{TRICK_CFLAGS} =~ s/\"//g ; + +# set and open the output file +if ( $sim{args}{o} ne "" ) { + my ($version, $thread) = get_trick_version() ; + $thread =~ s/\d+\.// ; + local *OUTFILE ; + open OUTFILE , ">$sim{args}{o}" + or warn "ICG cannot open $sim{args}{o} for writing\n" ; + $sim{fh} = *OUTFILE ; + print OUTFILE "Output for $0 version $version-$thread at " . localtime() . "\n\n" ; +} + +push @icg_h_files , (grep !/(^-|(\.d|\.dd)$)/ , @ARGV) ; + +#-------------------------------------------------------------- +# Get all headers used by the sim and their modification dates +#if ( $icg_operation eq "s_source" ) { +# get_headers(\%sim, abs_path("S_source.hh")) ; +#} + +$ret = ICG(@icg_h_files, $icg_operation, \@defs, \%sim) ; + +if ($ret eq -1) { + trick_print($sim{fh}, + "\nICG No files specified or found\n" , + "normal_yellow" , $sim{args}{v}) ; +} + +sub unit_summary() { + print " + Trick Measurement Units Summary +--------------------------------------------------------------------------------------------------- +Standard Units |Description +--------------------------------------------------------------------------------------------------- + Time: s min hr day |second, minute, hour, day +Angular Displacement: r d as am rev |radian, degree, arc-second, arc-minute, revolution + Voltage: v |volt + Amperage: amp |ampere + Resistance: ohm |ohm + Sound: dB |decibel + Unitless: -- cnt one mol |no unit, count, one, mole + | +--------------------------------------------------------------------------------------------------- +English System Units |Description +--------------------------------------------------------------------------------------------------- + Linear Displacement: ft kft in yd mi n.m. |foot, kilofoot, inch, yard, mile, nautical mile + Mass: sl lbm |slug, pound(mass) + Force: oz lbf |ounce, pound(force) + Temperature: R F |Rankine, Fahrenheit + Energy: BTU |British Thermal Unit + Power: hp |horsepower + Pressure: psi |pound per square inch + Volume: gal floz |gallon, fluid ounce + | +--------------------------------------------------------------------------------------------------- +Metric System Units |Description +--------------------------------------------------------------------------------------------------- + Linear Displacement: m |meter + Mass: g mt |gram, metric ton + Force: N |Newton + Temperature: C K |Celsius, Kelvin + Energy: J TNT |Joule, ton of TNT + Power: W |Watt + Pressure: Pa atm mHg |Pascal, atmosphere, meter of mercury + Frequency: Hz |Herz + Volume: l |liter + +--------------------------------------------------------------------------------------------------- + +--------------------------------------------------------- +You can use these prefixes for Multiples and Submultiples +(Only valid for units: r v amp ohm m g N J W Pa mHg Hz) +--------------------------------------------------------- +10**-1 d 10 da +10**-2 c 10**2 h +10**-3 m 10**3 k +10**-6 u 10**6 M +10**-9 n 10**9 G +10**-12 p 10**12 T +--------------------------------------------------------- +\n\n" ; + + exit() ; +} + +__END__ + +=head1 NAME + +ICG - Trick Interface Code Generator + +=head1 SYNOPSIS + +ICG [-D B