[117] | 1 | |
---|
[88] | 2 | # |
---|
| 3 | # $Id: Makefile 131 2009-07-08 18:40:08Z 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 |
---|
[125] | 54 | PATH_DATA = ./data |
---|
| 55 | PATH_LOGS = $(patsubst $(PATH_DATA)/%,$(PATH_LOG)/%,$(wildcard $(PATH_DATA)/*)) |
---|
[117] | 56 | |
---|
[125] | 57 | PATH_SOFT = $(MORPHEO_TOPLEVEL)/Softwares |
---|
[88] | 58 | |
---|
| 59 | #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 60 | #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 61 | #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 62 | #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 63 | #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 64 | |
---|
| 65 | #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 66 | #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 67 | #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 68 | #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 69 | |
---|
| 70 | #---------------------------------------------------------- |
---|
| 71 | #---------------------------------------------------------- |
---|
| 72 | #-----[ Variables ]---------------------------------------- |
---|
| 73 | #---------------------------------------------------------- |
---|
| 74 | #---------------------------------------------------------- |
---|
[125] | 75 | SOURCES = $(wildcard $(PATH_SRC)/*.cpp) |
---|
| 76 | OBJECTS = $(patsubst $(PATH_SRC)/%.cpp,$(PATH_OBJ)/%.o,$(SOURCES)) |
---|
| 77 | LOGS = $(patsubst $(PATH_DATA)/%.cfg,$(PATH_LOG)/%.log,$(wildcard $(PATH_DATA)/$(DATA)/*.cfg)) |
---|
[131] | 78 | |
---|
| 79 | BIN = Platforms_Test.x |
---|
| 80 | EXEC = $(PATH_BIN)/$(BIN) |
---|
[128] | 81 | EXEC_PREFIX = $(NICE) -n $(PRIORITY) |
---|
[129] | 82 | # $(VALGRIND) |
---|
[128] | 83 | EXEC_PARAMS = $(SYSTEMC_EXEC_PARAMS_$(SIMULATOR_SYSTEMC)) |
---|
[88] | 84 | |
---|
[125] | 85 | SCRIPT = make.sh |
---|
| 86 | |
---|
[88] | 87 | #-----[ Compilation ]-------------------------------------- |
---|
[117] | 88 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
[88] | 89 | $(MORPHEO_INCDIR) \ |
---|
| 90 | $(ENVIRONMENT_INCDIR) \ |
---|
[125] | 91 | -I$(PATH_INC) |
---|
[88] | 92 | |
---|
[117] | 93 | #LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
[113] | 94 | # $(ENVIRONMENT_LIBDIR) \ |
---|
| 95 | # $(MORPHEO_LIBDIR) |
---|
| 96 | |
---|
[117] | 97 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR_SYSTEMC)) \ |
---|
[125] | 98 | -L$(PATH_LIB) |
---|
[88] | 99 | |
---|
| 100 | LIBNAME = $(ENVIRONMENT_LIBNAME) \ |
---|
| 101 | $(MORPHEO_LIBNAME) \ |
---|
[117] | 102 | $(SYSTEMC_LIBNAME_$(SIMULATOR_SYSTEMC)) |
---|
[88] | 103 | |
---|
[117] | 104 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR_SYSTEMC)) |
---|
[88] | 105 | |
---|
| 106 | PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
| 107 | PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
| 108 | |
---|
| 109 | #---------------------------------------------------------- |
---|
| 110 | #---------------------------------------------------------- |
---|
| 111 | #-----[ Rules ]-------------------------------------------- |
---|
| 112 | #---------------------------------------------------------- |
---|
| 113 | #---------------------------------------------------------- |
---|
| 114 | |
---|
[125] | 115 | vpath %.h $(PATH_INC) |
---|
| 116 | vpath %.cpp $(PATH_SRC) |
---|
| 117 | vpath %.o $(PATH_OBJ) |
---|
| 118 | vpath %.cfg $(PATH_DATA)/*/ |
---|
[88] | 119 | |
---|
[125] | 120 | .PRECIOUS : $(PATH_OBJ)/%.o $(PATH_BIN)/%.x $(PATH_LOG)/%.log |
---|
[88] | 121 | |
---|
[113] | 122 | all : $(EXEC) |
---|
[88] | 123 | |
---|
[125] | 124 | $(PATH_BIN)/%.x : $(PATH_OBJ) $(PATH_BIN) |
---|
[88] | 125 | @\ |
---|
[113] | 126 | $(ECHO) "Linkage : $*";\ |
---|
[117] | 127 | case "${SIMULATOR_SYSTEMC}" in \ |
---|
[113] | 128 | "modelsim") \ |
---|
| 129 | $(MAKE) $(WORK_NAME); \ |
---|
| 130 | $(MODELTECH_SCCOM) $(PLATFORMS_CXX_FLAGS) $(SOURCES); \ |
---|
| 131 | $(MODELTECH_SCCOM) -link $(PLATFORMS_L_FLAGS) $(LIBNAME); \ |
---|
| 132 | $(ECHO) "#!$(SHELL)" > $@; \ |
---|
| 133 | $(ECHO) "cd $${PWD};" >> $@; \ |
---|
| 134 | $(ECHO) "$(MODELTECH_VSIM) -sc_arg "'"$${*}"'" $(WORK_NAME).top;" >> $@;\ |
---|
| 135 | $(ECHO) "cd -;" >> $@; \ |
---|
| 136 | $(CHMOD) +x $@; \ |
---|
| 137 | ;; \ |
---|
| 138 | *) \ |
---|
| 139 | $(MAKE) $(OBJECTS); \ |
---|
| 140 | $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $(OBJECTS) $(LIBNAME); \ |
---|
| 141 | ;; \ |
---|
| 142 | esac; \ |
---|
[88] | 143 | |
---|
[119] | 144 | run : |
---|
[88] | 145 | @\ |
---|
[120] | 146 | declare -i clean=$(CLEAN); \ |
---|
| 147 | if $(TEST) $${clean} -ne 0 -a "$(DATA)" != "$(DATA_ALL)"; then \ |
---|
[125] | 148 | $(RM) $(PATH_LOG)/$(DATA); \ |
---|
[120] | 149 | fi; \ |
---|
| 150 | declare logs="$(LOGS)"; \ |
---|
| 151 | $(MAKE) $${logs}; \ |
---|
| 152 | declare -i nb_test=0; \ |
---|
| 153 | declare -i nb_test_ko=0; \ |
---|
| 154 | for log in $${logs}; do \ |
---|
| 155 | $(GREP) -q "Test OK" $$log; \ |
---|
| 156 | declare -i test_ok=$$?; \ |
---|
| 157 | $(GREP) -q "Test KO" $$log; \ |
---|
| 158 | declare -i test_ko=$$?; \ |
---|
| 159 | if $(TEST) $${test_ko} -eq 0 -o $${test_ok} -ne 0; \ |
---|
| 160 | then nb_test_ko=$$(($${nb_test_ko} + 1)); \ |
---|
| 161 | fi; \ |
---|
| 162 | nb_test=$$(($${nb_test} + 1)); \ |
---|
| 163 | done; \ |
---|
| 164 | if $(TEST) $${nb_test_ko} -ne 0; \ |
---|
[101] | 165 | then $(ECHO) "-------------------| Test KO !!! ($${nb_test_ko}/$${nb_test})"; exit 1; \ |
---|
[123] | 166 | else $(ECHO) "-------------------| Test OK ($${nb_test})"; exit 0; \ |
---|
[88] | 167 | fi; |
---|
| 168 | |
---|
[117] | 169 | execute : run |
---|
| 170 | |
---|
| 171 | debug : |
---|
[108] | 172 | @\ |
---|
[120] | 173 | $(MAKE) run DATA=debug CLEAN=1; |
---|
[88] | 174 | |
---|
[117] | 175 | bench : |
---|
| 176 | @\ |
---|
| 177 | $(MAKE) run DATA=bench; |
---|
[108] | 178 | |
---|
[125] | 179 | distexe : |
---|
[88] | 180 | @\ |
---|
[129] | 181 | $(ECHO) -n "Generate : $(SCRIPT) ";\ |
---|
[125] | 182 | $(RM) $(SCRIPT); \ |
---|
| 183 | for log in $(LOGS); do \ |
---|
[129] | 184 | $(ECHO) -n "."; \ |
---|
| 185 | $(ECHO) -n "cd $(MORPHEO_TOPLEVEL); source environment.sh; cd -; path=\"${PWD}\"; " >> $(SCRIPT);\ |
---|
[125] | 186 | if $(TEST) $(CLEAN) -ne 0; then \ |
---|
| 187 | $(ECHO) -n "$(RM) $${log}; " >> $(SCRIPT); \ |
---|
| 188 | fi; \ |
---|
| 189 | $(ECHO) "$(MAKE) -C "'$${path}'" $${log} PRIORITY=$(PRIORITY);" >> $(SCRIPT); \ |
---|
[128] | 190 | done; \ |
---|
[129] | 191 | $(CHMOD) +x $(SCRIPT); \ |
---|
| 192 | $(ECHO) " done"; |
---|
[125] | 193 | |
---|
[129] | 194 | |
---|
[128] | 195 | $(PATH_LOG)/%.log : $(PATH_DATA)/%.cfg $(EXEC) $(PATH_LOGS) |
---|
[125] | 196 | @\ |
---|
[88] | 197 | file=$$($(BASENAME) $<); \ |
---|
[124] | 198 | data=$$(eval echo $$($(CAT) $<)); \ |
---|
[88] | 199 | log=$@; \ |
---|
[117] | 200 | $(ECHO) "Run : $*"; \ |
---|
[128] | 201 | $(EXEC_PREFIX) $(EXEC) $(EXEC_PARAMS) $${data} &> $$log; \ |
---|
[88] | 202 | $(GREP) -q "Test OK" $$log; \ |
---|
| 203 | declare -i test_ok=$$?; \ |
---|
| 204 | $(GREP) -q "Test KO" $$log; \ |
---|
| 205 | declare -i test_ko=$$?; \ |
---|
| 206 | declare timing=$$($(GREP) -h "Timing" $$log); \ |
---|
[120] | 207 | if $(TEST) $${test_ko} -ne 0 -a $${test_ok} -eq 0; \ |
---|
[117] | 208 | then test="... OK "; \ |
---|
| 209 | else test="... KO !!!"; \ |
---|
[88] | 210 | fi; \ |
---|
[117] | 211 | $(ECHO) -e " $* $${test}\t$${timing}";\ |
---|
| 212 | echo "{$$($(date))} $* $${test} $${timing}" >> $$($(DIRNAME) $*).res;\ |
---|
[88] | 213 | |
---|
| 214 | #-----[ Library + Software ]------------------------------- |
---|
| 215 | |
---|
[119] | 216 | env : soft lib |
---|
[122] | 217 | @$(MAKE) $(EXEC) |
---|
[119] | 218 | |
---|
[88] | 219 | lib : |
---|
| 220 | @\ |
---|
| 221 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
| 222 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
| 223 | |
---|
| 224 | soft : |
---|
| 225 | @\ |
---|
[125] | 226 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile; |
---|
[88] | 227 | |
---|
| 228 | #-----[ Rules ]-------------------------------------------- |
---|
| 229 | |
---|
[125] | 230 | $(PATH_OBJ)/%.o : %.cpp |
---|
[88] | 231 | @\ |
---|
| 232 | $(ECHO) "Compilation : $*";\ |
---|
| 233 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
| 234 | |
---|
[125] | 235 | $(PATH_OBJ) $(PATH_BIN) $(PATH_LOGS) : |
---|
[88] | 236 | @\ |
---|
| 237 | $(ECHO) "Create directory : $@";\ |
---|
| 238 | $(MKDIR) $@ |
---|
| 239 | |
---|
| 240 | #-----[ Clean + help ]------------------------------------- |
---|
| 241 | |
---|
| 242 | clean : |
---|
| 243 | @\ |
---|
| 244 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
[117] | 245 | $(RM) $(OBJECTS) $(EXEC) $(LOGS) \ |
---|
[125] | 246 | *~ $(PATH_SRC)/*~ $(PATH_INC)/*~ $(PATH_DATA)/*/*~ *.res *.txt\ |
---|
[113] | 247 | *core* \ |
---|
| 248 | tty* \ |
---|
| 249 | *.vhdl \ |
---|
| 250 | *.log \ |
---|
| 251 | *.stat \ |
---|
| 252 | *.pos \ |
---|
| 253 | modelsim.ini transcript *wlf* $(WORK_NAME) |
---|
[88] | 254 | |
---|
| 255 | clean_all : clean |
---|
| 256 | @\ |
---|
| 257 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
[125] | 258 | $(RM) $(PATH_OBJ) $(PATH_BIN) $(PATH_LOG) $(SCRIPT);\ |
---|
| 259 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile clean_all; \ |
---|
[88] | 260 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
[109] | 261 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; |
---|
[88] | 262 | |
---|
| 263 | |
---|
| 264 | help : |
---|
| 265 | @\ |
---|
| 266 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
| 267 | $(ECHO) "";\ |
---|
| 268 | $(ECHO) " * all (default rules) : create software";\ |
---|
[117] | 269 | $(ECHO) " * run : execute platforms with test configuration";\ |
---|
[125] | 270 | $(ECHO) " set DATA to select a specific directory in $(PATH_DATA) (default : all)";\ |
---|
[117] | 271 | $(ECHO) " set PRIORITY to nice the execution (default : 0)";\ |
---|
[120] | 272 | $(ECHO) " set CLEAN to remove previous log (default : 0)";\ |
---|
| 273 | $(ECHO) " example : make run DATA=debug PRIORITY=10 CLEAN";\ |
---|
[117] | 274 | $(ECHO) " * execute : cf 'make run'";\ |
---|
| 275 | $(ECHO) " * debug : cf 'make run DATA=debug'";\ |
---|
| 276 | $(ECHO) " * bench : cf 'make run DATA=bench'";\ |
---|
[125] | 277 | $(ECHO) " * distexe : Generate an command file to distexe. It's as run command, but just generate an script with all make";\ |
---|
[88] | 278 | $(ECHO) " * lib : make library";\ |
---|
| 279 | $(ECHO) " * soft : make software";\ |
---|
| 280 | $(ECHO) " * clean : erase temporary files";\ |
---|
| 281 | $(ECHO) " * clean_all : erase generated files";\ |
---|
| 282 | $(ECHO) " * help : print this message";\ |
---|
| 283 | $(ECHO) ""; |
---|
| 284 | |
---|
[113] | 285 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Behavioural/Makefile.Synthesis |
---|
[88] | 286 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 287 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|