1 # FreeEMS - the open source engine management system
3 # Copyright 2008, 2009, 2010 Fred Cooke
5 # This Makefile is part of the FreeEMS project.
7 # FreeEMS software is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # FreeEMS software is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
20 # We ask that if you make any changes to this file you email them upstream to
21 # us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
23 # Thank you for choosing FreeEMS to run your engine!
28 ################################################################################
30 # About This Makefile #
32 # This makefile incorporates many non-standard features. In particular, it #
33 # is inspired by Maven 2 and it's highly disciplined release mechanism. By #
34 # automating the release process as much as possible the chance of human #
35 # error is minimised. As much as possible, reuse is employed to keep bugs #
36 # from being introduced when changes are made. Rather than compiling from #
37 # C source files directly to object files, the build is, by default, done #
38 # in three stages, C to pre-processed C, pre-processed C to assembly, and #
39 # assembly to object files. Linking is also a little different with two #
40 # variants available, with and without garbage collection. Target device #
41 # memory usage statistics are available and generated by default when the #
42 # all target is called. Finally, extensive debug information can be #
43 # generated with a single make call. #
45 ################################################################################
50 ################################################################################
51 # All Fixed Variables #
52 ################################################################################
56 VERSION
= 0.1.1-XGATED
57 PREVIOUSVERSION
= 0.1.0
59 LABEL
= $(OUTPREFIX
)-$(VERSION
)
63 # Windows uses backslash
65 # Windows mkdir does not accept -p
67 # Windows echo repeats " symbols (Q stands for quote...)
76 RELEASEDIR = ../firmware
77 DISTRIBUTIONDIR = ../../$(LABEL)
78 DOXYDOCDIR = ../docs/doxygen-html
79 MAINDIR = freeems-vanilla
86 PPCDIR = preprocessedc
87 XGASMDIR = $(ASMDIR)$(PATHSEP)xgate
88 XGOBJDIR = $(OBJDIR)$(PATHSEP)xgate
90 # Release tag message file
91 RELTAG = $(OUTDIR)/gitTagMessage.txt
92 TAGNAME = $(OUTDIR)/gitTagName.txt
94 # Program prefixes, for the main cpu and for the xgate coprocessor
103 COPY = $(PREFIX)objcopy
104 DUMP = $(PREFIX)objdump
106 RE = $(PREFIX)readelf
113 ################################################################################
115 ################################################################################
118 # Indirect dependencies - any header change means a full recompile. This can be
119 # improved upon and made more specific. GCC actually has a function to output a
120 # dependency set for a C source file, maybe we should use that?
126 CINCS = injectorISR.c
127 FLASHH = flashWrite.h
128 ASMH = 9S12XDP512asm.s
129 LOOKUPH = tableLookup.h
130 WMFILE = Makefile.windows
131 ISRSH = commsISRs.h injectionISRs.h
132 COMMSH = commsCore.h blockDetailsLookup.h
133 LINKER = memory.x regions.x hc9s12xdp512elfb.x
134 GLOBALH1 = freeEMS.h 9S12XDP512.h memory.h globalConstants.h structs.h
135 GLOBALH2 = globalDefines.h errorDefines.h TunableConfigs.h FixedConfigs.h
136 FUELH = fuelAndIgnitionCalcs.h derivedVarsGenerator.h coreVarsGenerator.h
137 RPMH = Simple.h NipponDenso.h LT1-360-8.h Subaru-36-2-2-2.h MissingTeeth.h MiataNB.h
139 # Let's keep this to a bare minimum! If you write ASM code
140 # please provide an matching alternate C implementation too.
141 HANDASMS = flashBurn.s
144 # .c files from inc/ should be included here as deps for the parts they are relied on by!!
145 ALLHEADERS1 = $(GLOBALH1) $(COMMSH) $(ISRSH) $(UTILH) $(RPMH) $(FLASHH)
146 ALLHEADERS2 = $(GLOBALH2) $(FUELH) $(MAINH) $(INITH) $(ISRH) $(LOOKUPH)
147 ALLH1 = $(patsubst %.h,$(INCDIR)/%.h,$(ALLHEADERS1))
148 ALLH2 = $(patsubst %.h,$(INCDIR)/%.h,$(ALLHEADERS2))
149 ALLH3 = $(patsubst %.c,$(INCDIR)/%.c,$(CINCS))
150 ALLH4 = $(LINKER) $(MFILE) $(INCDIR)/$(ASMH)
151 ALLH = $(ALLH1) $(ALLH2) $(ALLH3) $(ALLH4)
153 # Warning : do not include .c files from inc/ as they are
154 # included into the other C files and automatically compiled.
157 FIXEDCLASSES = FixedConfig1.c FixedConfig2.c
158 LOOKUPCLASSES1 = IATTransferTable.c CHTTransferTable.c
159 LOOKUPCLASSES2 = MAFTransferTable.c TestTransferTable.c
160 FUELCLASSES = FuelTables.c FuelTables2.c
161 TIMECLASSES = TimingTables.c TimingTables2.c
162 TUNECLASSES = TunableConfig.c TunableConfig2.c
165 UTILCLASSES = tableLookup.c init.c utils.c globalConstants.c
166 MATHCLASSES = coreVarsGenerator.c derivedVarsGenerator.c fuelAndIgnitionCalcs.c
167 COMCLASSES = flashWrite.c commsCore.c blockDetailsLookup.c
168 ISRCLASSES = interrupts.c injectionISRs.c ignitionISRs.c commsISRs.c realtimeISRs.c miscISRs.c xgateVectors.c
170 # All but the engine position/RPM combined here
171 SOURCE = freeEMS.c staticInit.c main.c $(UTILCLASSES) $(MATHCLASSES) $(COMCLASSES) $(ISRCLASSES)
172 DATA = $(FIXEDCLASSES) $(LOOKUPCLASSES1) $(LOOKUPCLASSES2) $(FUELCLASSES) $(TIMECLASSES) $(TUNECLASSES)
173 CLASSES = $(SOURCE) $(DATA)
175 # Engine position/RPM here
176 RPMCLASSES = Simple.c NipponDenso.c LT1-360-8.c Subaru-36-2-2-2.c MissingTeeth.c MiataNB.c
177 # future rpm = NissanRB2X.c NissanSR20.c MiataNA.c etc... Insert your file above and get coding!
182 PREPROCESSED = $(patsubst %.c,$(PPCDIR)/%.pp.c,$(CLASSES))
183 ASSEMBLIES = $(patsubst %.c,$(ASMDIR)/%.s,$(CLASSES))
184 OBJECTS = $(patsubst %.c,$(OBJDIR)/%.o,$(CLASSES)) $(patsubst %.s,$(OBJDIR)/%.o,$(HANDASMS))
185 DUMPS = $(patsubst %.c,$(BUGDIR)/%.dmp,$(CLASSES)) $(patsubst %.s,$(BUGDIR)/%.dmp,$(HANDASMS))
186 XGOBJECTS = $(patsubst %.s,$(XGOBJDIR)/%.o,$(XGASMSRCS))
188 # Convert RPM extensions
189 PREPROCESSEDRPM = $(patsubst %.c,$(PPCDIR)/%.pp.c,$(RPMCLASSES))
190 ASSEMBLIESRPM = $(patsubst %.c,$(ASMDIR)/%.s,$(RPMCLASSES))
191 OBJECTSRPM = $(patsubst %.c,$(OBJDIR)/%.o,$(RPMCLASSES)) #$(patsubst %.s,$(OBJDIR)/%.o,$(RPMHANDASMS))
192 DUMPSRPM = $(patsubst %.c,$(BUGDIR)/%.dmp,$(RPMCLASSES)) #$(patsubst %.s,$(BUGDIR)/%.dmp,$(RPMHANDASMS))
194 # Convert to output files for source
195 ALLELFSC = $(patsubst %.c,$(OUTDIR)/$(LABEL)-%.elf,$(RPMCLASSES))
196 ALLELFSASM = #$(patsubst %.s,$(OUTDIR)/$(LABEL)-%.elf,$(RPMHANDASMS))
197 ALLDMPSC = $(patsubst %.c,$(BUGDIR)/$(LABEL)-%.dmp,$(RPMCLASSES))
198 ALLDMPSASM = #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.dmp,$(RPMHANDASMS))
199 ALLMAPSC = $(patsubst %.c,$(BUGDIR)/$(LABEL)-%.map,$(RPMCLASSES))
200 ALLMAPSASM = #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.map,$(RPMHANDASMS))
201 ALLREADC = $(patsubst %.c,$(BUGDIR)/$(LABEL)-%.ree,$(RPMCLASSES))
202 ALLREADASM = #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.ree,$(RPMHANDASMS))
203 ALLS19SC = $(patsubst %.c,$(S19DIR)/$(LABEL)-%.s19,$(RPMCLASSES))
204 ALLS19SASM = #$(patsubst %.s,$(S19DIR)/$(LABEL)-%.s19,$(RPMHANDASMS))
206 # Convert to output files for as-is variants
207 ALLELFS = $(ALLELFSC) $(ALLELFSASM)
208 ALLDMPS = $(ALLDMPSC) $(ALLDMPSASM)
209 ALLMAPS = $(ALLMAPSC) $(ALLMAPSASM)
210 ALLREAD = $(ALLREADC) $(ALLREADASM)
211 ALLS19S = $(ALLS19SC) $(ALLS19SASM)
212 ALLSIZES = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt,$(ALLS19S))
213 ALLDUMMY = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt.dummy,$(ALLS19S))
214 ALLMD5S = $(patsubst $(S19DIR)/%,$(DISTRIBUTIONDIR)/%.md5,$(ALLS19S))
215 ALLSHA1S = $(patsubst $(S19DIR)/%,$(DISTRIBUTIONDIR)/%.sha1,$(ALLS19S))
216 ALLS19RELS = $(patsubst $(S19DIR)/%,$(RELEASEDIR)/%,$(ALLS19S))
217 ALLS19ZIPS = $(patsubst $(S19DIR)/%,$(DISTRIBUTIONDIR)/%.zip,$(ALLS19S))
219 # Convert to output files for GC variants
220 GCDELFSC = $(patsubst %.c,$(OUTDIR)/$(LABEL)-%.gc.elf,$(RPMCLASSES))
221 GCDELFSASM = #$(patsubst %.s,$(OUTDIR)/$(LABEL)-%.gc.elf,$(RPMHANDASMS))
222 GCDS19SC = $(patsubst %.c,$(S19DIR)/$(LABEL)-%.gc.s19,$(RPMCLASSES))
223 GCDS19SASM = #$(patsubst %.s,$(S19DIR)/$(LABEL)-%.gc.s19,$(RPMHANDASMS))
224 GCDELFS = $(GCDELFSC) $(GCDELFSASM)
225 GCDS19S = $(GCDS19SC) $(GCDELFSASM)
226 GCDSIZES = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt,$(GCDS19S))
227 GCDDUMMY = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt.dummy,$(GCDS19S))
228 GCDMD5S = $(patsubst $(S19DIR)/%,$(DISTRIBUTIONDIR)/%.md5,$(GCDS19S))
229 GCDSHA1S = $(patsubst $(S19DIR)/%,$(DISTRIBUTIONDIR)/%.sha1,$(GCDS19S))
230 GCDS19RELS = $(patsubst $(S19DIR)/%,$(RELEASEDIR)/%,$(GCDS19S))
231 GCDS19ZIPS = $(patsubst $(S19DIR)/%,$(DISTRIBUTIONDIR)/%.zip,$(GCDS19S))
236 ################################################################################
237 # All Command Line Options #
238 ################################################################################
241 # M68hc1x GCC Options we may want : -minmax -mlong-calls
243 # http://www.gnu.org/software/m68hc11/m68hc11_gcc.html shows code size with different options used
244 # include debug info, optimise , 16 bit ints, hcs12 platform
245 GCCOPTS1 = -g -Wall -Werror -Winline -O -m68hcs12 -mshort -ffunction-sections
246 GCCOPTS2 = -fomit-frame-pointer -msoft-reg-count=8 -mauto-incdec -fsigned-char
247 GCCOPTS = $(GCCOPTS1) $(GCCOPTS2)
248 # -ffunction-sections option splits out the functions such that the garbage collection can get
249 # them on a per section basis. I'm not sure, but this could be harmful to paged code so may
250 # have to review this at a later date perhaps splitting paged functions from nonpaged ones.
252 # pass to linker, link for hc12
253 # The vectors address in the linker options is the VMA address and must be short form 0xF710, not a paged address.
254 LINKOPTS = -no-warn-mismatch,-defsym,vectors_addr=0xF710,-m,m68hc12elfb,-T,hc9s12xdp512elfb.x
255 LINKOPTSGC = -no-warn-mismatch,--gc-sections,--print-gc-sections,-defsym,vectors_addr=0xF710,-m,m68hc12elfb,-T,hc9s12xdp512elfb.x
256 # Use this to get a map dump when the linker fails in a confusing way : --print-map
258 # If using the below option for paged flash, the ADDRESS_TYPE
259 # field in the freeEMSloader script should be updated to match.
260 COPYOPTS = --output-target=srec \
261 --change-section-lma .fixedconf1+0xFD4000 \
262 --change-section-lma .fixedconf2+0xFD4000 \
263 --change-section-lma .text1+0xFD4000 \
264 --change-section-lma .text+0xFEC000 \
265 --change-section-lma .data+0xFEC000 \
266 --change-section-lma .vectors+0xFEC000 \
267 --change-section-lma .rodata+0xFEC000 \
268 --only-section=.fixedconf1 \
269 --only-section=.fixedconf2 \
270 --only-section=.text \
271 --only-section=.text1 \
272 --only-section=.data \
273 --only-section=.vectors \
274 --only-section=.rodata \
275 --change-section-lma .ppageF8=0xF88000 \
276 --change-section-lma .fpageF9=0xF98000 \
277 --change-section-lma .dpageF9=0xF9A000 \
278 --change-section-lma .ppageFE=0xFE8000 \
279 --only-section=.ppageF8 \
280 --only-section=.fpageF9 \
281 --only-section=.dpageF9 \
282 --only-section=.ppageFE \
283 --change-section-lma .fpageFA=0xFA8000 \
284 --change-section-lma .dpageFA=0xFAA000 \
285 --change-section-lma .fpageFB=0xFB8000 \
286 --change-section-lma .dpageFB1=0xFBA000 \
287 --change-section-lma .dpageFB2=0xFBA400 \
288 --change-section-lma .dpageFB3=0xFBA800 \
289 --change-section-lma .dpageFB4=0xFBAC00 \
290 --change-section-lma .dpageFB5=0xFBB000 \
291 --change-section-lma .dpageFB6=0xFBB400 \
292 --change-section-lma .dpageFB7=0xFBB800 \
293 --change-section-lma .dpageFB8=0xFBBC00 \
294 --change-section-lma .fpageFC=0xFC8000 \
295 --change-section-lma .dpageFC=0xFCA000 \
296 --only-section=.dpageFA \
297 --only-section=.fpageFA \
298 --only-section=.dpageFB1 \
299 --only-section=.dpageFB2 \
300 --only-section=.dpageFB3 \
301 --only-section=.dpageFB4 \
302 --only-section=.dpageFB5 \
303 --only-section=.dpageFB6 \
304 --only-section=.dpageFB7 \
305 --only-section=.dpageFB8 \
306 --only-section=.fpageFB \
307 --only-section=.dpageFC \
308 --only-section=.fpageFC
309 # --change-section-lma .ppageFD=0xFD8000 \
310 # --change-section-lma .ppageFF=0xFF8000 \
311 # --only-section=.ppageFD \ This is left here for clarity only (equivalent to text1 but paged)
312 # --only-section=.ppageFF This is left here for clarity only (equivalent to text but paged)
313 # Changes to the above options should be reflected in memory.x and memory.h also!
315 # The following flash areas can only be used once Sean has written his loader app :
316 # --only-section=.ppageE0 \
317 # --only-section=.ppageE1 \
318 # --only-section=.ppageE2 \
319 # --only-section=.ppageE3 \
320 # --only-section=.ppageE4 \
321 # --only-section=.ppageE5 \
322 # --only-section=.ppageE6 \
323 # --only-section=.ppageE7 \
324 # --only-section=.ppageE8 \
325 # --only-section=.ppageE9 \
326 # --only-section=.ppageEA \
327 # --only-section=.ppageEB \
328 # --only-section=.ppageEC \
329 # --only-section=.ppageED \
330 # --only-section=.ppageEE \
331 # --only-section=.ppageEF \
332 # --only-section=.ppageF0 \
333 # --only-section=.ppageF1 \
334 # --only-section=.ppageF2 \
335 # --only-section=.ppageF3 \
336 # --only-section=.ppageF4 \
337 # --only-section=.ppageF5 \
338 # --only-section=.ppageF6 \
339 # --only-section=.ppageF7 \
340 # --change-section-lma .ppageE0=0xE08000 \
341 # --change-section-lma .ppageE1=0xE18000 \
342 # --change-section-lma .ppageE2=0xE28000 \
343 # --change-section-lma .ppageE3=0xE38000 \
344 # --change-section-lma .ppageE4=0xE48000 \
345 # --change-section-lma .ppageE5=0xE58000 \
346 # --change-section-lma .ppageE6=0xE68000 \
347 # --change-section-lma .ppageE7=0xE78000 \
348 # --change-section-lma .ppageE8=0xE88000 \
349 # --change-section-lma .ppageE9=0xE98000 \
350 # --change-section-lma .ppageEA=0xEA8000 \
351 # --change-section-lma .ppageEB=0xEB8000 \
352 # --change-section-lma .ppageEC=0xEC8000 \
353 # --change-section-lma .ppageED=0xED8000 \
354 # --change-section-lma .ppageEE=0xEE8000 \
355 # --change-section-lma .ppageEF=0xEF8000 \
356 # --change-section-lma .ppageF0=0xF08000 \
357 # --change-section-lma .ppageF1=0xF18000 \
358 # --change-section-lma .ppageF2=0xF28000 \
359 # --change-section-lma .ppageF3=0xF38000 \
360 # --change-section-lma .ppageF4=0xF48000 \
361 # --change-section-lma .ppageF5=0xF58000 \
362 # --change-section-lma .ppageF6=0xF68000 \
363 # --change-section-lma .ppageF7=0xF78000 \
368 @echo $(Q)################################################################################$(Q)
369 @echo $(Q)# Dependency And Target Summary #$(Q)
370 @echo $(Q)################################################################################$(Q)
372 @echo $(Q)# Common targets: #$(Q)
374 @echo $(Q)# 1) help - This comment block #$(Q)
375 @echo $(Q)# 2) all - Executes alldebug, slow, slowgc and size #$(Q)
376 @echo $(Q)# 3) dirs - Creates all of the directories required to build #$(Q)
377 @echo $(Q)# 4) fast - Compiles direct to object code and links once with no debug #$(Q)
378 @echo $(Q)# 5) slow - Three stage compilation with assembly retained #$(Q)
379 @echo $(Q)# 6) slowgc - As above, but with garbage collection during linking #$(Q)
380 @echo $(Q)# 7) alldebug - Generates all debug output files #$(Q)
381 @echo $(Q)# 8) install - Not yet implemented #$(Q)
382 @echo $(Q)# 9) release - Performs a full release build #$(Q)
383 @echo $(Q)# 10) clean - Removes all files and directories generated by building #$(Q)
385 @echo $(Q)# Second level targets: #$(Q)
387 @echo $(Q)# Stage one: #$(Q)
389 @echo $(Q)# 1) preprocess - run the C preprocessor over the raw C files #$(Q)
390 @echo $(Q)# 2) compile - compile the preprocessed C into assembly #$(Q)
391 @echo $(Q)# 3) assemble - assemble the assembly files into object files #$(Q)
393 @echo $(Q)# Stage two #$(Q)
395 @echo $(Q)# 1) link - Generate ELFs objects #$(Q)
396 @echo $(Q)# 2) gclink - As above, but with garbage collection #$(Q)
397 @echo $(Q)# 3) s19 - Create s19s from elfs #$(Q)
398 @echo $(Q)# 4) gcs19 - Create s19s from gc elfs #$(Q)
399 @echo $(Q)# 5) sizes - Calculate the approximate s19 sizes #$(Q)
400 @echo $(Q)# 6) gcsizes - Calculate the approximate gc s19 sizes #$(Q)
402 @echo $(Q)# Stage three: #$(Q)
404 @echo $(Q)# 1) maps - Memory map files #$(Q)
405 @echo $(Q)# 2) rees - Readelf dumps #$(Q)
406 @echo $(Q)# 3) elfdmps - Classic objdump output for final elfs #$(Q)
407 @echo $(Q)# 4) objdmps - Classic objdump output for each object file #$(Q)
409 @echo $(Q)# When doing a full build the following steps are taken: #$(Q)
411 @echo $(Q)# 1) Pre-process all of the C files #$(Q)
412 @echo $(Q)# 2) Compile all preprocessed C files into assembly files #$(Q)
413 @echo $(Q)# 3) Assemble all assembly files into object files #$(Q)
414 @echo $(Q)# 4) Link each decoder without garbage collection #$(Q)
415 @echo $(Q)# 5) Produce a memory map for each elf #$(Q)
416 @echo $(Q)# 6) Produce a readelf dump for each elf #$(Q)
417 @echo $(Q)# 7) Dump the contents of each decoders elf #$(Q)
418 @echo $(Q)# 8) Dump the contents of all object files #$(Q)
419 @echo $(Q)# 9) Link each decoder with garbage collection and reporting turned on #$(Q)
420 @echo $(Q)# 10) Produce an s19 loadable firmware file for each elf #$(Q)
421 @echo $(Q)# 11) Measure each binary image approximately #$(Q)
422 @echo $(Q)# 12) Measure each decoder object file #$(Q)
423 @echo $(Q)# 13) Measure each other object file and summarise #$(Q)
425 @echo $(Q)# The release target: #$(Q)
427 @echo $(Q)# This target is purely for use by lead developers to produce a file set #$(Q)
428 @echo $(Q)# that is suitable for release and distribution to users and interested #$(Q)
429 @echo $(Q)# parties. The steps performed are listed below: #$(Q)
431 @echo $(Q)# 1) Checks that the repository is consistent #$(Q)
432 @echo $(Q)# 2) Performs a full clean #$(Q)
433 @echo $(Q)# 3) Removes the previous release files #$(Q)
434 @echo $(Q)# 4) Removes the doxygen files #$(Q)
435 @echo $(Q)# 5) Builds binaries for each decoder type #$(Q)
436 @echo $(Q)# 6) Copies the binaries into the release directory #$(Q)
437 @echo $(Q)# 7) Generates a new doxygen site #$(Q)
438 @echo $(Q)# 8) Performs a full clean #$(Q)
439 @echo $(Q)# 9) Commits the release files #$(Q)
440 @echo $(Q)# 10) Asks for a tag name and tag message #$(Q)
441 @echo $(Q)# 11) Tags the release at the automatic commit point #$(Q)
442 @echo $(Q)# 12) Generates md5 and sha1 checksums into the distribution directory #$(Q)
443 @echo $(Q)# 13) Zips the binaries into the distribution directory #$(Q)
444 @echo $(Q)# 14) Zips the doxygen site into the distribution directory #$(Q)
445 @echo $(Q)# 15) Zips the documentation into the distribution directory #$(Q)
446 @echo $(Q)# 16) Zips the repository into the distribution directory #$(Q)
447 @echo $(Q)# 17) Zips the source code into the distribution directory #$(Q)
449 @echo $(Q)# At that point the developer in charge of release has only to upload #$(Q)
450 @echo $(Q)# the files found in the distribution directory to appropriate locations #$(Q)
451 @echo $(Q)# and publicise the fact that a new release has been performed! This #$(Q)
452 @echo $(Q)# automation removes most opportunity for mistakes and makes release #$(Q)
453 @echo $(Q)# quality consistent between each successive release cycle! #$(Q)
455 @echo $(Q)# Unlisted targets: #$(Q)
457 @echo $(Q)# Additionally any of the output files can be used as a target directly. #$(Q)
458 @echo $(Q)# This is perfect for building only what is required for a specific s19. #$(Q)
459 @echo $(Q)# It is also perfect for working with a single file as you don't have to #$(Q)
460 @echo $(Q)# wait for other unrelated things to build first nor do you have to wait #$(Q)
461 @echo $(Q)# for other files to continue building after yours is successful. Before #$(Q)
462 @echo $(Q)# using individual output files for targets, please run 'make dirs'. #$(Q)
464 @echo $(Q)################################################################################$(Q)
469 ################################################################################
470 # All Target Dependencies #
471 ################################################################################
474 # Build everything the long way
475 all: alldebug gcsizes sizes size
476 # Single stage compilation
477 fast: single sizes size
478 # Multi stage compilation
480 # Multi stage compilation with garbage collection
482 # Clean all except release
483 clean: cleanasm cleanobj cleanout cleanppc cleans19 cleandebug
485 alldebug: maps rees elfdmps objdmps
486 # Load the s19 of your choice
487 #install: clean fast loader
489 release: relprep relbuild relperf relpack1 relpack2
490 relprep: testgit clean cleanrelease cleandoxy
491 relbuild: gendoxy s19rel s19relgc
492 relperf: relcommit tagrelease
493 relpack1: md5sums md5sumsgc sha1sums sha1sumsgc s19zips s19zipsgc
494 relpack2: zipsite zipdocs zipmain zipsrc
499 ################################################################################
500 # Debug Target Definitions #
501 ################################################################################
505 @echo $(Q)################################################################################$(Q)
506 @echo $(Q)# Generating memory maps.... #$(Q)
507 @echo $(Q)################################################################################$(Q)
509 maps: link $(BUGDIR) mapsmsg $(ALLMAPS)
511 $(ALLMAPS): $(BUGDIR)/%.map: $(OUTDIR)/%.elf
516 @echo $(Q)################################################################################$(Q)
517 @echo $(Q)# Reading all elf files... #$(Q)
518 @echo $(Q)################################################################################$(Q)
520 rees: link $(BUGDIR) reesmsg $(ALLREAD)
522 $(ALLREAD): $(BUGDIR)/%.ree: $(OUTDIR)/%.elf
527 @echo $(Q)################################################################################$(Q)
528 @echo $(Q)# Dumping all elf files... #$(Q)
529 @echo $(Q)################################################################################$(Q)
531 elfdmps: link $(BUGDIR) elfdmpsmsg $(ALLDMPS)
533 $(ALLDMPS): $(BUGDIR)/%.dmp: $(OUTDIR)/%.elf
534 $(DUMP) -spSd $< > $@
538 @echo $(Q)################################################################################$(Q)
539 @echo $(Q)# Dumping all object files.... #$(Q)
540 @echo $(Q)################################################################################$(Q)
542 objdmps: assemble $(BUGDIR) objdmpmsg $(DUMPS) $(DUMPSRPM)
544 $(DUMPS) $(DUMPSRPM): $(BUGDIR)/%.dmp: $(OBJDIR)/%.o
545 $(DUMP) -spSd $< > $@
550 ################################################################################
551 # Fast Single Stage Compile Target Definition #
552 ################################################################################
556 # TODO fast compile and figure out overlapping dependencies...
561 ################################################################################
562 # Link and Copy Target Definitions #
563 ################################################################################
567 @echo $(Q)################################################################################$(Q)
568 @echo $(Q)# Linking the Objects into an ELF... #$(Q)
569 @echo $(Q)################################################################################$(Q)
571 link: assemble $(OUTDIR) linkmsg $(ALLELFS)
573 # link the object files into an elf executable
574 $(ALLELFS): $(OUTDIR)/$(LABEL)-%.elf: $(OBJDIR)/%.o $(OBJECTS) $(XGOBJECTS)
575 @echo $(Q)################################################################################$(Q)
576 @echo $(Q)# Linking $@ ...$(Q)
577 @echo $(Q)################################################################################$(Q)
578 $(GCC) $(GCCOPTS) -Wl,$(LINKOPTS) -o $@ $< $(OBJECTS) $(XGOBJECTS)
582 @echo $(Q)################################################################################$(Q)
583 @echo $(Q)# Linking the Objects into an ELF... #$(Q)
584 @echo $(Q)################################################################################$(Q)
586 gclink: assemble $(OUTDIR) linkmsg $(GCDELFS)
588 # link the object files into an elf executable with gc enabled
589 $(GCDELFS): $(OUTDIR)/$(LABEL)-%.gc.elf: $(OBJDIR)/%.o $(OBJECTS) $(XGOBJECTS)
590 @echo $(Q)################################################################################$(Q)
591 @echo $(Q)# Linking $@ ...$(Q)
592 @echo $(Q)################################################################################$(Q)
593 $(GCC) $(GCCOPTS) -Wl,$(LINKOPTSGC) -o $@ $< $(OBJECTS) $(XGOBJECTS)
594 # The links with garbage collection are to ensure that there are no warnings
595 # TODO find out how to stop .tramp from being collected (or inserted)!
596 # This will be the only way once Sean's stuff is done and distributed, I can't wait to cut all this bullshit out!
600 @echo $(Q)################################################################################$(Q)
601 @echo $(Q)# Building The S19 Files.... #$(Q)
602 @echo $(Q)################################################################################$(Q)
604 s19: link $(S19DIR) s19msg $(ALLS19S)
605 # the gc dependency is temporary until i figure out if the .tramp removal is an issue or not.
607 # Generate the loadable s19 firmware files
608 $(ALLS19S): $(S19DIR)/%.s19: $(OUTDIR)/%.elf
609 @echo $(Q)################################################################################$(Q)
610 @echo $(Q)# Building $@ ...$(Q)
611 @echo $(Q)################################################################################$(Q)
612 $(COPY) $(COPYOPTS) $< $@
616 @echo $(Q)################################################################################$(Q)
617 @echo $(Q)# Measuring The S19 Files... #$(Q)
618 @echo $(Q)################################################################################$(Q)
620 sizes: s19 $(OUTDIR) sizesmsg $(ALLDUMMY)
622 # Roughly measure the s19 sizes
623 $(ALLSIZES): $(OUTDIR)/%.txt: $(S19DIR)/%
624 @echo $(shell cat $< | wc -l) $(Q)* 16$(Q) > $@
626 # Have to do this in two stages to allow $(shell exp) use and portability to windows
627 $(ALLDUMMY): $(OUTDIR)/%.dummy: $(OUTDIR)/%
628 @echo $(Q)Flash image size is$(Q) $(shell cat $< | bc -l) $(Q)bytes for $<$(Q)
632 @echo $(Q)################################################################################$(Q)
633 @echo $(Q)# Building The GC S19 Files.... #$(Q)
634 @echo $(Q)################################################################################$(Q)
636 gcs19: gclink $(S19DIR) gcs19msg $(GCDS19S)
638 # Generate the garbage collected s19 files temporarily
639 $(GCDS19S): $(S19DIR)/%.s19: $(OUTDIR)/%.elf
640 @echo $(Q)################################################################################$(Q)
641 @echo $(Q)# Building $@ ...$(Q)
642 @echo $(Q)################################################################################$(Q)
643 $(COPY) $(COPYOPTS) $< $@
646 @echo $(Q)################################################################################$(Q)
647 @echo $(Q)# Measuring The GC S19 Files... #$(Q)
648 @echo $(Q)################################################################################$(Q)
650 gcsizes: gcs19 $(OUTDIR) gcsizesmsg $(GCDDUMMY)
652 # Roughly measure the gc s19 sizes
653 $(GCDSIZES): $(OUTDIR)/%.txt: $(S19DIR)/%
654 @echo $(shell cat $< | wc -l) $(Q)* 16$(Q) > $@
656 # Have to do this in two stages to allow $(shell exp) use and portability to windows
657 $(GCDDUMMY): $(OUTDIR)/%.dummy: $(OUTDIR)/%
658 @echo $(Q)Flash image size is$(Q) $(shell cat $< | bc -l) $(Q)bytes for $<$(Q)
664 ################################################################################
665 # Size Measuring Target Definition #
666 ################################################################################
669 size: assemble # TODO this should be run for each s19 target with only the one rpm .o file
670 @echo $(Q)################################################################################$(Q)
671 @echo $(Q)# Measuring The Decoder Binaries... #$(Q)
672 @echo $(Q)################################################################################$(Q)
673 $(SIZE) $(OBJECTSRPM)
674 @echo $(Q)################################################################################$(Q)
675 @echo $(Q)# Measuring All Other Binaries... #$(Q)
676 @echo $(Q)################################################################################$(Q)
677 $(SIZE) -t $(OBJECTS)
678 @echo $(Q)################################################################################$(Q)
679 @echo $(Q)# Add one decoder to the total above and #$(Q)
680 @echo $(Q)# subtract the size reported for freeEMS.o #$(Q)
681 @echo $(Q)# this will give you the actual image size #$(Q)
682 @echo $(Q)################################################################################$(Q)
684 @echo $(Q)# Thank you for building FreeEMS firmware!!! #$(Q)
686 @echo $(Q)################################################################################$(Q)
691 ################################################################################
692 # Preprocess, Compile and Assemble Target Definitions #
693 ################################################################################
697 @echo $(Q)################################################################################$(Q)
698 @echo $(Q)# Running the C Pre Processor... #$(Q)
699 @echo $(Q)################################################################################$(Q)
701 preprocess: $(PPCDIR) preprocessmsg $(PREPROCESSED) $(PREPROCESSEDRPM)
703 # Generate preprocessed source files to examine
704 $(PREPROCESSED) $(PREPROCESSEDRPM): $(PPCDIR)/%.pp.c: %.c $(ALLH)
705 $(GCC) $(GCCOPTS) -E $< > $@
709 @echo $(Q)################################################################################$(Q)
710 @echo $(Q)# Compiling PPC to Assembly... #$(Q)
711 @echo $(Q)################################################################################$(Q)
713 compile: preprocess compilemsg $(ASSEMBLIES) $(ASSEMBLIESRPM)
715 # Generate assembly files to examine
716 $(ASSEMBLIES) $(ASSEMBLIESRPM): $(ASMDIR)/%.s: $(PPCDIR)/%.pp.c
717 $(GCC) $(GCCOPTS) -x cpp-output -S -o $@ $<
721 @echo $(Q)################################################################################$(Q)
722 @echo $(Q)# Assembling Object Files... #$(Q)
723 @echo $(Q)################################################################################$(Q)
725 assemble: compile $(OBJDIR) $(XGOBJDIR) assemblemsg $(OBJECTS) $(OBJECTSRPM) $(XGOBJECTS)
727 # Generate object files to link
728 $(OBJECTS) $(OBJECTSRPM): $(OBJDIR)/%.o: $(ASMDIR)/%.s
729 $(GCC) $(GCCOPTS) -c -o $@ $<
731 $(XGOBJECTS): $(XGOBJDIR)/%.o: $(XGASMDIR)/%.s
736 ################################################################################
737 # Release Procedure Target Definitions #
738 ################################################################################
743 @echo "################################################################################"
744 @echo
"# Checking git status... #"
745 @echo
"################################################################################"
746 @echo
"Fetching from origin..."
748 @echo
"Is everything checked in?"
749 test `git status -s | wc -l` -eq
0
750 @echo
"Are we behind?"
751 test `git rev-list \`git show-ref
--hash refs
/heads
/master\
`..\`git show-ref
--hash refs
/remotes
/origin/master\
` | wc -l` -eq
0
752 @echo
"Are we ahead?"
753 test `git rev-list \`git show-ref
--hash refs
/remotes
/origin/master\
`..\`git show-ref
--hash refs
/heads
/master\
` | wc -l` -eq
0
759 @echo
$(Q
)################################################################################$(Q)
760 @echo
$(Q
)# Generating MD5 Sums... #$(Q)
761 @echo
$(Q
)################################################################################$(Q)
763 md5sums
: s19 distributiondir md5sumsmsg
$(ALLMD5S
)
765 $(ALLMD5S
): $(DISTRIBUTIONDIR
)/%.s19.md5
: $(S19DIR
)/%.s19
770 @echo
$(Q
)################################################################################$(Q)
771 @echo
$(Q
)# Generating SHA1 Sums... #$(Q)
772 @echo
$(Q
)################################################################################$(Q)
774 sha1sums
: s19 distributiondir sha1sumsmsg
$(ALLSHA1S
)
776 $(ALLSHA1S
): $(DISTRIBUTIONDIR
)/%.s19.sha1
: $(S19DIR
)/%.s19
783 @echo
$(Q
)################################################################################$(Q)
784 @echo
$(Q
)# Generating MD5 Sums... #$(Q)
785 @echo
$(Q
)################################################################################$(Q)
787 md5sumsgc
: gcs19 distributiondir md5sumsmsggc
$(GCDMD5S
)
789 $(GCDMD5S
): $(DISTRIBUTIONDIR
)/%.s19.md5
: $(S19DIR
)/%.s19
794 @echo
$(Q
)################################################################################$(Q)
795 @echo
$(Q
)# Generating SHA1 Sums... #$(Q)
796 @echo
$(Q
)################################################################################$(Q)
798 sha1sumsgc
: gcs19 distributiondir sha1sumsmsggc
$(GCDSHA1S
)
800 $(GCDSHA1S
): $(DISTRIBUTIONDIR
)/%.s19.sha1
: $(S19DIR
)/%.s19
805 @echo
$(Q
)################################################################################$(Q)
806 @echo
$(Q
)# Zipping S19s... #$(Q)
807 @echo
$(Q
)################################################################################$(Q)
809 s19zips
: s19 distributiondir s19zipsmsg
$(ALLS19ZIPS
)
811 $(ALLS19ZIPS
): $(DISTRIBUTIONDIR
)/%.s19.zip
: $(S19DIR
)/%.s19
816 @echo
$(Q
)################################################################################$(Q)
817 @echo
$(Q
)# Copying S19s... #$(Q)
818 @echo
$(Q
)################################################################################$(Q)
820 s19rel
: sizes s19relmsg
$(ALLS19RELS
)
822 $(ALLS19RELS
): $(RELEASEDIR
)/%.s19
: $(S19DIR
)/%.s19
827 @echo
$(Q
)################################################################################$(Q)
828 @echo
$(Q
)# Zipping GC S19s... #$(Q)
829 @echo
$(Q
)################################################################################$(Q)
831 s19zipsgc
: gcs19 distributiondir s19zipsmsg
$(GCDS19ZIPS
)
833 $(GCDS19ZIPS
): $(DISTRIBUTIONDIR
)/%.s19.zip
: $(S19DIR
)/%.s19
838 @echo
$(Q
)################################################################################$(Q)
839 @echo
$(Q
)# Copying GC S19s... #$(Q)
840 @echo
$(Q
)################################################################################$(Q)
842 s19relgc
: gcsizes s19relgcmsg
$(GCDS19RELS
)
844 $(GCDS19RELS
): $(RELEASEDIR
)/%.s19
: $(S19DIR
)/%.s19
849 git add
$(RELEASEDIR
)
850 git commit
-m
"Automatically committing release files for FreeEMS version $(VERSION)!" ..
859 tagrelease
: tagname tagmessage
860 git tag
-F
$(RELTAG
) `cat $(TAGNAME)` HEAD
863 zipmain
: distributiondir
864 cd ..
/;git archive
--format
=zip
--prefix=$(LABEL
)/ HEAD
> ..
/$(LABEL
)/$(LABEL
).zip
;cd
-
866 zipdocs
: distributiondir
867 cd ..
/;git archive
--format
=zip
--prefix=$(LABEL
)- HEAD docs
/ > ..
/$(LABEL
)/$(LABEL
)-docs.zip
;cd
-
870 cd ..
;doxygen docs
/Doxyfile | grep Warning
> src
/doxygen.output
;cd
-
872 zipsite
: distributiondir gendoxy
873 cd ..
/docs
/;zip
-r
$(DISTRIBUTIONDIR
)/doxygen-html.zip doxygen-html
/;cd
-
875 zipsrc
: distributiondir
876 cd ..
/;git archive
--format
=zip
--prefix=$(LABEL
)- HEAD src
/ > ..
/$(LABEL
)/$(LABEL
)-src.zip
;cd
-
881 ################################################################################
882 # Create Directory Target Definitions #
883 ################################################################################
885 # Assembly, release and inc directories don't get removed.
887 dirs
: $(BUGDIR
) $(S19DIR
) $(PPCDIR
) $(OUTDIR
) $(OBJDIR
) $(XGOBJDIR
)
890 @echo
$(Q
)################################################################################$(Q)
891 @echo
$(Q
)# Creating the debug directory.... #$(Q)
892 @echo
$(Q
)################################################################################$(Q)
893 $(MKDIR
) $(BUGDIR
)$(PATHSEP
)hack
894 rmdir
$(BUGDIR
)$(PATHSEP
)hack
897 @echo
$(Q
)################################################################################$(Q)
898 @echo
$(Q
)# Creating the firmware directory... #$(Q)
899 @echo
$(Q
)################################################################################$(Q)
900 $(MKDIR
) $(S19DIR
)$(PATHSEP
)hack
901 rmdir
$(S19DIR
)$(PATHSEP
)hack
904 @echo
$(Q
)################################################################################$(Q)
905 @echo
$(Q
)# Creating the preprocessedc directory.... #$(Q)
906 @echo
$(Q
)################################################################################$(Q)
907 $(MKDIR
) $(PPCDIR
)$(PATHSEP
)hack
908 rmdir
$(PPCDIR
)$(PATHSEP
)hack
911 @echo
$(Q
)################################################################################$(Q)
912 @echo
$(Q
)# Creating the output directory... #$(Q)
913 @echo
$(Q
)################################################################################$(Q)
914 $(MKDIR
) $(OUTDIR
)$(PATHSEP
)hack
915 rmdir
$(OUTDIR
)$(PATHSEP
)hack
918 @echo
$(Q
)################################################################################$(Q)
919 @echo
$(Q
)# Creating the object directory... #$(Q)
920 @echo
$(Q
)################################################################################$(Q)
921 $(MKDIR
) $(OBJDIR
)$(PATHSEP
)hack
922 rmdir
$(OBJDIR
)$(PATHSEP
)hack
925 @echo
$(Q
)################################################################################$(Q)
926 @echo
$(Q
)# Creating the xgate object directory... #$(Q)
927 @echo
$(Q
)################################################################################$(Q)
928 $(MKDIR
) $(XGOBJDIR
)$(PATHSEP
)hack
929 rmdir
$(XGOBJDIR
)$(PATHSEP
)hack
932 @echo
$(Q
)################################################################################$(Q)
933 @echo
$(Q
)# Creating the distribution directory... #$(Q)
934 @echo
$(Q
)################################################################################$(Q)
935 $(MKDIR
) $(DISTRIBUTIONDIR
)$(PATHSEP
)hack
936 rmdir
$(DISTRIBUTIONDIR
)$(PATHSEP
)hack
941 ################################################################################
942 # Clean Target Definitions #
943 ################################################################################
946 @echo
$(Q
)################################################################################$(Q)
947 @echo
$(Q
)# Removing generated assembly files.... #$(Q)
948 @echo
$(Q
)################################################################################$(Q)
949 $(RM
) $(ASSEMBLIES
) $(ASSEMBLIESRPM
)
952 @echo
$(Q
)################################################################################$(Q)
953 @echo
$(Q
)# Removing pre-processed C output directory... #$(Q)
954 @echo
$(Q
)################################################################################$(Q)
958 @echo
$(Q
)################################################################################$(Q)
959 @echo
$(Q
)# Removing object directory... #$(Q)
960 @echo
$(Q
)################################################################################$(Q)
964 @echo
$(Q
)################################################################################$(Q)
965 @echo
$(Q
)# Removing link output directory... #$(Q)
966 @echo
$(Q
)################################################################################$(Q)
970 @echo
$(Q
)################################################################################$(Q)
971 @echo
$(Q
)# Removing s19 directory... #$(Q)
972 @echo
$(Q
)################################################################################$(Q)
976 @echo
$(Q
)################################################################################$(Q)
977 @echo
$(Q
)# Removing debug directory... #$(Q)
978 @echo
$(Q
)################################################################################$(Q)
982 @echo
$(Q
)################################################################################$(Q)
983 @echo
$(Q
)# Removing all release files... #$(Q)
984 @echo
$(Q
)################################################################################$(Q)
985 $(RM
) $(RELEASEDIR
)/*-$(PREVIOUSVERSION
)*
988 @echo
$(Q
)################################################################################$(Q)
989 @echo
$(Q
)# Removing Doxygen HTML... #$(Q)
990 @echo
$(Q
)################################################################################$(Q)
991 $(RM
) ..
/docs
/doxygen-html
/
994 ################################################################################
995 # Declare targets that aren't real files #
996 ################################################################################
999 # Aggregators top level
1000 .PHONY
: all fast slow slowgc single help dirs
1002 # Aggregators middle level
1003 .PHONY
: preprocess compile assemble link gclink s19 gcs19 sizes gcsizes
1005 # Aggregators debug level
1006 .PHONY
: alldebug maps rees objdmps elfdmps size
1009 .PHONY
: release relprep relperf relbuild relpack
1010 .PHONY
: md5sums sha1sums s19zips sha1sumsgc s19zips s19zipsgc
1011 .PHONY
: testgit relcommit tagname tagmessage tagrelease
1012 .PHONY
: zipmain zipdocs zipsite zipsource
1015 .PHONY
: mapsmsg reesmsg elfdmpsmsg objdmpmsg linkmsg gclinkmsg
1016 .PHONY
: s19msg gcs19msg preprocessmsg compilemsg assemblemsg
1017 .PHONY
: md5sumsmsg sha1sumsmsg s19zipsmsg
1020 .PHONY
: clean cleanasm cleanppc cleanobj cleanout cleans19 cleandebug cleanrelease cleandoxy
1022 # Lonely documentation target :-(