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