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