forked from coelacant1/ProtoTracer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
312 lines (219 loc) · 10.9 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#Generated by VisualGDB project wizard.
#Note: VisualGDB will automatically update this file when you add new sources to the project.
#All other changes you make in this file will be preserved.
#Visit http://visualgdb.com/makefiles for more details
#VisualGDB: AutoSourceFiles #<--- remove this line to disable auto-updating of SOURCEFILES and EXTERNAL_LIBS
TARGETNAME := Prototracer
#TARGETTYPE can be APP, STATIC or SHARED
TARGETTYPE := APP
to_lowercase = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
macros-to-preprocessor-directives = $(foreach __macro, $(strip $1), \
$(if $(findstring =,$(__macro)), \
--pd "$(firstword $(subst =, ,$(__macro))) SETA $(subst ",\",$(lastword $(subst =, ,$(__macro))))", \
--pd "$(__macro) SETA 1")) \
CONFIG ?= DEBUG
CONFIGURATION_FLAGS_FILE := $(call to_lowercase,$(CONFIG)).mak
TOOLCHAIN_ROOT ?= $(toolchain_root)
include $(CONFIGURATION_FLAGS_FILE)
#LINKER_SCRIPT defined inside the configuration file (e.g. debug.mak) should override any linker scripts defined in shared .mak files
CONFIGURATION_LINKER_SCRIPT := $(LINKER_SCRIPT)
include $(ADDITIONAL_MAKE_FILES)
ifneq ($(CONFIGURATION_LINKER_SCRIPT),)
LINKER_SCRIPT := $(CONFIGURATION_LINKER_SCRIPT)
endif
ifneq ($(LINKER_SCRIPT),)
ifeq ($(TOOLCHAIN_SUBTYPE),iar)
LDFLAGS += --config $(LINKER_SCRIPT)
else
LDFLAGS += -T$(LINKER_SCRIPT)
endif
endif
ifeq ($(AS),)
AS := as
endif
ifeq ($(AS),as)
AS := $(CC)
ASFLAGS := $(CFLAGS) $(ASFLAGS)
endif
ifeq ($(TOOLCHAIN_SUBTYPE),iar)
CC_DEPENDENCY_FILE_SPECIFIER := --dependencies=m
ASM_DEPENDENCY_FILE_SPECIFIER := && echo >
CXXFLAGS += --c++
COMMONFLAGS += --silent
else ifeq ($(TOOLCHAIN_SUBTYPE),armcc)
CC_DEPENDENCY_FILE_SPECIFIER := --depend
ASM_DEPENDENCY_FILE_SPECIFIER := --depend
USING_KEIL_TOOLCHAIN := 1
else ifeq ($(TOOLCHAIN_SUBTYPE),armclang)
CC_DEPENDENCY_FILE_SPECIFIER := -MD -MF
ASM_DEPENDENCY_FILE_SPECIFIER := --depend
USING_KEIL_TOOLCHAIN := 1
else
CC_DEPENDENCY_FILE_SPECIFIER := -MD -MF
ASM_DEPENDENCY_FILE_SPECIFIER := -MD -MF
endif
ifeq ($(BINARYDIR),)
error:
$(error Invalid configuration, please check your inputs)
endif
SOURCEFILES := Include/Controllers/rpi-led-matrix/lib/bdf-font.cc Include/Controllers/rpi-led-matrix/lib/content-streamer.cc Include/Controllers/rpi-led-matrix/lib/framebuffer.cc Include/Controllers/rpi-led-matrix/lib/gpio.cc Include/Controllers/rpi-led-matrix/lib/graphics.cc Include/Controllers/rpi-led-matrix/lib/hardware-mapping.c Include/Controllers/rpi-led-matrix/lib/led-matrix-c.cc Include/Controllers/rpi-led-matrix/lib/led-matrix.cc Include/Controllers/rpi-led-matrix/lib/multiplex-mappers.cc Include/Controllers/rpi-led-matrix/lib/options-initialize.cc Include/Controllers/rpi-led-matrix/lib/pixel-mapper.cc Include/Controllers/rpi-led-matrix/lib/thread.cc Prototracer.cpp
EXTERNAL_LIBS :=
EXTERNAL_LIBS_COPIED := $(foreach lib, $(EXTERNAL_LIBS),$(BINARYDIR)/$(notdir $(lib)))
CFLAGS += $(COMMONFLAGS)
CXXFLAGS += $(COMMONFLAGS)
ASFLAGS += $(COMMONFLAGS)
LDFLAGS += $(COMMONFLAGS)
CFLAGS += $(addprefix -I,$(INCLUDE_DIRS))
CXXFLAGS += $(addprefix -I,$(INCLUDE_DIRS))
CFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS))
CXXFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS))
ifeq ($(USING_KEIL_TOOLCHAIN),1)
ASFLAGS +=$(call macros-to-preprocesor-directives, $(PREPROCESSOR_MACROS))
else ifeq ($(TOOLCHAIN_SUBTYPE),iar)
ASFLAGS := $(subst --cpu=,--cpu ,$(ASFLAGS))
ASFLAGS := $(subst --fpu=,--fpu ,$(ASFLAGS))
ASFLAGS := $(subst --silent,-S ,$(ASFLAGS))
ASFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS))
else
ASFLAGS += $(addprefix -D,$(PREPROCESSOR_MACROS))
endif
CXXFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS))
CFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS))
LDFLAGS += $(addprefix -framework ,$(MACOS_FRAMEWORKS))
LDFLAGS += $(addprefix -L,$(LIBRARY_DIRS))
ifeq ($(GENERATE_MAP_FILE),1)
ifeq ($(USING_KEIL_TOOLCHAIN),1)
LDFLAGS += --map --list=$(BINARYDIR)/$(basename $(TARGETNAME)).map
else
LDFLAGS += -Wl,-Map=$(BINARYDIR)/$(basename $(TARGETNAME)).map
endif
endif
LIBRARY_LDFLAGS = $(addprefix -l,$(LIBRARY_NAMES))
ifeq ($(IS_LINUX_PROJECT),1)
RPATH_PREFIX := -Wl,--rpath='$$ORIGIN/../
LIBRARY_LDFLAGS += $(EXTERNAL_LIBS)
LIBRARY_LDFLAGS += -Wl,--rpath='$$ORIGIN'
LIBRARY_LDFLAGS += $(addsuffix ',$(addprefix $(RPATH_PREFIX),$(dir $(EXTERNAL_LIBS))))
ifeq ($(TARGETTYPE),SHARED)
CFLAGS += -fPIC
CXXFLAGS += -fPIC
ASFLAGS += -fPIC
LIBRARY_LDFLAGS += -Wl,-soname,$(TARGETNAME)
endif
ifneq ($(LINUX_PACKAGES),)
PACKAGE_CFLAGS := $(foreach pkg,$(LINUX_PACKAGES),$(shell pkg-config --cflags $(pkg)))
PACKAGE_LDFLAGS := $(foreach pkg,$(LINUX_PACKAGES),$(shell pkg-config --libs $(pkg)))
CFLAGS += $(PACKAGE_CFLAGS)
CXXFLAGS += $(PACKAGE_CFLAGS)
LIBRARY_LDFLAGS += $(PACKAGE_LDFLAGS)
endif
else
LIBRARY_LDFLAGS += $(EXTERNAL_LIBS)
endif
LIBRARY_LDFLAGS += $(ADDITIONAL_LINKER_INPUTS)
all_make_files := $(firstword $(MAKEFILE_LIST)) $(CONFIGURATION_FLAGS_FILE) $(ADDITIONAL_MAKE_FILES)
ifeq ($(STARTUPFILES),)
all_source_files := $(SOURCEFILES)
else
all_source_files := $(STARTUPFILES) $(filter-out $(STARTUPFILES),$(SOURCEFILES))
endif
source_obj1 := $(all_source_files:.cpp=.o)
source_obj2 := $(source_obj1:.c=.o)
source_obj3 := $(source_obj2:.s=.o)
source_obj4 := $(source_obj3:.S=.o)
source_obj5 := $(source_obj4:.cc=.o)
source_objs := $(source_obj5:.cxx=.o)
all_objs := $(addprefix $(BINARYDIR)/, $(notdir $(source_objs)))
PRIMARY_OUTPUTS :=
ifeq ($(GENERATE_BIN_FILE),1)
PRIMARY_OUTPUTS += $(BINARYDIR)/$(basename $(TARGETNAME)).bin
endif
ifeq ($(GENERATE_IHEX_FILE),1)
PRIMARY_OUTPUTS += $(BINARYDIR)/$(basename $(TARGETNAME)).ihex
endif
ifeq ($(PRIMARY_OUTPUTS),)
PRIMARY_OUTPUTS := $(BINARYDIR)/$(TARGETNAME)
endif
all: $(PRIMARY_OUTPUTS)
ifeq ($(USING_KEIL_TOOLCHAIN),1)
$(BINARYDIR)/$(basename $(TARGETNAME)).bin: $(BINARYDIR)/$(TARGETNAME)
$(OBJCOPY) --bin $< --output $@
$(BINARYDIR)/$(basename $(TARGETNAME)).ihex: $(BINARYDIR)/$(TARGETNAME)
$(OBJCOPY) --i32 $< --output $@
else ifeq ($(TOOLCHAIN_SUBTYPE),iar)
$(BINARYDIR)/$(basename $(TARGETNAME)).bin: $(BINARYDIR)/$(TARGETNAME)
$(OBJCOPY) --silent --bin $< $@
$(BINARYDIR)/$(basename $(TARGETNAME)).ihex: $(BINARYDIR)/$(TARGETNAME)
$(OBJCOPY) --silent --bin $< $@
else
$(BINARYDIR)/$(basename $(TARGETNAME)).bin: $(BINARYDIR)/$(TARGETNAME)
$(OBJCOPY) -O binary $< $@
$(BINARYDIR)/$(basename $(TARGETNAME)).ihex: $(BINARYDIR)/$(TARGETNAME)
$(OBJCOPY) -O ihex $< $@
endif
EXTRA_DEPENDENCIES :=
ifneq ($(LINKER_SCRIPT),)
EXTRA_DEPENDENCIES += $(LINKER_SCRIPT)
endif
ifeq ($(TARGETTYPE),APP)
$(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTERNAL_LIBS) $(EXTRA_DEPENDENCIES)
ifeq ($(DETACH_CODE_COVERAGE),1)
$(VISUALGDB_DIR)/VisualGDB.exe /decover $@ $(all_objs)
endif
$(LD) -o $@ $(LDFLAGS) $(START_GROUP) $(all_objs) $(LIBRARY_LDFLAGS) $(END_GROUP)
endif
ifeq ($(TARGETTYPE),SHARED)
$(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTERNAL_LIBS) $(EXTRA_DEPENDENCIES)
$(LD) -shared -o $@ $(LDFLAGS) $(START_GROUP) $(all_objs) $(LIBRARY_LDFLAGS) $(END_GROUP)
endif
ifeq ($(TARGETTYPE),STATIC)
$(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTRA_DEPENDENCIES)
$(AR) -r $@ $^
endif
-include $(all_objs:.o=.dep)
clean:
ifeq ($(USE_DEL_TO_CLEAN),1)
cmd /C del /S /Q $(BINARYDIR)
else
rm -rf $(BINARYDIR)
endif
$(BINARYDIR):
mkdir $(BINARYDIR)
#VisualGDB: FileSpecificTemplates #<--- VisualGDB will use the following lines to define rules for source files in subdirectories
$(BINARYDIR)/%.o : %.cpp $(all_make_files) |$(BINARYDIR)
$(CXX) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/%.o : %.c $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/%.o : %.S $(all_make_files) |$(BINARYDIR)
$(AS) $(ASFLAGS) -c $< -o $@ $(ASM_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/%.o : %.s $(all_make_files) |$(BINARYDIR)
$(AS) $(ASFLAGS) -c $< -o $@ $(ASM_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/%.o : %.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/%.o : %.cxx $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER)F $(@:.o=.dep)
#VisualGDB: GeneratedRules #<--- All lines below are auto-generated. Remove this line to suppress auto-generation of file rules.
$(BINARYDIR)/bdf-font.o : Include/Controllers/rpi-led-matrix/lib/bdf-font.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/content-streamer.o : Include/Controllers/rpi-led-matrix/lib/content-streamer.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/framebuffer.o : Include/Controllers/rpi-led-matrix/lib/framebuffer.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/gpio.o : Include/Controllers/rpi-led-matrix/lib/gpio.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/graphics.o : Include/Controllers/rpi-led-matrix/lib/graphics.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/hardware-mapping.o : Include/Controllers/rpi-led-matrix/lib/hardware-mapping.c $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/led-matrix-c.o : Include/Controllers/rpi-led-matrix/lib/led-matrix-c.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/led-matrix.o : Include/Controllers/rpi-led-matrix/lib/led-matrix.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/multiplex-mappers.o : Include/Controllers/rpi-led-matrix/lib/multiplex-mappers.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/options-initialize.o : Include/Controllers/rpi-led-matrix/lib/options-initialize.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/pixel-mapper.o : Include/Controllers/rpi-led-matrix/lib/pixel-mapper.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)
$(BINARYDIR)/thread.o : Include/Controllers/rpi-led-matrix/lib/thread.cc $(all_make_files) |$(BINARYDIR)
$(CC) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ $(CC_DEPENDENCY_FILE_SPECIFIER) $(@:.o=.dep)