1 | # common definition |
---|
2 | include Makefile.morpheo |
---|
3 | |
---|
4 | #-----[ Directory ]--------------------------------------------------------------- |
---|
5 | |
---|
6 | DIR_LOCAL = . |
---|
7 | DIR_LOCAL_C = $(DIR_LOCAL)/src/c |
---|
8 | DIR_LOCAL_ASM = $(DIR_LOCAL)/src/asm |
---|
9 | DIR_LOCAL_SYS = $(DIR_LOCAL)/src/sys |
---|
10 | DIR_LOCAL_INC = $(DIR_LOCAL)/src/c/include |
---|
11 | |
---|
12 | DIR_GLOBAL = $(SOFT)/Global.or32 |
---|
13 | DIR_GLOBAL_C = $(DIR_GLOBAL)/src/c |
---|
14 | DIR_GLOBAL_ASM = $(DIR_GLOBAL)/src/asm |
---|
15 | DIR_GLOBAL_SYS = $(DIR_GLOBAL)/src/sys |
---|
16 | DIR_GLOBAL_INC = $(DIR_GLOBAL)/include |
---|
17 | |
---|
18 | DIR_INC = -I$(DIR_LOCAL_INC) -I$(DIR_GLOBAL_INC) |
---|
19 | DIR_OBJ = obj |
---|
20 | DIR_BIN = bin |
---|
21 | |
---|
22 | EXE = soft |
---|
23 | |
---|
24 | #-----[ Files ]------------------------------------------------------------------- |
---|
25 | OBJ_ASM = $(patsubst $(DIR_LOCAL_ASM)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_LOCAL_ASM)/*.s)) \ |
---|
26 | $(patsubst $(DIR_GLOBAL_ASM)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_GLOBAL_ASM)/*.s)) |
---|
27 | OBJ_SYS = $(patsubst $(DIR_LOCAL_SYS)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_LOCAL_SYS)/*.s)) \ |
---|
28 | $(patsubst $(DIR_GLOBAL_SYS)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_GLOBAL_SYS)/*.s)) |
---|
29 | OBJ_C = $(patsubst $(DIR_LOCAL_C)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_LOCAL_C)/*.c)) \ |
---|
30 | $(patsubst $(DIR_GLOBAL_C)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_GLOBAL_C)/*.c)) |
---|
31 | |
---|
32 | OBJ = $(OBJ_SYS) $(OBJ_ASM) $(OBJ_C) |
---|
33 | |
---|
34 | #-----[ Rules ]------------------------------------------------------------------- |
---|
35 | .PRECIOUS : $(DIR_BIN)/%.x $(DIR_OBJ)/%.o $(DIR_OBJ)/%.a |
---|
36 | |
---|
37 | all : test_env $(DIR_BIN)/$(EXE).x.txt |
---|
38 | |
---|
39 | $(DIR_BIN)/%.x.txt : $(DIR_BIN)/%.x |
---|
40 | @\ |
---|
41 | $(ECHO) "List symbols of $*";\ |
---|
42 | $(NM) $(NM_OPT) $^ > $@.nm;\ |
---|
43 | $(ECHO) "Display information of $*";\ |
---|
44 | $(OBJDUMP) $(OBJDUMP_OPT) $^ > $@; |
---|
45 | |
---|
46 | $(DIR_BIN)/%.x : $(OBJ_SYS) $(OBJ) |
---|
47 | @\ |
---|
48 | $(ECHO) "Linkage of $*";\ |
---|
49 | $(LD) -o $@ $^ $(LD_OPT); |
---|
50 | |
---|
51 | $(DIR_OBJ)/%.o : $(DIR_LOCAL_ASM)/%.s |
---|
52 | @\ |
---|
53 | $(ECHO) "Compile of $*";\ |
---|
54 | $(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ ;\ |
---|
55 | $(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ ; |
---|
56 | # @$(AS) $(AS_OPT) $^ -o $@ |
---|
57 | |
---|
58 | $(DIR_OBJ)/%.o : $(DIR_LOCAL_SYS)/%.s |
---|
59 | @\ |
---|
60 | $(ECHO) "Compile of $*";\ |
---|
61 | $(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ ;\ |
---|
62 | $(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ ; |
---|
63 | # @$(AS) $(AS_OPT) $^ -o $@ |
---|
64 | |
---|
65 | $(DIR_OBJ)/%.o : $(DIR_LOCAL_C)/%.c |
---|
66 | @\ |
---|
67 | $(ECHO) "Compile of $*";\ |
---|
68 | $(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ ;\ |
---|
69 | $(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ ; |
---|
70 | |
---|
71 | $(DIR_OBJ)/%.o : $(DIR_GLOBAL_ASM)/%.s |
---|
72 | @\ |
---|
73 | $(ECHO) "Compile of $*";\ |
---|
74 | $(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ ;\ |
---|
75 | $(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ ; |
---|
76 | # @$(AS) $(AS_OPT) $^ -o $@ |
---|
77 | |
---|
78 | $(DIR_OBJ)/%.o : $(DIR_GLOBAL_SYS)/%.s |
---|
79 | @\ |
---|
80 | $(ECHO) "Compile of $*";\ |
---|
81 | $(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ ;\ |
---|
82 | $(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ ; |
---|
83 | # @$(AS) $(AS_OPT) $^ -o $@ |
---|
84 | |
---|
85 | $(DIR_OBJ)/%.o : $(DIR_GLOBAL_C)/%.c |
---|
86 | @\ |
---|
87 | $(ECHO) "Compile of $*";\ |
---|
88 | $(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ ;\ |
---|
89 | $(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ ; |
---|
90 | |
---|
91 | #-----[ Environement ]------------------------------------------------------------ |
---|
92 | test_env : |
---|
93 | # ifeq ($(origin TOOLS), undefined) |
---|
94 | # $(error "variable TOOLS is undefined"); |
---|
95 | # endif |
---|
96 | # ifeq ($(origin SOFT), undefined) |
---|
97 | # $(error "variable SOFT is undefined"); |
---|
98 | # endif |
---|
99 | @$(MKDIR) $(DIR_OBJ) $(DIR_BIN) |
---|
100 | |
---|
101 | #-----[ Maintenance ]------------------------------------------------------------- |
---|
102 | clean : |
---|
103 | @\ |
---|
104 | $(ECHO) "Delete temporary files "`$(PWD)`;\ |
---|
105 | $(RM) $(DIR_OBJ) $(DIR_BIN);\ |
---|
106 | $(MAKE) clean_rec DIR_CLEAN=.; |
---|
107 | |
---|
108 | #Clean recursive |
---|
109 | clean_rec : |
---|
110 | @\ |
---|
111 | $(ECHO) "Delete temporary files in directory $(DIR_CLEAN)";\ |
---|
112 | $(RM) -f $(DIR_CLEAN)/*~;\ |
---|
113 | for files in `$(LS) $(DIR_CLEAN)`; do \ |
---|
114 | if $(TEST) -d $(DIR_CLEAN)/$$files; \ |
---|
115 | then \ |
---|
116 | $(MAKE) clean_rec DIR_CLEAN=$(DIR_CLEAN)/$$files; \ |
---|
117 | fi; \ |
---|
118 | done; |
---|
119 | |
---|
120 | #-----[ Help ]-------------------------------------------------------------------- |
---|
121 | help : |
---|
122 | @\ |
---|
123 | $(ECHO) "";\ |
---|
124 | $(ECHO) "List of directive : ";\ |
---|
125 | $(ECHO) " * make : Compile the software";\ |
---|
126 | $(ECHO) " * make clean : Erase all files generates";\ |
---|
127 | $(ECHO) " * make bench_list : View all benchmark";\ |
---|
128 | $(ECHO) " * make bench_exec : Print the file \"$(FILE_BENCH)\" - it's the Workload";\ |
---|
129 | $(ECHO) " * make bench : Compile the Benchmark Suite";\ |
---|
130 | $(ECHO) ""; |
---|