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