[117] | 1 | |
---|
[88] | 2 | # |
---|
| 3 | # $Id: Makefile 128 2009-06-26 08:43:23Z 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) |
---|
[127] | 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 | @\ |
---|
[125] | 177 | $(RM) $(SCRIPT); \ |
---|
| 178 | for log in $(LOGS); do \ |
---|
| 179 | $(ECHO) -n "cd $(MORPHEO_TOPLEVEL); source environment.sh; cd -; path=\"${PWD}\"; " >> $(SCRIPT); \ |
---|
| 180 | if $(TEST) $(CLEAN) -ne 0; then \ |
---|
| 181 | $(ECHO) -n "$(RM) $${log}; " >> $(SCRIPT); \ |
---|
| 182 | fi; \ |
---|
| 183 | $(ECHO) "$(MAKE) -C "'$${path}'" $${log} PRIORITY=$(PRIORITY);" >> $(SCRIPT); \ |
---|
[128] | 184 | done; \ |
---|
| 185 | $(CHMOD) +x $(SCRIPT); |
---|
[125] | 186 | |
---|
[128] | 187 | $(PATH_LOG)/%.log : $(PATH_DATA)/%.cfg $(EXEC) $(PATH_LOGS) |
---|
[125] | 188 | @\ |
---|
[88] | 189 | file=$$($(BASENAME) $<); \ |
---|
[124] | 190 | data=$$(eval echo $$($(CAT) $<)); \ |
---|
[88] | 191 | log=$@; \ |
---|
[117] | 192 | $(ECHO) "Run : $*"; \ |
---|
[128] | 193 | $(EXEC_PREFIX) $(EXEC) $(EXEC_PARAMS) $${data} &> $$log; \ |
---|
[88] | 194 | $(GREP) -q "Test OK" $$log; \ |
---|
| 195 | declare -i test_ok=$$?; \ |
---|
| 196 | $(GREP) -q "Test KO" $$log; \ |
---|
| 197 | declare -i test_ko=$$?; \ |
---|
| 198 | declare timing=$$($(GREP) -h "Timing" $$log); \ |
---|
[120] | 199 | if $(TEST) $${test_ko} -ne 0 -a $${test_ok} -eq 0; \ |
---|
[117] | 200 | then test="... OK "; \ |
---|
| 201 | else test="... KO !!!"; \ |
---|
[88] | 202 | fi; \ |
---|
[117] | 203 | $(ECHO) -e " $* $${test}\t$${timing}";\ |
---|
| 204 | echo "{$$($(date))} $* $${test} $${timing}" >> $$($(DIRNAME) $*).res;\ |
---|
[88] | 205 | |
---|
| 206 | #-----[ Library + Software ]------------------------------- |
---|
| 207 | |
---|
[119] | 208 | env : soft lib |
---|
[122] | 209 | @$(MAKE) $(EXEC) |
---|
[119] | 210 | |
---|
[88] | 211 | lib : |
---|
| 212 | @\ |
---|
| 213 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
| 214 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
| 215 | |
---|
| 216 | soft : |
---|
| 217 | @\ |
---|
[125] | 218 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile; |
---|
[88] | 219 | |
---|
| 220 | #-----[ Rules ]-------------------------------------------- |
---|
| 221 | |
---|
[125] | 222 | $(PATH_OBJ)/%.o : %.cpp |
---|
[88] | 223 | @\ |
---|
| 224 | $(ECHO) "Compilation : $*";\ |
---|
| 225 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
| 226 | |
---|
[125] | 227 | $(PATH_OBJ) $(PATH_BIN) $(PATH_LOGS) : |
---|
[88] | 228 | @\ |
---|
| 229 | $(ECHO) "Create directory : $@";\ |
---|
| 230 | $(MKDIR) $@ |
---|
| 231 | |
---|
| 232 | #-----[ Clean + help ]------------------------------------- |
---|
| 233 | |
---|
| 234 | clean : |
---|
| 235 | @\ |
---|
| 236 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
[117] | 237 | $(RM) $(OBJECTS) $(EXEC) $(LOGS) \ |
---|
[125] | 238 | *~ $(PATH_SRC)/*~ $(PATH_INC)/*~ $(PATH_DATA)/*/*~ *.res *.txt\ |
---|
[113] | 239 | *core* \ |
---|
| 240 | tty* \ |
---|
| 241 | *.vhdl \ |
---|
| 242 | *.log \ |
---|
| 243 | *.stat \ |
---|
| 244 | *.pos \ |
---|
| 245 | modelsim.ini transcript *wlf* $(WORK_NAME) |
---|
[88] | 246 | |
---|
| 247 | clean_all : clean |
---|
| 248 | @\ |
---|
| 249 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
[125] | 250 | $(RM) $(PATH_OBJ) $(PATH_BIN) $(PATH_LOG) $(SCRIPT);\ |
---|
| 251 | $(MAKE) --directory=$(PATH_SOFT) --makefile=Makefile clean_all; \ |
---|
[88] | 252 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
[109] | 253 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; |
---|
[88] | 254 | |
---|
| 255 | |
---|
| 256 | help : |
---|
| 257 | @\ |
---|
| 258 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
| 259 | $(ECHO) "";\ |
---|
| 260 | $(ECHO) " * all (default rules) : create software";\ |
---|
[117] | 261 | $(ECHO) " * run : execute platforms with test configuration";\ |
---|
[125] | 262 | $(ECHO) " set DATA to select a specific directory in $(PATH_DATA) (default : all)";\ |
---|
[117] | 263 | $(ECHO) " set PRIORITY to nice the execution (default : 0)";\ |
---|
[120] | 264 | $(ECHO) " set CLEAN to remove previous log (default : 0)";\ |
---|
| 265 | $(ECHO) " example : make run DATA=debug PRIORITY=10 CLEAN";\ |
---|
[117] | 266 | $(ECHO) " * execute : cf 'make run'";\ |
---|
| 267 | $(ECHO) " * debug : cf 'make run DATA=debug'";\ |
---|
| 268 | $(ECHO) " * bench : cf 'make run DATA=bench'";\ |
---|
[125] | 269 | $(ECHO) " * distexe : Generate an command file to distexe. It's as run command, but just generate an script with all make";\ |
---|
[88] | 270 | $(ECHO) " * lib : make library";\ |
---|
| 271 | $(ECHO) " * soft : make software";\ |
---|
| 272 | $(ECHO) " * clean : erase temporary files";\ |
---|
| 273 | $(ECHO) " * clean_all : erase generated files";\ |
---|
| 274 | $(ECHO) " * help : print this message";\ |
---|
| 275 | $(ECHO) ""; |
---|
| 276 | |
---|
[113] | 277 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Behavioural/Makefile.Synthesis |
---|
[88] | 278 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 279 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|