1 | ifeq ($(origin MORPHEO_TOPLEVEL), undefined) |
---|
2 | $(error "variable MORPHEO_TOPLEVEL is undefined"); |
---|
3 | else |
---|
4 | include $(MORPHEO_TOPLEVEL)/Makefile.tools |
---|
5 | include $(MORPHEO_TOPLEVEL)/Makefile.flags |
---|
6 | endif |
---|
7 | |
---|
8 | #-----[ Directory ]---------------------------------------- |
---|
9 | ENTITY ?= Environment |
---|
10 | |
---|
11 | DIR_TMP = $(MORPHEO_TMP)/$(ENTITY) |
---|
12 | DIR_TST = ./selftest |
---|
13 | DIR_INC = ./include |
---|
14 | DIR_SRC = ./src |
---|
15 | DIR_OBJ = ./obj |
---|
16 | DIR_BIN = $(DIR_TMP)/bin |
---|
17 | |
---|
18 | #-----[ Compilation ]-------------------------------------- |
---|
19 | INCDIR = $(SYSTEMC_INCDIR_$(SIMULATOR)) \ |
---|
20 | -I$(DIR_INC) \ |
---|
21 | -I../processor/Morpheo |
---|
22 | |
---|
23 | LIBDIR = $(SYSTEMC_LIBDIR_$(SIMULATOR)) |
---|
24 | |
---|
25 | LIBNAME = -lbfd \ |
---|
26 | -liberty \ |
---|
27 | $(SYSTEMC_LIBNAME_$(SIMULATOR)) |
---|
28 | |
---|
29 | FLAGS = $(SYSTEMC_CFLAGS_$(SIMULATOR)) |
---|
30 | |
---|
31 | MORPHEO_CC_FLAGS = $(MORPHEO_FLAGS) $(CC_FLAGS) $(INCDIR) |
---|
32 | MORPHEO_CXX_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(INCDIR) |
---|
33 | MORPHEO_L_FLAGS = $(MORPHEO_FLAGS) $(CXX_FLAGS) $(FLAGS) $(LIBDIR) |
---|
34 | |
---|
35 | #-----[ Variable ]----------------------------------------- |
---|
36 | |
---|
37 | OBJECTS = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_OBJ)/%.o,$(wildcard $(DIR_SRC)/*.cpp)) \ |
---|
38 | $(patsubst $(DIR_SRC)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_SRC)/*.c)) |
---|
39 | OBJECTS_BIN = $(patsubst $(DIR_TST)/%.cpp,$(DIR_OBJ)/%.o,$(wildcard $(DIR_TST)/*.cpp)) |
---|
40 | |
---|
41 | HEADERS = $(wildcard $(DIR_INC)/*.h) |
---|
42 | |
---|
43 | EXE = $(DIR_BIN)/soft.x |
---|
44 | |
---|
45 | EXEC_PREFIX = |
---|
46 | #$(VALGRIND) |
---|
47 | |
---|
48 | #-----[ Rules ]-------------------------------------------- |
---|
49 | |
---|
50 | vpath %.h $(DIR_INC) |
---|
51 | vpath %.c $(DIR_SRC) |
---|
52 | vpath %.cpp $(DIR_SRC):$(DIR_TST) |
---|
53 | vpath %.o $(DIR_OBJ) |
---|
54 | |
---|
55 | .PRECIOUS : $(DIR_OBJ)/%.o $(DIR_BIN)/%.x |
---|
56 | |
---|
57 | test_env : |
---|
58 | @\ |
---|
59 | $(ECHO) "-------------------| $(ENTITY)" |
---|
60 | |
---|
61 | $(DIR_OBJ)/%.o : %.cpp $(HEADERS) |
---|
62 | @\ |
---|
63 | $(ECHO) "Compilation : $*";\ |
---|
64 | $(CXX) $(MORPHEO_CXX_FLAGS) -c -o $@ $<; |
---|
65 | |
---|
66 | $(DIR_OBJ)/%.o : %.c $(HEADERS) |
---|
67 | @\ |
---|
68 | $(ECHO) "Compilation : $*";\ |
---|
69 | $(CC) $(MORPHEO_CC_FLAGS) -c -o $@ $<; |
---|
70 | |
---|
71 | $(DIR_BIN)/%.x : $(OBJECTS_DEPS) $(OBJECTS) $(OBJECTS_BIN) |
---|
72 | \ |
---|
73 | $(ECHO) "Compilation : $*";\ |
---|
74 | $(CXX) $(MORPHEO_L_FLAGS) -o $@ $^ $(LIBNAME); |
---|
75 | |
---|
76 | $(DIR_OBJ) : |
---|
77 | @\ |
---|
78 | $(ECHO) "Create directory : $@";\ |
---|
79 | $(MKDIR) $@ |
---|
80 | |
---|
81 | $(DIR_BIN) : |
---|
82 | @\ |
---|
83 | $(ECHO) "Create directory : $@";\ |
---|
84 | $(MKDIR) $@ |
---|
85 | |
---|
86 | |
---|
87 | exe : all $(DIR_BIN) |
---|
88 | @\ |
---|
89 | $(MAKE) $(EXE); \ |
---|
90 | export SYSTEMC=$(SYSTEMC_$(SIMULATOR)) ; $(EXEC_PREFIX) $(EXE) $(SYSTEMC_EXEC_PARAMS_$(SIMULATOR)) |
---|
91 | |
---|
92 | |
---|
93 | all_environment : test_env $(DIR_OBJ) |
---|
94 | @\ |
---|
95 | $(MAKE) $(OBJECTS_DEPS) $(OBJECTS) $(OBJECTS_BIN) |
---|
96 | |
---|
97 | environment_clean : |
---|
98 | @\ |
---|
99 | $(ECHO) "Delete temporary files in directory "$(PWD);\ |
---|
100 | $(RM) *~ \ |
---|
101 | $(DIR_OBJ) \ |
---|
102 | $(DIR_BIN) \ |
---|
103 | $(DIR_TST)/*~ \ |
---|
104 | $(DIR_SRC)/*~ \ |
---|
105 | $(DIR_INC)/*~ \ |
---|
106 | *.dot \ |
---|
107 | *.txt; |
---|
108 | |
---|
109 | environment_help : |
---|
110 | @\ |
---|
111 | $(ECHO) " -----[ Environment ]------------------------------";\ |
---|
112 | $(ECHO) "";\ |
---|
113 | $(ECHO) " * exe : execute testbench";\ |
---|
114 | $(ECHO) " * test_env : test if environnment's variable is set";\ |
---|
115 | $(ECHO) " * all_environment : generate object";\ |
---|
116 | $(ECHO) ""; |
---|