Salz' level #1
[hackover2013-badge-firmware.git] / Makefile
index 2151859..21b726e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -11,9 +11,7 @@ SRAM = 8K
 # For USB HID support the LPC134x reserves 384 bytes from the sram,\r
 # if you don't want to use the USB features, just use 0 here.\r
 SRAM_USB = 384\r
-\r
-VPATH = \r
-OBJS = main.o\r
+#SRAM_USB = 0\r
 \r
 ##########################################################################\r
 # Debug settings\r
@@ -27,135 +25,246 @@ DEBUGBUILD = FALSE
 # IDE Flags (Keeps various IDEs happy)\r
 ##########################################################################\r
 \r
-OPTDEFINES = -D __NEWLIB__\r
-\r
+OPTDEFINES = -D__NEWLIB__\r
+#OPTDEFINES += -DR0KET\r
+#OPTDEFINES += -DUSBONLY\r
 ##########################################################################\r
 # Project-specific files \r
 ##########################################################################\r
 \r
-VPATH += project\r
-OBJS += commands.o\r
-\r
-VPATH += project/commands\r
-OBJS += cmd_chibi_addr.o cmd_chibi_tx.o\r
-OBJS += cmd_i2ceeprom_read.o cmd_i2ceeprom_write.o cmd_lm75b_gettemp.o\r
-OBJS += cmd_reset.o cmd_sd_dir.o cmd_sysinfo.o cmd_uart.o \r
-OBJS += cmd_roundedcorner.o cmd_pwm.o\r
-\r
-VPATH += project/commands/drawing\r
-OBJS += cmd_backlight.o cmd_bmp.o cmd_button.o cmd_calibrate.o\r
-OBJS += cmd_circle.o cmd_clear.o cmd_line.o cmd_orientation.o\r
-OBJS += cmd_pixel.o cmd_progress.o cmd_rectangle.o cmd_text.o\r
-OBJS += cmd_textw.o cmd_tsthreshhold.o cmd_tswait.o cmd_triangle.o\r
+SRCS = \\r
+  badge/fahrplan.c \\r
+  badge/init.c \\r
+  badge/main.c \\r
+  badge/jumpnrun/collision.c \\r
+  badge/jumpnrun/enemies.c \\r
+  badge/jumpnrun/game_state.c \\r
+  badge/jumpnrun/items.c \\r
+  badge/jumpnrun/jumpnrun.c \\r
+  badge/jumpnrun/level_load.c \\r
+  badge/jumpnrun/player.c \\r
+  badge/jumpnrun/render.c \\r
+  badge/jumpnrun/shots.c \\r
+  badge/jumpnrun/starter.c \\r
+  badge/jumpnrun/stats.c \\r
+  badge/jumpnrun/tiles.c \\r
+  badge/ui/browser.c \\r
+  badge/ui/display.c \\r
+  badge/ui/event.c \\r
+  badge/ui/font.c \\r
+  badge/ui/menu.c \\r
+  badge/ui/sprite.c \\r
+  badge/ui/vanity.c\r
+\r
+SRCS += \\r
+  dataflash/iobase.c \\r
+  dataflash/diskio.c \\r
+  dataflash/at45db041d.c\r
+\r
+SRCS += \\r
+  funk/nrf24l01p.c\r
+\r
+SRCS += \\r
+  project/commands.c\r
+\r
+SRCS += \\r
+  project/commands/cmd_chibi_addr.c \\r
+  project/commands/cmd_chibi_tx.c \\r
+  project/commands/cmd_i2ceeprom_read.c \\r
+  project/commands/cmd_i2ceeprom_write.c \\r
+  project/commands/cmd_lm75b_gettemp.c \\r
+  project/commands/cmd_reset.c \\r
+  project/commands/cmd_sd_dir.c \\r
+  project/commands/cmd_sysinfo.c \\r
+  project/commands/cmd_uart.c \\r
+  project/commands/cmd_pwm.c\r
+\r
+SRCS += \\r
+  project/commands/drawing/cmd_backlight.c \\r
+  project/commands/drawing/cmd_bmp.c \\r
+  project/commands/drawing/cmd_button.c \\r
+  project/commands/drawing/cmd_calibrate.c \\r
+  project/commands/drawing/cmd_circle.c \\r
+  project/commands/drawing/cmd_clear.c \\r
+  project/commands/drawing/cmd_line.c \\r
+  project/commands/drawing/cmd_orientation.c \\r
+  project/commands/drawing/cmd_pixel.c \\r
+  project/commands/drawing/cmd_progress.c \\r
+  project/commands/drawing/cmd_rectangle.c \\r
+  project/commands/drawing/cmd_roundedcorner.c \\r
+  project/commands/drawing/cmd_text.c \\r
+  project/commands/drawing/cmd_textw.c \\r
+  project/commands/drawing/cmd_tsthreshhold.c \\r
+  project/commands/drawing/cmd_tswait.c \\r
+  project/commands/drawing/cmd_triangle.c\r
 \r
 ##########################################################################\r
 # Optional driver files \r
 ##########################################################################\r
 \r
 # Chibi Light-Weight Wireless Stack (AT86RF212)\r
-VPATH += drivers/rf/chibi\r
-OBJS += chb.o chb_buf.o chb_drvr.o chb_eeprom.o chb_spi.o\r
+SRCS += \\r
+  drivers/rf/chibi/chb.c \\r
+  drivers/rf/chibi/chb_buf.c \\r
+  drivers/rf/chibi/chb_drvr.c \\r
+  drivers/rf/chibi/chb_eeprom.c \\r
+  drivers/rf/chibi/chb_spi.c\r
 \r
 # 4K EEPROM\r
-VPATH += drivers/storage/eeprom drivers/storage/eeprom/mcp24aa\r
-OBJS += eeprom.o mcp24aa.o\r
+SRCS += \\r
+  drivers/storage/eeprom/eeprom.c \\r
+  drivers/storage/eeprom/mcp24aa/mcp24aa.c\r
 \r
 # LM75B temperature sensor\r
-VPATH += drivers/sensors/lm75b\r
-OBJS += lm75b.o\r
+SRCS += \\r
+  drivers/sensors/lm75b/lm75b.c\r
 \r
 # ISL12022M RTC\r
-VPATH += drivers/rtc/isl12022m\r
-OBJS += isl12022m.o\r
+SRCS += \\r
+  drivers/rtc/isl12022m/isl12022m.c\r
 \r
 # TFT LCD support\r
-VPATH += drivers/displays/tft drivers/displays/tft/hw \r
-OBJS += drawing.o touchscreen.o colors.o theme.o bmp.o\r
+SRCS += \\r
+  drivers/displays/tft/drawing.c \\r
+  drivers/displays/tft/touchscreen.c \\r
+  drivers/displays/tft/colors.c \\r
+  drivers/displays/tft/theme.c \\r
+  drivers/displays/tft/bmp.c\r
 \r
 # GUI Controls\r
-VPATH += drivers/displays/tft/controls\r
-OBJS += button.o hsbchart.o huechart.o label.o\r
-OBJS += labelcentered.o progressbar.o\r
+SRCS += \\r
+  drivers/displays/tft/controls/button.c \\r
+  drivers/displays/tft/controls/hsbchart.c \\r
+  drivers/displays/tft/controls/huechart.c \\r
+  drivers/displays/tft/controls/label.c \\r
+  drivers/displays/tft/controls/labelcentered.c \\r
+  drivers/displays/tft/controls/progressbar.c\r
 \r
 # Bitmap (non-AA) fonts\r
-VPATH += drivers/displays/tft/fonts\r
-OBJS += fonts.o \r
-OBJS += dejavusans9.o dejavusansbold9.o dejavusanscondensed9.o\r
-OBJS += dejavusansmono8.o dejavusansmonobold8.o\r
-OBJS += verdana9.o verdana14.o verdanabold14.o \r
+SRCS += \\r
+  drivers/displays/tft/fonts.c \\r
+  drivers/displays/tft/fonts/dejavusans9.c \\r
+  drivers/displays/tft/fonts/dejavusansbold9.c \\r
+  drivers/displays/tft/fonts/dejavusanscondensed9.c \\r
+  drivers/displays/tft/fonts/dejavusansmono8.c \\r
+  drivers/displays/tft/fonts/dejavusansmonobold8.c \\r
+  drivers/displays/tft/fonts/verdana9.c \\r
+  drivers/displays/tft/fonts/verdana14.c \\r
+  drivers/displays/tft/fonts/verdanabold14.c\r
 \r
 # Anti-aliased fonts\r
-VPATH += drivers/displays/tft/aafonts/aa2 drivers/displays/tft/aafonts/aa4\r
-OBJS += aafonts.o \r
-OBJS += DejaVuSansCondensed14_AA2.o DejaVuSansCondensedBold14_AA2.o\r
-OBJS += DejaVuSansMono10_AA2.o DejaVuSansMono13_AA2.o DejaVuSansMono14_AA2.o\r
+SRCS += \\r
+  drivers/displays/tft/aafonts.c \\r
+  drivers/displays/tft/aafonts/aa2/DejaVuSansCondensed14_AA2.c \\r
+  drivers/displays/tft/aafonts/aa2/DejaVuSansCondensedBold14_AA2.c \\r
+  drivers/displays/tft/aafonts/aa2/DejaVuSansMono10_AA2.c \\r
+  drivers/displays/tft/aafonts/aa2/DejaVuSansMono13_AA2.c \\r
+  drivers/displays/tft/aafonts/aa2/DejaVuSansMono14_AA2.c\r
 \r
 # LCD Driver (Only one can be included at a time!)\r
-# OBJS += hx8340b.o\r
-OBJS += ILI9328.o\r
-# OBJS += ILI9325.o\r
-# OBJS += ssd1331.o\r
-# OBJS += ssd1351.o\r
-# OBJS += st7735.o\r
-# OBJS += st7783.o\r
+# SRCS += drivers/displays/tft/hw/hx8340b.c\r
+# SRCS += drivers/displays/tft/hw/hx8347d.c\r
+# SRCS += drivers/displays/tft/hw/ILI9328.c\r
+# SRCS += drivers/displays/tft/hw/ILI9325.c\r
+# SRCS += drivers/displays/tft/hw/ssd1331.c\r
+# SRCS += drivers/displays/tft/hw/ssd1351.c\r
+# SRCS += drivers/displays/tft/hw/st7735.c\r
+# SRCS += drivers/displays/tft/hw/st7783.c\r
 \r
 # Bitmap/Monochrome LCD support (ST7565, SSD1306, etc.)\r
-VPATH += drivers/displays\r
-VPATH += drivers/displays/bitmap/sharpmem\r
-VPATH += drivers/displays/bitmap/st7565\r
-VPATH += drivers/displays/bitmap/ssd1306\r
-OBJS += smallfonts.o sharpmem.o st7565.o ssd1306.o\r
+SRCS += \\r
+  drivers/displays/smallfonts.c \\r
+  drivers/displays/bitmap/sharpmem/sharpmem.c \\r
+  drivers/displays/bitmap/st7565/st7565.c \\r
+  drivers/displays/bitmap/ssd1306/ssd1306.c\r
 \r
 #Character Displays (VFD text displays, etc.)\r
-VPATH += drivers/displays/character/samsung_20T202DA2JA\r
-OBJS += samsung_20T202DA2JA.o\r
+SRCS += \\r
+  drivers/displays/character/samsung_20T202DA2JA/samsung_20T202DA2JA.c\r
 \r
 # ChaN FatFS and SD card support\r
-VPATH += drivers/fatfs\r
-OBJS += ff.o mmc.o\r
+SRCS += \\r
+  drivers/fatfs/ff.c \r
+# drivers/fatfs/mmc.c\r
 \r
 # Motors\r
-VPATH += drivers/motor/stepper\r
-OBJS += stepper.o\r
+SRCS += \\r
+  drivers/motor/stepper/stepper.c\r
 \r
 # RSA Encryption/Descryption\r
-VPATH += drivers/rsa\r
-OBJS += rsa.o\r
+SRCS += \\r
+  drivers/rsa/rsa.c\r
 \r
 # DAC\r
-VPATH += drivers/dac/mcp4725 drivers/dac/mcp4901\r
-OBJS += mcp4725.o mcp4901.o\r
+SRCS += \\r
+  drivers/dac/mcp4725/mcp4725.c \\r
+  drivers/dac/mcp4901/mcp4901.c\r
 \r
 # RFID/NFC\r
-VPATH += drivers/rf/pn532 drivers/rf/pn532/helpers\r
-OBJS += pn532.o pn532_bus_i2c.o pn532_bus_uart.o\r
-OBJS += pn532_mifare_classic.o pn532_mifare_ultralight.o\r
+SRCS += \\r
+  drivers/rf/pn532/pn532.c \\r
+  drivers/rf/pn532/pn532_bus_i2c.c \\r
+  drivers/rf/pn532/pn532_bus_uart.c \\r
+  drivers/rf/pn532/helpers/pn532_mifare_classic.c \\r
+  drivers/rf/pn532/helpers/pn532_mifare_ultralight.c\r
 \r
 # TAOS Light Sensors\r
-VPATH += drivers/sensors/tcs3414 drivers/sensors/tsl2561\r
-OBJS += tcs3414.o tsl2561.o\r
+SRCS += \\r
+  drivers/sensors/tcs3414/tcs3414.c \\r
+  drivers/sensors/tsl2561/tsl2561.c\r
 \r
 # SPI Flash\r
-VPATH += drivers/storage/spiflash/w25q16bv\r
-OBJS += w25q16bv.o\r
+SRCS += \\r
+  drivers/storage/spiflash/w25q16bv/w25q16bv.c\r
 \r
 # FM Radio\r
-VPATH += drivers/audio/tea5767\r
-OBJS += tea5767.o\r
+SRCS += \\r
+  drivers/audio/tea5767/tea5767.c\r
+\r
+# IN219 Current Sensor\r
+SRCS += \\r
+  drivers/sensors/ina219/ina219.c\r
+\r
+# MPL115A2 Barometric Pressure Sensor\r
+SRCS += \\r
+  drivers/sensors/mpl115a2/mpl115a2.c\r
+\r
+# ADS1015 12-bit ADC\r
+SRCS += \\r
+  drivers/adc/ads1015/ads1015.c\r
 \r
 ##########################################################################\r
 # Library files \r
 ##########################################################################\r
 \r
-VPATH += core core/adc core/cmd core/cpu core/gpio core/i2c core/pmu\r
-VPATH += core/ssp core/systick core/timer16 core/timer32 core/uart\r
-VPATH += core/usbhid-rom core/wdt core/usbcdc core/pwm core/iap\r
-VPATH += core/libc\r
-OBJS += stdio.o string.o\r
-OBJS += adc.o cpu.o cmd.o gpio.o i2c.o pmu.o ssp.o systick.o timer16.o\r
-OBJS += timer32.o uart.o uart_buf.o usbconfig.o usbhid.o\r
-OBJS += wdt.o cdcuser.o cdc_buf.o usbcore.o usbdesc.o usbhw.o usbuser.o \r
-OBJS += sysinit.o pwm.o iap.o\r
+SRCS += \\r
+  core/adc/adc.c \\r
+  core/cmd/cmd.c \\r
+  core/cpu/cpu.c \\r
+  core/gpio/gpio.c \\r
+  core/iap/iap.c \\r
+  core/libc/stdio.c \\r
+  core/libc/string.c \\r
+  core/pmu/pmu.c \\r
+  core/pwm/pwm.c \\r
+  core/ssp/ssp.c \\r
+  core/systick/systick.c \\r
+  core/timer16/timer16.c \\r
+  core/timer32/timer32.c \\r
+  core/usbcdc/cdc_buf.c \\r
+  core/usbcdc/cdcuser.c \\r
+  core/usbcdc/usbcore.c \\r
+  core/usbcdc/usbdesc.c \\r
+  core/usbcdc/usbhw.c \\r
+  core/usbcdc/usbuser.c \\r
+  core/usbhid-rom/usbconfig.c \\r
+  core/usbhid-rom/usbhid.c \\r
+  core/usbhid-rom/usbmsc.c \\r
+  core/wdt/wdt.c\r
+\r
+#  core/i2c/i2c.c\r
+#  core/uart/uart_buf.c\r
+#  core/uart/uart.c\r
 \r
 ##########################################################################\r
 # GNU GCC compiler prefix and location\r
@@ -169,6 +278,8 @@ SIZE = $(CROSS_COMPILE)size
 OBJCOPY = $(CROSS_COMPILE)objcopy\r
 OBJDUMP = $(CROSS_COMPILE)objdump\r
 OUTFILE = firmware\r
+\r
+CC_FOR_BUILD = gcc\r
 LPCRC = ./lpcrc\r
 \r
 ##########################################################################\r
@@ -192,17 +303,22 @@ else
 endif\r
 \r
 CPU_TYPE = cortex-$(CORTEX_TYPE)\r
-VPATH += lpc1xxx\r
-OBJS += $(TARGET)_handlers.o LPC1xxx_startup.o\r
+\r
+SRCS += \\r
+  lpc1xxx/$(TARGET)_handlers.c \\r
+  lpc1xxx/LPC1xxx_startup.c\r
+\r
+OBJS = $(SRCS:%.c=%.o)\r
+DEPS = $(SRCS:%.c=%.dep)\r
 \r
 ##########################################################################\r
 # Compiler settings, parameters and flags\r
 ##########################################################################\r
 ifeq (TRUE,$(DEBUGBUILD))\r
-  CFLAGS  = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin $(OPTDEFINES)\r
+  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\r
   ASFLAGS = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp\r
 else\r
-  CFLAGS  = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin $(OPTDEFINES)\r
+  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\r
   ASFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp\r
 endif\r
 \r
@@ -210,30 +326,55 @@ LDFLAGS = -nostartfiles -mthumb -mcpu=$(CPU_TYPE) -Wl,--gc-sections
 LDLIBS  = -lm\r
 OCFLAGS = --strip-unneeded\r
 \r
-all: firmware\r
+all: dep size $(OUTFILE).bin $(OUTFILE).hex\r
 \r
-%.o : %.c\r
-       $(CC) $(CFLAGS) -o $@ $<\r
+dep: $(DEPS)\r
 \r
-%.o : %.s\r
-       $(AS) $(ASFLAGS) -o $@ $<\r
+$(DEPS) : %.dep : %.c\r
+       $(CC) $(CPPFLAGS) $(CFLAGS) -MM $< -MT $@ -MT $(@:%.dep=%.o) -MF $@\r
 \r
-firmware: $(OBJS) $(SYS_OBJS)\r
+sinclude $(DEPS)\r
+\r
+$(LD_TEMP): \r
        -@echo "MEMORY" > $(LD_TEMP)\r
        -@echo "{" >> $(LD_TEMP)\r
        -@echo "  flash(rx): ORIGIN = 0x00000000, LENGTH = $(FLASH)" >> $(LD_TEMP)\r
        -@echo "  sram(rwx): ORIGIN = 0x10000000+$(SRAM_USB), LENGTH = $(SRAM)-$(SRAM_USB)" >> $(LD_TEMP)\r
        -@echo "}" >> $(LD_TEMP)\r
        -@echo "INCLUDE $(LD_SCRIPT)" >> $(LD_TEMP)\r
+\r
+$(OUTFILE).elf: $(OBJS) $(LD_TEMP)\r
        $(LD) $(LDFLAGS) -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS)\r
-       -@echo ""\r
-       $(SIZE) $(OUTFILE).elf\r
-       -@echo ""\r
-       $(OBJCOPY) $(OCFLAGS) -O binary $(OUTFILE).elf $(OUTFILE).bin\r
+\r
+$(OUTFILE).bin: $(OUTFILE).elf $(LPCRC)\r
        $(OBJCOPY) $(OCFLAGS) -O binary $(OUTFILE).elf $(OUTFILE).bin\r
+       $(LPCRC) $(OUTFILE).bin\r
+\r
+$(OUTFILE).hex: $(OUTFILE).elf\r
        $(OBJCOPY) $(OCFLAGS) -O ihex $(OUTFILE).elf $(OUTFILE).hex\r
-       -@echo ""\r
-       $(LPCRC) firmware.bin\r
+\r
+size: $(OUTFILE).elf\r
+       $(SIZE) $(OUTFILE).elf\r
 \r
 clean:\r
        rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex\r
+\r
+distclean: clean\r
+       rm -f $(DEPS) $(LPCRC)\r
+\r
+.PHONY: all dep size clean distclean\r
+\r
+CFLAGS_FOR_BUILD = -Wall -Wextra -std=c99 -O0 -g\r
+\r
+LPCRC_SRCS = tools/lpcrc/lpcrc.c\r
+LPCRC_OBJS = $(LPCRC_SRCS:%.c=%.o)\r
+LPCRC_DEPS = $(LPCRC_SRCS:%.c=%.dep)\r
+\r
+$(LPCRC_DEPS) : %.dep : %.c\r
+       $(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -MM $< -MT $@ -MT $(@:%.dep=%.o) -MF $@\r
+\r
+$(LPCRC_OBJS): %.o : %.c\r
+       $(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o $@ -c $<\r
+\r
+$(LPCRC):  $(LPCRC_OBJS)\r
+       $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $+ $(LDLIBS_FOR_BUILD)\r
This page took 0.027928 seconds and 4 git commands to generate.