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