[88] | 1 | # |
---|
| 2 | # $Id: Makefile 109 2009-02-16 20:28:31Z rosiere $ |
---|
| 3 | # |
---|
| 4 | # [ Description ] |
---|
| 5 | # |
---|
| 6 | # Makefile |
---|
| 7 | # |
---|
| 8 | |
---|
| 9 | #---------------------------------------------------------- |
---|
| 10 | #---------------------------------------------------------- |
---|
| 11 | #-----[ Environment ]-------------------------------------- |
---|
| 12 | #---------------------------------------------------------- |
---|
| 13 | #---------------------------------------------------------- |
---|
| 14 | ifeq ($(origin MORPHEO_TOPLEVEL), undefined) |
---|
| 15 | $(error "variable MORPHEO_TOPLEVEL is undefined") |
---|
| 16 | else |
---|
| 17 | include $(MORPHEO_TOPLEVEL)/Makefile.tools |
---|
| 18 | include $(MORPHEO_TOPLEVEL)/Makefile.flags |
---|
| 19 | endif |
---|
| 20 | |
---|
| 21 | ifeq ($(origin MORPHEO_TMP), undefined) |
---|
| 22 | $(error "variable MORPHEO_TMP is undefined") |
---|
| 23 | endif |
---|
| 24 | |
---|
| 25 | #---------------------------------------------------------- |
---|
| 26 | #---------------------------------------------------------- |
---|
| 27 | #-----[ Directory ]---------------------------------------- |
---|
| 28 | #---------------------------------------------------------- |
---|
| 29 | #---------------------------------------------------------- |
---|
| 30 | ENTITY = Test |
---|
| 31 | |
---|
| 32 | DIR_TMP = $(MORPHEO_TMP) |
---|
| 33 | DIR_INC = include |
---|
| 34 | DIR_SRC = src |
---|
| 35 | DIR_OBJ = $(DIR_TMP)/obj |
---|
| 36 | DIR_BIN = $(DIR_TMP)/bin |
---|
[101] | 37 | DIR_LOG = $(DIR_TMP)/log |
---|
[108] | 38 | DIR_DATA_TEST = ./data_test |
---|
| 39 | DIR_DATA_BENCH = ./data_bench |
---|
[88] | 40 | DIR_SOFT = $(MORPHEO_TOPLEVEL)/Softwares |
---|
| 41 | |
---|
| 42 | #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 43 | #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 44 | #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 45 | #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 46 | #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 47 | |
---|
| 48 | #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 49 | #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 50 | #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 51 | #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 52 | |
---|
| 53 | #---------------------------------------------------------- |
---|
| 54 | #---------------------------------------------------------- |
---|
| 55 | #-----[ Variables ]---------------------------------------- |
---|
| 56 | #---------------------------------------------------------- |
---|
| 57 | #---------------------------------------------------------- |
---|
| 58 | |
---|
| 59 | OBJECTS = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_OBJ)/%.o,$(wildcard $(DIR_SRC)/*.cpp)) |
---|
[108] | 60 | LOGS = $(patsubst $(DIR_DATA_TEST)/%.cfg,$(DIR_LOG)/%.log,$(wildcard $(DIR_DATA_TEST)/*.cfg)) |
---|
| 61 | BENCHS = $(patsubst $(DIR_DATA_BENCH)/%.cfg,$(DIR_LOG)/%.log,$(wildcard $(DIR_DATA_BENCH)/*.cfg)) |
---|
| 62 | DEBUG_CFG = $(DIR_DATA_TEST)/debug.cfg |
---|
[97] | 63 | DEBUG_LOG = $(DIR_LOG)/debug.log |
---|
[88] | 64 | |
---|
| 65 | EXEC = $(DIR_BIN)/soft.x |
---|
| 66 | EXEC_PREFIX = |
---|
| 67 | #$(VALGRIND) |
---|
| 68 | |
---|
| 69 | #-----[ Compilation ]-------------------------------------- |
---|
| 70 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR)) \ |
---|
| 71 | $(MORPHEO_INCDIR) \ |
---|
| 72 | $(ENVIRONMENT_INCDIR) \ |
---|
| 73 | -I$(DIR_INC) |
---|
| 74 | |
---|
| 75 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR)) \ |
---|
| 76 | $(ENVIRONMENT_LIBDIR) \ |
---|
| 77 | $(MORPHEO_LIBDIR) |
---|
| 78 | |
---|
| 79 | LIBNAME = $(ENVIRONMENT_LIBNAME) \ |
---|
| 80 | $(MORPHEO_LIBNAME) \ |
---|
| 81 | $(SYSTEMC_LIBNAME_$(SIMULATOR)) |
---|
| 82 | |
---|
| 83 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR)) |
---|
| 84 | |
---|
| 85 | PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
| 86 | PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
| 87 | |
---|
| 88 | #---------------------------------------------------------- |
---|
| 89 | #---------------------------------------------------------- |
---|
| 90 | #-----[ Rules ]-------------------------------------------- |
---|
| 91 | #---------------------------------------------------------- |
---|
| 92 | #---------------------------------------------------------- |
---|
| 93 | |
---|
| 94 | vpath %.h $(DIR_INC) |
---|
| 95 | vpath %.cpp $(DIR_SRC) |
---|
| 96 | vpath %.o $(DIR_OBJ) |
---|
[108] | 97 | vpath %.cfg $(DIR_DATA_TEST) $(DIR_DATA_BENCH) |
---|
[88] | 98 | |
---|
| 99 | .PRECIOUS : $(DIR_OBJ)/%.o $(DIR_BIN)/%.x $(DIR_LOG)/%.log |
---|
| 100 | |
---|
| 101 | all : $(DIR_OBJ) $(DIR_BIN) |
---|
| 102 | @\ |
---|
| 103 | $(MAKE) $(EXEC) |
---|
| 104 | |
---|
| 105 | $(DIR_BIN)/%.x : $(OBJECTS) |
---|
| 106 | @\ |
---|
| 107 | $(ECHO) "Compilation : $*";\ |
---|
| 108 | $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $^ $(LIBNAME); |
---|
| 109 | |
---|
[108] | 110 | test : $(DIR_LOG) all |
---|
[88] | 111 | @\ |
---|
[97] | 112 | declare logs; \ |
---|
| 113 | if $(TEST) -f "$(DEBUG_CFG)"; then \ |
---|
| 114 | logs="$(DEBUG_LOG)"; \ |
---|
| 115 | else \ |
---|
| 116 | logs="$(LOGS)"; \ |
---|
| 117 | fi; \ |
---|
| 118 | $(MAKE) $$logs; \ |
---|
[101] | 119 | declare -i nb_test=0; \ |
---|
| 120 | declare -i nb_test_ko=0; \ |
---|
[97] | 121 | for log in $$logs; do \ |
---|
[88] | 122 | $(GREP) -q "Test OK" $$log; \ |
---|
| 123 | declare -i test_ok=$$?; \ |
---|
| 124 | $(GREP) -q "Test KO" $$log; \ |
---|
| 125 | declare -i test_ko=$$?; \ |
---|
| 126 | if $(TEST) $$test_ko -eq 0 -o $$test_ok -ne 0; \ |
---|
[101] | 127 | then nb_test_ko=$$(($${nb_test_ko} + 1)); \ |
---|
[88] | 128 | fi; \ |
---|
[101] | 129 | nb_test=$$(($${nb_test} + 1)); \ |
---|
[88] | 130 | done; \ |
---|
[101] | 131 | if $(TEST) $${nb_test_ko} -ne 0; \ |
---|
| 132 | then $(ECHO) "-------------------| Test KO !!! ($${nb_test_ko}/$${nb_test})"; exit 1; \ |
---|
[88] | 133 | else $(ECHO) "-------------------| Test OK"; exit 0; \ |
---|
| 134 | fi; |
---|
| 135 | |
---|
[108] | 136 | bench : $(DIR_LOG) all |
---|
| 137 | @\ |
---|
| 138 | declare logs="$(BENCHS)"; \ |
---|
| 139 | $(MAKE) $$logs; |
---|
[88] | 140 | |
---|
[108] | 141 | execute : bench |
---|
| 142 | |
---|
[88] | 143 | $(DIR_LOG)/%.log : %.cfg |
---|
| 144 | @\ |
---|
| 145 | file=$$($(BASENAME) $<); \ |
---|
| 146 | data=$$($(CAT) $<); \ |
---|
| 147 | log=$@; \ |
---|
| 148 | $(ECHO) "Run : $$file"; \ |
---|
| 149 | $(EXEC_PREFIX) $(EXEC) $${data} &> $$log; \ |
---|
| 150 | $(GREP) -q "Test OK" $$log; \ |
---|
| 151 | declare -i test_ok=$$?; \ |
---|
| 152 | $(GREP) -q "Test KO" $$log; \ |
---|
| 153 | declare -i test_ko=$$?; \ |
---|
| 154 | declare timing=$$($(GREP) -h "Timing" $$log); \ |
---|
| 155 | if $(TEST) $$test_ko -ne 0 -a $$test_ok -eq 0; \ |
---|
[101] | 156 | then $(ECHO) -e " $$file ... OK \t$$timing"; \ |
---|
| 157 | else $(ECHO) -e " $$file ... KO !!!\t$$timing"; \ |
---|
[88] | 158 | fi; \ |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | #-----[ Library + Software ]------------------------------- |
---|
| 162 | |
---|
| 163 | lib : |
---|
| 164 | @\ |
---|
| 165 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
| 166 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
| 167 | |
---|
| 168 | soft : |
---|
| 169 | @\ |
---|
| 170 | $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile; |
---|
| 171 | |
---|
| 172 | #-----[ Rules ]-------------------------------------------- |
---|
| 173 | |
---|
| 174 | $(DIR_OBJ)/%.o : %.cpp |
---|
| 175 | @\ |
---|
| 176 | $(ECHO) "Compilation : $*";\ |
---|
| 177 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
| 178 | |
---|
| 179 | $(DIR_OBJ) : |
---|
| 180 | @\ |
---|
| 181 | $(ECHO) "Create directory : $@";\ |
---|
| 182 | $(MKDIR) $@ |
---|
| 183 | |
---|
| 184 | $(DIR_BIN) : |
---|
| 185 | @\ |
---|
| 186 | $(ECHO) "Create directory : $@";\ |
---|
| 187 | $(MKDIR) $@ |
---|
| 188 | |
---|
| 189 | $(DIR_LOG) : |
---|
| 190 | @\ |
---|
| 191 | $(ECHO) "Create directory : $@";\ |
---|
| 192 | $(MKDIR) $@ |
---|
| 193 | |
---|
| 194 | #-----[ Clean + help ]------------------------------------- |
---|
| 195 | |
---|
| 196 | clean : |
---|
| 197 | @\ |
---|
| 198 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
[108] | 199 | $(RM) *~ $(DIR_SRC)/*~ $(DIR_INC)/*~ $(DIR_DATA_TEST)/*~ $(DIR_DATA_BENCH)/*~ *core* tty* *.vhdl *.log *.stat *.pos\ |
---|
[88] | 200 | $(DIR_OBJ) $(DIR_BIN) $(DIR_LOG); |
---|
| 201 | |
---|
| 202 | clean_all : clean |
---|
| 203 | @\ |
---|
| 204 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
[109] | 205 | $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile clean_all; \ |
---|
[88] | 206 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
[109] | 207 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; |
---|
[88] | 208 | |
---|
| 209 | |
---|
| 210 | help : |
---|
| 211 | @\ |
---|
| 212 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
| 213 | $(ECHO) "";\ |
---|
| 214 | $(ECHO) " * all (default rules) : create software";\ |
---|
[108] | 215 | $(ECHO) " * test : execute platforms with test configuration";\ |
---|
| 216 | $(ECHO) " * bench : execute platforms with bench configuration";\ |
---|
[88] | 217 | $(ECHO) " * lib : make library";\ |
---|
| 218 | $(ECHO) " * soft : make software";\ |
---|
[108] | 219 | $(ECHO) " * execute : cf 'make bench'";\ |
---|
[88] | 220 | $(ECHO) " * clean : erase temporary files";\ |
---|
| 221 | $(ECHO) " * clean_all : erase generated files";\ |
---|
| 222 | $(ECHO) " * help : print this message";\ |
---|
| 223 | $(ECHO) ""; |
---|
| 224 | |
---|
| 225 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 226 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|