[88] | 1 | # |
---|
| 2 | # $Id: Makefile 98 2008-12-31 10:18: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 |
---|
| 37 | DIR_LOG = ./log |
---|
| 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; \ |
---|
[88] | 117 | declare -i have_test_ko=0; \ |
---|
[97] | 118 | for log in $$logs; do \ |
---|
[88] | 119 | $(GREP) -q "Test OK" $$log; \ |
---|
| 120 | declare -i test_ok=$$?; \ |
---|
| 121 | $(GREP) -q "Test KO" $$log; \ |
---|
| 122 | declare -i test_ko=$$?; \ |
---|
| 123 | if $(TEST) $$test_ko -eq 0 -o $$test_ok -ne 0; \ |
---|
| 124 | then have_test_ko=1; \ |
---|
| 125 | fi; \ |
---|
| 126 | done; \ |
---|
| 127 | if $(TEST) $$have_test_ko -ne 0; \ |
---|
| 128 | then $(ECHO) "-------------------| Test KO"; exit 1; \ |
---|
| 129 | else $(ECHO) "-------------------| Test OK"; exit 0; \ |
---|
| 130 | fi; |
---|
| 131 | |
---|
| 132 | execute : run |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | $(DIR_LOG)/%.log : %.cfg |
---|
| 136 | @\ |
---|
| 137 | file=$$($(BASENAME) $<); \ |
---|
| 138 | data=$$($(CAT) $<); \ |
---|
| 139 | log=$@; \ |
---|
| 140 | $(ECHO) "Run : $$file"; \ |
---|
| 141 | $(EXEC_PREFIX) $(EXEC) $${data} &> $$log; \ |
---|
| 142 | $(GREP) -q "Test OK" $$log; \ |
---|
| 143 | declare -i test_ok=$$?; \ |
---|
| 144 | $(GREP) -q "Test KO" $$log; \ |
---|
| 145 | declare -i test_ko=$$?; \ |
---|
| 146 | declare timing=$$($(GREP) -h "Timing" $$log); \ |
---|
| 147 | if $(TEST) $$test_ko -ne 0 -a $$test_ok -eq 0; \ |
---|
| 148 | then $(ECHO) -e " $$file ... OK\t$$timing"; \ |
---|
| 149 | else $(ECHO) -e " $$file ... KO\t$$timing"; \ |
---|
| 150 | have_test_ko=1; \ |
---|
| 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 |
---|