[88] | 1 | # |
---|
| 2 | # $Id: Makefile 101 2009-01-15 17:19:08Z 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 |
---|
| 36 | DIR_BIN = $(DIR_TMP)/bin |
---|
[101] | 37 | DIR_LOG = $(DIR_TMP)/log |
---|
[88] | 38 | DIR_DATA = ./data |
---|
| 39 | DIR_SOFT = $(MORPHEO_TOPLEVEL)/Softwares |
---|
| 40 | |
---|
| 41 | #MORPHEO - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 42 | #MORPHEO_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 43 | #MORPHEO_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 44 | #MORPHEO_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 45 | #MORPHEO_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 46 | |
---|
| 47 | #ENVIRONMENT_DIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 48 | #ENVIRONMENT_INCDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 49 | #ENVIRONMENT_LIBDIR - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 50 | #ENVIRONMENT_LIBNAME - define in $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|
| 51 | |
---|
| 52 | #---------------------------------------------------------- |
---|
| 53 | #---------------------------------------------------------- |
---|
| 54 | #-----[ Variables ]---------------------------------------- |
---|
| 55 | #---------------------------------------------------------- |
---|
| 56 | #---------------------------------------------------------- |
---|
| 57 | |
---|
| 58 | OBJECTS = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_OBJ)/%.o,$(wildcard $(DIR_SRC)/*.cpp)) |
---|
| 59 | LOGS = $(patsubst $(DIR_DATA)/%.cfg,$(DIR_LOG)/%.log,$(wildcard $(DIR_DATA)/*.cfg)) |
---|
[97] | 60 | DEBUG_CFG = $(DIR_DATA)/debug.cfg |
---|
| 61 | DEBUG_LOG = $(DIR_LOG)/debug.log |
---|
[88] | 62 | |
---|
| 63 | EXEC = $(DIR_BIN)/soft.x |
---|
| 64 | EXEC_PREFIX = |
---|
| 65 | #$(VALGRIND) |
---|
| 66 | |
---|
| 67 | #-----[ Compilation ]-------------------------------------- |
---|
| 68 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR)) \ |
---|
| 69 | $(MORPHEO_INCDIR) \ |
---|
| 70 | $(ENVIRONMENT_INCDIR) \ |
---|
| 71 | -I$(DIR_INC) |
---|
| 72 | |
---|
| 73 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR)) \ |
---|
| 74 | $(ENVIRONMENT_LIBDIR) \ |
---|
| 75 | $(MORPHEO_LIBDIR) |
---|
| 76 | |
---|
| 77 | LIBNAME = $(ENVIRONMENT_LIBNAME) \ |
---|
| 78 | $(MORPHEO_LIBNAME) \ |
---|
| 79 | $(SYSTEMC_LIBNAME_$(SIMULATOR)) |
---|
| 80 | |
---|
| 81 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR)) |
---|
| 82 | |
---|
| 83 | PLATFORMS_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
| 84 | PLATFORMS_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
| 85 | |
---|
| 86 | #---------------------------------------------------------- |
---|
| 87 | #---------------------------------------------------------- |
---|
| 88 | #-----[ Rules ]-------------------------------------------- |
---|
| 89 | #---------------------------------------------------------- |
---|
| 90 | #---------------------------------------------------------- |
---|
| 91 | |
---|
| 92 | vpath %.h $(DIR_INC) |
---|
| 93 | vpath %.cpp $(DIR_SRC) |
---|
| 94 | vpath %.o $(DIR_OBJ) |
---|
| 95 | vpath %.cfg $(DIR_DATA) |
---|
| 96 | |
---|
| 97 | .PRECIOUS : $(DIR_OBJ)/%.o $(DIR_BIN)/%.x $(DIR_LOG)/%.log |
---|
| 98 | |
---|
| 99 | all : $(DIR_OBJ) $(DIR_BIN) |
---|
| 100 | @\ |
---|
| 101 | $(MAKE) $(EXEC) |
---|
| 102 | |
---|
| 103 | $(DIR_BIN)/%.x : $(OBJECTS) |
---|
| 104 | @\ |
---|
| 105 | $(ECHO) "Compilation : $*";\ |
---|
| 106 | $(CXX) $(PLATFORMS_L_FLAGS) -o $@ $^ $(LIBNAME); |
---|
| 107 | |
---|
| 108 | run : $(DIR_LOG) all |
---|
| 109 | @\ |
---|
[97] | 110 | declare logs; \ |
---|
| 111 | if $(TEST) -f "$(DEBUG_CFG)"; then \ |
---|
| 112 | logs="$(DEBUG_LOG)"; \ |
---|
| 113 | else \ |
---|
| 114 | logs="$(LOGS)"; \ |
---|
| 115 | fi; \ |
---|
| 116 | $(MAKE) $$logs; \ |
---|
[101] | 117 | declare -i nb_test=0; \ |
---|
| 118 | declare -i nb_test_ko=0; \ |
---|
[97] | 119 | for log in $$logs; do \ |
---|
[88] | 120 | $(GREP) -q "Test OK" $$log; \ |
---|
| 121 | declare -i test_ok=$$?; \ |
---|
| 122 | $(GREP) -q "Test KO" $$log; \ |
---|
| 123 | declare -i test_ko=$$?; \ |
---|
| 124 | if $(TEST) $$test_ko -eq 0 -o $$test_ok -ne 0; \ |
---|
[101] | 125 | then nb_test_ko=$$(($${nb_test_ko} + 1)); \ |
---|
[88] | 126 | fi; \ |
---|
[101] | 127 | nb_test=$$(($${nb_test} + 1)); \ |
---|
[88] | 128 | done; \ |
---|
[101] | 129 | if $(TEST) $${nb_test_ko} -ne 0; \ |
---|
| 130 | then $(ECHO) "-------------------| Test KO !!! ($${nb_test_ko}/$${nb_test})"; exit 1; \ |
---|
[88] | 131 | else $(ECHO) "-------------------| Test OK"; exit 0; \ |
---|
| 132 | fi; |
---|
| 133 | |
---|
| 134 | execute : run |
---|
| 135 | |
---|
| 136 | $(DIR_LOG)/%.log : %.cfg |
---|
| 137 | @\ |
---|
| 138 | file=$$($(BASENAME) $<); \ |
---|
| 139 | data=$$($(CAT) $<); \ |
---|
| 140 | log=$@; \ |
---|
| 141 | $(ECHO) "Run : $$file"; \ |
---|
| 142 | $(EXEC_PREFIX) $(EXEC) $${data} &> $$log; \ |
---|
| 143 | $(GREP) -q "Test OK" $$log; \ |
---|
| 144 | declare -i test_ok=$$?; \ |
---|
| 145 | $(GREP) -q "Test KO" $$log; \ |
---|
| 146 | declare -i test_ko=$$?; \ |
---|
| 147 | declare timing=$$($(GREP) -h "Timing" $$log); \ |
---|
| 148 | if $(TEST) $$test_ko -ne 0 -a $$test_ok -eq 0; \ |
---|
[101] | 149 | then $(ECHO) -e " $$file ... OK \t$$timing"; \ |
---|
| 150 | else $(ECHO) -e " $$file ... KO !!!\t$$timing"; \ |
---|
[88] | 151 | fi; \ |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | #-----[ Library + Software ]------------------------------- |
---|
| 155 | |
---|
| 156 | lib : |
---|
| 157 | @\ |
---|
| 158 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile;\ |
---|
| 159 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile; |
---|
| 160 | |
---|
| 161 | soft : |
---|
| 162 | @\ |
---|
| 163 | $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile; |
---|
| 164 | |
---|
| 165 | #-----[ Rules ]-------------------------------------------- |
---|
| 166 | |
---|
| 167 | $(DIR_OBJ)/%.o : %.cpp |
---|
| 168 | @\ |
---|
| 169 | $(ECHO) "Compilation : $*";\ |
---|
| 170 | $(CXX) $(PLATFORMS_CXX_FLAGS) -c -o $@ $<; |
---|
| 171 | |
---|
| 172 | $(DIR_OBJ) : |
---|
| 173 | @\ |
---|
| 174 | $(ECHO) "Create directory : $@";\ |
---|
| 175 | $(MKDIR) $@ |
---|
| 176 | |
---|
| 177 | $(DIR_BIN) : |
---|
| 178 | @\ |
---|
| 179 | $(ECHO) "Create directory : $@";\ |
---|
| 180 | $(MKDIR) $@ |
---|
| 181 | |
---|
| 182 | $(DIR_LOG) : |
---|
| 183 | @\ |
---|
| 184 | $(ECHO) "Create directory : $@";\ |
---|
| 185 | $(MKDIR) $@ |
---|
| 186 | |
---|
| 187 | #-----[ Clean + help ]------------------------------------- |
---|
| 188 | |
---|
| 189 | clean : |
---|
| 190 | @\ |
---|
| 191 | $(ECHO) "Delete temporary files in directory $(PWD)";\ |
---|
[98] | 192 | $(RM) *~ $(DIR_SRC)/*~ $(DIR_INC)/*~ $(DIR_DATA)/*~ *core* tty* *.vhdl *.log *.stat *.pos\ |
---|
[88] | 193 | $(DIR_OBJ) $(DIR_BIN) $(DIR_LOG); |
---|
| 194 | |
---|
| 195 | clean_all : clean |
---|
| 196 | @\ |
---|
| 197 | $(ECHO) "Delete generated files in directory $(PWD)";\ |
---|
| 198 | $(MAKE) --directory=$(ENVIRONMENT_DIR) --makefile=Makefile clean_all; \ |
---|
| 199 | $(MAKE) --directory=$(MORPHEO_DIR) --makefile=Makefile clean_all; \ |
---|
| 200 | $(MAKE) --directory=$(DIR_SOFT) --makefile=Makefile clean_all; |
---|
| 201 | |
---|
| 202 | |
---|
| 203 | help : |
---|
| 204 | @\ |
---|
| 205 | $(ECHO) " -----[ Common ]-------------------------------------";\ |
---|
| 206 | $(ECHO) "";\ |
---|
| 207 | $(ECHO) " * all (default rules) : create software";\ |
---|
| 208 | $(ECHO) " * run : execute platforms";\ |
---|
| 209 | $(ECHO) " * lib : make library";\ |
---|
| 210 | $(ECHO) " * soft : make software";\ |
---|
| 211 | $(ECHO) " * execute : cf 'make run'";\ |
---|
| 212 | $(ECHO) " * clean : erase temporary files";\ |
---|
| 213 | $(ECHO) " * clean_all : erase generated files";\ |
---|
| 214 | $(ECHO) " * help : print this message";\ |
---|
| 215 | $(ECHO) ""; |
---|
| 216 | |
---|
| 217 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/processor/Morpheo/Makefile.deps |
---|
| 218 | include $(MORPHEO_TOPLEVEL)/IPs/systemC/Environment/Makefile.deps |
---|