Zerocat Chipflasher  v0.4.3 (board-edition-1)
Flash free firmware to BIOS chips, kick the Manageability Engine.
Makefile
Go to the documentation of this file.
1 ##>!
2 ##>! Zerocat Chipflasher --- Flash free firmware to BIOS chips,
3 ##>! kick the Manageability Engine.
4 ##>!
5 ##>! Copyright (C) 2015 Tomás Zerolo <tomas@tuxteam.de> @n
6 ##>! Copyright (C) 2015, 2016, 2017, 2018 Kai Mertens <kmx@posteo.net>
7 ##>!
8 ##>! The Zerocat Chipflasher is free software: you can redistribute it
9 ##>! and/or modify it under the terms of the GNU General Public License
10 ##>! as published by the Free Software Foundation, either version 3 of
11 ##>! the License, or (at your option) any later version.
12 ##>!
13 ##>! The Zerocat Chipflasher is distributed in the hope that it will be
14 ##>! useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 ##>! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ##>! GNU General Public License for more details.
17 ##>!
18 ##>! You should have received a copy of the GNU General Public License
19 ##>! along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##>!
21 ##>! This file is part of the Zerocat Chipflasher.
22 ##>!
23 ##>! @file firmware/src/Makefile
24 ##>!
25 ##>! @brief Build the chipflasher software, `kick` and `connect`.
26 ##>!
27 ##>! Usage:
28 ##>! `$ make all`
29 ##>!
30 
31 ##>! @cond
32 #######################################################################
33 # Variable settings for sub-shells.
34 # FIXME refine this:
35 # Have to set shell explicitly for PATH setting to take effect (why?)
36 SHELL := /bin/sh
37 
38 
39 #######################################################################
40 # Buildchain Options
41 #
42 # Note it is assumed that you have installed the original
43 # Parallax "SimpleIDE 1.0 RC1" binary tool bundle as a fallback. Paths
44 # to these tools are using the postfix "_OLD".
45 #
46 # Updated tools shall be installed via the GNU Guix Package Manager,
47 # thus paths to updated tools are using the postfix "_GUIX".
48 #
49 # The updated "Simple Libraries" folder may be downloaded separately,
50 # we are using the postfix "_MASTER" for it.
51 #
52 # Please see zerocat-tools.md from the doc repository for details. It is
53 # available like: git clone git://zerocat.org/zerocat/projects/doc
54 #
55 PATH_PARALLAX = /opt/parallax/
56 PATH_GNUGUIX = $(shell echo "$$GUIX_ENVIRONMENT"/;)
57 PATH_SIMPLELIBS_PARALLAX = $(PATH_PARALLAX)Workspace/Learn/Simple\ Libraries/
58 PATH_SIMPLELIBS_MASTER = ../../firmware1/src/parallaxinc/Simple-Libraries/Learn/Simple\ Libraries/
59 PATH_HOST_SRC = ../../host/src/
60 PROPGCC_PARALLAX = $(PATH_PARALLAX)bin/propeller-elf-gcc
61 PROPGCC_GNUGUIX = $(PATH_GNUGUIX)bin/propeller-elf-gcc
62 
63 # This is needed so gcc finds all its parts ("propeller-elf-gcc: error
64 # trying to exec 'cc1': execvp: No such file or directory"). Is a prefix,
65 # mind the trailing slash!
66 # Note that the environment variable GCC_EXEC_PREFIX doesn't work for
67 # us. But GCC's option -B works!
68 PATH_GCC_LIBEXEC_PARALLAX = $(PATH_PARALLAX)libexec/gcc/propeller-elf/4.6.1/
69 PATH_GCC_LIBEXEC_GNUGUIX = $(PATH_GNUGUIX)libexec/gcc/propeller-elf/4.6.1/
70 
71 #######################################################################
72 # Buildchain settings
73 # possibly to be overridden by those in buildchain.cfg
74 PATH_SIMPLELIBS = $(PATH_SIMPLELIBS_PARALLAX)
75 PROPGCC = $(PROPGCC_PARALLAX)
76 PATH_GCC_LIBEXEC := $(PATH_GCC_LIBEXEC_PARALLAX)
77 -include buildchain.cfg
78 
79 #######################################################################
80 # Compiler flags
81 
82 # Memory model
83 # cmm: the program image is compiled into a size-optimized form
84 # lmm: stores the program image and variable data in Main RAM, fastest execution
85 # xmmc: stores program images in external flash memory, an SD card, or EEPROM.
86 MMODEL := lmm
87 
88 # Base CFLAGS: apply those always:
89 BASE_CFLAGS = -Os -m$(MMODEL) -Wall -m32bit-doubles -fno-exceptions -std=c99
90 
91 # CFLAGS: let user specify:
92 override CFLAGS += $(BASE_CFLAGS)
93 
94 # Paths for compilation
95 INCLUDES = -I . \
96  -I $(PATH_SIMPLELIBS)TextDevices/libsimpletext \
97  -I $(PATH_SIMPLELIBS)Utility/libsimpletools \
98  -I $(PATH_SIMPLELIBS)Protocol/libsimplei2c
99 
100 LIBDIRS = -L . \
101  -L $(PATH_SIMPLELIBS)TextDevices/libsimpletext/$(MMODEL) \
102  -L $(PATH_SIMPLELIBS)Utility/libsimpletools/$(MMODEL) \
103  -L $(PATH_SIMPLELIBS)Protocol/libsimplei2c/$(MMODEL)
104 ##>! @endcond
105 
106 
107 ##>! @cond
108 # Libraries for kick, the chipflasher's firmware
109 LIBS = -lsimpletext -lsimpletools -lsimplei2c
110 LIBPROP = \
111  libprop/putChar.h \
112  libprop/putChar.c
113 LIBCOMMON = \
114  libcommon/common.h \
115  libcommon/serial-codes.h \
116  libcommon/filespec.h \
117  libcommon/hexdigit2bin.c \
118  libcommon/bin2hexdigit.c \
119  libcommon/line_info.c \
120  libcommon/filespec.c
121 LIBSPI = \
122  libSPI/SPI-command-set.h \
123  libSPI/SPI-flash-bits.h
124 LIBKICK = \
125  libkick/chipspec.h \
126  libkick/proppins.h \
127  libkick/key-enable-bits.h \
128  libkick/fast-SPI.h \
129  libkick/chipspec.c
130 
131 #######################################################################
132 # Explicit dependencies
133 .PHONY: kick connect all clean cleanall
134 
135 # build kick
136 kick: kick.elf
137 
138 # build connect
139 connect:
140  $(MAKE) -C $(PATH_HOST_SRC);
141 
142 # build kick and connect
143 all: kick connect
144 
145 # clean kick
146 clean:
147  rm -f *.elf;
148 
149 # clean kick and connect
150 cleanall: clean
151  $(MAKE) -C $(PATH_HOST_SRC) clean;
152 
153 # FIXME a patern rule would be nice. But where to stick the -lm -lfdserial and so on?
154 # NOTE lib order matters (-lfoo -lbar). And $^ must go before libs.
155 # NOTE Propeller code allows some non ANSI standard format specifiers,
156 # i.e. "%b" for binary representation of an integer.
157 # That will produce warnings according to -Wformat and -Wformat-extra-args.
158 #
159 # You can temporarily disable these warnings in your source code:
160 #
161 # [...]
162 # #pragma GCC diagnostic push
163 # #pragma GCC diagnostic ignored "-Wall"
164 # #pragma GCC diagnostic ignored "-Wformat-extra-args"
165 # //your code goes here, i.e.:
166 # //printi("binary number: %08b", x);
167 # #pragma GCC diagnostic pop
168 # [...]
169 #
170 # Please compare to:
171 # https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas)
172 #
173 
174 kick.elf: kick.c $(LIBPROP) $(LIBCOMMON) $(LIBSPI) $(LIBKICK) kick.h
175  $(PROPGCC) $(INCLUDES) $(LIBDIRS) $(CFLAGS) \
176  $< $(LIBS) \
177  -o $@;
178 ##>! @endcond