From b247e56368513ab07bfef4cd0c808f17ff686518 Mon Sep 17 00:00:00 2001 From: Fred Cooke Date: Sat, 21 Jun 2014 20:47:23 +1200 Subject: [PATCH] Refactor the Makefile into pieces. This commit inspired by AncientGeek, my hatred for overly long files, and my love of separation of concerns. --- src/main/Makefile | 1456 ++++++++++++--------------------------------- src/main/make/clean.mk | 82 +++ src/main/make/decoders.mk | 51 ++ src/main/make/dirs.mk | 101 ++++ src/main/make/groups.mk | 86 +++ src/main/make/help.mk | 136 +++++ src/main/make/options.mk | 160 +++++ src/main/make/paths.mk | 117 ++++ src/main/make/phony.mk | 60 ++ src/main/make/release.mk | 119 ++++ src/main/make/sources.mk | 91 +++ 11 files changed, 1380 insertions(+), 1079 deletions(-) rewrite src/main/Makefile (70%) create mode 100644 src/main/make/clean.mk create mode 100644 src/main/make/decoders.mk create mode 100644 src/main/make/dirs.mk create mode 100644 src/main/make/groups.mk create mode 100644 src/main/make/help.mk create mode 100644 src/main/make/options.mk create mode 100644 src/main/make/paths.mk create mode 100644 src/main/make/phony.mk create mode 100644 src/main/make/release.mk create mode 100644 src/main/make/sources.mk diff --git a/src/main/Makefile b/src/main/Makefile dissimilarity index 70% index 901f684..4cf085d 100644 --- a/src/main/Makefile +++ b/src/main/Makefile @@ -1,1079 +1,377 @@ -# FreeEMS - the open source engine management system -# -# Makefile -# -# Copyright 2008-2014 Fred Cooke -# -# This Makefile is part of the FreeEMS project. -# -# FreeEMS software is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# FreeEMS software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ -# -# We ask that if you make any changes to this file you email them upstream to -# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! -# -# Thank you for choosing FreeEMS to run your engine! - - - - -################################################################################ -# # -# About This Makefile # -# # -# This makefile incorporates many non-standard features. In particular, it # -# is inspired by Maven 2 and it's highly disciplined release mechanism. By # -# automating the release process as much as possible the chance of human # -# error is minimised. As much as possible, reuse is employed to keep bugs # -# from being introduced when changes are made. Rather than compiling from # -# C source files directly to object files, the build is, by default, done # -# in three stages, C to pre-processed C, pre-processed C to assembly, and # -# assembly to object files. Linking is also a little different with two # -# variants available, with and without garbage collection. Target device # -# memory usage statistics are available and generated by default when the # -# all target is called. Finally, extensive debug information can be # -# generated with a single make call. # -# # -################################################################################ - - - - -################################################################################ -# All Fixed Variables # -################################################################################ - - -# Constants -FIRMWARE_VERSION := $(shell git describe --always --dirty=-DEV) -OUTPREFIX := FreeEMS -BUILD_DATE := "$(shell date)" -OS := $(shell uname) -BUILT_BY_NAME := "$(shell git config --global --get user.name)" -SUPPORT_EMAIL := "$(shell git config --global --get user.email)" - -# Windows differences -ifdef ComSpec -# Windows uses backslash -PATHSEP = \\ -# Windows mkdir does not accept -p -MKDIR = mkdir -# Windows echo repeats " symbols (Q stands for quote...) -Q = -SHASUM = sha1sum -else -PATHSEP = / -MKDIR = mkdir -p -Q = " -SHASUM = shasum -endif - -# Mac differences -ifeq ($(OS), Darwin) -MD5SUM = md5 -r -else -# If using this on windows, we're in cygwin, same as Linux -MD5SUM = md5sum -endif - -ifdef CLIFLAGS -CLIBUILD = -D CLIFLAGS=1 -ifdef XGATE -CLIFLAGSARG = -D $(CLIFLAGS)=1 -D XGATE=1 -LABEL := $(OUTPREFIX)-$(FIRMWARE_VERSION)-$(CLIFLAGS)-XGATE -else -CLIFLAGSARG = -D $(CLIFLAGS)=1 -LABEL := $(OUTPREFIX)-$(FIRMWARE_VERSION)-$(CLIFLAGS) -endif -else -LABEL := $(OUTPREFIX)-$(FIRMWARE_VERSION) -endif - -# Directories here -DISTRIBUTIONDIR = ../../tmp/$(LABEL) -FIRMWAREDISTRIBUTIONDIR = $(DISTRIBUTIONDIR)/$(LABEL)-firmware -DOXYDOCDIR = ../../docs/doxygen-html -MAINDIR = freeems-vanilla -INCDIR = inc -DEPDIR = dependencies -DECDIR = decoders -DATADIR = initialisers -BUGDIR = debug -OUTDIR = output -OBJDIR = objects -ASMDIR = assembly -XGASMDIR = assemblyxgate -HANDASMDIR = assemblyhand -S19DIR = firmware -PPCDIR = preprocessedc -XGOBJDIR = $(OBJDIR)$(PATHSEP)xgate - -# Release tag message file -RELTAG = $(OUTDIR)/gitTagMessage.txt -TAGNAME = $(OUTDIR)/gitTagName.txt - -# Program prefixes, for the main cpu and for the xgate coprocessor -PREFIX = m68hc11- -XGPREFIX = mc9xgate- - -# All of the tools -CP = cp -RM = rm -rf -ZIP = zip -GCC = $(PREFIX)gcc -COPY = $(PREFIX)objcopy -DUMP = $(PREFIX)objdump -NM = $(PREFIX)nm -RE = $(PREFIX)readelf -SIZE = $(PREFIX)size -XGAS = $(XGPREFIX)as - - - - -################################################################################ -# All Source Files # -################################################################################ - - -# Indirect dependencies that can affect everything and cause a full rebuild -MFILE = Makefile -ASMH = 9S12XDP512asm.s -LINKER = memory.x regions.x hc9s12xdp512elfb.x - - -# Let's keep this to a bare minimum! If you write ASM code -# please provide an matching alternate C implementation too. -HANDASMS = flashBurn.s -#RPMHANDASMS = - -ALLH = $(LINKER) $(MFILE) $(INCDIR)/$(ASMH) - -# Warning : do not include .c files from inc/ as they are -# included into the other C files and automatically compiled. - -# Flash data files -FIXEDCLASSES = FixedConfig1.c FixedConfig2.c -LOOKUPCLASSES1 = IATTransferTable.c CHTTransferTable.c -LOOKUPCLASSES2 = MAFTransferTable.c TestTransferTable.c -FUELCLASSES = FuelTables.c FuelTables2.c -TIMECLASSES = TimingTables.c TimingTables2.c -TUNECLASSES = TunableConfig.c TunableConfig2.c -# Combined data files -DATARAW = $(FIXEDCLASSES) $(LOOKUPCLASSES1) $(LOOKUPCLASSES2) $(FUELCLASSES) $(TIMECLASSES) $(TUNECLASSES) -DATA = $(patsubst %.c,$(DATADIR)/%.c,$(DATARAW)) - -# Source code files -UTILCLASSES = tableLookup.c init.c utils.c globalConstants.c StaticBenchTest.c simpleGPIO.c -MATHCLASSES = coreVarsGenerator.c derivedVarsGenerator.c fuelAndIgnitionCalcs.c outputScheduler.c decoderInterface.c -COMCLASSES = flashWrite.c commsCore.c blockDetailsLookup.c -ISRCLASSES = interrupts.c injectionISRs.c commsISRs.c realtimeISRs.c miscISRs.c xgateVectors.c -# Combined source code files -SOURCE = freeEMS.c staticInit.c main.c $(UTILCLASSES) $(MATHCLASSES) $(COMCLASSES) $(ISRCLASSES) - -# All but the engine position/RPM combined here -CLASSES = $(SOURCE) $(DATA) - -# Engine position/RPM here -# Special decoders are not for use running an engine -RPMSPECIAL = Listener.c BenchTest.c -# TODO: Automate file naming for the following 4 lines -RPMEVENTEETH = EvenTeeth-Cam-24and1.c EvenTeeth-Cam-16and1.c EvenTeeth-Cam-6and1.c EvenTeeth-Distributor-4of6and1.c EvenTeeth-Cam-4and1.c -RPMMISSINGTEETH = MissingTeeth-TestFile.c MissingTeeth-Cam-24minus1.c MissingTeeth-Crank-8minus1.c MissingTeeth-Crank-12minus1.c MissingTeeth-Crank-36minus1.c MissingTeeth-Crank-60minus2.c MissingTeeth-Cam-6minus2.c MissingTeeth-Crank-30minus2.c MissingTeeth-Cam-12minus1.c MissingTeeth-Crank-36minus2.c -RPMHALLOROPTICAL = HallOrOptical-Distributor-4of64.c HallOrOptical-Distributor-4of90.c -RPMVRDISTRIBUTOR = -# Specific purpose per engine stuff here -RPMMITSISTYLE = MitsiAndMazda-CAS-4and1.c MitsiAndMazda-CAS-4and2.c -RPMHONDASTYLE = JSeries-12CrankWith6-2Cam.c R18A1-13CrankWith5Cam.c -RPMNISSANSTYLE = GM-LT1-CAS-360and8.c -# Insert your file above and get coding! -RPMSPECIFICENGINES = $(RPMMITSISTYLE) $(RPMHONDASTYLE) $(RPMNISSANSTYLE) -RPMCLASSESRAW = $(RPMSPECIAL) $(RPMEVENTEETH) $(RPMMISSINGTEETH) $(RPMHALLOROPTICAL) $(RPMVRDISTRIBUTOR) $(RPMSPECIFICENGINES) -RPMCLASSES = $(patsubst %.c,$(DECDIR)/%.c,$(RPMCLASSESRAW)) - -# XGATE stuff here! -XGASMSRCS = xgate.s - - -# Convert extensions -DEPENDENCIES = $(patsubst %.c,$(DEPDIR)/%.d,$(CLASSES)) -DDEPENDENCIES = $(patsubst %.c,$(DEPDIR)/%.dd,$(CLASSES)) -PREPROCESSED = $(patsubst %.c,$(PPCDIR)/%.pp.c,$(CLASSES)) -ASSEMBLIES = $(patsubst %.c,$(ASMDIR)/%.s,$(CLASSES)) -OBJECTS = $(patsubst %.c,$(OBJDIR)/%.o,$(CLASSES)) -HANDOBJECTS = $(patsubst %.s,$(OBJDIR)/%.o,$(HANDASMS)) -DUMPS = $(patsubst %.c,$(BUGDIR)/%.dmp,$(CLASSES)) $(patsubst %.s,$(BUGDIR)/%.dmp,$(HANDASMS)) -XGOBJECTS = $(patsubst %.s,$(XGOBJDIR)/%.o,$(XGASMSRCS)) - -# Convert RPM extensions -DEPENDENCIESRPM = $(patsubst %.c,$(DEPDIR)/%.d,$(RPMCLASSES)) -DDEPENDENCIESRPM = $(patsubst %.c,$(DEPDIR)/%.dd,$(RPMCLASSES)) -PREPROCESSEDRPM = $(patsubst %.c,$(PPCDIR)/%.pp.c,$(RPMCLASSES)) -ASSEMBLIESRPM = $(patsubst %.c,$(ASMDIR)/%.s,$(RPMCLASSES)) -OBJECTSRPM = $(patsubst %.c,$(OBJDIR)/%.o,$(RPMCLASSES)) #$(patsubst $(DECDIR???)%.s,$(OBJDIR)/%.o,$(RPMHANDASMS)) -DUMPSRPM = $(patsubst %.c,$(BUGDIR)/%.dmp,$(RPMCLASSES)) #$(patsubst $(DECDIR???)%.s,$(BUGDIR)/%.dmp,$(RPMHANDASMS)) - -# Convert to output files for source -ALLELFSC = $(patsubst $(DECDIR)/%.c,$(OUTDIR)/$(LABEL)-%.elf,$(RPMCLASSES)) -ALLELFSASM = #$(patsubst %.s,$(OUTDIR)/$(LABEL)-%.elf,$(RPMHANDASMS)) -ALLDMPSC = $(patsubst $(DECDIR)/%.c,$(BUGDIR)/$(LABEL)-%.dmp,$(RPMCLASSES)) -ALLDMPSASM = #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.dmp,$(RPMHANDASMS)) -ALLMAPSC = $(patsubst $(DECDIR)/%.c,$(BUGDIR)/$(LABEL)-%.map,$(RPMCLASSES)) -ALLMAPSASM = #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.map,$(RPMHANDASMS)) -ALLREADC = $(patsubst $(DECDIR)/%.c,$(BUGDIR)/$(LABEL)-%.ree,$(RPMCLASSES)) -ALLREADASM = #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.ree,$(RPMHANDASMS)) -ALLS19SC = $(patsubst $(DECDIR)/%.c,$(S19DIR)/$(LABEL)-%.s19,$(RPMCLASSES)) -ALLS19SASM = #$(patsubst %.s,$(S19DIR)/$(LABEL)-%.s19,$(RPMHANDASMS)) - -# Convert to output files for as-is variants -ALLELFS = $(ALLELFSC) $(ALLELFSASM) -ALLDMPS = $(ALLDMPSC) $(ALLDMPSASM) -ALLMAPS = $(ALLMAPSC) $(ALLMAPSASM) -ALLREAD = $(ALLREADC) $(ALLREADASM) -ALLS19S = $(ALLS19SC) $(ALLS19SASM) -ALLSIZES = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt,$(ALLS19S)) -ALLDUMMY = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt.dummy,$(ALLS19S)) -ALLMD5S = $(patsubst $(S19DIR)/%,$(FIRMWAREDISTRIBUTIONDIR)/%.md5,$(ALLS19S)) -ALLSHA1S = $(patsubst $(S19DIR)/%,$(FIRMWAREDISTRIBUTIONDIR)/%.sha1,$(ALLS19S)) -ALLS19ZIPS = $(patsubst $(S19DIR)/%,$(FIRMWAREDISTRIBUTIONDIR)/%.zip,$(ALLS19S)) - - -# Convert to output files for GC variants -GCDELFSC = $(patsubst $(DECDIR)/%.c,$(OUTDIR)/$(LABEL)-%.gc.elf,$(RPMCLASSES)) -GCDELFSASM = #$(patsubst %.s,$(OUTDIR)/$(LABEL)-%.gc.elf,$(RPMHANDASMS)) -GCDS19SC = $(patsubst $(DECDIR)/%.c,$(S19DIR)/$(LABEL)-%.gc.s19,$(RPMCLASSES)) -GCDS19SASM = #$(patsubst %.s,$(S19DIR)/$(LABEL)-%.gc.s19,$(RPMHANDASMS)) -GCDELFS = $(GCDELFSC) $(GCDELFSASM) -GCDS19S = $(GCDS19SC) $(GCDELFSASM) -GCDSIZES = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt,$(GCDS19S)) -GCDDUMMY = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt.dummy,$(GCDS19S)) - - - - -################################################################################ -# All Command Line Options # -################################################################################ - - -# M68hc1x GCC Options we may want : -minmax -mlong-calls - -# http://www.gnu.org/software/m68hc11/m68hc11_gcc.html shows code size with different options used -# include debug info, optimise , 16 bit ints, hcs12 platform -GCCOPTS1 = -Wall -Werror -Winline -O -m68hcs12 -mshort -ffunction-sections -GCCOPTS2 = -fomit-frame-pointer -msoft-reg-count=8 -mauto-incdec -fsigned-char -GCCOPTS = $(GCCOPTS1) $(GCCOPTS2) $(CLIBUILD) $(CLIFLAGSARG) -D SUPPORT_EMAIL=\"$(SUPPORT_EMAIL)\" -D BUILT_BY_NAME=\"$(BUILT_BY_NAME)\" -D FIRMWARE_VERSION=\"$(FIRMWARE_VERSION)\" -D FIRMWARE_BUILD_DATE=\"$(BUILD_DATE)\" -D OPERATING_SYSTEM=\"$(OS)\" -# -ffunction-sections option splits out the functions such that the garbage collection can get -# them on a per section basis. I'm not sure, but this could be harmful to paged code so may -# have to review this at a later date perhaps splitting paged functions from nonpaged ones. - -# pass to linker, link for hc12 -# The vectors address in the linker options is the VMA address and must be short form 0xF710, not a paged address. -LINKOPTS = -no-warn-mismatch,-defsym,vectors_addr=0xF710,-m,m68hc12elfb,-T,hc9s12xdp512elfb.x -LINKOPTSGC = -no-warn-mismatch,--gc-sections,--print-gc-sections,-defsym,vectors_addr=0xF710,-m,m68hc12elfb,-T,hc9s12xdp512elfb.x -# Use this to get a map dump when the linker fails in a confusing way : --print-map - -# If using the below option for paged flash, the ADDRESS_TYPE -# field in the freeEMSloader script should be updated to match. -COPYOPTS = --output-target=srec \ - --change-section-lma .fixedconf1+0xFD4000 \ - --change-section-lma .fixedconf2+0xFD4000 \ - --change-section-lma .text1+0xFD4000 \ - --change-section-lma .text+0xFEC000 \ - --change-section-lma .data+0xFEC000 \ - --change-section-lma .vectors+0xFEC000 \ - --change-section-lma .rodata+0xFEC000 \ - --only-section=.fixedconf1 \ - --only-section=.fixedconf2 \ - --only-section=.text \ - --only-section=.text1 \ - --only-section=.data \ - --only-section=.vectors \ - --only-section=.rodata \ - --change-section-lma .ppageE0X=0xE08800 \ - --change-section-lma .ppageE1=0xE18000 \ - --only-section=.ppageE0X \ - --only-section=.ppageE1 \ - --set-section-flags .ppageE1=alloc,load \ - --change-section-lma .ppageF8=0xF88000 \ - --change-section-lma .fpageF9=0xF98000 \ - --change-section-lma .dpageF9=0xF9A000 \ - --change-section-lma .ppageFE=0xFE8000 \ - --only-section=.ppageF8 \ - --only-section=.fpageF9 \ - --only-section=.dpageF9 \ - --only-section=.ppageFE \ - --change-section-lma .fpageFA=0xFA8000 \ - --change-section-lma .dpageFA=0xFAA000 \ - --change-section-lma .fpageFB=0xFB8000 \ - --change-section-lma .dpageFB1=0xFBA000 \ - --change-section-lma .dpageFB2=0xFBA400 \ - --change-section-lma .dpageFB3=0xFBA800 \ - --change-section-lma .dpageFB4=0xFBAC00 \ - --change-section-lma .dpageFB5=0xFBB000 \ - --change-section-lma .dpageFB6=0xFBB400 \ - --change-section-lma .dpageFB7=0xFBB800 \ - --change-section-lma .dpageFB8=0xFBBC00 \ - --change-section-lma .fpageFC=0xFC8000 \ - --change-section-lma .dpageFC=0xFCA000 \ - --only-section=.dpageFA \ - --only-section=.fpageFA \ - --only-section=.dpageFB1 \ - --only-section=.dpageFB2 \ - --only-section=.dpageFB3 \ - --only-section=.dpageFB4 \ - --only-section=.dpageFB5 \ - --only-section=.dpageFB6 \ - --only-section=.dpageFB7 \ - --only-section=.dpageFB8 \ - --only-section=.fpageFB \ - --only-section=.dpageFC \ - --only-section=.fpageFC -# --change-section-lma .ppageFD=0xFD8000 \ -# --change-section-lma .ppageFF=0xFF8000 \ -# --only-section=.ppageFD \ This is left here for clarity only (equivalent to text1 but paged) -# --only-section=.ppageFF This is left here for clarity only (equivalent to text but paged) -# Changes to the above options should be reflected in memory.x and memory.h also! - -# The following flash areas should only be included if they are used. -# --only-section=.ppageE0S \ -# --only-section=.ppageE2 \ -# --only-section=.ppageE3 \ -# --only-section=.ppageE4 \ -# --only-section=.ppageE5 \ -# --only-section=.ppageE6 \ -# --only-section=.ppageE7 \ -# --only-section=.ppageE8 \ -# --only-section=.ppageE9 \ -# --only-section=.ppageEA \ -# --only-section=.ppageEB \ -# --only-section=.ppageEC \ -# --only-section=.ppageED \ -# --only-section=.ppageEE \ -# --only-section=.ppageEF \ -# --only-section=.ppageF0 \ -# --only-section=.ppageF1 \ -# --only-section=.ppageF2 \ -# --only-section=.ppageF3 \ -# --only-section=.ppageF4 \ -# --only-section=.ppageF5 \ -# --only-section=.ppageF6 \ -# --only-section=.ppageF7 \ -# --change-section-lma .ppageE0S=0xE08000 \ -# --change-section-lma .ppageE2=0xE28000 \ -# --change-section-lma .ppageE3=0xE38000 \ -# --change-section-lma .ppageE4=0xE48000 \ -# --change-section-lma .ppageE5=0xE58000 \ -# --change-section-lma .ppageE6=0xE68000 \ -# --change-section-lma .ppageE7=0xE78000 \ -# --change-section-lma .ppageE8=0xE88000 \ -# --change-section-lma .ppageE9=0xE98000 \ -# --change-section-lma .ppageEA=0xEA8000 \ -# --change-section-lma .ppageEB=0xEB8000 \ -# --change-section-lma .ppageEC=0xEC8000 \ -# --change-section-lma .ppageED=0xED8000 \ -# --change-section-lma .ppageEE=0xEE8000 \ -# --change-section-lma .ppageEF=0xEF8000 \ -# --change-section-lma .ppageF0=0xF08000 \ -# --change-section-lma .ppageF1=0xF18000 \ -# --change-section-lma .ppageF2=0xF28000 \ -# --change-section-lma .ppageF3=0xF38000 \ -# --change-section-lma .ppageF4=0xF48000 \ -# --change-section-lma .ppageF5=0xF58000 \ -# --change-section-lma .ppageF6=0xF68000 \ -# --change-section-lma .ppageF7=0xF78000 \ - - - - -help: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Dependency And Target Summary #$(Q) - @echo $(Q)################################################################################$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# Common targets: #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# 1) help - This comment block #$(Q) - @echo $(Q)# 2) all - Executes alldebug, slow, slowgc and size #$(Q) - @echo $(Q)# 3) dirs - Creates all of the directories required to build #$(Q) - @echo $(Q)# 5) slow - Three stage compilation with assembly retained #$(Q) - @echo $(Q)# 6) slowgc - As above, but with garbage collection during linking #$(Q) - @echo $(Q)# 7) alldebug - Generates all debug output files #$(Q) - @echo $(Q)# 8) install - Not yet implemented #$(Q) - @echo $(Q)# 9) release - Performs a full release build #$(Q) - @echo $(Q)# 10) clean - Removes all files and directories generated by building #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# Second level targets: #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# Stage one: #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# 1) preprocess - run the C preprocessor over the raw C files #$(Q) - @echo $(Q)# 2) compile - compile the preprocessed C into assembly #$(Q) - @echo $(Q)# 3) assemble - assemble the assembly files into object files #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# Stage two #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# 1) link - Generate ELFs objects #$(Q) - @echo $(Q)# 2) gclink - As above, but with garbage collection #$(Q) - @echo $(Q)# 3) s19 - Create s19s from elfs #$(Q) - @echo $(Q)# 4) gcs19 - Create s19s from gc elfs #$(Q) - @echo $(Q)# 5) sizes - Calculate the approximate s19 sizes #$(Q) - @echo $(Q)# 6) gcsizes - Calculate the approximate gc s19 sizes #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# Stage three: #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# 1) maps - Memory map files #$(Q) - @echo $(Q)# 2) rees - Readelf dumps #$(Q) - @echo $(Q)# 3) elfdmps - Classic objdump output for final elfs #$(Q) - @echo $(Q)# 4) objdmps - Classic objdump output for each object file #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# When doing a full build the following steps are taken: #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# 1) Pre-process all of the C files #$(Q) - @echo $(Q)# 2) Compile all preprocessed C files into assembly files #$(Q) - @echo $(Q)# 3) Assemble all assembly files into object files #$(Q) - @echo $(Q)# 4) Link each decoder without garbage collection #$(Q) - @echo $(Q)# 5) Produce a memory map for each elf #$(Q) - @echo $(Q)# 6) Produce a readelf dump for each elf #$(Q) - @echo $(Q)# 7) Dump the contents of each decoders elf #$(Q) - @echo $(Q)# 8) Dump the contents of all object files #$(Q) - @echo $(Q)# 9) Link each decoder with garbage collection and reporting turned on #$(Q) - @echo $(Q)# 10) Produce an s19 loadable firmware file for each elf #$(Q) - @echo $(Q)# 11) Measure each binary image approximately #$(Q) - @echo $(Q)# 12) Measure each decoder object file #$(Q) - @echo $(Q)# 13) Measure each other object file and summarise #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# The release target: #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# This target is purely for use by lead developers to produce a file set #$(Q) - @echo $(Q)# that is suitable for release and distribution to users and interested #$(Q) - @echo $(Q)# parties. The steps performed are listed below: #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# 1) Checks that the repository is consistent #$(Q) - @echo $(Q)# 2) Performs a full clean #$(Q) - @echo $(Q)# 4) Removes the doxygen files #$(Q) - @echo $(Q)# 5) Builds binaries for each decoder type #$(Q) - @echo $(Q)# 7) Generates a new doxygen site #$(Q) - @echo $(Q)# 8) Performs a full clean #$(Q) - @echo $(Q)# 9) Commits the release files #$(Q) - @echo $(Q)# 10) Asks for a tag name and tag message #$(Q) - @echo $(Q)# 11) Tags the release at the automatic commit point #$(Q) - @echo $(Q)# 12) Generates md5 and sha1 checksums into the distribution directory #$(Q) - @echo $(Q)# 13) Zips the binaries into the distribution directory #$(Q) - @echo $(Q)# 14) Zips the doxygen site into the distribution directory #$(Q) - @echo $(Q)# 15) Zips the documentation into the distribution directory #$(Q) - @echo $(Q)# 16) Zips the repository into the distribution directory #$(Q) - @echo $(Q)# 17) Zips the source code into the distribution directory #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# At that point the developer in charge of release has only to upload #$(Q) - @echo $(Q)# the files found in the distribution directory to appropriate locations #$(Q) - @echo $(Q)# and publicise the fact that a new release has been performed! This #$(Q) - @echo $(Q)# automation removes most opportunity for mistakes and makes release #$(Q) - @echo $(Q)# quality consistent between each successive release cycle! #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# Unlisted targets: #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# Additionally any of the output files can be used as a target directly. #$(Q) - @echo $(Q)# This is perfect for building only what is required for a specific s19. #$(Q) - @echo $(Q)# It is also perfect for working with a single file as you don't have to #$(Q) - @echo $(Q)# wait for other unrelated things to build first nor do you have to wait #$(Q) - @echo $(Q)# for other files to continue building after yours is successful. #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# Common goals: #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# You most likely just want to run \"make s19\" or \"make clean\", do that! #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# To build with a specific compiled in configuration do this instead: #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# CLIFLAGS=\"YOURBUILDNAME\" make clean s19 #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)################################################################################$(Q) - - - - -################################################################################ -# Single Decoder Builds # -################################################################################ - - -Listener: $(S19DIR)/$(LABEL)-Listener.s19 -BenchTest: $(S19DIR)/$(LABEL)-BenchTest.s19 -EvenTeeth-Cam-24and1: $(S19DIR)/$(LABEL)-EvenTeeth-Cam-24and1.s19 -EvenTeeth-Cam-16and1: $(S19DIR)/$(LABEL)-EvenTeeth-Cam-16and1.s19 -EvenTeeth-Cam-6and1: $(S19DIR)/$(LABEL)-EvenTeeth-Cam-6and1.s19 -EvenTeeth-Cam-4and1: $(S19DIR)/$(LABEL)-EvenTeeth-Cam-4and1.s19 -MissingTeeth-Crank-8minus1: $(S19DIR)/$(LABEL)-MissingTeeth-Crank-8minus1.s19 -MissingTeeth-Crank-12minus1: $(S19DIR)/$(LABEL)-MissingTeeth-Crank-12minus1.s19 -MissingTeeth-Cam-12minus1: $(S19DIR)/$(LABEL)-MissingTeeth-Cam-12minus1.s19 -HallOrOptical-Distributor-4of90: $(S19DIR)/$(LABEL)-HallOrOptical-Distributor-4of90.s19 -MitsiAndMazda-CAS-4and1: $(S19DIR)/$(LABEL)-MitsiAndMazda-CAS-4and1.s19 -MitsiAndMazda-CAS-4and2: $(S19DIR)/$(LABEL)-MitsiAndMazda-CAS-4and2.s19 -GM-LT1-CAS-360and8: $(S19DIR)/$(LABEL)-GM-LT1-CAS-360and8.s19 -JSeries-12CrankWith6-2Cam: $(S19DIR)/$(LABEL)-JSeries-12CrankWith6-2Cam.s19 -EvenTeeth-Distributor-4of6and1: $(S19DIR)/$(LABEL)-EvenTeeth-Distributor-4of6and1.s19 -MissingTeeth-Crank-36minus2: $(S19DIR)/$(LABEL)-MissingTeeth-Crank-36minus2.s19 -R18A1-13CrankWith5Cam: $(S19DIR)/$(LABEL)-R18A1-13CrankWith5Cam.s19 - - - - -################################################################################ -# Generated Dependencies # -################################################################################ - - -# Bring in all of the generated deps. Note, if these fail on the first pass of parsing, Make will generate them and reparse. --include $(DEPENDENCIES) $(DEPENDENCIESRPM) $(DDEPENDENCIES) $(DDEPENDENCIESRPM) - - - - -################################################################################ -# All Target Dependencies # -################################################################################ - - -# Build everything the long way -all: alldebug gcsizes sizes size -# Multi stage compilation -slow: sizes size -# Multi stage compilation with garbage collection -slowgc: gcsizes size -# Clean all except release -clean: cleandep cleanasm cleanobj cleanout cleanppc cleans19 cleandebug -# Generate all debug -alldebug: maps rees elfdmps objdmps -# Load the s19 of your choice -#install: clean slow loader -# Perform a release -release: testgit relbuildfull tagrelease -package: relbuildfull relpack1 relpack2 zipsite -publish: package deploydoxy deploy -publishnodoxy: packagenodoxy deploy -packagenodoxy: relbuildfirmware relpack1 relpack2 -relbuildfull: clean cleandoxy gendoxy s19 -relbuildfirmware: clean s19 -relpack1: md5sums sha1sums s19zips -relpack2: zipdocs zipmain zipsrc - - -# Force dates and versions to be up to date -$(PPCDIR)/globalConstants.pp.c: .FORCE -.FORCE: - - -################################################################################ -# Debug Target Definitions # -################################################################################ - - -mapsmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Generating memory maps.... #$(Q) - @echo $(Q)################################################################################$(Q) - -maps: link mapsmsg $(ALLMAPS) - -$(BUGDIR)/%.map: $(OUTDIR)/%.elf $(BUGDIR) - $(NM) $< | sort > $@ - - -reesmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Reading all elf files... #$(Q) - @echo $(Q)################################################################################$(Q) - -rees: link reesmsg $(ALLREAD) - -$(BUGDIR)/%.ree: $(OUTDIR)/%.elf $(BUGDIR) - $(RE) -a -W $< > $@ - - -elfdmpsmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Dumping all elf files... #$(Q) - @echo $(Q)################################################################################$(Q) - -elfdmps: link elfdmpsmsg $(ALLDMPS) - -$(BUGDIR)/%.dmp: $(OUTDIR)/%.elf $(BUGDIR) - $(DUMP) -spSd $< > $@ - - -objdmpmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Dumping all object files.... #$(Q) - @echo $(Q)################################################################################$(Q) - -objdmps: assemble objdmpmsg $(DUMPS) $(DUMPSRPM) - -$(BUGDIR)/%.dmp: $(OBJDIR)/%.o $(BUGDIR) - $(DUMP) -spSd $< > $@ - - - - -################################################################################ -# Link and Copy Target Definitions # -################################################################################ - - -linkmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Linking the Objects into an ELF... #$(Q) - @echo $(Q)################################################################################$(Q) - -link: assemble linkmsg $(ALLELFS) - -# link the object files into an elf executable -$(OUTDIR)/$(LABEL)-%.elf: $(OBJDIR)/$(DECDIR)/%.o $(OBJECTS) $(HANDOBJECTS) $(XGOBJECTS) $(OUTDIR) - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Linking $@ ...$(Q) - @echo $(Q)################################################################################$(Q) - $(GCC) $(GCCOPTS) -Wl,$(LINKOPTS) -o $@ $(OBJECTS) $(HANDOBJECTS) $(XGOBJECTS) $< - - -gclinkmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Linking the Objects into an ELF... #$(Q) - @echo $(Q)################################################################################$(Q) - -gclink: assemble linkmsg $(GCDELFS) - -# link the object files into an elf executable with gc enabled -$(OUTDIR)/$(LABEL)-%.gc.elf: $(OBJDIR)/$(DECDIR)/%.o $(OBJECTS) $(HANDOBJECTS) $(XGOBJECTS) $(OUTDIR) - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Linking $@ ...$(Q) - @echo $(Q)################################################################################$(Q) - $(GCC) $(GCCOPTS) -Wl,$(LINKOPTSGC) -o $@ $(OBJECTS) $(HANDOBJECTS) $(XGOBJECTS) $< -# The links with garbage collection are to ensure that there are no warnings -# TODO find out how to stop .tramp from being collected (or inserted)! -# This will be the only way once Sean's stuff is done and distributed, I can't wait to cut all this bullshit out! - - -s19msg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Building The S19 Files.... #$(Q) - @echo $(Q)################################################################################$(Q) - -s19: link s19msg $(ALLS19S) -# the gc dependency is temporary until i figure out if the .tramp removal is an issue or not. - -# Generate the loadable s19 firmware files -$(S19DIR)/%.s19: $(OUTDIR)/%.elf $(S19DIR) - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Building $(@F) ...$(Q) - @echo $(Q)################################################################################$(Q) - $(COPY) $(COPYOPTS) $< $(@F) - mv $(@F) $@ - - -sizesmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Measuring The S19 Files... #$(Q) - @echo $(Q)################################################################################$(Q) - -sizes: s19 sizesmsg $(ALLSIZES) $(ALLDUMMY) - - -# Roughly measure the s19 sizes -$(OUTDIR)/%.txt: $(S19DIR)/% $(OUTDIR) - echo $(shell cat $< | wc -l) $(Q)* 16$(Q) > $@ - -# Have to do this in two stages to allow $(shell exp) use and portability to windows -$(OUTDIR)/%.dummy: $(OUTDIR)/% $(OUTDIR) - echo $(Q)Flash image size is$(Q) $(shell cat $< | bc -l) $(Q)bytes for $<$(Q) - - -gcs19msg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Building The GC S19 Files.... #$(Q) - @echo $(Q)################################################################################$(Q) - -gcs19: gclink gcs19msg $(GCDS19S) - -# Generate the garbage collected s19 files temporarily -$(S19DIR)/%.s19: $(OUTDIR)/%.elf $(S19DIR) - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Building $(@F) ...$(Q) - @echo $(Q)################################################################################$(Q) - $(COPY) $(COPYOPTS) $< $(@F) - mv $(@F) $@ - -gcsizesmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Measuring The GC S19 Files... #$(Q) - @echo $(Q)################################################################################$(Q) - -gcsizes: gcs19 gcsizesmsg $(GCDSIZES) $(GCDDUMMY) - -# Roughly measure the gc s19 sizes -$(OUTDIR)/%.txt: $(S19DIR)/% $(OUTDIR) - @echo $(shell cat $< | wc -l) $(Q)* 16$(Q) > $@ - -# Have to do this in two stages to allow $(shell exp) use and portability to windows -$(OUTDIR)/%.dummy: $(OUTDIR)/% $(OUTDIR) - @echo $(Q)Flash image size is$(Q) $(shell cat $< | bc -l) $(Q)bytes for $<$(Q) - - - - - -################################################################################ -# Size Measuring Target Definition # -################################################################################ - - -size: assemble # TODO this should be run for each s19 target with only the one rpm .o file - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Measuring The Decoder Binaries... #$(Q) - @echo $(Q)################################################################################$(Q) - $(SIZE) $(OBJECTSRPM) - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Measuring All Other Binaries... #$(Q) - @echo $(Q)################################################################################$(Q) - $(SIZE) -t $(OBJECTS) - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Add one decoder to the total above and #$(Q) - @echo $(Q)# subtract the size reported for freeEMS.o #$(Q) - @echo $(Q)# this will give you the actual image size #$(Q) - @echo $(Q)################################################################################$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)# Thank you for building FreeEMS firmware!!! #$(Q) - @echo $(Q)# #$(Q) - @echo $(Q)################################################################################$(Q) - - - - -################################################################################ -# Preprocess, Compile and Assemble Target Definitions # -################################################################################ - - -dependenciesmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Generating the dependencies... #$(Q) - @echo $(Q)################################################################################$(Q) - -dependencies: dependenciesmsg $(DEPENDENCIES) $(DEPENDENCIESRPM) $(DDEPENDENCIES) $(DDEPENDENCIESRPM) - -# Generate dependency files for recompilation on change semantics -$(DEPENDENCIES) $(DEPENDENCIESRPM): $(DEPDIR)/%.d: %.c $(ALLH) - $(GCC) $(CLIBUILD) $(CLIFLAGSARG) -MM -MF $@ -MT $(PPCDIR)/$*.pp.c $< -# Generate dependency files for the dependency files... -$(DDEPENDENCIES) $(DDEPENDENCIESRPM): $(DEPDIR)/%.dd: %.c $(ALLH) - $(GCC) $(CLIBUILD) $(CLIFLAGSARG) -MM -MF $@ -MT $(DEPDIR)/$*.d $< - - -preprocessmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Running the C Pre Processor... #$(Q) - @echo $(Q)################################################################################$(Q) - -preprocess: preprocessmsg $(PREPROCESSED) $(PREPROCESSEDRPM) - -# Generate preprocessed source files to examine -$(PPCDIR)/%.pp.c: %.c $(ALLH) $(PPCDIR) - $(GCC) $(GCCOPTS) -D BASE_FILE_NAME=\"$(*F)\" -E $< > $@ -$(PPCDIR)/decoders/%.pp.c: decoders/%.c $(ALLH) $(PPCDIR) - $(GCC) $(GCCOPTS) -D BASE_FILE_NAME=\"$(*F)\" -E $< > $@ - - -compilemsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Compiling PPC to Assembly... #$(Q) - @echo $(Q)################################################################################$(Q) - -compile: preprocess compilemsg $(ASSEMBLIES) $(ASSEMBLIESRPM) - -# Generate assembly files to examine -$(ASMDIR)/%.s: $(PPCDIR)/%.pp.c $(ASMDIR) - $(GCC) -g $(GCCOPTS) -x cpp-output -S -o $@ $< - - -assemblemsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Assembling Object Files... #$(Q) - @echo $(Q)################################################################################$(Q) - -assemble: compile assemblemsg $(OBJECTS) $(HANDOBJECTS) $(OBJECTSRPM) $(XGOBJECTS) - -# Generate object files to link -$(OBJDIR)/%.o: $(ASMDIR)/%.s $(OBJDIR) - $(GCC) $(GCCOPTS) -c -o $@ $< - -$(OBJDIR)/%.o: $(HANDASMDIR)/%.s $(OBJDIR) - $(GCC) -g $(GCCOPTS) -c -o $@ $< - -$(XGOBJDIR)/%.o: $(XGASMDIR)/%.s $(XGOBJDIR) - $(XGAS) -o $@ $< - - - -################################################################################ -# Release Procedure Target Definitions # -################################################################################ - - -# Debian only :-p -testgit: - @echo "################################################################################" - @echo "# Checking git status... #" - @echo "################################################################################" - @echo "Are we on master?" - test `git symbolic-ref HEAD` = refs/heads/master - @echo "Is everything checked in?" - test `git status -s | wc -l` -eq 0 - @echo "Fetching from origin..." - git fetch - @echo "Are we behind?" - test `git rev-list \`git show-ref --hash refs/heads/master\`..\`git show-ref --hash refs/remotes/origin/master\` | wc -l` -eq 0 - @echo "Are we ahead?" - test `git rev-list \`git show-ref --hash refs/remotes/origin/master\`..\`git show-ref --hash refs/heads/master\` | wc -l` -eq 0 - - -md5sumsmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Generating MD5 Sums... #$(Q) - @echo $(Q)################################################################################$(Q) - -md5sums: s19 md5sumsmsg $(ALLMD5S) - -$(FIRMWAREDISTRIBUTIONDIR)/%.s19.md5: $(S19DIR)/%.s19 distributiondir - $(MD5SUM) $< > $@ - - -sha1sumsmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Generating SHA1 Sums... #$(Q) - @echo $(Q)################################################################################$(Q) - -sha1sums: s19 sha1sumsmsg $(ALLSHA1S) - -$(FIRMWAREDISTRIBUTIONDIR)/%.s19.sha1: $(S19DIR)/%.s19 distributiondir - $(SHASUM) $< > $@ - - - - -s19zipsmsg: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Zipping S19s... #$(Q) - @echo $(Q)################################################################################$(Q) - -s19zips: s19 s19zipsmsg $(ALLS19ZIPS) - -$(FIRMWAREDISTRIBUTIONDIR)/%.s19.zip: $(S19DIR)/%.s19 distributiondir - zip -j $@ $< - - -tagmessage: - vim $(RELTAG) - -tagname: - vim $(TAGNAME) - - -tagrelease: tagname tagmessage - git tag -F $(RELTAG) `cat $(TAGNAME)` HEAD - - -zipmain: distributiondir - cd ../../ ; git archive --format=zip --prefix=$(LABEL)/ HEAD > ./tmp/$(DISTRIBUTIONDIR)/$(LABEL)-full.zip;cd - - -zipdocs: distributiondir - cd ../../ ; git archive --format=zip --prefix=$(LABEL)- HEAD docs/ > ./tmp/$(DISTRIBUTIONDIR)/$(LABEL)-docs.zip;cd - - -gendoxy: clean - cd ../../ ; ( cat docs/Doxyfile ; echo "PROJECT_NUMBER=$(FIRMWARE_VERSION)" ) | doxygen - | grep Warning > src/doxygen.output;cd - - -zipsite: distributiondir gendoxy - cd ../../docs/ ; zip -r $(DISTRIBUTIONDIR)/$(LABEL)-doxygen-html.zip doxygen-html/;cd - - -zipsrc: distributiondir - cd ../../ ; git archive --format=zip --prefix=$(LABEL)- HEAD src/ > ./tmp/$(DISTRIBUTIONDIR)/$(LABEL)-src.zip;cd - - -deploy: distributiondir - scp -r $(DISTRIBUTIONDIR) raptor:/home/firmware/releases/ - -deploydoxy: zipsite - scp -r $(DISTRIBUTIONDIR)/$(LABEL)-doxygen-html.zip raptor:/home/docs/releases/ - ssh raptor unzip /home/docs/releases/$(LABEL)-doxygen-html.zip -d /home/docs/releases/ - ssh raptor mv /home/docs/releases/doxygen-html/ /home/docs/releases/$(FIRMWARE_VERSION) - - - - -################################################################################ -# Create Directory Target Definitions # -################################################################################ - -# Assembly, release and inc directories don't get removed. - -dirs: $(BUGDIR) $(S19DIR) $(PPCDIR) $(OUTDIR) $(OBJDIR) $(XGOBJDIR) $(ASMDIR) - -$(BUGDIR): - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Creating the debug directory.... #$(Q) - @echo $(Q)################################################################################$(Q) - $(MKDIR) $(BUGDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack - rmdir $(BUGDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack - $(MKDIR) $(BUGDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack - rmdir $(BUGDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack - -$(S19DIR): - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Creating the firmware directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(MKDIR) $(S19DIR)$(PATHSEP)hack - rmdir $(S19DIR)$(PATHSEP)hack - -$(PPCDIR): - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Creating the preprocessedc directory.... #$(Q) - @echo $(Q)################################################################################$(Q) - $(MKDIR) $(PPCDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack - rmdir $(PPCDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack - $(MKDIR) $(PPCDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack - rmdir $(PPCDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack - -$(ASMDIR): - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Creating the assembly directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(MKDIR) $(ASMDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack - rmdir $(ASMDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack - $(MKDIR) $(ASMDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack - rmdir $(ASMDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack - -$(OUTDIR): - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Creating the output directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(MKDIR) $(OUTDIR)$(PATHSEP)hack - rmdir $(OUTDIR)$(PATHSEP)hack - -$(OBJDIR): - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Creating the object directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(MKDIR) $(OBJDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack - rmdir $(OBJDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack - $(MKDIR) $(OBJDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack - rmdir $(OBJDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack - -$(XGOBJDIR): - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Creating the xgate object directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(MKDIR) $(XGOBJDIR)$(PATHSEP)hack - rmdir $(XGOBJDIR)$(PATHSEP)hack - -distributiondir: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Creating the distribution directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(MKDIR) $(FIRMWAREDISTRIBUTIONDIR)$(PATHSEP)hack - rmdir $(FIRMWAREDISTRIBUTIONDIR)$(PATHSEP)hack - - - - -################################################################################ -# Clean Target Definitions # -################################################################################ - -cleanasm: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Removing generated assembly files.... #$(Q) - @echo $(Q)################################################################################$(Q) - $(RM) $(ASMDIR) - -cleandep: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Removing pre-processed C output directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(RM) $(DEPDIR)$(PATHSEP)*.d $(DEPDIR)$(PATHSEP)*.dd - $(RM) $(DEPDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)*.d $(DEPDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)*.dd - $(RM) $(DEPDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)*.d $(DEPDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)*.dd - -cleanppc: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Removing pre-processed C output directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(RM) $(PPCDIR) - -cleanobj: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Removing object directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(RM) $(OBJDIR) - -cleanout: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Removing link output directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(RM) $(OUTDIR) - -cleans19: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Removing s19 directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(RM) $(S19DIR) - -cleandebug: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Removing debug directory... #$(Q) - @echo $(Q)################################################################################$(Q) - $(RM) $(BUGDIR) - -cleandoxy: - @echo $(Q)################################################################################$(Q) - @echo $(Q)# Removing Doxygen HTML... #$(Q) - @echo $(Q)################################################################################$(Q) - $(RM) ../../docs/doxygen-html/ - - -################################################################################ -# Declare targets that aren't real files # -################################################################################ - - -# Aggregators top level -.PHONY: all slow slowgc single help dirs - -# Aggregators middle level -.PHONY: dependencies preprocess compile assemble link gclink s19 gcs19 sizes gcsizes - -# Aggregators debug level -.PHONY: alldebug maps rees objdmps elfdmps size - -# Release targets -.PHONY: release relpack1 relpack2 package packagenodoxy publish publishnodoxy -.PHONY: rebuildfull rebuildnodoxy relbuildfirmware deploy deploydoxy -.PHONY: md5sums sha1sums s19zips sha1sumsgc s19zips s19zipsgc -.PHONY: testgit tagname tagmessage tagrelease -.PHONY: zipmain zipdocs zipsite zipsrc - -# Messages -.PHONY: mapsmsg reesmsg elfdmpsmsg objdmpmsg linkmsg gclinkmsg -.PHONY: s19msg gcs19msg preprocessmsg compilemsg assemblemsg -.PHONY: md5sumsmsg sha1sumsmsg s19zipsmsg - -# Clean targets -.PHONY: clean cleandep cleanasm cleanppc cleanobj cleanout cleans19 cleandebug cleandoxy - -# Lonely documentation target :-( -.PHONY: gendoxy +# FreeEMS - the open source engine management system +# +# Makefile +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# # +# About This Makefile # +# # +# This makefile incorporates many non-standard features. In particular, it # +# is inspired by Maven 2 and it's highly disciplined release mechanism. By # +# automating the release process as much as possible the chance of human # +# error is minimised. As much as possible, reuse is employed to keep bugs # +# from being introduced when changes are made. Rather than compiling from # +# C source files directly to object files, the build is, by default, done # +# in three stages, C to pre-processed C, pre-processed C to assembly, and # +# assembly to object files. Linking is also a little different with two # +# variants available, with and without garbage collection. Target device # +# memory usage statistics are available and generated by default when the # +# all target is called. Finally, extensive debug information can be # +# generated with a single make call. # +# # +################################################################################ + + + + +# All vars, commands and paths +include make/paths.mk + +# Source file listings +include make/sources.mk +# Processed groups from the above +include make/groups.mk + +# All command options +include make/options.mk + +# Default help target text +include make/help.mk + +# Individual targets for each decoder +include make/decoders.mk + + + + +################################################################################ +# Generated Dependencies # +################################################################################ + + +# Bring in all of the generated deps. Note, if these fail on the first pass of parsing, Make will generate them and reparse. +-include $(DEPENDENCIES) $(DEPENDENCIESRPM) $(DDEPENDENCIES) $(DDEPENDENCIESRPM) + + + + +################################################################################ +# All Target Dependencies # +################################################################################ + + +# Build everything the long way +all: alldebug gcsizes sizes size +# Multi stage compilation +slow: sizes size +# Multi stage compilation with garbage collection +slowgc: gcsizes size +# Clean all except release +clean: cleandep cleanasm cleanobj cleanout cleanppc cleans19 cleandebug +# Generate all debug +alldebug: maps rees elfdmps objdmps +# Load the s19 of your choice +#install: clean slow loader +# Perform a release +release: testgit relbuildfull tagrelease +package: relbuildfull relpack1 relpack2 zipsite +publish: package deploydoxy deploy +publishnodoxy: packagenodoxy deploy +packagenodoxy: relbuildfirmware relpack1 relpack2 +relbuildfull: clean cleandoxy gendoxy s19 +relbuildfirmware: clean s19 +relpack1: md5sums sha1sums s19zips +relpack2: zipdocs zipmain zipsrc + + +# Force dates and versions to be up to date +$(PPCDIR)/globalConstants.pp.c: .FORCE +.FORCE: + + +################################################################################ +# Debug Target Definitions # +################################################################################ + + +mapsmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Generating memory maps.... #$(Q) + @echo $(Q)################################################################################$(Q) + +maps: link mapsmsg $(ALLMAPS) + +$(BUGDIR)/%.map: $(OUTDIR)/%.elf $(BUGDIR) + $(NM) $< | sort > $@ + + +reesmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Reading all elf files... #$(Q) + @echo $(Q)################################################################################$(Q) + +rees: link reesmsg $(ALLREAD) + +$(BUGDIR)/%.ree: $(OUTDIR)/%.elf $(BUGDIR) + $(RE) -a -W $< > $@ + + +elfdmpsmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Dumping all elf files... #$(Q) + @echo $(Q)################################################################################$(Q) + +elfdmps: link elfdmpsmsg $(ALLDMPS) + +$(BUGDIR)/%.dmp: $(OUTDIR)/%.elf $(BUGDIR) + $(DUMP) -spSd $< > $@ + + +objdmpmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Dumping all object files.... #$(Q) + @echo $(Q)################################################################################$(Q) + +objdmps: assemble objdmpmsg $(DUMPS) $(DUMPSRPM) + +$(BUGDIR)/%.dmp: $(OBJDIR)/%.o $(BUGDIR) + $(DUMP) -spSd $< > $@ + + + + +################################################################################ +# Link and Copy Target Definitions # +################################################################################ + + +linkmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Linking the Objects into an ELF... #$(Q) + @echo $(Q)################################################################################$(Q) + +link: assemble linkmsg $(ALLELFS) + +# link the object files into an elf executable +$(OUTDIR)/$(LABEL)-%.elf: $(OBJDIR)/$(DECDIR)/%.o $(OBJECTS) $(HANDOBJECTS) $(XGOBJECTS) $(OUTDIR) + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Linking $@ ...$(Q) + @echo $(Q)################################################################################$(Q) + $(GCC) $(GCCOPTS) -Wl,$(LINKOPTS) -o $@ $(OBJECTS) $(HANDOBJECTS) $(XGOBJECTS) $< + + +gclinkmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Linking the Objects into an ELF... #$(Q) + @echo $(Q)################################################################################$(Q) + +gclink: assemble linkmsg $(GCDELFS) + +# link the object files into an elf executable with gc enabled +$(OUTDIR)/$(LABEL)-%.gc.elf: $(OBJDIR)/$(DECDIR)/%.o $(OBJECTS) $(HANDOBJECTS) $(XGOBJECTS) $(OUTDIR) + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Linking $@ ...$(Q) + @echo $(Q)################################################################################$(Q) + $(GCC) $(GCCOPTS) -Wl,$(LINKOPTSGC) -o $@ $(OBJECTS) $(HANDOBJECTS) $(XGOBJECTS) $< +# The links with garbage collection are to ensure that there are no warnings +# TODO find out how to stop .tramp from being collected (or inserted)! +# This will be the only way once Sean's stuff is done and distributed, I can't wait to cut all this bullshit out! + + +s19msg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Building The S19 Files.... #$(Q) + @echo $(Q)################################################################################$(Q) + +s19: link s19msg $(ALLS19S) +# the gc dependency is temporary until i figure out if the .tramp removal is an issue or not. + +# Generate the loadable s19 firmware files +$(S19DIR)/%.s19: $(OUTDIR)/%.elf $(S19DIR) + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Building $(@F) ...$(Q) + @echo $(Q)################################################################################$(Q) + $(COPY) $(COPYOPTS) $< $(@F) + mv $(@F) $@ + + +sizesmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Measuring The S19 Files... #$(Q) + @echo $(Q)################################################################################$(Q) + +sizes: s19 sizesmsg $(ALLSIZES) $(ALLDUMMY) + + +# Roughly measure the s19 sizes +$(OUTDIR)/%.txt: $(S19DIR)/% $(OUTDIR) + echo $(shell cat $< | wc -l) $(Q)* 16$(Q) > $@ + +# Have to do this in two stages to allow $(shell exp) use and portability to windows +$(OUTDIR)/%.dummy: $(OUTDIR)/% $(OUTDIR) + echo $(Q)Flash image size is$(Q) $(shell cat $< | bc -l) $(Q)bytes for $<$(Q) + + +gcs19msg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Building The GC S19 Files.... #$(Q) + @echo $(Q)################################################################################$(Q) + +gcs19: gclink gcs19msg $(GCDS19S) + +# Generate the garbage collected s19 files temporarily +$(S19DIR)/%.s19: $(OUTDIR)/%.elf $(S19DIR) + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Building $(@F) ...$(Q) + @echo $(Q)################################################################################$(Q) + $(COPY) $(COPYOPTS) $< $(@F) + mv $(@F) $@ + +gcsizesmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Measuring The GC S19 Files... #$(Q) + @echo $(Q)################################################################################$(Q) + +gcsizes: gcs19 gcsizesmsg $(GCDSIZES) $(GCDDUMMY) + +# Roughly measure the gc s19 sizes +$(OUTDIR)/%.txt: $(S19DIR)/% $(OUTDIR) + @echo $(shell cat $< | wc -l) $(Q)* 16$(Q) > $@ + +# Have to do this in two stages to allow $(shell exp) use and portability to windows +$(OUTDIR)/%.dummy: $(OUTDIR)/% $(OUTDIR) + @echo $(Q)Flash image size is$(Q) $(shell cat $< | bc -l) $(Q)bytes for $<$(Q) + + + + + +################################################################################ +# Size Measuring Target Definition # +################################################################################ + + +size: assemble # TODO this should be run for each s19 target with only the one rpm .o file + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Measuring The Decoder Binaries... #$(Q) + @echo $(Q)################################################################################$(Q) + $(SIZE) $(OBJECTSRPM) + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Measuring All Other Binaries... #$(Q) + @echo $(Q)################################################################################$(Q) + $(SIZE) -t $(OBJECTS) + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Add one decoder to the total above and #$(Q) + @echo $(Q)# subtract the size reported for freeEMS.o #$(Q) + @echo $(Q)# this will give you the actual image size #$(Q) + @echo $(Q)################################################################################$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# Thank you for building FreeEMS firmware!!! #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)################################################################################$(Q) + + + + +################################################################################ +# Preprocess, Compile and Assemble Target Definitions # +################################################################################ + + +dependenciesmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Generating the dependencies... #$(Q) + @echo $(Q)################################################################################$(Q) + +dependencies: dependenciesmsg $(DEPENDENCIES) $(DEPENDENCIESRPM) $(DDEPENDENCIES) $(DDEPENDENCIESRPM) + +# Generate dependency files for recompilation on change semantics +$(DEPENDENCIES) $(DEPENDENCIESRPM): $(DEPDIR)/%.d: %.c $(ALLH) + $(GCC) $(CLIBUILD) $(CLIFLAGSARG) -MM -MF $@ -MT $(PPCDIR)/$*.pp.c $< +# Generate dependency files for the dependency files... +$(DDEPENDENCIES) $(DDEPENDENCIESRPM): $(DEPDIR)/%.dd: %.c $(ALLH) + $(GCC) $(CLIBUILD) $(CLIFLAGSARG) -MM -MF $@ -MT $(DEPDIR)/$*.d $< + + +preprocessmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Running the C Pre Processor... #$(Q) + @echo $(Q)################################################################################$(Q) + +preprocess: preprocessmsg $(PREPROCESSED) $(PREPROCESSEDRPM) + +# Generate preprocessed source files to examine +$(PPCDIR)/%.pp.c: %.c $(ALLH) $(PPCDIR) + $(GCC) $(GCCOPTS) -D BASE_FILE_NAME=\"$(*F)\" -E $< > $@ +$(PPCDIR)/decoders/%.pp.c: decoders/%.c $(ALLH) $(PPCDIR) + $(GCC) $(GCCOPTS) -D BASE_FILE_NAME=\"$(*F)\" -E $< > $@ + + +compilemsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Compiling PPC to Assembly... #$(Q) + @echo $(Q)################################################################################$(Q) + +compile: preprocess compilemsg $(ASSEMBLIES) $(ASSEMBLIESRPM) + +# Generate assembly files to examine +$(ASMDIR)/%.s: $(PPCDIR)/%.pp.c $(ASMDIR) + $(GCC) -g $(GCCOPTS) -x cpp-output -S -o $@ $< + + +assemblemsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Assembling Object Files... #$(Q) + @echo $(Q)################################################################################$(Q) + +assemble: compile assemblemsg $(OBJECTS) $(HANDOBJECTS) $(OBJECTSRPM) $(XGOBJECTS) + +# Generate object files to link +$(OBJDIR)/%.o: $(ASMDIR)/%.s $(OBJDIR) + $(GCC) $(GCCOPTS) -c -o $@ $< + +$(OBJDIR)/%.o: $(HANDASMDIR)/%.s $(OBJDIR) + $(GCC) -g $(GCCOPTS) -c -o $@ $< + +$(XGOBJDIR)/%.o: $(XGASMDIR)/%.s $(XGOBJDIR) + $(XGAS) -o $@ $< + + + + +# Release process targets +include make/release.mk + +# All directory creating targets +include make/dirs.mk + +# All clean up targets +include make/clean.mk + +# Things which are not real targets +include make/phony.mk diff --git a/src/main/make/clean.mk b/src/main/make/clean.mk new file mode 100644 index 0000000..177c624 --- /dev/null +++ b/src/main/make/clean.mk @@ -0,0 +1,82 @@ +# FreeEMS - the open source engine management system +# +# clean.mk +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# Clean Target Definitions # +################################################################################ + +cleanasm: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Removing generated assembly files.... #$(Q) + @echo $(Q)################################################################################$(Q) + $(RM) $(ASMDIR) + +cleandep: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Removing pre-processed C output directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(RM) $(DEPDIR)$(PATHSEP)*.d $(DEPDIR)$(PATHSEP)*.dd + $(RM) $(DEPDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)*.d $(DEPDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)*.dd + $(RM) $(DEPDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)*.d $(DEPDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)*.dd + +cleanppc: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Removing pre-processed C output directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(RM) $(PPCDIR) + +cleanobj: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Removing object directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(RM) $(OBJDIR) + +cleanout: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Removing link output directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(RM) $(OUTDIR) + +cleans19: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Removing s19 directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(RM) $(S19DIR) + +cleandebug: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Removing debug directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(RM) $(BUGDIR) + +cleandoxy: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Removing Doxygen HTML... #$(Q) + @echo $(Q)################################################################################$(Q) + $(RM) ../../docs/doxygen-html/ diff --git a/src/main/make/decoders.mk b/src/main/make/decoders.mk new file mode 100644 index 0000000..492b59d --- /dev/null +++ b/src/main/make/decoders.mk @@ -0,0 +1,51 @@ +# FreeEMS - the open source engine management system +# +# decoders.mk +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# Single Decoder Builds # +################################################################################ + + +Listener: $(S19DIR)/$(LABEL)-Listener.s19 +BenchTest: $(S19DIR)/$(LABEL)-BenchTest.s19 +EvenTeeth-Cam-24and1: $(S19DIR)/$(LABEL)-EvenTeeth-Cam-24and1.s19 +EvenTeeth-Cam-16and1: $(S19DIR)/$(LABEL)-EvenTeeth-Cam-16and1.s19 +EvenTeeth-Cam-6and1: $(S19DIR)/$(LABEL)-EvenTeeth-Cam-6and1.s19 +EvenTeeth-Cam-4and1: $(S19DIR)/$(LABEL)-EvenTeeth-Cam-4and1.s19 +MissingTeeth-Crank-8minus1: $(S19DIR)/$(LABEL)-MissingTeeth-Crank-8minus1.s19 +MissingTeeth-Crank-12minus1: $(S19DIR)/$(LABEL)-MissingTeeth-Crank-12minus1.s19 +MissingTeeth-Cam-12minus1: $(S19DIR)/$(LABEL)-MissingTeeth-Cam-12minus1.s19 +HallOrOptical-Distributor-4of90: $(S19DIR)/$(LABEL)-HallOrOptical-Distributor-4of90.s19 +MitsiAndMazda-CAS-4and1: $(S19DIR)/$(LABEL)-MitsiAndMazda-CAS-4and1.s19 +MitsiAndMazda-CAS-4and2: $(S19DIR)/$(LABEL)-MitsiAndMazda-CAS-4and2.s19 +GM-LT1-CAS-360and8: $(S19DIR)/$(LABEL)-GM-LT1-CAS-360and8.s19 +JSeries-12CrankWith6-2Cam: $(S19DIR)/$(LABEL)-JSeries-12CrankWith6-2Cam.s19 +EvenTeeth-Distributor-4of6and1: $(S19DIR)/$(LABEL)-EvenTeeth-Distributor-4of6and1.s19 +MissingTeeth-Crank-36minus2: $(S19DIR)/$(LABEL)-MissingTeeth-Crank-36minus2.s19 +R18A1-13CrankWith5Cam: $(S19DIR)/$(LABEL)-R18A1-13CrankWith5Cam.s19 diff --git a/src/main/make/dirs.mk b/src/main/make/dirs.mk new file mode 100644 index 0000000..dbfc5a7 --- /dev/null +++ b/src/main/make/dirs.mk @@ -0,0 +1,101 @@ +# FreeEMS - the open source engine management system +# +# dirs.mk +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# Create Directory Target Definitions # +################################################################################ + + +# Assembly, release and inc directories don't get removed. + +dirs: $(BUGDIR) $(S19DIR) $(PPCDIR) $(OUTDIR) $(OBJDIR) $(XGOBJDIR) $(ASMDIR) + +$(BUGDIR): + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Creating the debug directory.... #$(Q) + @echo $(Q)################################################################################$(Q) + $(MKDIR) $(BUGDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack + rmdir $(BUGDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack + $(MKDIR) $(BUGDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack + rmdir $(BUGDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack + +$(S19DIR): + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Creating the firmware directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(MKDIR) $(S19DIR)$(PATHSEP)hack + rmdir $(S19DIR)$(PATHSEP)hack + +$(PPCDIR): + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Creating the preprocessedc directory.... #$(Q) + @echo $(Q)################################################################################$(Q) + $(MKDIR) $(PPCDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack + rmdir $(PPCDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack + $(MKDIR) $(PPCDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack + rmdir $(PPCDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack + +$(ASMDIR): + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Creating the assembly directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(MKDIR) $(ASMDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack + rmdir $(ASMDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack + $(MKDIR) $(ASMDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack + rmdir $(ASMDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack + +$(OUTDIR): + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Creating the output directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(MKDIR) $(OUTDIR)$(PATHSEP)hack + rmdir $(OUTDIR)$(PATHSEP)hack + +$(OBJDIR): + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Creating the object directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(MKDIR) $(OBJDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack + rmdir $(OBJDIR)$(PATHSEP)$(DECDIR)$(PATHSEP)hack + $(MKDIR) $(OBJDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack + rmdir $(OBJDIR)$(PATHSEP)$(DATADIR)$(PATHSEP)hack + +$(XGOBJDIR): + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Creating the xgate object directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(MKDIR) $(XGOBJDIR)$(PATHSEP)hack + rmdir $(XGOBJDIR)$(PATHSEP)hack + +distributiondir: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Creating the distribution directory... #$(Q) + @echo $(Q)################################################################################$(Q) + $(MKDIR) $(FIRMWAREDISTRIBUTIONDIR)$(PATHSEP)hack + rmdir $(FIRMWAREDISTRIBUTIONDIR)$(PATHSEP)hack diff --git a/src/main/make/groups.mk b/src/main/make/groups.mk new file mode 100644 index 0000000..a5b0151 --- /dev/null +++ b/src/main/make/groups.mk @@ -0,0 +1,86 @@ +# FreeEMS - the open source engine management system +# +# groups.mk +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# Processed Groups # +################################################################################ + + +# Convert extensions +DEPENDENCIES = $(patsubst %.c,$(DEPDIR)/%.d,$(CLASSES)) +DDEPENDENCIES = $(patsubst %.c,$(DEPDIR)/%.dd,$(CLASSES)) +PREPROCESSED = $(patsubst %.c,$(PPCDIR)/%.pp.c,$(CLASSES)) +ASSEMBLIES = $(patsubst %.c,$(ASMDIR)/%.s,$(CLASSES)) +OBJECTS = $(patsubst %.c,$(OBJDIR)/%.o,$(CLASSES)) +HANDOBJECTS = $(patsubst %.s,$(OBJDIR)/%.o,$(HANDASMS)) +DUMPS = $(patsubst %.c,$(BUGDIR)/%.dmp,$(CLASSES)) $(patsubst %.s,$(BUGDIR)/%.dmp,$(HANDASMS)) +XGOBJECTS = $(patsubst %.s,$(XGOBJDIR)/%.o,$(XGASMSRCS)) + +# Convert RPM extensions +DEPENDENCIESRPM = $(patsubst %.c,$(DEPDIR)/%.d,$(RPMCLASSES)) +DDEPENDENCIESRPM = $(patsubst %.c,$(DEPDIR)/%.dd,$(RPMCLASSES)) +PREPROCESSEDRPM = $(patsubst %.c,$(PPCDIR)/%.pp.c,$(RPMCLASSES)) +ASSEMBLIESRPM = $(patsubst %.c,$(ASMDIR)/%.s,$(RPMCLASSES)) +OBJECTSRPM = $(patsubst %.c,$(OBJDIR)/%.o,$(RPMCLASSES)) #$(patsubst $(DECDIR???)%.s,$(OBJDIR)/%.o,$(RPMHANDASMS)) +DUMPSRPM = $(patsubst %.c,$(BUGDIR)/%.dmp,$(RPMCLASSES)) #$(patsubst $(DECDIR???)%.s,$(BUGDIR)/%.dmp,$(RPMHANDASMS)) + +# Convert to output files for source +ALLELFSC = $(patsubst $(DECDIR)/%.c,$(OUTDIR)/$(LABEL)-%.elf,$(RPMCLASSES)) +ALLELFSASM = #$(patsubst %.s,$(OUTDIR)/$(LABEL)-%.elf,$(RPMHANDASMS)) +ALLDMPSC = $(patsubst $(DECDIR)/%.c,$(BUGDIR)/$(LABEL)-%.dmp,$(RPMCLASSES)) +ALLDMPSASM = #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.dmp,$(RPMHANDASMS)) +ALLMAPSC = $(patsubst $(DECDIR)/%.c,$(BUGDIR)/$(LABEL)-%.map,$(RPMCLASSES)) +ALLMAPSASM = #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.map,$(RPMHANDASMS)) +ALLREADC = $(patsubst $(DECDIR)/%.c,$(BUGDIR)/$(LABEL)-%.ree,$(RPMCLASSES)) +ALLREADASM = #$(patsubst %.s,$(BUGDIR)/$(LABEL)-%.ree,$(RPMHANDASMS)) +ALLS19SC = $(patsubst $(DECDIR)/%.c,$(S19DIR)/$(LABEL)-%.s19,$(RPMCLASSES)) +ALLS19SASM = #$(patsubst %.s,$(S19DIR)/$(LABEL)-%.s19,$(RPMHANDASMS)) + +# Convert to output files for as-is variants +ALLELFS = $(ALLELFSC) $(ALLELFSASM) +ALLDMPS = $(ALLDMPSC) $(ALLDMPSASM) +ALLMAPS = $(ALLMAPSC) $(ALLMAPSASM) +ALLREAD = $(ALLREADC) $(ALLREADASM) +ALLS19S = $(ALLS19SC) $(ALLS19SASM) +ALLSIZES = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt,$(ALLS19S)) +ALLDUMMY = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt.dummy,$(ALLS19S)) +ALLMD5S = $(patsubst $(S19DIR)/%,$(FIRMWAREDISTRIBUTIONDIR)/%.md5,$(ALLS19S)) +ALLSHA1S = $(patsubst $(S19DIR)/%,$(FIRMWAREDISTRIBUTIONDIR)/%.sha1,$(ALLS19S)) +ALLS19ZIPS = $(patsubst $(S19DIR)/%,$(FIRMWAREDISTRIBUTIONDIR)/%.zip,$(ALLS19S)) + + +# Convert to output files for GC variants +GCDELFSC = $(patsubst $(DECDIR)/%.c,$(OUTDIR)/$(LABEL)-%.gc.elf,$(RPMCLASSES)) +GCDELFSASM = #$(patsubst %.s,$(OUTDIR)/$(LABEL)-%.gc.elf,$(RPMHANDASMS)) +GCDS19SC = $(patsubst $(DECDIR)/%.c,$(S19DIR)/$(LABEL)-%.gc.s19,$(RPMCLASSES)) +GCDS19SASM = #$(patsubst %.s,$(S19DIR)/$(LABEL)-%.gc.s19,$(RPMHANDASMS)) +GCDELFS = $(GCDELFSC) $(GCDELFSASM) +GCDS19S = $(GCDS19SC) $(GCDELFSASM) +GCDSIZES = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt,$(GCDS19S)) +GCDDUMMY = $(patsubst $(S19DIR)/%,$(OUTDIR)/%.txt.dummy,$(GCDS19S)) diff --git a/src/main/make/help.mk b/src/main/make/help.mk new file mode 100644 index 0000000..03b7e68 --- /dev/null +++ b/src/main/make/help.mk @@ -0,0 +1,136 @@ +# FreeEMS - the open source engine management system +# +# help.mk +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# Help Target Text # +################################################################################ + + +help: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Dependency And Target Summary #$(Q) + @echo $(Q)################################################################################$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# Common targets: #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# 1) help - This comment block #$(Q) + @echo $(Q)# 2) all - Executes alldebug, slow, slowgc and size #$(Q) + @echo $(Q)# 3) dirs - Creates all of the directories required to build #$(Q) + @echo $(Q)# 5) slow - Three stage compilation with assembly retained #$(Q) + @echo $(Q)# 6) slowgc - As above, but with garbage collection during linking #$(Q) + @echo $(Q)# 7) alldebug - Generates all debug output files #$(Q) + @echo $(Q)# 8) install - Not yet implemented #$(Q) + @echo $(Q)# 9) release - Performs a full release build #$(Q) + @echo $(Q)# 10) clean - Removes all files and directories generated by building #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# Second level targets: #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# Stage one: #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# 1) preprocess - run the C preprocessor over the raw C files #$(Q) + @echo $(Q)# 2) compile - compile the preprocessed C into assembly #$(Q) + @echo $(Q)# 3) assemble - assemble the assembly files into object files #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# Stage two #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# 1) link - Generate ELFs objects #$(Q) + @echo $(Q)# 2) gclink - As above, but with garbage collection #$(Q) + @echo $(Q)# 3) s19 - Create s19s from elfs #$(Q) + @echo $(Q)# 4) gcs19 - Create s19s from gc elfs #$(Q) + @echo $(Q)# 5) sizes - Calculate the approximate s19 sizes #$(Q) + @echo $(Q)# 6) gcsizes - Calculate the approximate gc s19 sizes #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# Stage three: #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# 1) maps - Memory map files #$(Q) + @echo $(Q)# 2) rees - Readelf dumps #$(Q) + @echo $(Q)# 3) elfdmps - Classic objdump output for final elfs #$(Q) + @echo $(Q)# 4) objdmps - Classic objdump output for each object file #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# When doing a full build the following steps are taken: #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# 1) Pre-process all of the C files #$(Q) + @echo $(Q)# 2) Compile all preprocessed C files into assembly files #$(Q) + @echo $(Q)# 3) Assemble all assembly files into object files #$(Q) + @echo $(Q)# 4) Link each decoder without garbage collection #$(Q) + @echo $(Q)# 5) Produce a memory map for each elf #$(Q) + @echo $(Q)# 6) Produce a readelf dump for each elf #$(Q) + @echo $(Q)# 7) Dump the contents of each decoders elf #$(Q) + @echo $(Q)# 8) Dump the contents of all object files #$(Q) + @echo $(Q)# 9) Link each decoder with garbage collection and reporting turned on #$(Q) + @echo $(Q)# 10) Produce an s19 loadable firmware file for each elf #$(Q) + @echo $(Q)# 11) Measure each binary image approximately #$(Q) + @echo $(Q)# 12) Measure each decoder object file #$(Q) + @echo $(Q)# 13) Measure each other object file and summarise #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# The release target: #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# This target is purely for use by lead developers to produce a file set #$(Q) + @echo $(Q)# that is suitable for release and distribution to users and interested #$(Q) + @echo $(Q)# parties. The steps performed are listed below: #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# 1) Checks that the repository is consistent #$(Q) + @echo $(Q)# 2) Performs a full clean #$(Q) + @echo $(Q)# 4) Removes the doxygen files #$(Q) + @echo $(Q)# 5) Builds binaries for each decoder type #$(Q) + @echo $(Q)# 7) Generates a new doxygen site #$(Q) + @echo $(Q)# 8) Performs a full clean #$(Q) + @echo $(Q)# 9) Commits the release files #$(Q) + @echo $(Q)# 10) Asks for a tag name and tag message #$(Q) + @echo $(Q)# 11) Tags the release at the automatic commit point #$(Q) + @echo $(Q)# 12) Generates md5 and sha1 checksums into the distribution directory #$(Q) + @echo $(Q)# 13) Zips the binaries into the distribution directory #$(Q) + @echo $(Q)# 14) Zips the doxygen site into the distribution directory #$(Q) + @echo $(Q)# 15) Zips the documentation into the distribution directory #$(Q) + @echo $(Q)# 16) Zips the repository into the distribution directory #$(Q) + @echo $(Q)# 17) Zips the source code into the distribution directory #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# At that point the developer in charge of release has only to upload #$(Q) + @echo $(Q)# the files found in the distribution directory to appropriate locations #$(Q) + @echo $(Q)# and publicise the fact that a new release has been performed! This #$(Q) + @echo $(Q)# automation removes most opportunity for mistakes and makes release #$(Q) + @echo $(Q)# quality consistent between each successive release cycle! #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# Unlisted targets: #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# Additionally any of the output files can be used as a target directly. #$(Q) + @echo $(Q)# This is perfect for building only what is required for a specific s19. #$(Q) + @echo $(Q)# It is also perfect for working with a single file as you don't have to #$(Q) + @echo $(Q)# wait for other unrelated things to build first nor do you have to wait #$(Q) + @echo $(Q)# for other files to continue building after yours is successful. #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# Common goals: #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# You most likely just want to run \"make s19\" or \"make clean\", do that! #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# To build with a specific compiled in configuration do this instead: #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)# CLIFLAGS=\"YOURBUILDNAME\" make clean s19 #$(Q) + @echo $(Q)# #$(Q) + @echo $(Q)################################################################################$(Q) diff --git a/src/main/make/options.mk b/src/main/make/options.mk new file mode 100644 index 0000000..a57d29d --- /dev/null +++ b/src/main/make/options.mk @@ -0,0 +1,160 @@ +# FreeEMS - the open source engine management system +# +# options.mk +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# All Command Line Options # +################################################################################ + + +# M68hc1x GCC Options we may want : -minmax -mlong-calls + +# http://www.gnu.org/software/m68hc11/m68hc11_gcc.html shows code size with different options used +# include debug info, optimise , 16 bit ints, hcs12 platform +GCCOPTS1 = -Wall -Werror -Winline -O -m68hcs12 -mshort -ffunction-sections +GCCOPTS2 = -fomit-frame-pointer -msoft-reg-count=8 -mauto-incdec -fsigned-char +GCCOPTS = $(GCCOPTS1) $(GCCOPTS2) $(CLIBUILD) $(CLIFLAGSARG) -D SUPPORT_EMAIL=\"$(SUPPORT_EMAIL)\" -D BUILT_BY_NAME=\"$(BUILT_BY_NAME)\" -D FIRMWARE_VERSION=\"$(FIRMWARE_VERSION)\" -D FIRMWARE_BUILD_DATE=\"$(BUILD_DATE)\" -D OPERATING_SYSTEM=\"$(OS)\" +# -ffunction-sections option splits out the functions such that the garbage collection can get +# them on a per section basis. I'm not sure, but this could be harmful to paged code so may +# have to review this at a later date perhaps splitting paged functions from nonpaged ones. + +# pass to linker, link for hc12 +# The vectors address in the linker options is the VMA address and must be short form 0xF710, not a paged address. +LINKOPTS = -no-warn-mismatch,-defsym,vectors_addr=0xF710,-m,m68hc12elfb,-T,hc9s12xdp512elfb.x +LINKOPTSGC = -no-warn-mismatch,--gc-sections,--print-gc-sections,-defsym,vectors_addr=0xF710,-m,m68hc12elfb,-T,hc9s12xdp512elfb.x +# Use this to get a map dump when the linker fails in a confusing way : --print-map + +# If using the below option for paged flash, the ADDRESS_TYPE +# field in the freeEMSloader script should be updated to match. +COPYOPTS = --output-target=srec \ + --change-section-lma .fixedconf1+0xFD4000 \ + --change-section-lma .fixedconf2+0xFD4000 \ + --change-section-lma .text1+0xFD4000 \ + --change-section-lma .text+0xFEC000 \ + --change-section-lma .data+0xFEC000 \ + --change-section-lma .vectors+0xFEC000 \ + --change-section-lma .rodata+0xFEC000 \ + --only-section=.fixedconf1 \ + --only-section=.fixedconf2 \ + --only-section=.text \ + --only-section=.text1 \ + --only-section=.data \ + --only-section=.vectors \ + --only-section=.rodata \ + --change-section-lma .ppageE0X=0xE08800 \ + --change-section-lma .ppageE1=0xE18000 \ + --only-section=.ppageE0X \ + --only-section=.ppageE1 \ + --set-section-flags .ppageE1=alloc,load \ + --change-section-lma .ppageF8=0xF88000 \ + --change-section-lma .fpageF9=0xF98000 \ + --change-section-lma .dpageF9=0xF9A000 \ + --change-section-lma .ppageFE=0xFE8000 \ + --only-section=.ppageF8 \ + --only-section=.fpageF9 \ + --only-section=.dpageF9 \ + --only-section=.ppageFE \ + --change-section-lma .fpageFA=0xFA8000 \ + --change-section-lma .dpageFA=0xFAA000 \ + --change-section-lma .fpageFB=0xFB8000 \ + --change-section-lma .dpageFB1=0xFBA000 \ + --change-section-lma .dpageFB2=0xFBA400 \ + --change-section-lma .dpageFB3=0xFBA800 \ + --change-section-lma .dpageFB4=0xFBAC00 \ + --change-section-lma .dpageFB5=0xFBB000 \ + --change-section-lma .dpageFB6=0xFBB400 \ + --change-section-lma .dpageFB7=0xFBB800 \ + --change-section-lma .dpageFB8=0xFBBC00 \ + --change-section-lma .fpageFC=0xFC8000 \ + --change-section-lma .dpageFC=0xFCA000 \ + --only-section=.dpageFA \ + --only-section=.fpageFA \ + --only-section=.dpageFB1 \ + --only-section=.dpageFB2 \ + --only-section=.dpageFB3 \ + --only-section=.dpageFB4 \ + --only-section=.dpageFB5 \ + --only-section=.dpageFB6 \ + --only-section=.dpageFB7 \ + --only-section=.dpageFB8 \ + --only-section=.fpageFB \ + --only-section=.dpageFC \ + --only-section=.fpageFC +# --change-section-lma .ppageFD=0xFD8000 \ +# --change-section-lma .ppageFF=0xFF8000 \ +# --only-section=.ppageFD \ This is left here for clarity only (equivalent to text1 but paged) +# --only-section=.ppageFF This is left here for clarity only (equivalent to text but paged) +# Changes to the above options should be reflected in memory.x and memory.h also! + +# The following flash areas should only be included if they are used. +# --only-section=.ppageE0S \ +# --only-section=.ppageE2 \ +# --only-section=.ppageE3 \ +# --only-section=.ppageE4 \ +# --only-section=.ppageE5 \ +# --only-section=.ppageE6 \ +# --only-section=.ppageE7 \ +# --only-section=.ppageE8 \ +# --only-section=.ppageE9 \ +# --only-section=.ppageEA \ +# --only-section=.ppageEB \ +# --only-section=.ppageEC \ +# --only-section=.ppageED \ +# --only-section=.ppageEE \ +# --only-section=.ppageEF \ +# --only-section=.ppageF0 \ +# --only-section=.ppageF1 \ +# --only-section=.ppageF2 \ +# --only-section=.ppageF3 \ +# --only-section=.ppageF4 \ +# --only-section=.ppageF5 \ +# --only-section=.ppageF6 \ +# --only-section=.ppageF7 \ +# --change-section-lma .ppageE0S=0xE08000 \ +# --change-section-lma .ppageE2=0xE28000 \ +# --change-section-lma .ppageE3=0xE38000 \ +# --change-section-lma .ppageE4=0xE48000 \ +# --change-section-lma .ppageE5=0xE58000 \ +# --change-section-lma .ppageE6=0xE68000 \ +# --change-section-lma .ppageE7=0xE78000 \ +# --change-section-lma .ppageE8=0xE88000 \ +# --change-section-lma .ppageE9=0xE98000 \ +# --change-section-lma .ppageEA=0xEA8000 \ +# --change-section-lma .ppageEB=0xEB8000 \ +# --change-section-lma .ppageEC=0xEC8000 \ +# --change-section-lma .ppageED=0xED8000 \ +# --change-section-lma .ppageEE=0xEE8000 \ +# --change-section-lma .ppageEF=0xEF8000 \ +# --change-section-lma .ppageF0=0xF08000 \ +# --change-section-lma .ppageF1=0xF18000 \ +# --change-section-lma .ppageF2=0xF28000 \ +# --change-section-lma .ppageF3=0xF38000 \ +# --change-section-lma .ppageF4=0xF48000 \ +# --change-section-lma .ppageF5=0xF58000 \ +# --change-section-lma .ppageF6=0xF68000 \ +# --change-section-lma .ppageF7=0xF78000 \ diff --git a/src/main/make/paths.mk b/src/main/make/paths.mk new file mode 100644 index 0000000..c94ad3d --- /dev/null +++ b/src/main/make/paths.mk @@ -0,0 +1,117 @@ +# FreeEMS - the open source engine management system +# +# paths.mk +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# All Fixed Variables # +################################################################################ + + +# Constants +FIRMWARE_VERSION := $(shell git describe --always --dirty=-DEV) +OUTPREFIX := FreeEMS +BUILD_DATE := "$(shell date)" +OS := $(shell uname) +BUILT_BY_NAME := "$(shell git config --global --get user.name)" +SUPPORT_EMAIL := "$(shell git config --global --get user.email)" + +# Windows differences +ifdef ComSpec +# Windows uses backslash +PATHSEP = \\ +# Windows mkdir does not accept -p +MKDIR = mkdir +# Windows echo repeats " symbols (Q stands for quote...) +Q = +SHASUM = sha1sum +else +PATHSEP = / +MKDIR = mkdir -p +Q = " +SHASUM = shasum +endif + +# Mac differences +ifeq ($(OS), Darwin) +MD5SUM = md5 -r +else +# If using this on windows, we're in cygwin, same as Linux +MD5SUM = md5sum +endif + +ifdef CLIFLAGS +CLIBUILD = -D CLIFLAGS=1 +ifdef XGATE +CLIFLAGSARG = -D $(CLIFLAGS)=1 -D XGATE=1 +LABEL := $(OUTPREFIX)-$(FIRMWARE_VERSION)-$(CLIFLAGS)-XGATE +else +CLIFLAGSARG = -D $(CLIFLAGS)=1 +LABEL := $(OUTPREFIX)-$(FIRMWARE_VERSION)-$(CLIFLAGS) +endif +else +LABEL := $(OUTPREFIX)-$(FIRMWARE_VERSION) +endif + +# Directories here +DISTRIBUTIONDIR = ../../tmp/$(LABEL) +FIRMWAREDISTRIBUTIONDIR = $(DISTRIBUTIONDIR)/$(LABEL)-firmware +DOXYDOCDIR = ../../docs/doxygen-html +MAINDIR = freeems-vanilla +INCDIR = inc +DEPDIR = dependencies +DECDIR = decoders +DATADIR = initialisers +BUGDIR = debug +OUTDIR = output +OBJDIR = objects +ASMDIR = assembly +XGASMDIR = assemblyxgate +HANDASMDIR = assemblyhand +S19DIR = firmware +PPCDIR = preprocessedc +XGOBJDIR = $(OBJDIR)$(PATHSEP)xgate + +# Release tag message file +RELTAG = $(OUTDIR)/gitTagMessage.txt +TAGNAME = $(OUTDIR)/gitTagName.txt + +# Program prefixes, for the main cpu and for the xgate coprocessor +PREFIX = m68hc11- +XGPREFIX = mc9xgate- + +# All of the tools +CP = cp +RM = rm -rf +ZIP = zip +GCC = $(PREFIX)gcc +COPY = $(PREFIX)objcopy +DUMP = $(PREFIX)objdump +NM = $(PREFIX)nm +RE = $(PREFIX)readelf +SIZE = $(PREFIX)size +XGAS = $(XGPREFIX)as diff --git a/src/main/make/phony.mk b/src/main/make/phony.mk new file mode 100644 index 0000000..cbd29ad --- /dev/null +++ b/src/main/make/phony.mk @@ -0,0 +1,60 @@ +# FreeEMS - the open source engine management system +# +# phony.mk +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# Declare targets that aren't real files # +################################################################################ + + +# Aggregators top level +.PHONY: all slow slowgc single help dirs + +# Aggregators middle level +.PHONY: dependencies preprocess compile assemble link gclink s19 gcs19 sizes gcsizes + +# Aggregators debug level +.PHONY: alldebug maps rees objdmps elfdmps size + +# Release targets +.PHONY: release relpack1 relpack2 package packagenodoxy publish publishnodoxy +.PHONY: rebuildfull rebuildnodoxy relbuildfirmware deploy deploydoxy +.PHONY: md5sums sha1sums s19zips sha1sumsgc s19zips s19zipsgc +.PHONY: testgit tagname tagmessage tagrelease +.PHONY: zipmain zipdocs zipsite zipsrc + +# Messages +.PHONY: mapsmsg reesmsg elfdmpsmsg objdmpmsg linkmsg gclinkmsg +.PHONY: s19msg gcs19msg preprocessmsg compilemsg assemblemsg +.PHONY: md5sumsmsg sha1sumsmsg s19zipsmsg + +# Clean targets +.PHONY: clean cleandep cleanasm cleanppc cleanobj cleanout cleans19 cleandebug cleandoxy + +# Lonely documentation target :-( +.PHONY: gendoxy diff --git a/src/main/make/release.mk b/src/main/make/release.mk new file mode 100644 index 0000000..b90c34a --- /dev/null +++ b/src/main/make/release.mk @@ -0,0 +1,119 @@ +# FreeEMS - the open source engine management system +# +# release.mk +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# Release Procedure Target Definitions # +################################################################################ + + +# Debian only :-p +testgit: + @echo "################################################################################" + @echo "# Checking git status... #" + @echo "################################################################################" + @echo "Are we on master?" + test `git symbolic-ref HEAD` = refs/heads/master + @echo "Is everything checked in?" + test `git status -s | wc -l` -eq 0 + @echo "Fetching from origin..." + git fetch + @echo "Are we behind?" + test `git rev-list \`git show-ref --hash refs/heads/master\`..\`git show-ref --hash refs/remotes/origin/master\` | wc -l` -eq 0 + @echo "Are we ahead?" + test `git rev-list \`git show-ref --hash refs/remotes/origin/master\`..\`git show-ref --hash refs/heads/master\` | wc -l` -eq 0 + + +md5sumsmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Generating MD5 Sums... #$(Q) + @echo $(Q)################################################################################$(Q) + +md5sums: s19 md5sumsmsg $(ALLMD5S) + +$(FIRMWAREDISTRIBUTIONDIR)/%.s19.md5: $(S19DIR)/%.s19 distributiondir + $(MD5SUM) $< > $@ + + +sha1sumsmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Generating SHA1 Sums... #$(Q) + @echo $(Q)################################################################################$(Q) + +sha1sums: s19 sha1sumsmsg $(ALLSHA1S) + +$(FIRMWAREDISTRIBUTIONDIR)/%.s19.sha1: $(S19DIR)/%.s19 distributiondir + $(SHASUM) $< > $@ + + + + +s19zipsmsg: + @echo $(Q)################################################################################$(Q) + @echo $(Q)# Zipping S19s... #$(Q) + @echo $(Q)################################################################################$(Q) + +s19zips: s19 s19zipsmsg $(ALLS19ZIPS) + +$(FIRMWAREDISTRIBUTIONDIR)/%.s19.zip: $(S19DIR)/%.s19 distributiondir + zip -j $@ $< + + +tagmessage: + vim $(RELTAG) + +tagname: + vim $(TAGNAME) + + +tagrelease: tagname tagmessage + git tag -F $(RELTAG) `cat $(TAGNAME)` HEAD + + +zipmain: distributiondir + cd ../../ ; git archive --format=zip --prefix=$(LABEL)/ HEAD > ./tmp/$(DISTRIBUTIONDIR)/$(LABEL)-full.zip;cd - + +zipdocs: distributiondir + cd ../../ ; git archive --format=zip --prefix=$(LABEL)- HEAD docs/ > ./tmp/$(DISTRIBUTIONDIR)/$(LABEL)-docs.zip;cd - + +gendoxy: clean + cd ../../ ; ( cat docs/Doxyfile ; echo "PROJECT_NUMBER=$(FIRMWARE_VERSION)" ) | doxygen - | grep Warning > src/doxygen.output;cd - + +zipsite: distributiondir gendoxy + cd ../../docs/ ; zip -r $(DISTRIBUTIONDIR)/$(LABEL)-doxygen-html.zip doxygen-html/;cd - + +zipsrc: distributiondir + cd ../../ ; git archive --format=zip --prefix=$(LABEL)- HEAD src/ > ./tmp/$(DISTRIBUTIONDIR)/$(LABEL)-src.zip;cd - + +deploy: distributiondir + scp -r $(DISTRIBUTIONDIR) raptor:/home/firmware/releases/ + +deploydoxy: zipsite + scp -r $(DISTRIBUTIONDIR)/$(LABEL)-doxygen-html.zip raptor:/home/docs/releases/ + ssh raptor unzip /home/docs/releases/$(LABEL)-doxygen-html.zip -d /home/docs/releases/ + ssh raptor mv /home/docs/releases/doxygen-html/ /home/docs/releases/$(FIRMWARE_VERSION) diff --git a/src/main/make/sources.mk b/src/main/make/sources.mk new file mode 100644 index 0000000..afad2b6 --- /dev/null +++ b/src/main/make/sources.mk @@ -0,0 +1,91 @@ +# FreeEMS - the open source engine management system +# +# sources.mk +# +# Copyright 2008-2014 Fred Cooke +# +# This Makefile is part of the FreeEMS project. +# +# FreeEMS software is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# FreeEMS software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ +# +# We ask that if you make any changes to this file you email them upstream to +# us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! +# +# Thank you for choosing FreeEMS to run your engine! + + + + +################################################################################ +# All Source Files # +################################################################################ + + +# Indirect dependencies that can affect everything and cause a full rebuild +MFILE = Makefile make/* +ASMH = 9S12XDP512asm.s +LINKER = memory.x regions.x hc9s12xdp512elfb.x + + +# Let's keep this to a bare minimum! If you write ASM code +# please provide a matching alternate C implementation too. +HANDASMS = flashBurn.s +#RPMHANDASMS = + +ALLH = $(LINKER) $(MFILE) $(INCDIR)/$(ASMH) + +# Warning : do not include .c files from inc/ as they are +# included into the other C files and automatically compiled. + +# Flash data files +FIXEDCLASSES = FixedConfig1.c FixedConfig2.c +LOOKUPCLASSES1 = IATTransferTable.c CHTTransferTable.c +LOOKUPCLASSES2 = MAFTransferTable.c TestTransferTable.c +FUELCLASSES = FuelTables.c FuelTables2.c +TIMECLASSES = TimingTables.c TimingTables2.c +TUNECLASSES = TunableConfig.c TunableConfig2.c +# Combined data files +DATARAW = $(FIXEDCLASSES) $(LOOKUPCLASSES1) $(LOOKUPCLASSES2) $(FUELCLASSES) $(TIMECLASSES) $(TUNECLASSES) +DATA = $(patsubst %.c,$(DATADIR)/%.c,$(DATARAW)) + +# Source code files +UTILCLASSES = tableLookup.c init.c utils.c globalConstants.c StaticBenchTest.c simpleGPIO.c +MATHCLASSES = coreVarsGenerator.c derivedVarsGenerator.c fuelAndIgnitionCalcs.c outputScheduler.c decoderInterface.c +COMCLASSES = flashWrite.c commsCore.c blockDetailsLookup.c +ISRCLASSES = interrupts.c injectionISRs.c commsISRs.c realtimeISRs.c miscISRs.c xgateVectors.c +# Combined source code files +SOURCE = freeEMS.c staticInit.c main.c $(UTILCLASSES) $(MATHCLASSES) $(COMCLASSES) $(ISRCLASSES) + +# All but the engine position/RPM combined here +CLASSES = $(SOURCE) $(DATA) + +# Engine position/RPM here +# Special decoders are not for use running an engine +RPMSPECIAL = Listener.c BenchTest.c +# TODO: Automate file naming for the following 4 lines +RPMEVENTEETH = EvenTeeth-Cam-24and1.c EvenTeeth-Cam-16and1.c EvenTeeth-Cam-6and1.c EvenTeeth-Distributor-4of6and1.c EvenTeeth-Cam-4and1.c +RPMMISSINGTEETH = MissingTeeth-TestFile.c MissingTeeth-Cam-24minus1.c MissingTeeth-Crank-8minus1.c MissingTeeth-Crank-12minus1.c MissingTeeth-Crank-36minus1.c MissingTeeth-Crank-60minus2.c MissingTeeth-Cam-6minus2.c MissingTeeth-Crank-30minus2.c MissingTeeth-Cam-12minus1.c MissingTeeth-Crank-36minus2.c +RPMHALLOROPTICAL = HallOrOptical-Distributor-4of64.c HallOrOptical-Distributor-4of90.c +RPMVRDISTRIBUTOR = +# Specific purpose per engine stuff here +RPMMITSISTYLE = MitsiAndMazda-CAS-4and1.c MitsiAndMazda-CAS-4and2.c +RPMHONDASTYLE = JSeries-12CrankWith6-2Cam.c R18A1-13CrankWith5Cam.c +RPMNISSANSTYLE = GM-LT1-CAS-360and8.c +# Insert your file above and get coding! +RPMSPECIFICENGINES = $(RPMMITSISTYLE) $(RPMHONDASTYLE) $(RPMNISSANSTYLE) +RPMCLASSESRAW = $(RPMSPECIAL) $(RPMEVENTEETH) $(RPMMISSINGTEETH) $(RPMHALLOROPTICAL) $(RPMVRDISTRIBUTOR) $(RPMSPECIFICENGINES) +RPMCLASSES = $(patsubst %.c,$(DECDIR)/%.c,$(RPMCLASSESRAW)) + +# XGATE stuff here! +XGASMSRCS = xgate.s -- 2.11.4.GIT