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!
26 ################################################################################
28 # This Makefile is designed to be run with GNU make! Accept no substitute! #
30 ################################################################################
32 # Top level targets: #
35 # Builds all output files in the slow multi stage way with all debugging #
37 # Compiles from C straight to objects, links to elfs and copies to s19s #
39 # Permanently removes all build artifact files and directories #
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 #
46 ################################################################################
48 # When doing a full build the following steps are taken: #
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 #
61 ################################################################################
66 ################################################################################
67 # All Fixed Variables #
68 ################################################################################
72 VERSION
= 0.1.1-SNAPSHOT
73 PREVIOUSVERSION
= 0.1.0
75 LABEL
= $(OUTPREFIX
)-$(VERSION
)
82 RELEASEDIR
= ..
/firmware
83 DISTRIBUTIONDIR
= ..
/..
/$(LABEL
)
84 DOXYDOCDIR
= ..
/docs
/doxygen-html
85 MAINDIR
= freeems-vanilla
92 PPCDIR
= preprocessedc
93 XGASMDIR
= $(ASMDIR
)$(PATHSEP
)xgate
94 XGOBJDIR
= $(OBJDIR
)$(PATHSEP
)xgate
96 # Release tag message file
97 RELTAG
= $(OUTDIR
)/gitTagMessage.txt
98 TAGNAME
= $(OUTDIR
)/gitTagName.txt
100 # Set the windows/non debian path first and then overwrite
101 # with the debian one so we can grep the deb line out and
102 # end up with a working windows make file in an automated
103 # way. Additionally, please ensure you do not add any sets
104 # of three . . . in a row or the line will be missing from
105 # the windows version. Likewise sets of ### longer than 6
106 # or so are also at risk :-)
114 MKDIR
= mkdir
-p
#REMOVE
117 COPY
= $(PREFIX
)objcopy
118 DUMP
= $(PREFIX
)objdump
120 RE
= $(PREFIX
)readelf
127 ################################################################################
129 ################################################################################
132 # Indirect dependencies - any header change means a full
133 # recompile. This can be improved upon and made more specific.
139 CINCS
= injectorISR.c
140 FLASHH
= flashWrite.h
141 ASMH
= 9S12XDP512asm.s
142 LOOKUPH
= tableLookup.h
143 WMFILE
= Makefile.windows
144 ISRSH
= commsISRs.h injectionISRs.h
145 COMMSH
= commsCore.h blockDetailsLookup.h
146 LINKER
= memory.x regions.x hc9s12xdp512elfb.x
147 GLOBALH1
= freeEMS.h
9S12XDP512.h memory.h globalConstants.h structs.h
148 GLOBALH2
= globalDefines.h errorDefines.h TunableConfigs.h FixedConfigs.h
149 FUELH
= fuelAndIgnitionCalcs.h derivedVarsGenerator.h coreVarsGenerator.h
150 RPMH
= Simple.h NipponDenso.h LT1-360-8.h Subaru-36-2-2-2.h MissingTeeth.h MiataNB.h
152 # Let's keep this to a bare minimum! If you write ASM code
153 # please provide an matching alternate C implementation too.
154 HANDASMS
= flashBurn.s
157 # .c files from inc/ should be included here as deps for the parts they are relied on by!!
158 ALLHEADERS1
= $(GLOBALH1
) $(COMMSH
) $(ISRSH
) $(UTILH
) $(RPMH
) $(FLASHH
)
159 ALLHEADERS2
= $(GLOBALH2
) $(FUELH
) $(MAINH
) $(INITH
) $(ISRH
) $(LOOKUPH
)
160 ALLH1
= $(patsubst %.h
,$(INCDIR
)/%.h
,$(ALLHEADERS1
))
161 ALLH2
= $(patsubst %.h
,$(INCDIR
)/%.h
,$(ALLHEADERS2
))
162 ALLH3
= $(patsubst %.c
,$(INCDIR
)/%.c
,$(CINCS
))
163 ALLH4
= $(LINKER
) $(MFILE
) $(INCDIR
)/$(ASMH
)
164 ALLH
= $(ALLH1
) $(ALLH2
) $(ALLH3
) $(ALLH4
)
166 # Warning : do not include .c files from inc/ as they are
167 # included into the other C files and automatically compiled.
170 FIXEDCLASSES
= FixedConfig1.c FixedConfig2.c
171 LOOKUPCLASSES1
= IATTransferTable.c CHTTransferTable.c
172 LOOKUPCLASSES2
= MAFTransferTable.c TestTransferTable.c
173 FUELCLASSES
= FuelTables.c FuelTables2.c
174 TIMECLASSES
= TimingTables.c TimingTables2.c
175 TUNECLASSES
= TunableConfig.c TunableConfig2.c
178 UTILCLASSES
= tableLookup.c init.c utils.c globalConstants.c
179 MATHCLASSES
= coreVarsGenerator.c derivedVarsGenerator.c fuelAndIgnitionCalcs.c
180 COMCLASSES
= flashWrite.c commsCore.c blockDetailsLookup.c
181 ISRCLASSES
= interrupts.c injectionISRs.c ignitionISRs.c commsISRs.c realtimeISRs.c miscISRs.c xgateVectors.c
183 # All but the engine position/RPM combined here
184 SOURCE
= freeEMS.c staticInit.c main.c
$(UTILCLASSES
) $(MATHCLASSES
) $(COMCLASSES
) $(ISRCLASSES
)
185 DATA
= $(FIXEDCLASSES
) $(LOOKUPCLASSES1
) $(LOOKUPCLASSES2
) $(FUELCLASSES
) $(TIMECLASSES
) $(TUNECLASSES
)
186 CLASSES
= $(SOURCE
) $(DATA
)
188 # Engine position/RPM here
189 RPMCLASSES
= Simple.c NipponDenso.c LT1-360-8.c Subaru-36-2-2-2.c MissingTeeth.c MiataNB.c
190 # future rpm = NissanRB2X.c NissanSR20.c MiataNA.c etc... Insert your file above and get coding!
195 PREPROCESSED
= $(patsubst %.c
,$(PPCDIR
)/%.pp.c
,$(CLASSES
))
196 ASSEMBLIES
= $(patsubst %.c
,$(ASMDIR
)/%.s
,$(CLASSES
))
197 OBJECTS
= $(patsubst %.c
,$(OBJDIR
)/%.o
,$(CLASSES
)) $(patsubst %.s
,$(OBJDIR
)/%.o
,$(HANDASMS
))
198 DUMPS
= $(patsubst %.c
,$(BUGDIR
)/%.dmp
,$(CLASSES
)) $(patsubst %.s
,$(BUGDIR
)/%.dmp
,$(HANDASMS
))
199 XGOBJECTS
= $(patsubst %.s
,$(XGOBJDIR
)/%.o
,$(XGASMSRCS
))
201 # Convert RPM extensions
202 PREPROCESSEDRPM
= $(patsubst %.c
,$(PPCDIR
)/%.pp.c
,$(RPMCLASSES
))
203 ASSEMBLIESRPM
= $(patsubst %.c
,$(ASMDIR
)/%.s
,$(RPMCLASSES
))
204 OBJECTSRPM
= $(patsubst %.c
,$(OBJDIR
)/%.o
,$(RPMCLASSES
)) #$(patsubst %.s,$(OBJDIR)/%.o,$(RPMHANDASMS))
205 DUMPSRPM
= $(patsubst %.c
,$(BUGDIR
)/%.dmp
,$(RPMCLASSES
)) #$(patsubst %.s,$(BUGDIR)/%.dmp,$(RPMHANDASMS))
207 # Convert to output files
208 ALLELFSC
= $(patsubst %.c
,$(OUTDIR
)/$(LABEL
)-%.elf
,$(RPMCLASSES
))
209 ALLELFSASM
= #$(patsubst %.s,$(OUTDIR)/$(LABEL)-%.elf,$(RPMHANDASMS))
210 ALLDMPSC
= $(patsubst %.c
,$(BUGDIR
)/$(LABEL
)-%.dmp
,$(RPMCLASSES
))
211 ALLDMPSASM
= #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.dmp,$(RPMHANDASMS))
212 ALLMAPSC
= $(patsubst %.c
,$(BUGDIR
)/$(LABEL
)-%.map
,$(RPMCLASSES
))
213 ALLMAPSASM
= #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.map,$(RPMHANDASMS))
214 ALLREADC
= $(patsubst %.c
,$(BUGDIR
)/$(LABEL
)-%.ree
,$(RPMCLASSES
))
215 ALLREADASM
= #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.ree,$(RPMHANDASMS))
216 ALLS19SC
= $(patsubst %.c
,$(S19DIR
)/$(LABEL
)-%.s19
,$(RPMCLASSES
))
217 ALLS19SASM
= #$(patsubst %.s,$(S19DIR)/$(LABEL)-%.s19,$(RPMHANDASMS))
218 ALLELFS
= $(ALLELFSC
) $(ALLELFSASM
)
219 ALLDMPS
= $(ALLDMPSC
) $(ALLDMPSASM
)
220 ALLMAPS
= $(ALLMAPSC
) $(ALLMAPSASM
)
221 ALLREAD
= $(ALLREADC
) $(ALLREADASM
)
222 ALLS19S
= $(ALLS19SC
) $(ALLS19SASM
)
223 ALLMD5S
= $(patsubst $(S19DIR
)/%,$(DISTRIBUTIONDIR
)/%.md5
,$(ALLS19S
))
224 ALLSHA1S
= $(patsubst $(S19DIR
)/%,$(DISTRIBUTIONDIR
)/%.sha1
,$(ALLS19S
))
225 ALLS19RELS
= $(patsubst $(S19DIR
)/%,$(RELEASEDIR
)/%,$(ALLS19S
))
226 ALLS19ZIPS
= $(patsubst $(S19DIR
)/%,$(DISTRIBUTIONDIR
)/%.zip
,$(ALLS19S
))
228 # Convert to output files for GC variants
229 GCDELFSC
= $(patsubst %.c
,$(OUTDIR
)/$(LABEL
)-%.gc.elf
,$(RPMCLASSES
))
230 GCDELFSASM
= #$(patsubst %.s,$(OUTDIR)/$(LABEL)-%.gc.elf,$(RPMHANDASMS))
231 GCDS19SC
= $(patsubst %.c
,$(S19DIR
)/$(LABEL
)-%.gc.s19
,$(RPMCLASSES
))
232 GCDS19SASM
= #$(patsubst %.s,$(S19DIR)/$(LABEL)-%.gc.s19,$(RPMHANDASMS))
233 GCDELFS
= $(GCDELFSC
) $(GCDELFSASM
)
234 GCDS19S
= $(GCDS19SC
) $(GCDELFSASM
)
235 GCDMD5S
= $(patsubst $(S19DIR
)/%,$(DISTRIBUTIONDIR
)/%.md5
,$(GCDS19S
))
236 GCDSHA1S
= $(patsubst $(S19DIR
)/%,$(DISTRIBUTIONDIR
)/%.sha1
,$(GCDS19S
))
237 GCDS19RELS
= $(patsubst $(S19DIR
)/%,$(RELEASEDIR
)/%,$(GCDS19S
))
238 GCDS19ZIPS
= $(patsubst $(S19DIR
)/%,$(DISTRIBUTIONDIR
)/%.zip
,$(GCDS19S
))
243 ################################################################################
244 # All Command Line Options #
245 ################################################################################
248 # M68hc1x GCC Options we may want : -minmax -mlong-calls
250 # http://www.gnu.org/software/m68hc11/m68hc11_gcc.html shows code size with different options used
251 # include debug info, optimise , 16 bit ints, hcs12 platform
252 GCCOPTS1
= -g
-Wall
-Werror
-Winline
-O
-m68hcs12
-mshort
-ffunction-sections
253 GCCOPTS2
= -fomit-frame-pointer
-msoft-reg-count
=8 -mauto-incdec
-fsigned-char
254 GCCOPTS
= $(GCCOPTS1
) $(GCCOPTS2
)
255 # -ffunction-sections option splits out the functions such that the garbage collection can get
256 # them on a per section basis. I'm not sure, but this could be harmful to paged code so may
257 # have to review this at a later date perhaps splitting paged functions from nonpaged ones.
259 # pass to linker, link for hc12
260 # The vectors address in the linker options is the VMA address and must be short form 0xF710, not a paged address.
261 LINKOPTS
= -no-warn-mismatch
,-defsym
,vectors_addr
=0xF710,-m
,m68hc12elfb
,-T
,hc9s12xdp512elfb.x
262 LINKOPTSGC
= -no-warn-mismatch
,--gc-sections
,--print-gc-sections
,-defsym
,vectors_addr
=0xF710,-m
,m68hc12elfb
,-T
,hc9s12xdp512elfb.x
263 # Use this to get a map dump when the linker fails in a confusing way : --print-map
265 # If using the below option for paged flash, the ADDRESS_TYPE
266 # field in the freeEMSloader script should be updated to match.
267 COPYOPTS
= --output-target
=srec \
268 --change-section-lma .fixedconf1
+0xFD4000 \
269 --change-section-lma .fixedconf2
+0xFD4000 \
270 --change-section-lma .text1
+0xFD4000 \
271 --change-section-lma .text
+0xFEC000 \
272 --change-section-lma .data
+0xFEC000 \
273 --change-section-lma .vectors
+0xFEC000 \
274 --change-section-lma .rodata
+0xFEC000 \
275 --only-section
=.fixedconf1 \
276 --only-section
=.fixedconf2 \
277 --only-section
=.text \
278 --only-section
=.text1 \
279 --only-section
=.data \
280 --only-section
=.vectors \
281 --only-section
=.rodata \
282 --change-section-lma .ppageF8
=0xF88000 \
283 --change-section-lma .fpageF9
=0xF98000 \
284 --change-section-lma .dpageF9
=0xF9A000 \
285 --change-section-lma .ppageFE
=0xFE8000 \
286 --only-section
=.ppageF8 \
287 --only-section
=.fpageF9 \
288 --only-section
=.dpageF9 \
289 --only-section
=.ppageFE \
290 --change-section-lma .fpageFA
=0xFA8000 \
291 --change-section-lma .dpageFA
=0xFAA000 \
292 --change-section-lma .fpageFB
=0xFB8000 \
293 --change-section-lma .dpageFB1
=0xFBA000 \
294 --change-section-lma .dpageFB2
=0xFBA400 \
295 --change-section-lma .dpageFB3
=0xFBA800 \
296 --change-section-lma .dpageFB4
=0xFBAC00 \
297 --change-section-lma .dpageFB5
=0xFBB000 \
298 --change-section-lma .dpageFB6
=0xFBB400 \
299 --change-section-lma .dpageFB7
=0xFBB800 \
300 --change-section-lma .dpageFB8
=0xFBBC00 \
301 --change-section-lma .fpageFC
=0xFC8000 \
302 --change-section-lma .dpageFC
=0xFCA000 \
303 --only-section
=.dpageFA \
304 --only-section
=.fpageFA \
305 --only-section
=.dpageFB1 \
306 --only-section
=.dpageFB2 \
307 --only-section
=.dpageFB3 \
308 --only-section
=.dpageFB4 \
309 --only-section
=.dpageFB5 \
310 --only-section
=.dpageFB6 \
311 --only-section
=.dpageFB7 \
312 --only-section
=.dpageFB8 \
313 --only-section
=.fpageFB \
314 --only-section
=.dpageFC \
315 --only-section
=.fpageFC
316 # --change-section-lma .ppageFD=0xFD8000 \
317 # --change-section-lma .ppageFF=0xFF8000 \
318 # --only-section=.ppageFD \ This is left here for clarity only (equivalent to text1 but paged)
319 # --only-section=.ppageFF This is left here for clarity only (equivalent to text but paged)
320 # Changes to the above options should be reflected in memory.x and memory.h also!
322 # The following flash areas can only be used once Sean has written his loader app :
323 # --only-section=.ppageE0 \
324 # --only-section=.ppageE1 \
325 # --only-section=.ppageE2 \
326 # --only-section=.ppageE3 \
327 # --only-section=.ppageE4 \
328 # --only-section=.ppageE5 \
329 # --only-section=.ppageE6 \
330 # --only-section=.ppageE7 \
331 # --only-section=.ppageE8 \
332 # --only-section=.ppageE9 \
333 # --only-section=.ppageEA \
334 # --only-section=.ppageEB \
335 # --only-section=.ppageEC \
336 # --only-section=.ppageED \
337 # --only-section=.ppageEE \
338 # --only-section=.ppageEF \
339 # --only-section=.ppageF0 \
340 # --only-section=.ppageF1 \
341 # --only-section=.ppageF2 \
342 # --only-section=.ppageF3 \
343 # --only-section=.ppageF4 \
344 # --only-section=.ppageF5 \
345 # --only-section=.ppageF6 \
346 # --only-section=.ppageF7 \
347 # --change-section-lma .ppageE0=0xE08000 \
348 # --change-section-lma .ppageE1=0xE18000 \
349 # --change-section-lma .ppageE2=0xE28000 \
350 # --change-section-lma .ppageE3=0xE38000 \
351 # --change-section-lma .ppageE4=0xE48000 \
352 # --change-section-lma .ppageE5=0xE58000 \
353 # --change-section-lma .ppageE6=0xE68000 \
354 # --change-section-lma .ppageE7=0xE78000 \
355 # --change-section-lma .ppageE8=0xE88000 \
356 # --change-section-lma .ppageE9=0xE98000 \
357 # --change-section-lma .ppageEA=0xEA8000 \
358 # --change-section-lma .ppageEB=0xEB8000 \
359 # --change-section-lma .ppageEC=0xEC8000 \
360 # --change-section-lma .ppageED=0xED8000 \
361 # --change-section-lma .ppageEE=0xEE8000 \
362 # --change-section-lma .ppageEF=0xEF8000 \
363 # --change-section-lma .ppageF0=0xF08000 \
364 # --change-section-lma .ppageF1=0xF18000 \
365 # --change-section-lma .ppageF2=0xF28000 \
366 # --change-section-lma .ppageF3=0xF38000 \
367 # --change-section-lma .ppageF4=0xF48000 \
368 # --change-section-lma .ppageF5=0xF58000 \
369 # --change-section-lma .ppageF6=0xF68000 \
370 # --change-section-lma .ppageF7=0xF78000 \
375 @echo
"################################################################################"
376 @echo
"# Dependency And Target Summary #"
377 @echo
"################################################################################"
379 @echo
"# Common targets: #"
381 @echo
"# 1) help - This comment block #"
382 @echo
"# 2) all - Executes alldebug, slow, slowgc and size #"
383 @echo
"# 3) dirs - Creates all of the directories required to build #"
384 @echo
"# 4) fast - Compiles direct to object code and links once with no debug #"
385 @echo
"# 5) slow - Three stage compilation with assembly retained #"
386 @echo
"# 6) slowgc - As above, but with garbage collection during linking #"
387 @echo
"# 7) alldebug - Generates all debug output files #"
388 @echo
"# 8) install - Not yet implemented #"
389 @echo
"# 9) release - Not yet implemented #"
390 @echo
"# 10) clean - Removes all files and directories generated by building #"
392 @echo
"# Second level targets: #"
394 @echo
"# Stage one: #"
396 @echo
"# 1) preprocess - run the C preprocessor over the raw C files #"
397 @echo
"# 2) compile - compile the preprocessed C into assembly #"
398 @echo
"# 3) assemble - assemble the assembly files into object files #"
400 @echo
"# Stage two #"
402 @echo
"# 1) link - Generate ELFs objects #"
403 @echo
"# 2) gclink - As above, but with garbage collection #"
404 @echo
"# 3) s19 - Create s19s from elfs #"
405 @echo
"# 4) gcs19 - Create s19s from gc elfs #"
407 @echo
"# Stage three: #"
409 @echo
"# 1) maps - Memory map files #"
410 @echo
"# 2) rees - Readelf dumps #"
411 @echo
"# 3) elfdmps - Classic objdump output for final elfs #"
412 @echo
"# 4) objdmps - Classic objdump output for each object file #"
414 @echo
"# Additionally any of the output files can be used as a target directly. #"
415 @echo
"# This is perfect for building only what is required for a specific s19. #"
416 @echo
"# It is also perfect for working with a single file as you don't have to #"
417 @echo
"# wait for other unrelated things to build first nor do you have to wait #"
418 @echo
"# for other files to continue building after yours is successful. Before #"
419 @echo
"# using individual output files for targets, please run 'make dirs'. #"
421 @echo
"################################################################################"
426 ################################################################################
427 # All Target Dependencies #
428 ################################################################################
431 # Build everything the long way
432 all: alldebug gcs19 s19 size
433 # Single stage compilation
434 fast
: single s19 size
435 # Multi stage compilation
437 # Multi stage compilation with garbage collection
439 # Clean all except release
440 clean: cleanasm cleanobj cleanout cleanppc cleans19 cleandebug
442 alldebug
: maps rees elfdmps objdmps
443 # Load the s19 of your choice
444 #install: clean fast loader
446 release
: relprep relbuild relperf relpack1 relpack2
447 relprep
: testgit
clean cleanrelease cleandoxy
448 relbuild
: s19rel s19relgc gendoxy
449 relperf
: clean relcommit tagmessage tagrelease
450 relpack1
: md5sums md5sumsgc sha1sums sha1sumsgc s19zips s19zipsgc
451 relpack2
: zipsite zipdocs zipmain zipsite zipsrc
456 ################################################################################
457 # Debug Target Definitions #
458 ################################################################################
462 @echo
"################################################################################"
463 @echo
"# Generating memory maps.... #"
464 @echo
"################################################################################"
466 maps
: link
$(BUGDIR
) mapsmsg
$(ALLMAPS
)
468 $(ALLMAPS
): $(BUGDIR
)/%.map
: $(OUTDIR
)/%.elf
473 @echo
"################################################################################"
474 @echo
"# Reading all elf files... #"
475 @echo
"################################################################################"
477 rees
: link
$(BUGDIR
) reesmsg
$(ALLREAD
)
479 $(ALLREAD
): $(BUGDIR
)/%.ree
: $(OUTDIR
)/%.elf
484 @echo
"################################################################################"
485 @echo
"# Dumping all elf files... #"
486 @echo
"################################################################################"
488 elfdmps
: link
$(BUGDIR
) elfdmpsmsg
$(ALLDMPS
)
490 $(ALLDMPS
): $(BUGDIR
)/%.dmp
: $(OUTDIR
)/%.elf
491 $(DUMP
) -spSd
$< > $@
495 @echo
"################################################################################"
496 @echo
"# Dumping all object files.... #"
497 @echo
"################################################################################"
499 objdmps
: assemble
$(BUGDIR
) objdmpmsg
$(DUMPS
) $(DUMPSRPM
)
501 $(DUMPS
) $(DUMPSRPM
): $(BUGDIR
)/%.dmp
: $(OBJDIR
)/%.o
502 $(DUMP
) -spSd
$< > $@
507 ################################################################################
508 # Fast Single Stage Compile Target Definition #
509 ################################################################################
513 # TODO fast compile and figure out overlapping dependencies...
518 ################################################################################
519 # Link and Copy Target Definitions #
520 ################################################################################
524 @echo
"################################################################################"
525 @echo
"# Linking the Objects into an ELF... #"
526 @echo
"################################################################################"
528 link
: assemble
$(OUTDIR
) linkmsg
$(ALLELFS
)
530 # link the object files into an elf executable
531 $(ALLELFS
): $(OUTDIR
)/$(LABEL
)-%.elf
: $(OBJDIR
)/%.o
$(OBJECTS
) $(XGOBJECTS
)
532 @echo
"################################################################################"
533 @echo
"# Linking $@ ..."
534 @echo
"################################################################################"
535 $(GCC
) $(GCCOPTS
) -Wl
,$(LINKOPTS
) -o
$@
$< $(OBJECTS
) $(XGOBJECTS
)
539 @echo
"################################################################################"
540 @echo
"# Linking the Objects into an ELF... #"
541 @echo
"################################################################################"
543 gclink
: assemble
$(OUTDIR
) linkmsg
$(GCDELFS
)
545 # link the object files into an elf executable with gc enabled
546 $(GCDELFS
): $(OUTDIR
)/$(LABEL
)-%.gc.elf
: $(OBJDIR
)/%.o
$(OBJECTS
) $(XGOBJECTS
)
547 @echo
"################################################################################"
548 @echo
"# Linking $@ ..."
549 @echo
"################################################################################"
550 $(GCC
) $(GCCOPTS
) -Wl
,$(LINKOPTSGC
) -o
$@
$< $(OBJECTS
) $(XGOBJECTS
)
551 # The links with garbage collection are to ensure that there are no warnings
552 # TODO find out how to stop .tramp from being collected (or inserted)!
553 # This will be the only way once Sean's stuff is done and distributed, I can't wait to cut all this bullshit out!
557 @echo
"################################################################################"
558 @echo
"# Building The S19 Files.... #"
559 @echo
"################################################################################"
561 s19
: link
$(S19DIR
) s19msg
$(ALLS19S
)
562 # the gc dependency is temporary until i figure out if the .tramp removal is an issue or not.
564 # Generate the loadable s19 firmware files
565 $(ALLS19S
): $(S19DIR
)/%.s19
: $(OUTDIR
)/%.elf
566 @echo
"################################################################################"
567 @echo
"# Building $@ ..."
568 @echo
"################################################################################"
569 $(COPY
) $(COPYOPTS
) $< $@
570 @echo
"################################################################################"
571 @echo
"# Measuring $@ ..."
572 @echo
"################################################################################"
573 echo
"Flash image size of $@ is" `echo \`cat
$@ | wc
-l\
` "* 16" | bc -l` "bytes!"
577 @echo
"################################################################################"
578 @echo
"# Building The S19 Files.... #"
579 @echo
"################################################################################"
581 gcs19
: gclink
$(S19DIR
) gcs19msg
$(GCDS19S
)
583 # Generate the garbage collected s19 files temporarily
584 $(GCDS19S
): $(S19DIR
)/%.s19
: $(OUTDIR
)/%.elf
585 @echo
"################################################################################"
586 @echo
"# Building $@ ..."
587 @echo
"################################################################################"
588 $(COPY
) $(COPYOPTS
) $< $@
589 @echo
"################################################################################"
590 @echo
"# Measuring $@ ..."
591 @echo
"################################################################################"
592 echo
"Flash image size of $@ is" `echo \`cat
$@ | wc
-l\
` "* 16" | bc -l` "bytes!"
597 ################################################################################
598 # Size Measuring Target Definition #
599 ################################################################################
602 size
: assemble
# TODO this should be run for each s19 target with only the one rpm .o file
603 @echo
"################################################################################"
604 @echo
"# Measuring The Decoder Binaries... #"
605 @echo
"################################################################################"
606 $(SIZE
) $(OBJECTSRPM
)
607 @echo
"################################################################################"
608 @echo
"# Measuring All Other Binaries... #"
609 @echo
"################################################################################"
610 $(SIZE
) -t
$(OBJECTS
)
611 @echo
"################################################################################"
612 @echo
"# Add one decoder to the total above and #"
613 @echo
"# subtract the size reported for freeEMS.o #"
614 @echo
"# this will give you the actual image size #"
615 @echo
"################################################################################"
617 @echo
"# Thank you for building FreeEMS firmware!!! #"
619 @echo
"################################################################################"
624 ################################################################################
625 # Preprocess, Compile and Assemble Target Definitions #
626 ################################################################################
630 @echo
"################################################################################"
631 @echo
"# Running the C Pre Processor... #"
632 @echo
"################################################################################"
634 preprocess
: $(PPCDIR
) preprocessmsg
$(PREPROCESSED
) $(PREPROCESSEDRPM
)
636 # Generate preprocessed source files to examine
637 $(PREPROCESSED
) $(PREPROCESSEDRPM
): $(PPCDIR
)/%.pp.c
: %.c
$(ALLH
)
638 $(GCC
) $(GCCOPTS
) -E
$< > $@
642 @echo
"################################################################################"
643 @echo
"# Compiling PPC to Assembly... #"
644 @echo
"################################################################################"
646 compile
: preprocess compilemsg
$(ASSEMBLIES
) $(ASSEMBLIESRPM
)
648 # Generate assembly files to examine
649 $(ASSEMBLIES
) $(ASSEMBLIESRPM
): $(ASMDIR
)/%.s
: $(PPCDIR
)/%.pp.c
650 $(GCC
) $(GCCOPTS
) -x cpp-output
-S
-o
$@
$<
654 @echo
"################################################################################"
655 @echo
"# Assembling Object Files... #"
656 @echo
"################################################################################"
658 assemble
: compile
$(OBJDIR
) $(XGOBJDIR
) assemblemsg
$(OBJECTS
) $(OBJECTSRPM
) $(XGOBJECTS
)
660 # Generate object files to link
661 $(OBJECTS
) $(OBJECTSRPM
): $(OBJDIR
)/%.o
: $(ASMDIR
)/%.s
662 $(GCC
) $(GCCOPTS
) -c
-o
$@
$<
664 $(XGOBJECTS
): $(XGOBJDIR
)/%.o
: $(XGASMDIR
)/%.s
669 ################################################################################
670 # Release Procedure Target Definitions #
671 ################################################################################
676 @echo
"################################################################################"
677 @echo
"# Checking git status... #"
678 @echo
"################################################################################"
679 @echo
"Fetching from origin..."
681 @echo
"Is everything checked in?"
682 test `git status -s | wc -l` -eq
0
683 @echo
"Are we behind?"
684 test `git rev-list \`git show-ref
--hash refs
/heads
/master\
`..\`git show-ref
--hash refs
/remotes
/origin/master\
` | wc -l` -eq
0
685 @echo
"Are we ahead?"
686 test `git rev-list \`git show-ref
--hash refs
/remotes
/origin/master\
`..\`git show-ref
--hash refs
/heads
/master\
` | wc -l` -eq
0
692 @echo
"################################################################################"
693 @echo
"# Generating MD5 Sums... #"
694 @echo
"################################################################################"
696 md5sums
: s19 distributiondir md5sumsmsg
$(ALLMD5S
)
698 $(ALLMD5S
): $(DISTRIBUTIONDIR
)/%.s19.md5
: $(S19DIR
)/%.s19
703 @echo
"################################################################################"
704 @echo
"# Generating SHA1 Sums... #"
705 @echo
"################################################################################"
707 sha1sums
: s19 distributiondir sha1sumsmsg
$(ALLSHA1S
)
709 $(ALLSHA1S
): $(DISTRIBUTIONDIR
)/%.s19.sha1
: $(S19DIR
)/%.s19
716 @echo
"################################################################################"
717 @echo
"# Generating MD5 Sums... #"
718 @echo
"################################################################################"
720 md5sumsgc
: gcs19 distributiondir md5sumsmsggc
$(GCDMD5S
)
722 $(GCDMD5S
): $(DISTRIBUTIONDIR
)/%.s19.md5
: $(S19DIR
)/%.s19
727 @echo
"################################################################################"
728 @echo
"# Generating SHA1 Sums... #"
729 @echo
"################################################################################"
731 sha1sumsgc
: gcs19 distributiondir sha1sumsmsggc
$(GCDSHA1S
)
733 $(GCDSHA1S
): $(DISTRIBUTIONDIR
)/%.s19.sha1
: $(S19DIR
)/%.s19
738 @echo
"################################################################################"
739 @echo
"# Zipping S19s... #"
740 @echo
"################################################################################"
742 s19zips
: s19 distributiondir s19zipsmsg
$(ALLS19ZIPS
)
744 $(ALLS19ZIPS
): $(DISTRIBUTIONDIR
)/%.s19.zip
: $(S19DIR
)/%.s19
749 @echo
"################################################################################"
750 @echo
"# Copying S19s... #"
751 @echo
"################################################################################"
753 s19rel
: s19 s19relmsg
$(ALLS19RELS
)
755 $(ALLS19RELS
): $(RELEASEDIR
)/%.s19
: $(S19DIR
)/%.s19
760 @echo
"################################################################################"
761 @echo
"# Zipping GC S19s... #"
762 @echo
"################################################################################"
764 s19zipsgc
: gcs19 distributiondir s19zipsmsg
$(GCDS19ZIPS
)
766 $(GCDS19ZIPS
): $(DISTRIBUTIONDIR
)/%.s19.zip
: $(S19DIR
)/%.s19
771 @echo
"################################################################################"
772 @echo
"# Copying GC S19s... #"
773 @echo
"################################################################################"
775 s19relgc
: gcs19 s19relgcmsg
$(GCDS19RELS
)
777 $(GCDS19RELS
): $(RELEASEDIR
)/%.s19
: $(S19DIR
)/%.s19
782 git add
$(RELEASEDIR
)
783 git commit
-m
"Automatically committing release files for FreeEMS version $(VERSION)!" ..
792 tagrelease
: tagname tagmessage
793 git tag
-F
$(RELTAG
) `cat $(TAGNAME)` HEAD
796 zipmain
: distributiondir
797 cd ..
/;git archive
--format
=zip
--prefix=$(LABEL
)/ HEAD
> ..
/$(LABEL
)/$(LABEL
).zip
;cd
-
799 zipdocs
: distributiondir
800 cd ..
/;git archive
--format
=zip
--prefix=$(LABEL
)- HEAD docs
/ > ..
/$(LABEL
)/$(LABEL
)-docs.zip
;cd
-
803 cd ..
;doxygen docs
/Doxyfile | grep Warning
> src
/doxygen.output
;cd
-
805 zipsite
: distributiondir gendoxy
806 cd ..
/docs
/;zip
-r
$(DISTRIBUTIONDIR
)/doxygen-html.zip doxygen-html
/;cd
-
808 zipsrc
: distributiondir
809 cd ..
/;git archive
--format
=zip
--prefix=$(LABEL
)- HEAD src
/ > ..
/$(LABEL
)/$(LABEL
)-src.zip
;cd
-
814 ################################################################################
815 # Create Directory Target Definitions #
816 ################################################################################
818 # Assembly, release and inc directories don't get removed.
820 dirs
: $(BUGDIR
) $(S19DIR
) $(PPCDIR
) $(OUTDIR
) $(OBJDIR
) $(XGOBJDIR
)
823 @echo
"################################################################################"
824 @echo
"# Creating the debug directory.... #"
825 @echo
"################################################################################"
826 $(MKDIR
) $(BUGDIR
)$(PATHSEP
)hack
827 rmdir
$(BUGDIR
)$(PATHSEP
)hack
830 @echo
"################################################################################"
831 @echo
"# Creating the firmware directory... #"
832 @echo
"################################################################################"
833 $(MKDIR
) $(S19DIR
)$(PATHSEP
)hack
834 rmdir
$(S19DIR
)$(PATHSEP
)hack
837 @echo
"################################################################################"
838 @echo
"# Creating the preprocessedc directory.... #"
839 @echo
"################################################################################"
840 $(MKDIR
) $(PPCDIR
)$(PATHSEP
)hack
841 rmdir
$(PPCDIR
)$(PATHSEP
)hack
844 @echo
"################################################################################"
845 @echo
"# Creating the output directory... #"
846 @echo
"################################################################################"
847 $(MKDIR
) $(OUTDIR
)$(PATHSEP
)hack
848 rmdir
$(OUTDIR
)$(PATHSEP
)hack
851 @echo
"################################################################################"
852 @echo
"# Creating the object directory... #"
853 @echo
"################################################################################"
854 $(MKDIR
) $(OBJDIR
)$(PATHSEP
)hack
855 rmdir
$(OBJDIR
)$(PATHSEP
)hack
858 @echo
"################################################################################"
859 @echo
"# Creating the xgate object directory... #"
860 @echo
"################################################################################"
861 $(MKDIR
) $(XGOBJDIR
)$(PATHSEP
)hack
862 rmdir
$(XGOBJDIR
)$(PATHSEP
)hack
865 @echo
"################################################################################"
866 @echo
"# Creating the distribution directory... #"
867 @echo
"################################################################################"
868 $(MKDIR
) $(DISTRIBUTIONDIR
)$(PATHSEP
)hack
869 rmdir
$(DISTRIBUTIONDIR
)$(PATHSEP
)hack
874 ################################################################################
875 # Clean Target Definitions #
876 ################################################################################
879 @echo
"################################################################################"
880 @echo
"# Removing generated assembly files.... #"
881 @echo
"################################################################################"
882 $(RM
) $(ASSEMBLIES
) $(ASSEMBLIESRPM
)
885 @echo
"################################################################################"
886 @echo
"# Removing pre-processed C output directory... #"
887 @echo
"################################################################################"
891 @echo
"################################################################################"
892 @echo
"# Removing object directory... #"
893 @echo
"################################################################################"
897 @echo
"################################################################################"
898 @echo
"# Removing link output directory... #"
899 @echo
"################################################################################"
903 @echo
"################################################################################"
904 @echo
"# Removing s19 directory... #"
905 @echo
"################################################################################"
909 @echo
"################################################################################"
910 @echo
"# Removing debug directory... #"
911 @echo
"################################################################################"
915 @echo
"################################################################################"
916 @echo
"# Removing all release files... #"
917 @echo
"################################################################################"
918 $(RM
) $(RELEASEDIR
)/*-$(PREVIOUSVERSION
)*
921 @echo
"################################################################################"
922 @echo
"# Removing Doxygen HTML... #"
923 @echo
"################################################################################"
924 $(RM
) ..
/docs
/doxygen-html
/
927 ################################################################################
928 # Declare targets that aren't real files #
929 ################################################################################
932 # Aggregators top level
933 .PHONY
: all fast slow slowgc single help dirs
935 # Aggregators middle level
936 .PHONY
: preprocess compile assemble link gclink s19 gcs19
938 # Aggregators debug level
939 .PHONY
: alldebug maps rees objdmps elfdmps size
942 .PHONY
: release relprep relperf relbuild relpack
943 .PHONY
: md5sums sha1sums s19zips sha1sumsgc s19zips s19zipsgc
944 .PHONY
: testgit relcommit tagname tagmessage tagrelease
945 .PHONY
: zipmain zipdocs zipsite zipsource
948 .PHONY
: mapsmsg reesmsg elfdmpsmsg objdmpmsg linkmsg gclinkmsg
949 .PHONY
: s19msg gcs19msg preprocessmsg compilemsg assemblemsg
950 .PHONY
: md5sumsmsg sha1sumsmsg s19zipsmsg
953 .PHONY
: clean cleanasm cleanppc cleanobj cleanout cleans19 cleandebug cleanrelease cleandoxy
955 # Lonely documentation target :-(