[117] | 1 | |
---|
[88] | 2 | # |
---|
| 3 | # $Id: Makefile 146 2011-02-01 20:57:54Z rosiere $ |
---|
| 4 | # |
---|
| 5 | # [ Description ] |
---|
| 6 | # |
---|
| 7 | # Makefile |
---|
| 8 | # |
---|
| 9 | |
---|
| 10 | #---------------------------------------------------------- |
---|
| 11 | #---------------------------------------------------------- |
---|
| 12 | #-----[ Environment ]-------------------------------------- |
---|
| 13 | #---------------------------------------------------------- |
---|
| 14 | #---------------------------------------------------------- |
---|
| 15 | ifeq ($(origin MORPHEO_TOPLEVEL), undefined) |
---|
| 16 | $(error "variable MORPHEO_TOPLEVEL is undefined") |
---|
| 17 | else |
---|
| 18 | include $(MORPHEO_TOPLEVEL)/Makefile.tools |
---|
| 19 | include $(MORPHEO_TOPLEVEL)/Makefile.flags |
---|
| 20 | endif |
---|
| 21 | |
---|
| 22 | ifeq ($(origin MORPHEO_TMP), undefined) |
---|
| 23 | $(error "variable MORPHEO_TMP is undefined") |
---|
| 24 | endif |
---|
[130] | 25 | ifeq ($(origin MORPHEO_PREFIX), undefined) |
---|
| 26 | $(error "variable MORPHEO_PREFIX is undefined") |
---|
| 27 | endif |
---|
[88] | 28 | |
---|
[117] | 29 | DATA_ALL = * |
---|
| 30 | ifeq ($(origin DATA), undefined) |
---|
| 31 | DATA = $(DATA_ALL) |
---|
| 32 | endif |
---|
| 33 | ifeq ($(origin PRIORITY), undefined) |
---|
| 34 | PRIORITY = 0 |
---|
| 35 | endif |
---|
[120] | 36 | ifeq ($(flavor CLEAN), undefined) |
---|
| 37 | CLEAN = 0 |
---|
| 38 | endif |
---|
[117] | 39 | |
---|
[88] | 40 | #---------------------------------------------------------- |
---|
| 41 | #---------------------------------------------------------- |
---|
| 42 | #-----[ Directory ]---------------------------------------- |
---|
| 43 | #---------------------------------------------------------- |
---|
| 44 | #---------------------------------------------------------- |
---|
| 45 | ENTITY = Test |
---|
| 46 | |
---|
[125] | 47 | PATH_INC = include |
---|
| 48 | PATH_SRC = src |
---|
[139] | 49 | PATH_OBJ = $(MORPHEO_TMP)/obj/$(MORPHEO_TYPE) |
---|
| 50 | PATH_LIB = $(MORPHEO_PREFIX)/lib/$(MORPHEO_TYPE) |
---|
| 51 | PATH_BIN = $(MORPHEO_PREFIX)/bin/$(MORPHEO_TYPE) |
---|
[130] | 52 | PATH_LOG = $(MORPHEO_TMP)/log |
---|
[137] | 53 | PATH_GMON = $(MORPHEO_TMP)/gmon |
---|
[125] | 54 | PATH_DATA = ./data |
---|
[139] | 55 | PATH_DATA_CFG = $(PATH_DATA)/cfg |
---|
[125] | 56 | PATH_LOGS = $(patsubst $(PATH_DATA)/%,$(PATH_LOG)/%,$(wildcard $(PATH_DATA)/*)) |
---|
[139] | 57 | PATH_CFG_SUFFIX = IPs/systemC/processor/Morpheo/Files |
---|
| 58 | PATH_CFG = $(MORPHEO_TOPLEVEL)/$(PATH_CFG_SUFFIX) |
---|
[117] | 59 | |
---|
[125] | 60 | PATH_SOFT = $(MORPHEO_TOPLEVEL)/Softwares |
---|
[88] | 61 | |
---|
| 62 | #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 63 | #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 64 | #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 65 | #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 66 | #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 67 | |
---|
| 68 | #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 69 | #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 70 | #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 71 | #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 72 | |
---|
| 73 | #---------------------------------------------------------- |
---|
| 74 | #---------------------------------------------------------- |
---|
| 75 | #-----[ Variables ]---------------------------------------- |
---|
| 76 | #---------------------------------------------------------- |
---|
| 77 | #---------------------------------------------------------- |
---|
[125] | 78 | SOURCES = $(wildcard $(PATH_SRC)/*.cpp) |
---|
| 79 | OBJECTS = $(patsubst $(PATH_SRC)/%.cpp,$(PATH_OBJ)/%.o,$(SOURCES)) |
---|
| 80 | LOGS = $(patsubst $(PATH_DATA)/%.cfg,$(PATH_LOG)/%.log,$(wildcard $(PATH_DATA)/$(DATA)/*.cfg)) |
---|
[131] | 81 | |
---|
| 82 | BIN = Platforms_Test.x |
---|
[134] | 83 | EXEC = $(PATH_BIN)/$(BIN) |
---|
[139] | 84 | EXEC_PREFIX = $(NICE) -n $(PRIORITY) |
---|
[136] | 85 | #$(VALGRIND) |
---|
[128] | 86 | EXEC_PARAMS = $(SYSTEMC_EXEC_PARAMS_$(SIMULATOR_SYSTEMC)) |
---|
[88] | 87 | |
---|
[125] | 88 | SCRIPT = make.sh |
---|
| 89 | |
---|
[88] | 90 | #-----[ Compilation ]-------------------------------------- |
---|
[117] | 91 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
[88] | 92 | $(MORPHEO_INCDIR) \ |
---|
| 93 | $(ENVIRONMENT_INCDIR) \ |
---|
[125] | 94 | -I$(PATH_INC) |
---|
[88] | 95 | |
---|
[117] | 96 | #LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
[113] | 97 | # $(ENVIRONMENT_LIBDIR) \ |
---|
| 98 | # $(MORPHEO_LIBDIR) |
---|
| 99 | |
---|
[117] | 100 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
[125] | 101 | -L$(PATH_LIB) |
---|
[88] | 102 | |
---|
| 103 | LIBNAME = $(ENVIRONMENT_LIBNAME) \ |
---|
| 104 | $(MORPHEO_LIBNAME) \ |
---|
[117] | 105 | $(SYSTEMC_LIBNAME_$(SIMULATOR_SYSTEMC)) |
---|
[88] | 106 | |
---|
[117] | 107 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR_SYSTEMC)) |
---|
[88] | 108 | |
---|
| 109 | PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
| 110 | PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
| 111 | |
---|
| 112 | #---------------------------------------------------------- |
---|
| 113 | #---------------------------------------------------------- |
---|
| 114 | #-----[ Rules ]-------------------------------------------- |
---|
| 115 | #---------------------------------------------------------- |
---|
| 116 | #---------------------------------------------------------- |
---|
| 117 | |
---|
[125] | 118 | vpath %.h $(PATH_INC) |
---|
| 119 | vpath %.cpp $(PATH_SRC) |
---|
| 120 | vpath %.o $(PATH_OBJ) |
---|
| 121 | vpath %.cfg $(PATH_DATA)/*/ |
---|
[88] | 122 | |
---|
[125] | 123 | .PRECIOUS : $(PATH_OBJ)/%.o $(PATH_BIN)/%.x $(PATH_LOG)/%.log |
---|
[88] | 124 | |
---|
[113] | 125 | all : $(EXEC) |
---|
[88] | 126 | |
---|
[125] | 127 | $(PATH_BIN)/%.x : $(PATH_OBJ) $(PATH_BIN) |
---|
[88] | 128 | @\ |
---|
[117] | 129 | case "${SIMULATOR_SYSTEMC}" in \ |
---|
[113] | 130 | "modelsim") \ |
---|
| 131 | $(MAKE) $(WORK_NAME); \ |
---|
| 132 | $(MODELTECH_SCCOM) $(PLATFORMS_CXX_FLAGS) $(SOURCES); \ |
---|
| 133 | $(MODELTECH_SCCOM) -link $(PLATFORMS_L_FLAGS) $(LIBNAME); \ |
---|
| 134 | $(ECHO) "#!$(SHELL)" > $@; \ |
---|
| 135 | $(ECHO) "cd $${PWD};" >> $@; \ |
---|
| 136 | $(ECHO) "$(MODELTECH_VSIM) -sc_arg "'"$${*}"'" $(WORK_NAME).top;" >> $@;\ |
---|
| 137 | $(ECHO) "cd -;" >> $@; \ |
---|
| 138 | $(CHMOD) +x $@; \ |
---|
| 139 | ;; \ |
---|
| 140 | *) \ |
---|
| 141 | $(MAKE) $(OBJECTS); \ |
---|
[139] | 142 | $(ECHO) "Linkage : $*"; \ |
---|
[113] | 143 | $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $(OBJECTS) $(LIBNAME); \ |
---|
| 144 | ;; \ |
---|
| 145 | esac; \ |
---|
[88] | 146 | |
---|
[119] | 147 | run : |
---|
[88] | 148 | @\ |
---|
[120] | 149 | declare -i clean=$(CLEAN); \ |
---|
| 150 | if $(TEST) $${clean} -ne 0 -a "$(DATA)" != "$(DATA_ALL)"; then \ |
---|
[125] | 151 | $(RM) $(PATH_LOG)/$(DATA); \ |
---|
[120] | 152 | fi; \ |
---|
[139] | 153 | declare -a logs=($(LOGS)); \ |
---|
| 154 | declare -i nb_test=$${#logs[*]}; \ |
---|
| 155 | $(ECHO) "-------------------| Run $${nb_test} test(s)"; \ |
---|
| 156 | $(MAKE) $${logs[*]}; \ |
---|
[120] | 157 | declare -i nb_test_ko=0; \ |
---|
[139] | 158 | for log in $${logs[*]}; do \ |
---|
[120] | 159 | $(GREP) -q "Test OK" $$log; \ |
---|
| 160 | declare -i test_ok=$$?; \ |
---|
| 161 | $(GREP) -q "Test KO" $$log; \ |
---|
| 162 | declare -i test_ko=$$?; \ |
---|
| 163 | if $(TEST) $${test_ko} -eq 0 -o $${test_ok} -ne 0; \ |
---|
| 164 | then nb_test_ko=$$(($${nb_test_ko} + 1)); \ |
---|
| 165 | fi; \ |
---|
| 166 | done; \ |
---|
| 167 | if $(TEST) $${nb_test_ko} -ne 0; \ |
---|
[101] | 168 | then $(ECHO) "-------------------| Test KO !!! ($${nb_test_ko}/$${nb_test})"; exit 1; \ |
---|
[123] | 169 | else $(ECHO) "-------------------| Test OK ($${nb_test})"; exit 0; \ |
---|
[88] | 170 | fi; |
---|
| 171 | |
---|
[117] | 172 | debug : |
---|
[108] | 173 | @\ |
---|
[120] | 174 | $(MAKE) run DATA=debug CLEAN=1; |
---|
[88] | 175 | |
---|
[117] | 176 | bench : |
---|
| 177 | @\ |
---|
| 178 | $(MAKE) run DATA=bench; |
---|
[108] | 179 | |
---|
[125] | 180 | distexe : |
---|
[88] | 181 | @\ |
---|
[129] | 182 | $(ECHO) -n "Generate : $(SCRIPT) ";\ |
---|
[125] | 183 | $(RM) $(SCRIPT); \ |
---|
| 184 | for log in $(LOGS); do \ |
---|
[129] | 185 | $(ECHO) -n "."; \ |
---|
[145] | 186 | $(ECHO) -n "source $(MORPHEO_TOPLEVEL)/environment.sh -l $(MORPHEO_LOCALIZATION) -t $(MORPHEO_TYPE); path=\"${PWD}\"; " >> $(SCRIPT);\ |
---|
[125] | 187 | if $(TEST) $(CLEAN) -ne 0; then \ |
---|
| 188 | $(ECHO) -n "$(RM) $${log}; " >> $(SCRIPT); \ |
---|
| 189 | fi; \ |
---|
| 190 | $(ECHO) "$(MAKE) -C "'$${path}'" $${log} PRIORITY=$(PRIORITY);" >> $(SCRIPT); \ |
---|
[128] | 191 | done; \ |
---|
[129] | 192 | $(CHMOD) +x $(SCRIPT); \ |
---|
| 193 | $(ECHO) " done"; |
---|
[125] | 194 | |
---|
[129] | 195 | |
---|
[137] | 196 | $(PATH_LOG)/%.log : $(PATH_DATA)/%.cfg $(EXEC) $(PATH_LOGS) $(PATH_GMON) |
---|
[125] | 197 | @\ |
---|
[88] | 198 | file=$$($(BASENAME) $<); \ |
---|
[124] | 199 | data=$$(eval echo $$($(CAT) $<)); \ |
---|
[88] | 200 | log=$@; \ |
---|
[117] | 201 | $(ECHO) "Run : $*"; \ |
---|
[137] | 202 | \ |
---|
[139] | 203 | file_gmon="$$($(BASENAME) $*)-$$($(DATE))"; \ |
---|
| 204 | dir_gmon="$$($(DIRNAME) $*)"; \ |
---|
[137] | 205 | $(MKDIR) $(PATH_GMON)/$$dir_gmon; \ |
---|
| 206 | export GMON_OUT_PREFIX=$(PATH_GMON)/$$dir_gmon/$$file_gmon;\ |
---|
| 207 | \ |
---|
| 208 | $(EXEC_PREFIX) $(EXEC) $(EXEC_PARAMS) $${data} &> $$log;\ |
---|
[88] | 209 | $(GREP) -q "Test OK" $$log; \ |
---|
| 210 | declare -i test_ok=$$?; \ |
---|
| 211 | $(GREP) -q "Test KO" $$log; \ |
---|
| 212 | declare -i test_ko=$$?; \ |
---|
| 213 | declare timing=$$($(GREP) -h "Timing" $$log); \ |
---|
[120] | 214 | if $(TEST) $${test_ko} -ne 0 -a $${test_ok} -eq 0; \ |
---|
[117] | 215 | then test="... OK "; \ |
---|
| 216 | else test="... KO !!!"; \ |
---|
[88] | 217 | fi; \ |
---|
[117] | 218 | $(ECHO) -e " $* $${test}\t$${timing}";\ |
---|
| 219 | echo "{$$($(date))} $* $${test} $${timing}" >> $$($(DIRNAME) $*).res;\ |
---|
[88] | 220 | |
---|
[139] | 221 | cfg : $(PATH_DATA_CFG) |
---|
| 222 | @\ |
---|
| 223 | $(ECHO) "Create configuration file"; \ |
---|
| 224 | for file_cfg in $(PATH_CFG)/*.cfg; do \ |
---|
| 225 | file_data=$(PATH_DATA_CFG)/$$($(BASENAME) $${file_cfg}); \ |
---|
| 226 | $(ECHO) " * $${file_data}"; \ |
---|
| 227 | $(ECHO) '$${MORPHEO_TOPLEVEL}'"/$(PATH_CFG_SUFFIX)/debug.sim" > $${file_data}; \ |
---|
| 228 | $(ECHO) '$${MORPHEO_TOPLEVEL}'"/$(PATH_CFG_SUFFIX)/Morpheo.gen" >> $${file_data}; \ |
---|
| 229 | $(ECHO) '$${MORPHEO_TOPLEVEL}'"/$(PATH_CFG_SUFFIX)/$$($(BASENAME) $${file_cfg})" >> $${file_data}; \ |
---|
| 230 | $(ECHO) '$${MORPHEO_TOPLEVEL}'"/Softwares/Test/Test_x000/bin/soft_NEWLIB_MORPHEO.x" >> $${file_data}; \ |
---|
| 231 | $(ECHO) "0" >> $${file_data}; \ |
---|
| 232 | $(ECHO) "0" >> $${file_data}; \ |
---|
| 233 | $(ECHO) "4096" >> $${file_data}; \ |
---|
| 234 | $(ECHO) "2" >> $${file_data}; \ |
---|
| 235 | done; |
---|
| 236 | |
---|
[88] | 237 | #-----[ Library + Software ]------------------------------- |
---|
| 238 | |
---|
[119] | 239 | env : soft lib |
---|
[122] | 240 | @$(MAKE) $(EXEC) |
---|
[119] | 241 | |
---|
[146] | 242 | env_lib : lib |
---|
| 243 | @$(MAKE) $(EXEC) |
---|
| 244 | |
---|
[88] | 245 | lib : |
---|
| 246 | @\ |
---|
| 247 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
| 248 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
| 249 | |
---|
| 250 | soft : |
---|
| 251 | @\ |
---|
[125] | 252 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile; |
---|
[88] | 253 | |
---|
| 254 | #-----[ Rules ]-------------------------------------------- |
---|
| 255 | |
---|
[125] | 256 | $(PATH_OBJ)/%.o : %.cpp |
---|
[88] | 257 | @\ |
---|
| 258 | $(ECHO) "Compilation : $*";\ |
---|
| 259 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
| 260 | |
---|
[139] | 261 | $(PATH_OBJ) $(PATH_BIN) $(PATH_LOGS) $(PATH_GMON) $(PATH_DATA_CFG) : |
---|
[88] | 262 | @\ |
---|
| 263 | $(ECHO) "Create directory : $@";\ |
---|
| 264 | $(MKDIR) $@ |
---|
| 265 | |
---|
| 266 | #-----[ Clean + help ]------------------------------------- |
---|
| 267 | |
---|
| 268 | clean : |
---|
| 269 | @\ |
---|
| 270 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
[137] | 271 | $(RM) $(OBJECTS);\ |
---|
| 272 | $(RM) $(PATH_LOGS); \ |
---|
| 273 | $(RM) $(PATH_GMON); \ |
---|
| 274 | $(RM) *~ $(PATH_SRC)/*~ $(PATH_INC)/*~ $(PATH_DATA)/*/*~ *.res *.txt\ |
---|
[113] | 275 | *core* \ |
---|
| 276 | tty* \ |
---|
| 277 | *.vhdl \ |
---|
| 278 | *.log \ |
---|
| 279 | *.stat \ |
---|
| 280 | *.pos \ |
---|
| 281 | modelsim.ini transcript *wlf* $(WORK_NAME) |
---|
[88] | 282 | |
---|
| 283 | clean_all : clean |
---|
| 284 | @\ |
---|
| 285 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
[125] | 286 | $(RM) $(PATH_OBJ) $(PATH_BIN) $(PATH_LOG) $(SCRIPT);\ |
---|
[137] | 287 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile clean_all; \ |
---|
[88] | 288 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
[109] | 289 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; |
---|
[88] | 290 | |
---|
| 291 | |
---|
| 292 | help : |
---|
| 293 | @\ |
---|
| 294 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
| 295 | $(ECHO) "";\ |
---|
| 296 | $(ECHO) " * all (default rules) : create software";\ |
---|
[117] | 297 | $(ECHO) " * run : execute platforms with test configuration";\ |
---|
[125] | 298 | $(ECHO) " set DATA to select a specific directory in $(PATH_DATA) (default : all)";\ |
---|
[117] | 299 | $(ECHO) " set PRIORITY to nice the execution (default : 0)";\ |
---|
[120] | 300 | $(ECHO) " set CLEAN to remove previous log (default : 0)";\ |
---|
| 301 | $(ECHO) " example : make run DATA=debug PRIORITY=10 CLEAN";\ |
---|
[117] | 302 | $(ECHO) " * debug : cf 'make run DATA=debug'";\ |
---|
| 303 | $(ECHO) " * bench : cf 'make run DATA=bench'";\ |
---|
[145] | 304 | $(ECHO) " * distexe : Generate an command file to distexe (\"$(SCRIPT)\").";\ |
---|
| 305 | $(ECHO) " This file can be use with distexe or just run in local machine.";\ |
---|
[139] | 306 | $(ECHO) " * cfg : For each configuration in \"${PATH_CFG}\", create basic test";\ |
---|
[88] | 307 | $(ECHO) " * lib : make library";\ |
---|
| 308 | $(ECHO) " * soft : make software";\ |
---|
[142] | 309 | $(ECHO) " * env : execute rule \"lib\" and \"soft\"";\ |
---|
[88] | 310 | $(ECHO) " * clean : erase temporary files";\ |
---|
| 311 | $(ECHO) " * clean_all : erase generated files";\ |
---|
| 312 | $(ECHO) " * help : print this message";\ |
---|
[142] | 313 | $(ECHO) ""; \ |
---|
| 314 | $(ECHO) "In the compilation, set MORPHEO_TYPE for set/unset flags"; \ |
---|
| 315 | $(ECHO) "MORPHEO_TYPE can be set at $(MORPHEO_TYPE_LIST)"; \ |
---|
| 316 | $(ECHO) "Actual MORPHEO_TYPE is \"$(MORPHEO_TYPE)\""; \ |
---|
[88] | 317 | $(ECHO) ""; |
---|
| 318 | |
---|
[113] | 319 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Behavioural/Makefile.Synthesis |
---|
[88] | 320 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 321 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|