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