[117] | 1 | |
---|
[88] | 2 | # |
---|
| 3 | # $Id: Makefile 137 2010-02-16 12:35:48Z 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 |
---|
[122] | 36 | |
---|
[120] | 37 | ifeq ($(flavor CLEAN), undefined) |
---|
| 38 | CLEAN = 0 |
---|
| 39 | endif |
---|
[117] | 40 | |
---|
[88] | 41 | #---------------------------------------------------------- |
---|
| 42 | #---------------------------------------------------------- |
---|
| 43 | #-----[ Directory ]---------------------------------------- |
---|
| 44 | #---------------------------------------------------------- |
---|
| 45 | #---------------------------------------------------------- |
---|
| 46 | ENTITY = Test |
---|
| 47 | |
---|
[125] | 48 | PATH_INC = include |
---|
| 49 | PATH_SRC = src |
---|
[130] | 50 | PATH_OBJ = $(MORPHEO_TMP)/obj |
---|
| 51 | PATH_LIB = $(MORPHEO_PREFIX)/lib |
---|
| 52 | PATH_BIN = $(MORPHEO_PREFIX)/bin |
---|
| 53 | PATH_LOG = $(MORPHEO_TMP)/log |
---|
[137] | 54 | PATH_GMON = $(MORPHEO_TMP)/gmon |
---|
[125] | 55 | PATH_DATA = ./data |
---|
| 56 | PATH_LOGS = $(patsubst $(PATH_DATA)/%,$(PATH_LOG)/%,$(wildcard $(PATH_DATA)/*)) |
---|
[117] | 57 | |
---|
[125] | 58 | PATH_SOFT = $(MORPHEO_TOPLEVEL)/Softwares |
---|
[88] | 59 | |
---|
| 60 | #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 61 | #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 62 | #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 63 | #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 64 | #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 65 | |
---|
| 66 | #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 67 | #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 68 | #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 69 | #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 70 | |
---|
| 71 | #---------------------------------------------------------- |
---|
| 72 | #---------------------------------------------------------- |
---|
| 73 | #-----[ Variables ]---------------------------------------- |
---|
| 74 | #---------------------------------------------------------- |
---|
| 75 | #---------------------------------------------------------- |
---|
[125] | 76 | SOURCES = $(wildcard $(PATH_SRC)/*.cpp) |
---|
| 77 | OBJECTS = $(patsubst $(PATH_SRC)/%.cpp,$(PATH_OBJ)/%.o,$(SOURCES)) |
---|
| 78 | LOGS = $(patsubst $(PATH_DATA)/%.cfg,$(PATH_LOG)/%.log,$(wildcard $(PATH_DATA)/$(DATA)/*.cfg)) |
---|
[131] | 79 | |
---|
| 80 | BIN = Platforms_Test.x |
---|
[134] | 81 | EXEC = $(PATH_BIN)/$(BIN) |
---|
[136] | 82 | EXEC_PREFIX = $(NICE) -n $(PRIORITY) |
---|
| 83 | #$(VALGRIND) |
---|
[128] | 84 | EXEC_PARAMS = $(SYSTEMC_EXEC_PARAMS_$(SIMULATOR_SYSTEMC)) |
---|
[88] | 85 | |
---|
[125] | 86 | SCRIPT = make.sh |
---|
| 87 | |
---|
[88] | 88 | #-----[ Compilation ]-------------------------------------- |
---|
[117] | 89 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
[88] | 90 | $(MORPHEO_INCDIR) \ |
---|
| 91 | $(ENVIRONMENT_INCDIR) \ |
---|
[125] | 92 | -I$(PATH_INC) |
---|
[88] | 93 | |
---|
[117] | 94 | #LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
[113] | 95 | # $(ENVIRONMENT_LIBDIR) \ |
---|
| 96 | # $(MORPHEO_LIBDIR) |
---|
| 97 | |
---|
[117] | 98 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
[125] | 99 | -L$(PATH_LIB) |
---|
[88] | 100 | |
---|
| 101 | LIBNAME = $(ENVIRONMENT_LIBNAME) \ |
---|
| 102 | $(MORPHEO_LIBNAME) \ |
---|
[117] | 103 | $(SYSTEMC_LIBNAME_$(SIMULATOR_SYSTEMC)) |
---|
[88] | 104 | |
---|
[117] | 105 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR_SYSTEMC)) |
---|
[88] | 106 | |
---|
| 107 | PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
| 108 | PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
| 109 | |
---|
| 110 | #---------------------------------------------------------- |
---|
| 111 | #---------------------------------------------------------- |
---|
| 112 | #-----[ Rules ]-------------------------------------------- |
---|
| 113 | #---------------------------------------------------------- |
---|
| 114 | #---------------------------------------------------------- |
---|
| 115 | |
---|
[125] | 116 | vpath %.h $(PATH_INC) |
---|
| 117 | vpath %.cpp $(PATH_SRC) |
---|
| 118 | vpath %.o $(PATH_OBJ) |
---|
| 119 | vpath %.cfg $(PATH_DATA)/*/ |
---|
[88] | 120 | |
---|
[125] | 121 | .PRECIOUS : $(PATH_OBJ)/%.o $(PATH_BIN)/%.x $(PATH_LOG)/%.log |
---|
[88] | 122 | |
---|
[113] | 123 | all : $(EXEC) |
---|
[88] | 124 | |
---|
[125] | 125 | $(PATH_BIN)/%.x : $(PATH_OBJ) $(PATH_BIN) |
---|
[88] | 126 | @\ |
---|
[113] | 127 | $(ECHO) "Linkage : $*";\ |
---|
[117] | 128 | case "${SIMULATOR_SYSTEMC}" in \ |
---|
[113] | 129 | "modelsim") \ |
---|
| 130 | $(MAKE) $(WORK_NAME); \ |
---|
| 131 | $(MODELTECH_SCCOM) $(PLATFORMS_CXX_FLAGS) $(SOURCES); \ |
---|
| 132 | $(MODELTECH_SCCOM) -link $(PLATFORMS_L_FLAGS) $(LIBNAME); \ |
---|
| 133 | $(ECHO) "#!$(SHELL)" > $@; \ |
---|
| 134 | $(ECHO) "cd $${PWD};" >> $@; \ |
---|
| 135 | $(ECHO) "$(MODELTECH_VSIM) -sc_arg "'"$${*}"'" $(WORK_NAME).top;" >> $@;\ |
---|
| 136 | $(ECHO) "cd -;" >> $@; \ |
---|
| 137 | $(CHMOD) +x $@; \ |
---|
| 138 | ;; \ |
---|
| 139 | *) \ |
---|
| 140 | $(MAKE) $(OBJECTS); \ |
---|
| 141 | $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $(OBJECTS) $(LIBNAME); \ |
---|
| 142 | ;; \ |
---|
| 143 | esac; \ |
---|
[88] | 144 | |
---|
[119] | 145 | run : |
---|
[88] | 146 | @\ |
---|
[120] | 147 | declare -i clean=$(CLEAN); \ |
---|
| 148 | if $(TEST) $${clean} -ne 0 -a "$(DATA)" != "$(DATA_ALL)"; then \ |
---|
[125] | 149 | $(RM) $(PATH_LOG)/$(DATA); \ |
---|
[120] | 150 | fi; \ |
---|
| 151 | declare logs="$(LOGS)"; \ |
---|
| 152 | $(MAKE) $${logs}; \ |
---|
| 153 | declare -i nb_test=0; \ |
---|
| 154 | declare -i nb_test_ko=0; \ |
---|
| 155 | for log in $${logs}; do \ |
---|
| 156 | $(GREP) -q "Test OK" $$log; \ |
---|
| 157 | declare -i test_ok=$$?; \ |
---|
| 158 | $(GREP) -q "Test KO" $$log; \ |
---|
| 159 | declare -i test_ko=$$?; \ |
---|
| 160 | if $(TEST) $${test_ko} -eq 0 -o $${test_ok} -ne 0; \ |
---|
| 161 | then nb_test_ko=$$(($${nb_test_ko} + 1)); \ |
---|
| 162 | fi; \ |
---|
| 163 | nb_test=$$(($${nb_test} + 1)); \ |
---|
| 164 | done; \ |
---|
| 165 | if $(TEST) $${nb_test_ko} -ne 0; \ |
---|
[101] | 166 | then $(ECHO) "-------------------| Test KO !!! ($${nb_test_ko}/$${nb_test})"; exit 1; \ |
---|
[123] | 167 | else $(ECHO) "-------------------| Test OK ($${nb_test})"; exit 0; \ |
---|
[88] | 168 | fi; |
---|
| 169 | |
---|
[117] | 170 | execute : run |
---|
| 171 | |
---|
| 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 "."; \ |
---|
| 186 | $(ECHO) -n "cd $(MORPHEO_TOPLEVEL); source environment.sh; cd -; 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 | \ |
---|
| 203 | file_gmon=$$($(BASENAME) $*); \ |
---|
| 204 | dir_gmon=$$($(DIRNAME) $*); \ |
---|
| 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 | |
---|
| 221 | #-----[ Library + Software ]------------------------------- |
---|
| 222 | |
---|
[119] | 223 | env : soft lib |
---|
[122] | 224 | @$(MAKE) $(EXEC) |
---|
[119] | 225 | |
---|
[88] | 226 | lib : |
---|
| 227 | @\ |
---|
| 228 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
| 229 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
| 230 | |
---|
| 231 | soft : |
---|
| 232 | @\ |
---|
[125] | 233 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile; |
---|
[88] | 234 | |
---|
| 235 | #-----[ Rules ]-------------------------------------------- |
---|
| 236 | |
---|
[125] | 237 | $(PATH_OBJ)/%.o : %.cpp |
---|
[88] | 238 | @\ |
---|
| 239 | $(ECHO) "Compilation : $*";\ |
---|
| 240 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
| 241 | |
---|
[137] | 242 | $(PATH_OBJ) $(PATH_BIN) $(PATH_LOGS) $(PATH_GMON) : |
---|
[88] | 243 | @\ |
---|
| 244 | $(ECHO) "Create directory : $@";\ |
---|
| 245 | $(MKDIR) $@ |
---|
| 246 | |
---|
| 247 | #-----[ Clean + help ]------------------------------------- |
---|
| 248 | |
---|
| 249 | clean : |
---|
| 250 | @\ |
---|
| 251 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
[137] | 252 | $(RM) $(OBJECTS);\ |
---|
| 253 | $(RM) $(EXEC);\ |
---|
| 254 | $(RM) $(PATH_LOGS); \ |
---|
| 255 | $(RM) $(PATH_GMON); \ |
---|
| 256 | $(RM) *~ $(PATH_SRC)/*~ $(PATH_INC)/*~ $(PATH_DATA)/*/*~ *.res *.txt\ |
---|
[113] | 257 | *core* \ |
---|
| 258 | tty* \ |
---|
| 259 | *.vhdl \ |
---|
| 260 | *.log \ |
---|
| 261 | *.stat \ |
---|
| 262 | *.pos \ |
---|
| 263 | modelsim.ini transcript *wlf* $(WORK_NAME) |
---|
[88] | 264 | |
---|
| 265 | clean_all : clean |
---|
| 266 | @\ |
---|
| 267 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
[125] | 268 | $(RM) $(PATH_OBJ) $(PATH_BIN) $(PATH_LOG) $(SCRIPT);\ |
---|
[137] | 269 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile clean_all; \ |
---|
[88] | 270 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
[109] | 271 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; |
---|
[88] | 272 | |
---|
| 273 | |
---|
| 274 | help : |
---|
| 275 | @\ |
---|
| 276 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
| 277 | $(ECHO) "";\ |
---|
| 278 | $(ECHO) " * all (default rules) : create software";\ |
---|
[117] | 279 | $(ECHO) " * run : execute platforms with test configuration";\ |
---|
[125] | 280 | $(ECHO) " set DATA to select a specific directory in $(PATH_DATA) (default : all)";\ |
---|
[117] | 281 | $(ECHO) " set PRIORITY to nice the execution (default : 0)";\ |
---|
[120] | 282 | $(ECHO) " set CLEAN to remove previous log (default : 0)";\ |
---|
| 283 | $(ECHO) " example : make run DATA=debug PRIORITY=10 CLEAN";\ |
---|
[117] | 284 | $(ECHO) " * execute : cf 'make run'";\ |
---|
| 285 | $(ECHO) " * debug : cf 'make run DATA=debug'";\ |
---|
| 286 | $(ECHO) " * bench : cf 'make run DATA=bench'";\ |
---|
[125] | 287 | $(ECHO) " * distexe : Generate an command file to distexe. It's as run command, but just generate an script with all make";\ |
---|
[88] | 288 | $(ECHO) " * lib : make library";\ |
---|
| 289 | $(ECHO) " * soft : make software";\ |
---|
| 290 | $(ECHO) " * clean : erase temporary files";\ |
---|
| 291 | $(ECHO) " * clean_all : erase generated files";\ |
---|
| 292 | $(ECHO) " * help : print this message";\ |
---|
| 293 | $(ECHO) ""; |
---|
| 294 | |
---|
[113] | 295 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Behavioural/Makefile.Synthesis |
---|
[88] | 296 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 297 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|