diff options
Diffstat (limited to 'lib/chibios/os/common/startup/SIMIA32/compilers/GCC/rules.mk')
-rw-r--r-- | lib/chibios/os/common/startup/SIMIA32/compilers/GCC/rules.mk | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/lib/chibios/os/common/startup/SIMIA32/compilers/GCC/rules.mk b/lib/chibios/os/common/startup/SIMIA32/compilers/GCC/rules.mk new file mode 100644 index 000000000..200a6316b --- /dev/null +++ b/lib/chibios/os/common/startup/SIMIA32/compilers/GCC/rules.mk | |||
@@ -0,0 +1,206 @@ | |||
1 | # e200z common makefile scripts and rules. | ||
2 | |||
3 | ############################################################################## | ||
4 | # Processing options coming from the upper Makefile. | ||
5 | # | ||
6 | |||
7 | # Compiler options | ||
8 | OPT = $(USE_OPT) | ||
9 | COPT = $(USE_COPT) | ||
10 | CPPOPT = $(USE_CPPOPT) | ||
11 | |||
12 | # Garbage collection | ||
13 | ifeq ($(USE_LINK_GC),yes) | ||
14 | OPT += -ffunction-sections -fdata-sections -fno-common | ||
15 | LDOPT := --gc-sections | ||
16 | else | ||
17 | LDOPT := --no-gc-sections | ||
18 | endif | ||
19 | |||
20 | # Linker extra options | ||
21 | ifneq ($(USE_LDOPT),) | ||
22 | LDOPT := $(LDOPT),$(USE_LDOPT) | ||
23 | endif | ||
24 | |||
25 | # Link time optimizations | ||
26 | ifeq ($(USE_LTO),yes) | ||
27 | OPT += -flto | ||
28 | endif | ||
29 | |||
30 | # Output directory and files | ||
31 | ifeq ($(BUILDDIR),) | ||
32 | BUILDDIR = build | ||
33 | endif | ||
34 | ifeq ($(BUILDDIR),.) | ||
35 | BUILDDIR = build | ||
36 | endif | ||
37 | |||
38 | # Dependencies directory | ||
39 | ifeq ($(DEPDIR),) | ||
40 | DEPDIR = .dep | ||
41 | endif | ||
42 | ifeq ($(DEPDIR),.) | ||
43 | DEPDIR = .dep | ||
44 | endif | ||
45 | |||
46 | OUTFILES = $(BUILDDIR)/$(PROJECT) | ||
47 | |||
48 | # Source files groups and paths | ||
49 | SRC = $(CSRC)$(CPPSRC) | ||
50 | SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(SRC))) | ||
51 | |||
52 | # Various directories | ||
53 | OBJDIR = $(BUILDDIR)/obj | ||
54 | LSTDIR = $(BUILDDIR)/lst | ||
55 | |||
56 | # Object files groups | ||
57 | COBJS = $(addprefix $(OBJDIR)/, $(notdir $(CSRC:.c=.o))) | ||
58 | #CPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(CPPSRC:.cpp=.o))) | ||
59 | CPPOBJS := $(addprefix $(OBJDIR)/, $(notdir $(patsubst %.cpp, %.o, $(filter %.cpp, $(CPPSRC))))) | ||
60 | CCOBJS := $(addprefix $(OBJDIR)/, $(notdir $(patsubst %.cc, %.o, $(filter %.cc, $(CPPSRC))))) | ||
61 | ASMOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o))) | ||
62 | ASMXOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o))) | ||
63 | #OBJS = $(ASMXOBJS) $(ASMOBJS) $(COBJS) $(CPPOBJS) | ||
64 | OBJS = $(ASMXOBJS) $(ASMOBJS) $(COBJS) $(CPPOBJS) $(CCOBJS) | ||
65 | |||
66 | # Paths | ||
67 | IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR)) | ||
68 | LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) | ||
69 | |||
70 | # Macros | ||
71 | DEFS = $(DDEFS) $(UDEFS) | ||
72 | ADEFS = $(DADEFS) $(UADEFS) | ||
73 | |||
74 | # Libs | ||
75 | LIBS = $(DLIBS) $(ULIBS) | ||
76 | |||
77 | # Various settings | ||
78 | MCFLAGS = | ||
79 | ODFLAGS = -x --syms | ||
80 | ASFLAGS = $(MCFLAGS) $(OPT) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS) | ||
81 | ASXFLAGS = $(MCFLAGS) $(OPT) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS) | ||
82 | CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS) | ||
83 | CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS) | ||
84 | LDFLAGS = $(MCFLAGS) $(OPT) $(LLIBDIR) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,$(LDOPT) | ||
85 | |||
86 | # Generate dependency information | ||
87 | ASFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d | ||
88 | ASXFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d | ||
89 | CFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d | ||
90 | CPPFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d | ||
91 | |||
92 | # Paths where to search for sources | ||
93 | VPATH = $(SRCPATHS) | ||
94 | |||
95 | # | ||
96 | # Makefile rules | ||
97 | # | ||
98 | |||
99 | all: PRE_MAKE_ALL_RULE_HOOK $(OBJS) $(OUTFILES) POST_MAKE_ALL_RULE_HOOK | ||
100 | |||
101 | PRE_MAKE_ALL_RULE_HOOK: | ||
102 | |||
103 | POST_MAKE_ALL_RULE_HOOK: | ||
104 | |||
105 | $(OBJS): | PRE_MAKE_ALL_RULE_HOOK $(BUILDDIR) $(OBJDIR) $(LSTDIR) $(DEPDIR) | ||
106 | |||
107 | $(BUILDDIR): | ||
108 | ifneq ($(USE_VERBOSE_COMPILE),yes) | ||
109 | @echo Compiler Options | ||
110 | @echo $(CC) -c $(CFLAGS) -I. $(IINCDIR) main.c -o main.o | ||
111 | @echo | ||
112 | endif | ||
113 | @mkdir -p $(BUILDDIR) | ||
114 | |||
115 | $(OBJDIR): | ||
116 | @mkdir -p $(OBJDIR) | ||
117 | |||
118 | $(LSTDIR): | ||
119 | @mkdir -p $(LSTDIR) | ||
120 | |||
121 | $(DEPDIR): | ||
122 | @mkdir -p $(DEPDIR) | ||
123 | |||
124 | $(CPPOBJS) : $(OBJDIR)/%.o : %.cpp $(MAKEFILE_LIST) | ||
125 | ifeq ($(USE_VERBOSE_COMPILE),yes) | ||
126 | @echo | ||
127 | $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@ | ||
128 | else | ||
129 | @echo Compiling $(<F) | ||
130 | @$(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@ | ||
131 | endif | ||
132 | |||
133 | $(CCOBJS) : $(OBJDIR)/%.o : %.cc $(MAKEFILE_LIST) | ||
134 | ifeq ($(USE_VERBOSE_COMPILE),yes) | ||
135 | @echo | ||
136 | $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@ | ||
137 | else | ||
138 | @echo Compiling $(<F) | ||
139 | @$(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@ | ||
140 | endif | ||
141 | |||
142 | $(COBJS) : $(OBJDIR)/%.o : %.c $(MAKEFILE_LIST) | ||
143 | ifeq ($(USE_VERBOSE_COMPILE),yes) | ||
144 | @echo | ||
145 | $(CC) -c $(CFLAGS) -I. $(IINCDIR) $< -o $@ | ||
146 | else | ||
147 | @echo Compiling $(<F) | ||
148 | @$(CC) -c $(CFLAGS) -I. $(IINCDIR) $< -o $@ | ||
149 | endif | ||
150 | |||
151 | $(ASMOBJS) : $(OBJDIR)/%.o : %.s $(MAKEFILE_LIST) | ||
152 | ifeq ($(USE_VERBOSE_COMPILE),yes) | ||
153 | @echo | ||
154 | $(AS) -c $(ASFLAGS) -I. $(IINCDIR) $< -o $@ | ||
155 | else | ||
156 | @echo Compiling $(<F) | ||
157 | @$(AS) -c $(ASFLAGS) -I. $(IINCDIR) $< -o $@ | ||
158 | endif | ||
159 | |||
160 | $(ASMXOBJS) : $(OBJDIR)/%.o : %.S $(MAKEFILE_LIST) | ||
161 | ifeq ($(USE_VERBOSE_COMPILE),yes) | ||
162 | @echo | ||
163 | $(CC) -c $(ASXFLAGS) -I. $(IINCDIR) $< -o $@ | ||
164 | else | ||
165 | @echo Compiling $(<F) | ||
166 | @$(CC) -c $(ASXFLAGS) -I. $(IINCDIR) $< -o $@ | ||
167 | endif | ||
168 | |||
169 | $(BUILDDIR)/$(PROJECT): $(OBJS) | ||
170 | ifeq ($(USE_VERBOSE_COMPILE),yes) | ||
171 | @echo | ||
172 | $(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ | ||
173 | else | ||
174 | @echo Linking $@ | ||
175 | @$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ | ||
176 | endif | ||
177 | |||
178 | lib: $(OBJS) $(BUILDDIR)/lib$(PROJECT).a | ||
179 | |||
180 | $(BUILDDIR)/lib$(PROJECT).a: $(OBJS) | ||
181 | @$(AR) -r $@ $^ | ||
182 | @echo | ||
183 | @echo Done | ||
184 | |||
185 | clean: CLEAN_RULE_HOOK | ||
186 | @echo Cleaning | ||
187 | @echo - $(DEPDIR) | ||
188 | @-rm -fR $(DEPDIR)/* $(BUILDDIR)/* 2>/dev/null | ||
189 | @-if [ -d "$(DEPDIR)" ]; then rmdir -p --ignore-fail-on-non-empty $(subst ./,,$(DEPDIR)) 2>/dev/null; fi | ||
190 | @echo - $(BUILDDIR) | ||
191 | @-if [ -d "$(BUILDDIR)" ]; then rmdir -p --ignore-fail-on-non-empty $(subst ./,,$(BUILDDIR)) 2>/dev/null; fi | ||
192 | @echo | ||
193 | @echo Done | ||
194 | |||
195 | CLEAN_RULE_HOOK: | ||
196 | |||
197 | .PHONY: gcov | ||
198 | gcov: | ||
199 | $(COV) -u -b -o $(BUILDDIR)/obj $(GCOVSRC) | ||
200 | |||
201 | # | ||
202 | # Include the dependency files, should be the last of the makefile | ||
203 | # | ||
204 | -include $(wildcard $(DEPDIR)/*) | ||
205 | |||
206 | # *** EOF *** | ||