# # $Id: Makefile 108 2009-02-12 11:55:06Z 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 #---------------------------------------------------------- #---------------------------------------------------------- #-----[ Directory ]---------------------------------------- #---------------------------------------------------------- #---------------------------------------------------------- ENTITY = Test DIR_TMP = $(MORPHEO_TMP) DIR_INC = include DIR_SRC = src DIR_OBJ = $(DIR_TMP)/obj DIR_BIN = $(DIR_TMP)/bin DIR_LOG = $(DIR_TMP)/log DIR_DATA_TEST = ./data_test DIR_DATA_BENCH = ./data_bench DIR_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 ]---------------------------------------- #---------------------------------------------------------- #---------------------------------------------------------- OBJECTS = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_OBJ)/%.o,$(wildcard $(DIR_SRC)/*.cpp)) LOGS = $(patsubst $(DIR_DATA_TEST)/%.cfg,$(DIR_LOG)/%.log,$(wildcard $(DIR_DATA_TEST)/*.cfg)) BENCHS = $(patsubst $(DIR_DATA_BENCH)/%.cfg,$(DIR_LOG)/%.log,$(wildcard $(DIR_DATA_BENCH)/*.cfg)) DEBUG_CFG = $(DIR_DATA_TEST)/debug.cfg DEBUG_LOG = $(DIR_LOG)/debug.log EXEC = $(DIR_BIN)/soft.x EXEC_PREFIX = #$(VALGRIND) #-----[ Compilation ]-------------------------------------- INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR)) \ $(MORPHEO_INCDIR) \ $(ENVIRONMENT_INCDIR) \ -I$(DIR_INC) LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR)) \ $(ENVIRONMENT_LIBDIR) \ $(MORPHEO_LIBDIR) LIBNAME = $(ENVIRONMENT_LIBNAME) \ $(MORPHEO_LIBNAME) \ $(SYSTEMC_LIBNAME_$(SIMULATOR)) FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR)) PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) #---------------------------------------------------------- #---------------------------------------------------------- #-----[ Rules ]-------------------------------------------- #---------------------------------------------------------- #---------------------------------------------------------- vpath %.h $(DIR_INC) vpath %.cpp $(DIR_SRC) vpath %.o $(DIR_OBJ) vpath %.cfg $(DIR_DATA_TEST) $(DIR_DATA_BENCH) .PRECIOUS : $(DIR_OBJ)/%.o $(DIR_BIN)/%.x $(DIR_LOG)/%.log all : $(DIR_OBJ) $(DIR_BIN) @\ $(MAKE) $(EXEC) $(DIR_BIN)/%.x : $(OBJECTS) @\ $(ECHO) "Compilation : $*";\ $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $^ $(LIBNAME); test : $(DIR_LOG) all @\ declare logs; \ if $(TEST) -f "$(DEBUG_CFG)"; then \ logs="$(DEBUG_LOG)"; \ else \ logs="$(LOGS)"; \ fi; \ $(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"; exit 0; \ fi; bench : $(DIR_LOG) all @\ declare logs="$(BENCHS)"; \ $(MAKE) $$logs; execute : bench $(DIR_LOG)/%.log : %.cfg @\ file=$$($(BASENAME) $<); \ data=$$($(CAT) $<); \ log=$@; \ $(ECHO) "Run : $$file"; \ $(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 $(ECHO) -e " $$file ... OK \t$$timing"; \ else $(ECHO) -e " $$file ... KO !!!\t$$timing"; \ fi; \ #-----[ Library + Software ]------------------------------- lib : @\ $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; soft : @\ $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile; #-----[ Rules ]-------------------------------------------- $(DIR_OBJ)/%.o : %.cpp @\ $(ECHO) "Compilation : $*";\ $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; $(DIR_OBJ) : @\ $(ECHO) "Create directory : $@";\ $(MKDIR) $@ $(DIR_BIN) : @\ $(ECHO) "Create directory : $@";\ $(MKDIR) $@ $(DIR_LOG) : @\ $(ECHO) "Create directory : $@";\ $(MKDIR) $@ #-----[ Clean + help ]------------------------------------- clean : @\ $(ECHO) "Delete temporary files in directory $(PWD)";\ $(RM) *~ $(DIR_SRC)/*~ $(DIR_INC)/*~ $(DIR_DATA_TEST)/*~ $(DIR_DATA_BENCH)/*~ *core* tty* *.vhdl *.log *.stat *.pos\ $(DIR_OBJ) $(DIR_BIN) $(DIR_LOG); clean_all : clean @\ $(ECHO) "Delete generated files in directory $(PWD)";\ $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; \ $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile clean_all; help : @\ $(ECHO) " -----[ Common ]-------------------------------------";\ $(ECHO) "";\ $(ECHO) " * all (default rules) : create software";\ $(ECHO) " * test : execute platforms with test configuration";\ $(ECHO) " * bench : execute platforms with bench configuration";\ $(ECHO) " * lib : make library";\ $(ECHO) " * soft : make software";\ $(ECHO) " * execute : cf 'make bench'";\ $(ECHO) " * clean : erase temporary files";\ $(ECHO) " * clean_all : erase generated files";\ $(ECHO) " * help : print this message";\ $(ECHO) ""; include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps