# # $Id: Makefile 127 2009-06-17 21:21:10Z rosiere $ # # [ Description ] # # Makefile # #---------------------------------------------------------- #---------------------------------------------------------- #-----[ Environment ]-------------------------------------- #---------------------------------------------------------- #---------------------------------------------------------- ifeq ($(origin MORPHEO_TOPLEVEL), undefined) $(error "variable MORPHEO_TOPLEVEL is undefined") else include $(MORPHEO_TOPLEVEL)/Makefile.tools include $(MORPHEO_TOPLEVEL)/Makefile.flags endif ifeq ($(origin MORPHEO_TMP), undefined) $(error "variable MORPHEO_TMP is undefined") endif DATA_ALL = * ifeq ($(origin DATA), undefined) DATA = $(DATA_ALL) endif ifeq ($(origin PRIORITY), undefined) PRIORITY = 0 endif ifeq ($(flavor CLEAN), undefined) CLEAN = 0 endif #---------------------------------------------------------- #---------------------------------------------------------- #-----[ Directory ]---------------------------------------- #---------------------------------------------------------- #---------------------------------------------------------- ENTITY = Test PATH_TMP = $(MORPHEO_TMP) PATH_INC = include PATH_SRC = src PATH_OBJ = $(PATH_TMP)/obj PATH_LIB = $(PATH_TMP)/lib PATH_BIN = $(PATH_TMP)/bin PATH_LOG = $(PATH_TMP)/log PATH_DATA = ./data PATH_LOGS = $(patsubst $(PATH_DATA)/%,$(PATH_LOG)/%,$(wildcard $(PATH_DATA)/*)) PATH_SOFT = $(MORPHEO_TOPLEVEL)/Softwares #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps #---------------------------------------------------------- #---------------------------------------------------------- #-----[ Variables ]---------------------------------------- #---------------------------------------------------------- #---------------------------------------------------------- SOURCES = $(wildcard $(PATH_SRC)/*.cpp) OBJECTS = $(patsubst $(PATH_SRC)/%.cpp,$(PATH_OBJ)/%.o,$(SOURCES)) LOGS = $(patsubst $(PATH_DATA)/%.cfg,$(PATH_LOG)/%.log,$(wildcard $(PATH_DATA)/$(DATA)/*.cfg)) EXEC = $(PATH_BIN)/soft.x EXEC_PREFIX = $(NICE) -n $(PRIORITY) #$(VALGRIND) SCRIPT = make.sh #-----[ Compilation ]-------------------------------------- INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR_SYSTEMC)) \ $(MORPHEO_INCDIR) \ $(ENVIRONMENT_INCDIR) \ -I$(PATH_INC) #LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ # $(ENVIRONMENT_LIBDIR) \ # $(MORPHEO_LIBDIR) LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ -L$(PATH_LIB) LIBNAME = $(ENVIRONMENT_LIBNAME) \ $(MORPHEO_LIBNAME) \ $(SYSTEMC_LIBNAME_$(SIMULATOR_SYSTEMC)) FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR_SYSTEMC)) PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) #---------------------------------------------------------- #---------------------------------------------------------- #-----[ Rules ]-------------------------------------------- #---------------------------------------------------------- #---------------------------------------------------------- vpath %.h $(PATH_INC) vpath %.cpp $(PATH_SRC) vpath %.o $(PATH_OBJ) vpath %.cfg $(PATH_DATA)/*/ .PRECIOUS : $(PATH_OBJ)/%.o $(PATH_BIN)/%.x $(PATH_LOG)/%.log all : $(EXEC) $(PATH_BIN)/%.x : $(PATH_OBJ) $(PATH_BIN) @\ $(ECHO) "Linkage : $*";\ case "${SIMULATOR_SYSTEMC}" in \ "modelsim") \ $(MAKE) $(WORK_NAME); \ $(MODELTECH_SCCOM) $(PLATFORMS_CXX_FLAGS) $(SOURCES); \ $(MODELTECH_SCCOM) -link $(PLATFORMS_L_FLAGS) $(LIBNAME); \ $(ECHO) "#!$(SHELL)" > $@; \ $(ECHO) "cd $${PWD};" >> $@; \ $(ECHO) "$(MODELTECH_VSIM) -sc_arg "'"$${*}"'" $(WORK_NAME).top;" >> $@;\ $(ECHO) "cd -;" >> $@; \ $(CHMOD) +x $@; \ ;; \ *) \ $(MAKE) $(OBJECTS); \ $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $(OBJECTS) $(LIBNAME); \ ;; \ esac; \ run : @\ declare -i clean=$(CLEAN); \ if $(TEST) $${clean} -ne 0 -a "$(DATA)" != "$(DATA_ALL)"; then \ $(RM) $(PATH_LOG)/$(DATA); \ fi; \ $(MAKE) $(PATH_LOGS); \ declare logs="$(LOGS)"; \ $(MAKE) $${logs}; \ declare -i nb_test=0; \ declare -i nb_test_ko=0; \ for log in $${logs}; do \ $(GREP) -q "Test OK" $$log; \ declare -i test_ok=$$?; \ $(GREP) -q "Test KO" $$log; \ declare -i test_ko=$$?; \ if $(TEST) $${test_ko} -eq 0 -o $${test_ok} -ne 0; \ then nb_test_ko=$$(($${nb_test_ko} + 1)); \ fi; \ nb_test=$$(($${nb_test} + 1)); \ done; \ if $(TEST) $${nb_test_ko} -ne 0; \ then $(ECHO) "-------------------| Test KO !!! ($${nb_test_ko}/$${nb_test})"; exit 1; \ else $(ECHO) "-------------------| Test OK ($${nb_test})"; exit 0; \ fi; execute : run debug : @\ $(MAKE) run DATA=debug CLEAN=1; bench : @\ $(MAKE) run DATA=bench; distexe : @\ $(RM) $(SCRIPT); \ for log in $(LOGS); do \ $(ECHO) -n "cd $(MORPHEO_TOPLEVEL); source environment.sh; cd -; path=\"${PWD}\"; " >> $(SCRIPT); \ if $(TEST) $(CLEAN) -ne 0; then \ $(ECHO) -n "$(RM) $${log}; " >> $(SCRIPT); \ fi; \ $(ECHO) "$(MAKE) -C "'$${path}'" $${log} PRIORITY=$(PRIORITY);" >> $(SCRIPT); \ done $(PATH_LOG)/%.log : $(PATH_DATA)/%.cfg $(EXEC) @\ file=$$($(BASENAME) $<); \ data=$$(eval echo $$($(CAT) $<)); \ log=$@; \ $(ECHO) "Run : $*"; \ $(EXEC_PREFIX) $(EXEC) $${data} &> $$log; \ $(GREP) -q "Test OK" $$log; \ declare -i test_ok=$$?; \ $(GREP) -q "Test KO" $$log; \ declare -i test_ko=$$?; \ declare timing=$$($(GREP) -h "Timing" $$log); \ if $(TEST) $${test_ko} -ne 0 -a $${test_ok} -eq 0; \ then test="... OK "; \ else test="... KO !!!"; \ fi; \ $(ECHO) -e " $* $${test}\t$${timing}";\ echo "{$$($(date))} $* $${test} $${timing}" >> $$($(DIRNAME) $*).res;\ #-----[ Library + Software ]------------------------------- env : soft lib @$(MAKE) $(EXEC) lib : @\ $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; soft : @\ $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile; #-----[ Rules ]-------------------------------------------- $(PATH_OBJ)/%.o : %.cpp @\ $(ECHO) "Compilation : $*";\ $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; $(PATH_OBJ) $(PATH_BIN) $(PATH_LOGS) : @\ $(ECHO) "Create directory : $@";\ $(MKDIR) $@ #-----[ Clean + help ]------------------------------------- clean : @\ $(ECHO) "Delete temporary files in directory $(PWD)";\ $(RM) $(OBJECTS) $(EXEC) $(LOGS) \ *~ $(PATH_SRC)/*~ $(PATH_INC)/*~ $(PATH_DATA)/*/*~ *.res *.txt\ *core* \ tty* \ *.vhdl \ *.log \ *.stat \ *.pos \ modelsim.ini transcript *wlf* $(WORK_NAME) clean_all : clean @\ $(ECHO) "Delete generated files in directory $(PWD)";\ $(RM) $(PATH_OBJ) $(PATH_BIN) $(PATH_LOG) $(SCRIPT);\ $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile clean_all; \ $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; help : @\ $(ECHO) " -----[ Common ]-------------------------------------";\ $(ECHO) "";\ $(ECHO) " * all (default rules) : create software";\ $(ECHO) " * run : execute platforms with test configuration";\ $(ECHO) " set DATA to select a specific directory in $(PATH_DATA) (default : all)";\ $(ECHO) " set PRIORITY to nice the execution (default : 0)";\ $(ECHO) " set CLEAN to remove previous log (default : 0)";\ $(ECHO) " example : make run DATA=debug PRIORITY=10 CLEAN";\ $(ECHO) " * execute : cf 'make run'";\ $(ECHO) " * debug : cf 'make run DATA=debug'";\ $(ECHO) " * bench : cf 'make run DATA=bench'";\ $(ECHO) " * distexe : Generate an command file to distexe. It's as run command, but just generate an script with all make";\ $(ECHO) " * lib : make library";\ $(ECHO) " * soft : make software";\ $(ECHO) " * clean : erase temporary files";\ $(ECHO) " * clean_all : erase generated files";\ $(ECHO) " * help : print this message";\ $(ECHO) ""; include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Behavioural/Makefile.Synthesis include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps