Makefile: .os neben Sourcen bauen, Dependendy-Tracking.
[hackover2013-badge-firmware.git] / Makefile
1 ##########################################################################
2 # User configuration and firmware specific object files
3 ##########################################################################
4
5 # The target, flash and ram of the LPC1xxx microprocessor.
6 # Use for the target the value: LPC11xx, LPC13xx or LPC17xx
7 TARGET = LPC13xx
8 FLASH = 32K
9 SRAM = 8K
10
11 # For USB HID support the LPC134x reserves 384 bytes from the sram,
12 # if you don't want to use the USB features, just use 0 here.
13 SRAM_USB = 384
14
15 ##########################################################################
16 # Debug settings
17 ##########################################################################
18
19 # Set DEBUGBUILD to 'TRUE' for full debugging (larger, slower binaries),
20 # or to 'FALSE' for release builds (smallest, fastest binaries)
21 DEBUGBUILD = FALSE
22
23 ##########################################################################
24 # IDE Flags (Keeps various IDEs happy)
25 ##########################################################################
26
27 OPTDEFINES = -D __NEWLIB__
28
29 ##########################################################################
30 # Project-specific files
31 ##########################################################################
32
33 SRCS = \
34 badge/main.c \
35 badge/ui/display.c \
36 badge/ui/sprite.c
37
38 SRCS += \
39 dataflash/at45db041d.c \
40 dataflash/iobase.c \
41 dataflash/diskio.c
42
43 SRCS += \
44 project/commands.c
45
46 SRCS += \
47 project/commands/cmd_chibi_addr.c \
48 project/commands/cmd_chibi_tx.c \
49 project/commands/cmd_i2ceeprom_read.c \
50 project/commands/cmd_i2ceeprom_write.c \
51 project/commands/cmd_lm75b_gettemp.c \
52 project/commands/cmd_reset.c \
53 project/commands/cmd_sd_dir.c \
54 project/commands/cmd_sysinfo.c \
55 project/commands/cmd_uart.c \
56 project/commands/cmd_pwm.c
57
58 SRCS += \
59 project/commands/drawing/cmd_backlight.c \
60 project/commands/drawing/cmd_bmp.c \
61 project/commands/drawing/cmd_button.c \
62 project/commands/drawing/cmd_calibrate.c \
63 project/commands/drawing/cmd_circle.c \
64 project/commands/drawing/cmd_clear.c \
65 project/commands/drawing/cmd_line.c \
66 project/commands/drawing/cmd_orientation.c \
67 project/commands/drawing/cmd_pixel.c \
68 project/commands/drawing/cmd_progress.c \
69 project/commands/drawing/cmd_rectangle.c \
70 project/commands/drawing/cmd_roundedcorner.c \
71 project/commands/drawing/cmd_text.c \
72 project/commands/drawing/cmd_textw.c \
73 project/commands/drawing/cmd_tsthreshhold.c \
74 project/commands/drawing/cmd_tswait.c \
75 project/commands/drawing/cmd_triangle.c
76
77 ##########################################################################
78 # Optional driver files
79 ##########################################################################
80
81 # Chibi Light-Weight Wireless Stack (AT86RF212)
82 SRCS += \
83 drivers/rf/chibi/chb.c \
84 drivers/rf/chibi/chb_buf.c \
85 drivers/rf/chibi/chb_drvr.c \
86 drivers/rf/chibi/chb_eeprom.c \
87 drivers/rf/chibi/chb_spi.c
88
89 # 4K EEPROM
90 SRCS += \
91 drivers/storage/eeprom/eeprom.c \
92 drivers/storage/eeprom/mcp24aa/mcp24aa.c
93
94 # LM75B temperature sensor
95 SRCS += \
96 drivers/sensors/lm75b/lm75b.c
97
98 # ISL12022M RTC
99 SRCS += \
100 drivers/rtc/isl12022m/isl12022m.c
101
102 # TFT LCD support
103 SRCS += \
104 drivers/displays/tft/drawing.c \
105 drivers/displays/tft/touchscreen.c \
106 drivers/displays/tft/colors.c \
107 drivers/displays/tft/theme.c \
108 drivers/displays/tft/bmp.c
109
110 # GUI Controls
111 SRCS += \
112 drivers/displays/tft/controls/button.c \
113 drivers/displays/tft/controls/hsbchart.c \
114 drivers/displays/tft/controls/huechart.c \
115 drivers/displays/tft/controls/label.c \
116 drivers/displays/tft/controls/labelcentered.c \
117 drivers/displays/tft/controls/progressbar.c
118
119 # Bitmap (non-AA) fonts
120 SRCS += \
121 drivers/displays/tft/fonts.c \
122 drivers/displays/tft/fonts/dejavusans9.c \
123 drivers/displays/tft/fonts/dejavusansbold9.c \
124 drivers/displays/tft/fonts/dejavusanscondensed9.c \
125 drivers/displays/tft/fonts/dejavusansmono8.c \
126 drivers/displays/tft/fonts/dejavusansmonobold8.c \
127 drivers/displays/tft/fonts/verdana9.c \
128 drivers/displays/tft/fonts/verdana14.c \
129 drivers/displays/tft/fonts/verdanabold14.c
130
131 # Anti-aliased fonts
132 SRCS += \
133 drivers/displays/tft/aafonts.c \
134 drivers/displays/tft/aafonts/aa2/DejaVuSansCondensed14_AA2.c \
135 drivers/displays/tft/aafonts/aa2/DejaVuSansCondensedBold14_AA2.c \
136 drivers/displays/tft/aafonts/aa2/DejaVuSansMono10_AA2.c \
137 drivers/displays/tft/aafonts/aa2/DejaVuSansMono13_AA2.c \
138 drivers/displays/tft/aafonts/aa2/DejaVuSansMono14_AA2.c
139
140 # LCD Driver (Only one can be included at a time!)
141 # SRCS += drivers/displays/tft/hw/hx8340b.c
142 # SRCS += drivers/displays/tft/hw/hx8347d.c
143 # SRCS += drivers/displays/tft/hw/ILI9328.c
144 # SRCS += drivers/displays/tft/hw/ILI9325.c
145 # SRCS += drivers/displays/tft/hw/ssd1331.c
146 # SRCS += drivers/displays/tft/hw/ssd1351.c
147 # SRCS += drivers/displays/tft/hw/st7735.c
148 # SRCS += drivers/displays/tft/hw/st7783.c
149
150 # Bitmap/Monochrome LCD support (ST7565, SSD1306, etc.)
151 SRCS += \
152 drivers/displays/smallfonts.c \
153 drivers/displays/bitmap/sharpmem/sharpmem.c \
154 drivers/displays/bitmap/st7565/st7565.c \
155 drivers/displays/bitmap/ssd1306/ssd1306.c
156
157 #Character Displays (VFD text displays, etc.)
158 SRCS += \
159 drivers/displays/character/samsung_20T202DA2JA/samsung_20T202DA2JA.c
160
161 # ChaN FatFS and SD card support
162 SRCS += \
163 drivers/fatfs/ff.c
164 # drivers/fatfs/mmc.c
165
166 # Motors
167 SRCS += \
168 drivers/motor/stepper/stepper.c
169
170 # RSA Encryption/Descryption
171 SRCS += \
172 drivers/rsa/rsa.c
173
174 # DAC
175 SRCS += \
176 drivers/dac/mcp4725/mcp4725.c \
177 drivers/dac/mcp4901/mcp4901.c
178
179 # RFID/NFC
180 SRCS += \
181 drivers/rf/pn532/pn532.c \
182 drivers/rf/pn532/pn532_bus_i2c.c \
183 drivers/rf/pn532/pn532_bus_uart.c \
184 drivers/rf/pn532/helpers/pn532_mifare_classic.c \
185 drivers/rf/pn532/helpers/pn532_mifare_ultralight.c
186
187 # TAOS Light Sensors
188 SRCS += \
189 drivers/sensors/tcs3414/tcs3414.c \
190 drivers/sensors/tsl2561/tsl2561.c
191
192 # SPI Flash
193 SRCS += \
194 drivers/storage/spiflash/w25q16bv/w25q16bv.c
195
196 # FM Radio
197 SRCS += \
198 drivers/audio/tea5767/tea5767.c
199
200 # IN219 Current Sensor
201 SRCS += \
202 drivers/sensors/ina219/ina219.c
203
204 # MPL115A2 Barometric Pressure Sensor
205 SRCS += \
206 drivers/sensors/mpl115a2/mpl115a2.c
207
208 # ADS1015 12-bit ADC
209 SRCS += \
210 drivers/adc/ads1015/ads1015.c
211
212 ##########################################################################
213 # Library files
214 ##########################################################################
215
216 SRCS += \
217 core/adc/adc.c \
218 core/cmd/cmd.c \
219 core/cpu/cpu.c \
220 core/gpio/gpio.c \
221 core/i2c/i2c.c \
222 core/iap/iap.c \
223 core/libc/stdio.c \
224 core/libc/string.c \
225 core/pmu/pmu.c \
226 core/pwm/pwm.c \
227 core/ssp/ssp.c \
228 core/systick/systick.c \
229 core/timer16/timer16.c \
230 core/timer32/timer32.c \
231 core/uart/uart_buf.c \
232 core/uart/uart.c \
233 core/usbcdc/cdc_buf.c \
234 core/usbcdc/cdcuser.c \
235 core/usbcdc/usbcore.c \
236 core/usbcdc/usbdesc.c \
237 core/usbcdc/usbhw.c \
238 core/usbcdc/usbuser.c \
239 core/usbhid-rom/usbconfig.c \
240 core/usbhid-rom/usbhid.c \
241 core/usbhid-rom/usbmsc.c \
242 core/wdt/wdt.c
243
244 ##########################################################################
245 # GNU GCC compiler prefix and location
246 ##########################################################################
247
248 CROSS_COMPILE = arm-none-eabi-
249 AS = $(CROSS_COMPILE)gcc
250 CC = $(CROSS_COMPILE)gcc
251 LD = $(CROSS_COMPILE)gcc
252 SIZE = $(CROSS_COMPILE)size
253 OBJCOPY = $(CROSS_COMPILE)objcopy
254 OBJDUMP = $(CROSS_COMPILE)objdump
255 OUTFILE = firmware
256 LPCRC = ./lpcrc
257
258 ##########################################################################
259 # GNU GCC compiler flags
260 ##########################################################################
261 ROOT_PATH = .
262 INCLUDE_PATHS = -I$(ROOT_PATH) -I$(ROOT_PATH)/project
263
264 ##########################################################################
265 # Startup files
266 ##########################################################################
267
268 LD_PATH = lpc1xxx
269 LD_SCRIPT = $(LD_PATH)/linkscript.ld
270 LD_TEMP = $(LD_PATH)/memory.ld
271
272 ifeq (LPC11xx,$(TARGET))
273 CORTEX_TYPE=m0
274 else
275 CORTEX_TYPE=m3
276 endif
277
278 CPU_TYPE = cortex-$(CORTEX_TYPE)
279
280 SRCS += \
281 lpc1xxx/$(TARGET)_handlers.c \
282 lpc1xxx/LPC1xxx_startup.c
283
284 OBJS = $(SRCS:%.c=%.o)
285 DEPS = $(SRCS:%.c=%.dep)
286
287 ##########################################################################
288 # Compiler settings, parameters and flags
289 ##########################################################################
290 ifeq (TRUE,$(DEBUGBUILD))
291 CFLAGS = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin $(OPTDEFINES) -std=c99
292 ASFLAGS = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
293 else
294 CFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin $(OPTDEFINES) -std=c99
295 ASFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
296 endif
297
298 LDFLAGS = -nostartfiles -mthumb -mcpu=$(CPU_TYPE) -Wl,--gc-sections
299 LDLIBS = -lm
300 OCFLAGS = --strip-unneeded
301
302 all: dep size $(OUTFILE).bin $(OUTFILE).hex
303
304 dep: $(DEPS)
305
306 $(DEPS) : %.dep : %.c
307 $(CC) $(CPPFLAGS) $(CFLAGS) -MM $< -MT $@ -MT $(<:%.c=%.o) -MF $@
308
309 sinclude $(DEPS)
310
311 $(LD_TEMP):
312 -@echo "MEMORY" > $(LD_TEMP)
313 -@echo "{" >> $(LD_TEMP)
314 -@echo " flash(rx): ORIGIN = 0x00000000, LENGTH = $(FLASH)" >> $(LD_TEMP)
315 -@echo " sram(rwx): ORIGIN = 0x10000000+$(SRAM_USB), LENGTH = $(SRAM)-$(SRAM_USB)" >> $(LD_TEMP)
316 -@echo "}" >> $(LD_TEMP)
317 -@echo "INCLUDE $(LD_SCRIPT)" >> $(LD_TEMP)
318
319 $(OUTFILE).elf: $(OBJS) $(LD_TEMP)
320 $(LD) $(LDFLAGS) -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS)
321
322 $(OUTFILE).bin: $(OUTFILE).elf
323 $(OBJCOPY) $(OCFLAGS) -O binary $(OUTFILE).elf $(OUTFILE).bin
324 $(LPCRC) $(OUTFILE).bin
325
326 $(OUTFILE).hex: $(OUTFILE).elf
327 $(OBJCOPY) $(OCFLAGS) -O ihex $(OUTFILE).elf $(OUTFILE).hex
328
329 size: $(OUTFILE).elf
330 $(SIZE) $(OUTFILE).elf
331
332 clean:
333 rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex
334
335 distclean: clean
336 rm -f $(DEPS)
337
338 .PHONY: all dep size clean distclean
This page took 0.075039 seconds and 5 git commands to generate.