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