aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/os/common/startup/SIMIA32/compilers/GCC/rules.mk
diff options
context:
space:
mode:
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.mk206
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
8OPT = $(USE_OPT)
9COPT = $(USE_COPT)
10CPPOPT = $(USE_CPPOPT)
11
12# Garbage collection
13ifeq ($(USE_LINK_GC),yes)
14 OPT += -ffunction-sections -fdata-sections -fno-common
15 LDOPT := --gc-sections
16else
17 LDOPT := --no-gc-sections
18endif
19
20# Linker extra options
21ifneq ($(USE_LDOPT),)
22 LDOPT := $(LDOPT),$(USE_LDOPT)
23endif
24
25# Link time optimizations
26ifeq ($(USE_LTO),yes)
27 OPT += -flto
28endif
29
30# Output directory and files
31ifeq ($(BUILDDIR),)
32 BUILDDIR = build
33endif
34ifeq ($(BUILDDIR),.)
35 BUILDDIR = build
36endif
37
38# Dependencies directory
39ifeq ($(DEPDIR),)
40 DEPDIR = .dep
41endif
42ifeq ($(DEPDIR),.)
43 DEPDIR = .dep
44endif
45
46OUTFILES = $(BUILDDIR)/$(PROJECT)
47
48# Source files groups and paths
49SRC = $(CSRC)$(CPPSRC)
50SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(SRC)))
51
52# Various directories
53OBJDIR = $(BUILDDIR)/obj
54LSTDIR = $(BUILDDIR)/lst
55
56# Object files groups
57COBJS = $(addprefix $(OBJDIR)/, $(notdir $(CSRC:.c=.o)))
58#CPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(CPPSRC:.cpp=.o)))
59CPPOBJS := $(addprefix $(OBJDIR)/, $(notdir $(patsubst %.cpp, %.o, $(filter %.cpp, $(CPPSRC)))))
60CCOBJS := $(addprefix $(OBJDIR)/, $(notdir $(patsubst %.cc, %.o, $(filter %.cc, $(CPPSRC)))))
61ASMOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o)))
62ASMXOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o)))
63#OBJS = $(ASMXOBJS) $(ASMOBJS) $(COBJS) $(CPPOBJS)
64OBJS = $(ASMXOBJS) $(ASMOBJS) $(COBJS) $(CPPOBJS) $(CCOBJS)
65
66# Paths
67IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
68LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
69
70# Macros
71DEFS = $(DDEFS) $(UDEFS)
72ADEFS = $(DADEFS) $(UADEFS)
73
74# Libs
75LIBS = $(DLIBS) $(ULIBS)
76
77# Various settings
78MCFLAGS =
79ODFLAGS = -x --syms
80ASFLAGS = $(MCFLAGS) $(OPT) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
81ASXFLAGS = $(MCFLAGS) $(OPT) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS)
82CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
83CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
84LDFLAGS = $(MCFLAGS) $(OPT) $(LLIBDIR) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,$(LDOPT)
85
86# Generate dependency information
87ASFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d
88ASXFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d
89CFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d
90CPPFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d
91
92# Paths where to search for sources
93VPATH = $(SRCPATHS)
94
95#
96# Makefile rules
97#
98
99all: PRE_MAKE_ALL_RULE_HOOK $(OBJS) $(OUTFILES) POST_MAKE_ALL_RULE_HOOK
100
101PRE_MAKE_ALL_RULE_HOOK:
102
103POST_MAKE_ALL_RULE_HOOK:
104
105$(OBJS): | PRE_MAKE_ALL_RULE_HOOK $(BUILDDIR) $(OBJDIR) $(LSTDIR) $(DEPDIR)
106
107$(BUILDDIR):
108ifneq ($(USE_VERBOSE_COMPILE),yes)
109 @echo Compiler Options
110 @echo $(CC) -c $(CFLAGS) -I. $(IINCDIR) main.c -o main.o
111 @echo
112endif
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)
125ifeq ($(USE_VERBOSE_COMPILE),yes)
126 @echo
127 $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@
128else
129 @echo Compiling $(<F)
130 @$(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@
131endif
132
133$(CCOBJS) : $(OBJDIR)/%.o : %.cc $(MAKEFILE_LIST)
134ifeq ($(USE_VERBOSE_COMPILE),yes)
135 @echo
136 $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@
137else
138 @echo Compiling $(<F)
139 @$(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@
140endif
141
142$(COBJS) : $(OBJDIR)/%.o : %.c $(MAKEFILE_LIST)
143ifeq ($(USE_VERBOSE_COMPILE),yes)
144 @echo
145 $(CC) -c $(CFLAGS) -I. $(IINCDIR) $< -o $@
146else
147 @echo Compiling $(<F)
148 @$(CC) -c $(CFLAGS) -I. $(IINCDIR) $< -o $@
149endif
150
151$(ASMOBJS) : $(OBJDIR)/%.o : %.s $(MAKEFILE_LIST)
152ifeq ($(USE_VERBOSE_COMPILE),yes)
153 @echo
154 $(AS) -c $(ASFLAGS) -I. $(IINCDIR) $< -o $@
155else
156 @echo Compiling $(<F)
157 @$(AS) -c $(ASFLAGS) -I. $(IINCDIR) $< -o $@
158endif
159
160$(ASMXOBJS) : $(OBJDIR)/%.o : %.S $(MAKEFILE_LIST)
161ifeq ($(USE_VERBOSE_COMPILE),yes)
162 @echo
163 $(CC) -c $(ASXFLAGS) -I. $(IINCDIR) $< -o $@
164else
165 @echo Compiling $(<F)
166 @$(CC) -c $(ASXFLAGS) -I. $(IINCDIR) $< -o $@
167endif
168
169$(BUILDDIR)/$(PROJECT): $(OBJS)
170ifeq ($(USE_VERBOSE_COMPILE),yes)
171 @echo
172 $(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
173else
174 @echo Linking $@
175 @$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
176endif
177
178lib: $(OBJS) $(BUILDDIR)/lib$(PROJECT).a
179
180$(BUILDDIR)/lib$(PROJECT).a: $(OBJS)
181 @$(AR) -r $@ $^
182 @echo
183 @echo Done
184
185clean: 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
195CLEAN_RULE_HOOK:
196
197.PHONY: gcov
198gcov:
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 ***