Place braces on expressionless loops in utils.
[freeems-vanilla.git] / src / Makefile
blob0dd76011046f2da083e76839f68c28f386c8bddf
1 # FreeEMS - the open source engine management system
3 # Copyright 2008, 2009 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!
26 ################################################################################
27 # #
28 # This Makefile is designed to be run with GNU make! Accept no substitute! #
29 # #
30 ################################################################################
31 # #
32 # Top level targets: #
33 # #
34 # make: #
35 # Builds all output files in the slow multi stage way with all debugging #
36 # make fast: #
37 # Compiles from C straight to objects, links to elfs and copies to s19s #
38 # make clean: #
39 # Permanently removes all build artifact files and directories #
40 # make release: #
41 # Cleans the project, builds it from scratch, copies the s19 files up to #
42 # the firmware directory, zips each s19 separately, zips all of the #
43 # documentation, cleans the project again and lastly zips the entire #
44 # project directory #
45 # #
46 ################################################################################
47 # #
48 # When doing a full build the following steps are taken: #
49 # #
50 # 1) Pre-process all of the C files #
51 # 2) Compile all preprocessed C files into assembly files #
52 # 3) Assemble all assembly files into object files #
53 # 4) Dump the contents of all object files #
54 # 5) Link one decoder with garbage collection and reporting turned on #
55 # 6) Link each decoder without garbage collection #
56 # 7) Dump the contents of each decoders elf #
57 # 8) Produce a memory map for each elf #
58 # 9) Produce a readelf dump for each elf #
59 # 10) Produce an s19 loadable firmware file for each elf #
60 # #
61 ################################################################################
66 ################################################################################
67 # All Fixed Variables #
68 ################################################################################
71 # Constants
72 VERSION = 0.0.20
73 OUTPREFIX = freeems
75 # Directories here
76 RELEASEDIR = ../firmware
77 INCDIR = inc
78 BUGDIR = debug
79 OUTDIR = output
80 OBJDIR = objects
81 ASMDIR = assembly
82 S19DIR = firmware
83 PPCDIR = preprocessedc
85 # Set the windows/non debian path first and then overwrite
86 # with the debian one so we can grep the deb line out and
87 # end up with a working windows make file in an automated
88 # way. Additionally, please ensure you do not add any sets
89 # of three . . . in a row or the line will be missing from
90 # the windows version. Likewise sets of ### longer than 6
91 # or so are also at risk :-)
92 PREFIX = m6811-elf-
93 PREFIX = m68hc11-
94 PATHSEP = \\
95 PATHSEP = /#...
97 # All of the tools
98 CP = cp
99 RM = rm -rf
100 MKDIR = mkdir
101 MKDIR = mkdir -p #...
102 ZIP = zip
103 GCC = $(PREFIX)gcc
104 COPY = $(PREFIX)objcopy
105 DUMP = $(PREFIX)objdump
106 NM = $(PREFIX)nm
107 RE = $(PREFIX)readelf
108 SIZE = $(PREFIX)size
113 ################################################################################
114 # All Source Files #
115 ################################################################################
118 # Indirect dependencies - any header change means a full
119 # recompile. This can be improved upon and made more specific.
120 MAINH = main.h
121 INITH = init.h
122 UTILH = utils.h
123 MFILE = Makefile
124 ISRH = interrupts.h
125 CINCS = injectorISR.c
126 FLASHH = flashWrite.h
127 ASMH = 9S12XDP512asm.s
128 LOOKUPH = tableLookup.h
129 WMFILE = Makefile.windows
130 ISRSH = commsISRs.h injectionISRs.h
131 COMMSH = commsCore.h blockDetailsLookup.h
132 LINKER = memory.x regions.x hc9s12xdp512elfb.x
133 GLOBALH1 = freeEMS.h 9S12XDP512.h memory.h globalConstants.h structs.h
134 GLOBALH2 = globalDefines.h errorDefines.h TunableConfigs.h FixedConfigs.h
135 FUELH = fuelAndIgnitionCalcs.h derivedVarsGenerator.h coreVarsGenerator.h
136 RPMH = NipponDenso.h LT1-360-8.h Subaru-36-2-2-2.h MissingTeeth.h MiataNB.h
138 # Let's keep this to a bare minimum! If you write ASM code
139 # please provide an matching alternate C implementation too.
140 HANDASMS = flashBurn.s
141 #RPMHANDASMS =
143 # .c files from inc/ should be included here as deps for the parts they are relied on by!!
144 ALLHEADERS1 = $(GLOBALH1) $(COMMSH) $(ISRSH) $(UTILH) $(RPMH) $(FLASHH)
145 ALLHEADERS2 = $(GLOBALH2) $(FUELH) $(MAINH) $(INITH) $(ISRH) $(LOOKUPH)
146 ALLH1 = $(patsubst %.h,$(INCDIR)/%.h,$(ALLHEADERS1))
147 ALLH2 = $(patsubst %.h,$(INCDIR)/%.h,$(ALLHEADERS2))
148 ALLH3 = $(patsubst %.c,$(INCDIR)/%.c,$(CINCS))
149 ALLH4 = $(LINKER) $(MFILE) $(INCDIR)/$(ASMH)
150 ALLH = $(ALLH1) $(ALLH2) $(ALLH3) $(ALLH4)
152 # Warning : do not include .c files from inc/ as they are
153 # included into the other C files and automatically compiled.
155 # Flash data files
156 FIXEDCLASSES = FixedConfig1.c FixedConfig2.c
157 LOOKUPCLASSES1 = IATTransferTable.c CHTTransferTable.c
158 LOOKUPCLASSES2 = MAFTransferTable.c TestTransferTable.c
159 FUELCLASSES = FuelTables.c FuelTables2.c
160 TIMECLASSES = TimingTables.c TimingTables2.c
161 TUNECLASSES = TunableConfig.c TunableConfig2.c
163 # Source code files
164 UTILCLASSES = tableLookup.c init.c utils.c globalConstants.c
165 MATHCLASSES = coreVarsGenerator.c derivedVarsGenerator.c fuelAndIgnitionCalcs.c
166 COMCLASSES = flashWrite.c commsCore.c blockDetailsLookup.c
167 ISRCLASSES = interrupts.c injectionISRs.c ignitionISRs.c commsISRs.c realtimeISRs.c miscISRs.c
169 # All but the engine position/RPM combined here
170 SOURCE = freeEMS.c staticInit.c main.c $(UTILCLASSES) $(MATHCLASSES) $(COMCLASSES) $(ISRCLASSES)
171 DATA = $(FIXEDCLASSES) $(LOOKUPCLASSES1) $(LOOKUPCLASSES2) $(FUELCLASSES) $(TIMECLASSES) $(TUNECLASSES)
172 CLASSES = $(SOURCE) $(DATA)
174 # Engine position/RPM here
175 RPMCLASSES = NipponDenso.c LT1-360-8.c Subaru-36-2-2-2.c MissingTeeth.c MiataNB.c
176 # future rpm = NissanRB2X.c NissanSR20.c MiataNA.c etc... Insert your file above and get coding!
179 # Convert extensions
180 PREPROCESSED = $(patsubst %.c,$(PPCDIR)/%.pp.c,$(CLASSES))
181 ASSEMBLIES = $(patsubst %.c,$(ASMDIR)/%.s,$(CLASSES))
182 OBJECTS = $(patsubst %.c,$(OBJDIR)/%.o,$(CLASSES)) $(patsubst %.s,$(OBJDIR)/%.o,$(HANDASMS))
183 DUMPS = $(patsubst %.c,$(BUGDIR)/%.dmp,$(CLASSES)) $(patsubst %.s,$(BUGDIR)/%.dmp,$(HANDASMS))
185 # Convert RPM extensions
186 PREPROCESSEDRPM = $(patsubst %.c,$(PPCDIR)/%.pp.c,$(RPMCLASSES))
187 ASSEMBLIESRPM = $(patsubst %.c,$(ASMDIR)/%.s,$(RPMCLASSES))
188 OBJECTSRPM = $(patsubst %.c,$(OBJDIR)/%.o,$(RPMCLASSES)) #$(patsubst %.s,$(OBJDIR)/%.o,$(RPMHANDASMS))
189 DUMPSRPM = $(patsubst %.c,$(BUGDIR)/%.dmp,$(RPMCLASSES)) #$(patsubst %.s,$(BUGDIR)/%.dmp,$(RPMHANDASMS))
191 # Convert to output files
192 ALLELFSC = $(patsubst %.c,$(OUTDIR)/$(OUTPREFIX)-$(VERSION)-%.elf,$(RPMCLASSES))
193 ALLELFSASM = #$(patsubst %.s,$(OUTDIR)/$(OUTPREFIX)-$(VERSION)-%.elf,$(RPMHANDASMS))
194 ALLDMPSC = $(patsubst %.c,$(BUGDIR)/$(OUTPREFIX)-$(VERSION)-%.dmp,$(RPMCLASSES))
195 ALLDMPSASM = #$(patsubst %.s,$(BUGDIR)/$(OUTPREFIX)-$(VERSION)-%.dmp,$(RPMHANDASMS))
196 ALLMAPSC = $(patsubst %.c,$(BUGDIR)/$(OUTPREFIX)-$(VERSION)-%.map,$(RPMCLASSES))
197 ALLMAPSASM = #$(patsubst %.s,$(BUGDIR)/$(OUTPREFIX)-$(VERSION)-%.map,$(RPMHANDASMS))
198 ALLREADC = $(patsubst %.c,$(BUGDIR)/$(OUTPREFIX)-$(VERSION)-%.ree,$(RPMCLASSES))
199 ALLREADASM = #$(patsubst %.s,$(BUGDIR)/$(OUTPREFIX)-$(VERSION)-%.ree,$(RPMHANDASMS))
200 ALLS19SC = $(patsubst %.c,$(S19DIR)/$(OUTPREFIX)-$(VERSION)-%.s19,$(RPMCLASSES))
201 ALLS19SASM = #$(patsubst %.s,$(S19DIR)/$(OUTPREFIX)-$(VERSION)-%.s19,$(RPMHANDASMS))
202 ALLELFS = $(ALLELFSC) $(ALLELFSASM)
203 ALLDMPS = $(ALLDMPSC) $(ALLDMPSASM)
204 ALLMAPS = $(ALLMAPSC) $(ALLMAPSASM)
205 ALLREAD = $(ALLREADC) $(ALLREADASM)
206 ALLS19S = $(ALLS19SC) $(ALLS19SASM)
208 # Convert to output files for GC variants
209 GCDELFSC = $(patsubst %.c,$(OUTDIR)/$(OUTPREFIX)-$(VERSION)-%.gc.elf,$(RPMCLASSES))
210 GCDELFSASM = #$(patsubst %.s,$(OUTDIR)/$(OUTPREFIX)-$(VERSION)-%.gc.elf,$(RPMHANDASMS))
211 GCDS19SC = $(patsubst %.c,$(S19DIR)/$(OUTPREFIX)-$(VERSION)-%.gc.s19,$(RPMCLASSES))
212 GCDS19SASM = #$(patsubst %.s,$(S19DIR)/$(OUTPREFIX)-$(VERSION)-%.gc.s19,$(RPMHANDASMS))
213 GCDELFS = $(GCDELFSC) $(GCDELFSASM)
214 GCDS19S = $(GCDS19SC) $(GCDELFSASM)
219 ################################################################################
220 # All Command Line Options #
221 ################################################################################
224 # M68hc1x GCC Options we may want : -minmax -mlong-calls
226 # http://www.gnu.org/software/m68hc11/m68hc11_gcc.html shows code size with different options used
227 # include debug info, optimise , 16 bit ints, hcs12 platform
228 GCCOPTS1 = -g -Wall -Werror -Winline -O -m68hcs12 -mshort -ffunction-sections
229 GCCOPTS2 = -fomit-frame-pointer -msoft-reg-count=8 -mauto-incdec -fsigned-char
230 GCCOPTS = $(GCCOPTS1) $(GCCOPTS2)
231 # -ffunction-sections option splits out the functions such that the garbage collection can get
232 # them on a per section basis. I'm not sure, but this could be harmful to paged code so may
233 # have to review this at a later date perhaps splitting paged functions from nonpaged ones.
235 # pass to linker, link for hc12
236 # The vectors address in the linker options is the VMA address and must be short form 0xF710, not a paged address.
237 LINKOPTS = -Wl,-defsym,vectors_addr=0xF710,-m,m68hc12elfb,-T,hc9s12xdp512elfb.x
238 LINKOPTSGC = -Wl,--gc-sections,--print-gc-sections,-defsym,vectors_addr=0xF710,-m,m68hc12elfb,-T,hc9s12xdp512elfb.x
239 # Use this to get a map dump when the linker fails in a confusing way : --print-map
241 # If using the below option for paged flash, the ADDRESS_TYPE
242 # field in the freeEMSloader script should be updated to match.
243 COPYOPTS = --output-target=srec \
244 --change-section-lma .fixedconf1+0xFD4000 \
245 --change-section-lma .fixedconf2+0xFD4000 \
246 --change-section-lma .text1+0xFD4000 \
247 --change-section-lma .text+0xFEC000 \
248 --change-section-lma .data+0xFEC000 \
249 --change-section-lma .vectors+0xFEC000 \
250 --change-section-lma .rodata+0xFEC000 \
251 --only-section=.fixedconf1 \
252 --only-section=.fixedconf2 \
253 --only-section=.text \
254 --only-section=.text1 \
255 --only-section=.data \
256 --only-section=.vectors \
257 --only-section=.rodata \
258 --change-section-lma .ppageF8=0xF88000 \
259 --change-section-lma .fpageF9=0xF98000 \
260 --change-section-lma .dpageF9=0xF9A000 \
261 --change-section-lma .ppageFE=0xFE8000 \
262 --only-section=.ppageF8 \
263 --only-section=.fpageF9 \
264 --only-section=.dpageF9 \
265 --only-section=.ppageFE \
266 --change-section-lma .fpageFA=0xFA8000 \
267 --change-section-lma .dpageFA=0xFAA000 \
268 --change-section-lma .fpageFB=0xFB8000 \
269 --change-section-lma .dpageFB1=0xFBA000 \
270 --change-section-lma .dpageFB2=0xFBA400 \
271 --change-section-lma .dpageFB3=0xFBA800 \
272 --change-section-lma .dpageFB4=0xFBAC00 \
273 --change-section-lma .dpageFB5=0xFBB000 \
274 --change-section-lma .dpageFB6=0xFBB400 \
275 --change-section-lma .dpageFB7=0xFBB800 \
276 --change-section-lma .dpageFB8=0xFBBC00 \
277 --change-section-lma .fpageFC=0xFC8000 \
278 --change-section-lma .dpageFC=0xFCA000 \
279 --only-section=.dpageFA \
280 --only-section=.fpageFA \
281 --only-section=.dpageFB1 \
282 --only-section=.dpageFB2 \
283 --only-section=.dpageFB3 \
284 --only-section=.dpageFB4 \
285 --only-section=.dpageFB5 \
286 --only-section=.dpageFB6 \
287 --only-section=.dpageFB7 \
288 --only-section=.dpageFB8 \
289 --only-section=.fpageFB \
290 --only-section=.dpageFC \
291 --only-section=.fpageFC
292 # --change-section-lma .ppageFD=0xFD8000 \
293 # --change-section-lma .ppageFF=0xFF8000 \
294 # --only-section=.ppageFD \ This is left here for clarity only (equivalent to text1 but paged)
295 # --only-section=.ppageFF This is left here for clarity only (equivalent to text but paged)
296 # Changes to the above options should be reflected in memory.x and memory.h also!
298 # The following flash areas can only be used once Sean has written his loader app :
299 # --only-section=.ppageE0 \
300 # --only-section=.ppageE1 \
301 # --only-section=.ppageE2 \
302 # --only-section=.ppageE3 \
303 # --only-section=.ppageE4 \
304 # --only-section=.ppageE5 \
305 # --only-section=.ppageE6 \
306 # --only-section=.ppageE7 \
307 # --only-section=.ppageE8 \
308 # --only-section=.ppageE9 \
309 # --only-section=.ppageEA \
310 # --only-section=.ppageEB \
311 # --only-section=.ppageEC \
312 # --only-section=.ppageED \
313 # --only-section=.ppageEE \
314 # --only-section=.ppageEF \
315 # --only-section=.ppageF0 \
316 # --only-section=.ppageF1 \
317 # --only-section=.ppageF2 \
318 # --only-section=.ppageF3 \
319 # --only-section=.ppageF4 \
320 # --only-section=.ppageF5 \
321 # --only-section=.ppageF6 \
322 # --only-section=.ppageF7 \
323 # --change-section-lma .ppageE0=0xE08000 \
324 # --change-section-lma .ppageE1=0xE18000 \
325 # --change-section-lma .ppageE2=0xE28000 \
326 # --change-section-lma .ppageE3=0xE38000 \
327 # --change-section-lma .ppageE4=0xE48000 \
328 # --change-section-lma .ppageE5=0xE58000 \
329 # --change-section-lma .ppageE6=0xE68000 \
330 # --change-section-lma .ppageE7=0xE78000 \
331 # --change-section-lma .ppageE8=0xE88000 \
332 # --change-section-lma .ppageE9=0xE98000 \
333 # --change-section-lma .ppageEA=0xEA8000 \
334 # --change-section-lma .ppageEB=0xEB8000 \
335 # --change-section-lma .ppageEC=0xEC8000 \
336 # --change-section-lma .ppageED=0xED8000 \
337 # --change-section-lma .ppageEE=0xEE8000 \
338 # --change-section-lma .ppageEF=0xEF8000 \
339 # --change-section-lma .ppageF0=0xF08000 \
340 # --change-section-lma .ppageF1=0xF18000 \
341 # --change-section-lma .ppageF2=0xF28000 \
342 # --change-section-lma .ppageF3=0xF38000 \
343 # --change-section-lma .ppageF4=0xF48000 \
344 # --change-section-lma .ppageF5=0xF58000 \
345 # --change-section-lma .ppageF6=0xF68000 \
346 # --change-section-lma .ppageF7=0xF78000 \
350 help:
351 ################################################################################
352 # Dependency And Target Summary #
353 ################################################################################
355 # Common targets: #
357 # 1) help - This comment block #
358 # 2) all - Executes alldebug, slow, slowgc and size #
359 # 3) dirs - Creates all of the directories required to build #
360 # 4) fast - Compiles direct to object code and links once with no debug #
361 # 5) slow - Three stage compilation with assembly retained #
362 # 6) slowgc - As above, but with garbage collection during linking #
363 # 7) alldebug - Generates all debug output files #
364 # 8) install - Not yet implemented #
365 # 9) release - Not yet implemented #
366 # 10) clean - Removes all files and directories generated by building #
368 # Second level targets: #
370 # Stage one: #
372 # 1) preprocess - run the C preprocessor over the raw C files #
373 # 2) compile - compile the preprocessed C into assembly #
374 # 3) assemble - assemble the assembly files into object files #
376 # Stage two #
378 # 1) link - Generate ELFs objects #
379 # 2) gclink - As above, but with garbage collection #
380 # 3) s19 - Create s19s from elfs #
381 # 4) gcs19 - Create s19s from gc elfs #
383 # Stage three: #
385 # 1) maps - Memory map files #
386 # 2) rees - Readelf dumps #
387 # 3) elfdmps - Classic objdump output for final elfs #
388 # 4) objdmps - Classic objdump output for each object file #
390 # Additionally any of the output files can be used as a target directly. #
391 # This is perfect for building only what is required for a specific s19. #
392 # It is also perfect for working with a single file as you don't have to #
393 # wait for other unrelated things to build first nor do you have to wait #
394 # for other files to continue building after yours is successful. Before #
395 # using individual output files for targets, please run 'make dirs'. #
397 ################################################################################
402 ################################################################################
403 # All Target Dependencies #
404 ################################################################################
407 # Build everything the long way
408 all: alldebug gcs19 s19 size
409 # Single stage compilation
410 fast: single s19 size
411 # Multi stage compilation
412 slow: s19 size
413 # Multi stage compilation with garbage collection
414 slowgc: gcs19 size #...
415 # Clean all except release
416 clean: cleanasm cleanobj cleanout cleanppc cleans19 cleandebug
417 # Generate all debug
418 alldebug: maps rees elfdmps objdmps
419 # Load the s19 of your choice
420 #install: clean fast loader
421 # Perform a release
422 #release: clean cleanrelease fast someMoreStuffHere checksums zipping etc
427 ################################################################################
428 # Debug Target Definitions #
429 ################################################################################
432 mapsmsg:
433 ################################################################################
434 # Generating memory maps.... #
435 ################################################################################
437 maps: link $(BUGDIR) mapsmsg $(ALLMAPS)
439 $(ALLMAPS): $(BUGDIR)/%.map: $(OUTDIR)/%.elf
440 $(NM) $< | sort > $@
443 reesmsg:
444 ################################################################################
445 # Reading all elf files... #
446 ################################################################################
448 rees: link $(BUGDIR) reesmsg $(ALLREAD)
450 $(ALLREAD): $(BUGDIR)/%.ree: $(OUTDIR)/%.elf
451 $(RE) -a -W $< > $@
454 elfdmpsmsg:
455 ################################################################################
456 # Dumping all elf files... #
457 ################################################################################
459 elfdmps: link $(BUGDIR) elfdmpsmsg $(ALLDMPS)
461 $(ALLDMPS): $(BUGDIR)/%.dmp: $(OUTDIR)/%.elf
462 $(DUMP) -spSd $< > $@
465 objdmpmsg:
466 ################################################################################
467 # Dumping all object files.... #
468 ################################################################################
470 objdmps: assemble $(BUGDIR) objdmpmsg $(DUMPS) $(DUMPSRPM)
472 $(DUMPS) $(DUMPSRPM): $(BUGDIR)/%.dmp: $(OBJDIR)/%.o
473 $(DUMP) -spSd $< > $@
478 ################################################################################
479 # Fast Single Stage Compile Target Definition #
480 ################################################################################
483 single:
484 # TODO fast compile and figure out overlapping dependencies...
489 ################################################################################
490 # Link and Copy Target Definitions #
491 ################################################################################
494 linkmsg: #...
495 ################################################################################
496 # Linking the Objects into an ELF... #
497 ################################################################################
499 link: assemble $(OUTDIR) linkmsg $(ALLELFS)
501 # link the object files into an elf executable
502 $(ALLELFS): $(OUTDIR)/$(OUTPREFIX)-$(VERSION)-%.elf: $(OBJDIR)/%.o $(OBJECTS)
503 ################################################################################
504 # Linking $@ ...
505 ################################################################################
506 $(GCC) $(GCCOPTS) $(LINKOPTS) -o $@ $< $(OBJECTS)
509 gclinkmsg: #...
510 ################################################################################
511 # Linking the Objects into an ELF... #
512 ################################################################################
514 gclink: assemble $(OUTDIR) linkmsg $(GCDELFS) #...
516 # link the object files into an elf executable with gc...
517 $(GCDELFS): $(OUTDIR)/$(OUTPREFIX)-$(VERSION)-%.gc.elf: $(OBJDIR)/%.o $(OBJECTS) #...
518 ################################################################################
519 # Linking $@ ...
520 ################################################################################
521 $(GCC) $(GCCOPTS) $(LINKOPTSGC) -o $@ $< $(OBJECTS) # ...
522 # The links with garbage collection are to ensure that there are no warnings ...
523 # TODO find out how to stop .tramp from being collected (or inserted)! ...
526 s19msg: #...
527 ################################################################################
528 # Building The S19 Files.... #
529 ################################################################################
531 s19: link $(S19DIR) s19msg $(ALLS19S)
532 # the gc dependency is temporary until i figure out if the .tramp removal is an issue or not.
534 # Generate the loadable s19 firmware files
535 $(ALLS19S): $(S19DIR)/%.s19: $(OUTDIR)/%.elf
536 ################################################################################
537 # Building $@ ...
538 ################################################################################
539 $(COPY) $(COPYOPTS) $< $@
540 ################################################################################
541 # Measuring $@ ...
542 ################################################################################
543 echo "Flash image size of $@ is" `echo \`cat $@ | wc -l\` "* 16" | bc -l` "bytes..."
546 gcs19msg: #...
547 ################################################################################
548 # Building The S19 Files.... #
549 ################################################################################
551 gcs19: gclink $(S19DIR) gcs19msg $(GCDS19S) #...
553 # Generate the garbage collected s19 files temporarily...
554 $(GCDS19S): $(S19DIR)/%.s19: $(OUTDIR)/%.elf #...
555 ################################################################################
556 # Building $@ ...
557 ################################################################################
558 $(COPY) $(COPYOPTS) $< $@ #...
559 ################################################################################
560 # Measuring $@ ...
561 ################################################################################
562 echo "Flash image size of $@ is" `echo \`cat $@ | wc -l\` "* 16" | bc -l` "bytes..."
567 ################################################################################
568 # Size Measuring Target Definition #
569 ################################################################################
572 size: assemble # TODO this should be run for each s19 target with only the one rpm .o file
573 ################################################################################
574 # Measuring The Decoder Binaries... #
575 ################################################################################
576 $(SIZE) $(OBJECTSRPM)
577 ################################################################################
578 # Measuring All Other Binaries... #
579 ################################################################################
580 $(SIZE) -t $(OBJECTS)
581 ################################################################################
582 # Add one decoder to the total above and #
583 # subtract the size reported for freeEMS.o #
584 # this will give you the actual image size #
585 ################################################################################
587 # Thank you for building FreeEMS firmware!!! #
589 ################################################################################
594 ################################################################################
595 # Preprocess, Compile and Assemble Target Definitions #
596 ################################################################################
599 preprocessmsg: #...
600 ################################################################################
601 # Running the C Pre Processor... #
602 ################################################################################
604 preprocess: $(PPCDIR) preprocessmsg $(PREPROCESSED) $(PREPROCESSEDRPM)
606 # Generate preprocessed source files to examine
607 $(PREPROCESSED) $(PREPROCESSEDRPM): $(PPCDIR)/%.pp.c: %.c $(ALLH)
608 $(GCC) $(GCCOPTS) -E $< > $@
611 compilemsg: #...
612 ################################################################################
613 # Compiling PPC to Assembly... #
614 ################################################################################
616 compile: preprocess compilemsg $(ASSEMBLIES) $(ASSEMBLIESRPM)
618 # Generate assembly files to examine
619 $(ASSEMBLIES) $(ASSEMBLIESRPM): $(ASMDIR)/%.s: $(PPCDIR)/%.pp.c
620 $(GCC) $(GCCOPTS) -x cpp-output -S -o $@ $<
623 assemblemsg: #...
624 ################################################################################
625 # Assembling Object Files... #
626 ################################################################################
628 assemble: compile $(OBJDIR) assemblemsg $(OBJECTS) $(OBJECTSRPM)
630 # Generate object files to link
631 $(OBJECTS) $(OBJECTSRPM): $(OBJDIR)/%.o: $(ASMDIR)/%.s
632 $(GCC) $(GCCOPTS) -c -o $@ $<
637 ################################################################################
638 # Release Procedure Target Definitions #
639 ################################################################################
641 ### clean all
643 #check git status for changes, fail build if not fully commited
645 ### build all
647 #copy s19s up
649 #md5sum/sha1sum s19s above
651 ### clean all
653 #git commit s19s
655 #zip each s19 to parent
657 #zip docs to parent
659 #zip without docs to parent
661 #zip entire directory to parent
666 ################################################################################
667 # Create Directory Target Definitions #
668 ################################################################################
670 # Assembly, release and inc directories don't get removed.
672 dirs: $(BUGDIR) $(S19DIR) $(PPCDIR) $(OUTDIR) $(OBJDIR)
674 $(BUGDIR):
675 ################################################################################
676 # Creating the debug directory.... #
677 ################################################################################
678 $(MKDIR) $(BUGDIR)$(PATHSEP)hack
679 rmdir $(BUGDIR)$(PATHSEP)hack
681 $(S19DIR):
682 ################################################################################
683 # Creating the firmware directory... #
684 ################################################################################
685 $(MKDIR) $(S19DIR)$(PATHSEP)hack
686 rmdir $(S19DIR)$(PATHSEP)hack
688 $(PPCDIR):
689 ################################################################################
690 # Creating the preprocessedc directory.... #
691 ################################################################################
692 $(MKDIR) $(PPCDIR)$(PATHSEP)hack
693 rmdir $(PPCDIR)$(PATHSEP)hack
695 $(OUTDIR):
696 ################################################################################
697 # Creating the output directory... #
698 ################################################################################
699 $(MKDIR) $(OUTDIR)$(PATHSEP)hack
700 rmdir $(OUTDIR)$(PATHSEP)hack
702 $(OBJDIR):
703 ################################################################################
704 # Creating the object directory... #
705 ################################################################################
706 $(MKDIR) $(OBJDIR)$(PATHSEP)hack
707 rmdir $(OBJDIR)$(PATHSEP)hack
712 ################################################################################
713 # Clean Target Definitions #
714 ################################################################################
716 cleanasm:
717 ################################################################################
718 # Removing generated assembly files.... #
719 ################################################################################
720 $(RM) $(ASSEMBLIES) $(ASSEMBLIESRPM)
722 cleanppc:
723 ################################################################################
724 # Removing pre-processed C output directory... #
725 ################################################################################
726 $(RM) $(PPCDIR)
728 cleanobj:
729 ################################################################################
730 # Removing object directory... #
731 ################################################################################
732 $(RM) $(OBJDIR)
734 cleanout:
735 ################################################################################
736 # Removing link output directory... #
737 ################################################################################
738 $(RM) $(OUTDIR)
740 cleans19:
741 ################################################################################
742 # Removing s19 directory... #
743 ################################################################################
744 $(RM) $(S19DIR)
746 cleandebug:
747 ################################################################################
748 # Removing debug directory... #
749 ################################################################################
750 $(RM) $(BUGDIR)
752 cleanrelease:
753 ################################################################################
754 # Removing all release files... #
755 ################################################################################
756 $(RM) $(RELEASEDIR)/*.zip
757 $(RM) $(RELEASEDIR)/*.s19
758 $(RM) $(RELEASEDIR)/*.md5
759 $(RM) $(RELEASEDIR)/*.sha1
764 ################################################################################
765 # Declare targets that aren't real files #
766 ################################################################################
769 # Aggregators top level
770 .PHONY: all fast slow slowgc single help dirs
772 # Aggregators middle level
773 .PHONY: preprocess compile assemble link gclink s19 gcs19
775 # Aggregators debug level
776 .PHONY: alldebug maps rees objdmps elfdmps size
778 # Messages
779 .PHONY: mapsmsg reesmsg elfdmpsmsg objdmpmsg linkmsg gclinkmsg
780 .PHONY: s19msg gcs19msg preprocessmsg compilemsg assemblemsg
782 # Clean targets
783 .PHONY: clean cleanasm cleanppc cleanobj cleanout cleans19 cleandebug cleanrelease