]> git.earman.xyz Git - sensor-watch.git/commitdiff
simplify project makefiles
authorJoey Castillo <jose.castillo@gmail.com>
Sat, 28 Aug 2021 17:58:21 +0000 (13:58 -0400)
committerJoey Castillo <jose.castillo@gmail.com>
Sat, 28 Aug 2021 18:13:03 +0000 (14:13 -0400)
Sensor Watch BME280 Project/make/Makefile
Sensor Watch Buzzer Demo/make/Makefile
Sensor Watch Starter Project/make/Makefile
make.mk [new file with mode: 0644]
rules.mk [new file with mode: 0644]

index 9b8d25c066343781177a4a43155a61674847c849..358bb8600f90625dcfb8abb85b1fb1c060d16fec 100755 (executable)
@@ -1,151 +1,9 @@
-##############################################################################
-BUILD = build
-BIN = watch
+include ../../make.mk
 
-##############################################################################
-.PHONY: all directory clean size
-
-CC = arm-none-eabi-gcc
-OBJCOPY = arm-none-eabi-objcopy
-SIZE = arm-none-eabi-size
-UF2 = python ../../utils/uf2conv.py
-
-ifeq ($(OS), Windows_NT)
-  MKDIR = gmkdir
-else
-  MKDIR = mkdir
-endif
-
-CFLAGS += -W -Wall --std=gnu99 -Os
-CFLAGS += -fno-diagnostics-show-caret
-CFLAGS += -fdata-sections -ffunction-sections
-CFLAGS += -funsigned-char -funsigned-bitfields
-CFLAGS += -mcpu=cortex-m0plus -mthumb
-CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d
-
-LDFLAGS += -mcpu=cortex-m0plus -mthumb
-LDFLAGS += -Wl,--gc-sections
-LDFLAGS += -Wl,--script=../../watch-library/linker/saml22j18.ld
-
-# If you add any additional directories with headers, add them to this list, e.g.
-# ../drivers/
 INCLUDES += \
-  -I../ \
-  -I../../watch-library/include \
-  -I../../watch-library/hal/ \
-  -I../../watch-library/hal/documentation/ \
-  -I../../watch-library/hal/include/ \
-  -I../../watch-library/hal/src/ \
-  -I../../watch-library/hal/utils/ \
-  -I../../watch-library/hal/utils/include/ \
-  -I../../watch-library/hal/utils/src/ \
-  -I../../watch-library/hpl/ \
-  -I../../watch-library/hpl/adc/ \
-  -I../../watch-library/hpl/core/ \
-  -I../../watch-library/hpl/dmac/ \
-  -I../../watch-library/hpl/eic/ \
-  -I../../watch-library/hpl/gclk/ \
-  -I../../watch-library/hpl/mclk/ \
-  -I../../watch-library/hpl/osc32kctrl/ \
-  -I../../watch-library/hpl/oscctrl/ \
-  -I../../watch-library/hpl/pm/ \
-  -I../../watch-library/hpl/port/ \
-  -I../../watch-library/hpl/rtc/ \
-  -I../../watch-library/hpl/sercom/ \
-  -I../../watch-library/hpl/slcd/ \
-  -I../../watch-library/hpl/systick/ \
-  -I../../watch-library/hpl/tcc/ \
-  -I../../watch-library/hpl/tc/ \
-  -I../../watch-library/hri/ \
-  -I../../watch-library/config/ \
-  -I../../watch-library/hw/ \
-  -I../../watch-library/watch/ \
-  -I../../watch-library
+  -I../
 
-# If you add any additional C files to your project, add them each to this list, e.g.
-# ../drivers/st25dv.c
 SRCS += \
-  ../app.c \
-  ../../watch-library/main.c \
-  ../../watch-library/startup_saml22.c \
-  ../../watch-library/hw/driver_init.c \
-  ../../watch-library/watch/watch.c \
-  ../../watch-library/hal/src/hal_adc_sync.c \
-  ../../watch-library/hal/src/hal_atomic.c \
-  ../../watch-library/hal/src/hal_calendar.c \
-  ../../watch-library/hal/src/hal_delay.c \
-  ../../watch-library/hal/src/hal_ext_irq.c \
-  ../../watch-library/hal/src/hal_gpio.c \
-  ../../watch-library/hal/src/hal_i2c_m_sync.c \
-  ../../watch-library/hal/src/hal_init.c \
-  ../../watch-library/hal/src/hal_io.c \
-  ../../watch-library/hal/src/hal_pwm.c \
-  ../../watch-library/hal/src/hal_slcd_sync.c \
-  ../../watch-library/hal/src/hal_sleep.c \
-  ../../watch-library/hal/utils/src/utils_assert.c \
-  ../../watch-library/hal/utils/src/utils_event.c \
-  ../../watch-library/hal/utils/src/utils_list.c \
-  ../../watch-library/hal/utils/src/utils_syscalls.c \
-  ../../watch-library/hpl/adc/hpl_adc.c \
-  ../../watch-library/hpl/core/hpl_core_m0plus_base.c \
-  ../../watch-library/hpl/core/hpl_init.c \
-  ../../watch-library/hpl/dmac/hpl_dmac.c \
-  ../../watch-library/hpl/eic/hpl_eic.c \
-  ../../watch-library/hpl/gclk/hpl_gclk.c \
-  ../../watch-library/hpl/mclk/hpl_mclk.c \
-  ../../watch-library/hpl/osc32kctrl/hpl_osc32kctrl.c \
-  ../../watch-library/hpl/oscctrl/hpl_oscctrl.c \
-  ../../watch-library/hpl/pm/hpl_pm.c \
-  ../../watch-library/hpl/rtc/hpl_rtc.c \
-  ../../watch-library/hpl/sercom/hpl_sercom.c \
-  ../../watch-library/hpl/slcd/hpl_slcd.c \
-  ../../watch-library/hpl/systick/hpl_systick.c \
-  ../../watch-library/hpl/tcc/hpl_tcc.c \
-  ../../watch-library/hpl/tc/hpl_tc.c
-
-DEFINES += \
-  -D__SAML22J18A__ \
-  -DDONT_USE_CMSIS_INIT
-
-CFLAGS += $(INCLUDES) $(DEFINES)
-
-OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS))))
-
-all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 size
-
-$(BUILD)/$(BIN).elf: $(OBJS)
-       @echo LD $@
-       @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
-
-$(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf
-       @echo OBJCOPY $@
-       @$(OBJCOPY) -O ihex $^ $@
-
-$(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf
-       @echo OBJCOPY $@
-       @$(OBJCOPY) -O binary $^ $@
-
-$(BUILD)/$(BIN).uf2: $(BUILD)/$(BIN).bin
-       @echo UF2CONV $@
-       @$(UF2) $^ -co $@
-
-install:
-       @$(UF2) -D $(BUILD)/$(BIN).uf2
-
-%.o:
-       @echo CC $@
-       @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@
-
-directory:
-       @$(MKDIR) -p $(BUILD)
-
-size: $(BUILD)/$(BIN).elf
-       @echo size:
-       @$(SIZE) -t $^
-
-clean:
-       @echo clean
-       @-rm -rf $(BUILD)
-
--include $(wildcard $(BUILD)/*.d)
+  ../app.c
 
+include ../../rules.mk
index 9b8d25c066343781177a4a43155a61674847c849..358bb8600f90625dcfb8abb85b1fb1c060d16fec 100755 (executable)
@@ -1,151 +1,9 @@
-##############################################################################
-BUILD = build
-BIN = watch
+include ../../make.mk
 
-##############################################################################
-.PHONY: all directory clean size
-
-CC = arm-none-eabi-gcc
-OBJCOPY = arm-none-eabi-objcopy
-SIZE = arm-none-eabi-size
-UF2 = python ../../utils/uf2conv.py
-
-ifeq ($(OS), Windows_NT)
-  MKDIR = gmkdir
-else
-  MKDIR = mkdir
-endif
-
-CFLAGS += -W -Wall --std=gnu99 -Os
-CFLAGS += -fno-diagnostics-show-caret
-CFLAGS += -fdata-sections -ffunction-sections
-CFLAGS += -funsigned-char -funsigned-bitfields
-CFLAGS += -mcpu=cortex-m0plus -mthumb
-CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d
-
-LDFLAGS += -mcpu=cortex-m0plus -mthumb
-LDFLAGS += -Wl,--gc-sections
-LDFLAGS += -Wl,--script=../../watch-library/linker/saml22j18.ld
-
-# If you add any additional directories with headers, add them to this list, e.g.
-# ../drivers/
 INCLUDES += \
-  -I../ \
-  -I../../watch-library/include \
-  -I../../watch-library/hal/ \
-  -I../../watch-library/hal/documentation/ \
-  -I../../watch-library/hal/include/ \
-  -I../../watch-library/hal/src/ \
-  -I../../watch-library/hal/utils/ \
-  -I../../watch-library/hal/utils/include/ \
-  -I../../watch-library/hal/utils/src/ \
-  -I../../watch-library/hpl/ \
-  -I../../watch-library/hpl/adc/ \
-  -I../../watch-library/hpl/core/ \
-  -I../../watch-library/hpl/dmac/ \
-  -I../../watch-library/hpl/eic/ \
-  -I../../watch-library/hpl/gclk/ \
-  -I../../watch-library/hpl/mclk/ \
-  -I../../watch-library/hpl/osc32kctrl/ \
-  -I../../watch-library/hpl/oscctrl/ \
-  -I../../watch-library/hpl/pm/ \
-  -I../../watch-library/hpl/port/ \
-  -I../../watch-library/hpl/rtc/ \
-  -I../../watch-library/hpl/sercom/ \
-  -I../../watch-library/hpl/slcd/ \
-  -I../../watch-library/hpl/systick/ \
-  -I../../watch-library/hpl/tcc/ \
-  -I../../watch-library/hpl/tc/ \
-  -I../../watch-library/hri/ \
-  -I../../watch-library/config/ \
-  -I../../watch-library/hw/ \
-  -I../../watch-library/watch/ \
-  -I../../watch-library
+  -I../
 
-# If you add any additional C files to your project, add them each to this list, e.g.
-# ../drivers/st25dv.c
 SRCS += \
-  ../app.c \
-  ../../watch-library/main.c \
-  ../../watch-library/startup_saml22.c \
-  ../../watch-library/hw/driver_init.c \
-  ../../watch-library/watch/watch.c \
-  ../../watch-library/hal/src/hal_adc_sync.c \
-  ../../watch-library/hal/src/hal_atomic.c \
-  ../../watch-library/hal/src/hal_calendar.c \
-  ../../watch-library/hal/src/hal_delay.c \
-  ../../watch-library/hal/src/hal_ext_irq.c \
-  ../../watch-library/hal/src/hal_gpio.c \
-  ../../watch-library/hal/src/hal_i2c_m_sync.c \
-  ../../watch-library/hal/src/hal_init.c \
-  ../../watch-library/hal/src/hal_io.c \
-  ../../watch-library/hal/src/hal_pwm.c \
-  ../../watch-library/hal/src/hal_slcd_sync.c \
-  ../../watch-library/hal/src/hal_sleep.c \
-  ../../watch-library/hal/utils/src/utils_assert.c \
-  ../../watch-library/hal/utils/src/utils_event.c \
-  ../../watch-library/hal/utils/src/utils_list.c \
-  ../../watch-library/hal/utils/src/utils_syscalls.c \
-  ../../watch-library/hpl/adc/hpl_adc.c \
-  ../../watch-library/hpl/core/hpl_core_m0plus_base.c \
-  ../../watch-library/hpl/core/hpl_init.c \
-  ../../watch-library/hpl/dmac/hpl_dmac.c \
-  ../../watch-library/hpl/eic/hpl_eic.c \
-  ../../watch-library/hpl/gclk/hpl_gclk.c \
-  ../../watch-library/hpl/mclk/hpl_mclk.c \
-  ../../watch-library/hpl/osc32kctrl/hpl_osc32kctrl.c \
-  ../../watch-library/hpl/oscctrl/hpl_oscctrl.c \
-  ../../watch-library/hpl/pm/hpl_pm.c \
-  ../../watch-library/hpl/rtc/hpl_rtc.c \
-  ../../watch-library/hpl/sercom/hpl_sercom.c \
-  ../../watch-library/hpl/slcd/hpl_slcd.c \
-  ../../watch-library/hpl/systick/hpl_systick.c \
-  ../../watch-library/hpl/tcc/hpl_tcc.c \
-  ../../watch-library/hpl/tc/hpl_tc.c
-
-DEFINES += \
-  -D__SAML22J18A__ \
-  -DDONT_USE_CMSIS_INIT
-
-CFLAGS += $(INCLUDES) $(DEFINES)
-
-OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS))))
-
-all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 size
-
-$(BUILD)/$(BIN).elf: $(OBJS)
-       @echo LD $@
-       @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
-
-$(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf
-       @echo OBJCOPY $@
-       @$(OBJCOPY) -O ihex $^ $@
-
-$(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf
-       @echo OBJCOPY $@
-       @$(OBJCOPY) -O binary $^ $@
-
-$(BUILD)/$(BIN).uf2: $(BUILD)/$(BIN).bin
-       @echo UF2CONV $@
-       @$(UF2) $^ -co $@
-
-install:
-       @$(UF2) -D $(BUILD)/$(BIN).uf2
-
-%.o:
-       @echo CC $@
-       @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@
-
-directory:
-       @$(MKDIR) -p $(BUILD)
-
-size: $(BUILD)/$(BIN).elf
-       @echo size:
-       @$(SIZE) -t $^
-
-clean:
-       @echo clean
-       @-rm -rf $(BUILD)
-
--include $(wildcard $(BUILD)/*.d)
+  ../app.c
 
+include ../../rules.mk
index e9a581d55a3443fabbcc57b3129532270c9c853e..bf6d4232e5e877bac619bc56538f5d29e11968cb 100755 (executable)
-##############################################################################\r
-BUILD = build\r
-BIN = watch\r
-\r
-##############################################################################\r
-.PHONY: all directory clean size\r
-\r
-CC = arm-none-eabi-gcc\r
-OBJCOPY = arm-none-eabi-objcopy\r
-SIZE = arm-none-eabi-size\r
-UF2 = python ../../utils/uf2conv.py\r
-\r
-ifeq ($(OS), Windows_NT)\r
-  MKDIR = gmkdir\r
-else\r
-  MKDIR = mkdir\r
-endif\r
-\r
-CFLAGS += -W -Wall --std=gnu99 -Os\r
-CFLAGS += -fno-diagnostics-show-caret\r
-CFLAGS += -fdata-sections -ffunction-sections\r
-CFLAGS += -funsigned-char -funsigned-bitfields\r
-CFLAGS += -mcpu=cortex-m0plus -mthumb\r
-CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d\r
-\r
-LDFLAGS += -mcpu=cortex-m0plus -mthumb\r
-LDFLAGS += -Wl,--gc-sections\r
-LDFLAGS += -Wl,--script=../../watch-library/linker/saml22j18.ld\r
-\r
-# If you add any additional directories with headers, add them to this list, e.g.\r
-# ../drivers/\r
-INCLUDES += \\r
-  -I../ \\r
-  -I../../tinyusb/src \\r
-  -I../../watch-library/include \\r
-  -I../../watch-library/hal/ \\r
-  -I../../watch-library/hal/documentation/ \\r
-  -I../../watch-library/hal/include/ \\r
-  -I../../watch-library/hal/src/ \\r
-  -I../../watch-library/hal/utils/ \\r
-  -I../../watch-library/hal/utils/include/ \\r
-  -I../../watch-library/hal/utils/src/ \\r
-  -I../../watch-library/hpl/ \\r
-  -I../../watch-library/hpl/adc/ \\r
-  -I../../watch-library/hpl/core/ \\r
-  -I../../watch-library/hpl/dmac/ \\r
-  -I../../watch-library/hpl/eic/ \\r
-  -I../../watch-library/hpl/gclk/ \\r
-  -I../../watch-library/hpl/mclk/ \\r
-  -I../../watch-library/hpl/osc32kctrl/ \\r
-  -I../../watch-library/hpl/oscctrl/ \\r
-  -I../../watch-library/hpl/pm/ \\r
-  -I../../watch-library/hpl/port/ \\r
-  -I../../watch-library/hpl/rtc/ \\r
-  -I../../watch-library/hpl/sercom/ \\r
-  -I../../watch-library/hpl/slcd/ \\r
-  -I../../watch-library/hpl/systick/ \\r
-  -I../../watch-library/hpl/tcc/ \\r
-  -I../../watch-library/hpl/tc/ \\r
-  -I../../watch-library/hri/ \\r
-  -I../../watch-library/config/ \\r
-  -I../../watch-library/hw/ \\r
-  -I../../watch-library/watch/ \\r
-  -I../../watch-library\r
-\r
-# If you add any additional C files to your project, add them each to this list, e.g.\r
-# ../drivers/st25dv.c\r
-SRCS += \\r
-  ../app.c \\r
-  ../../tinyusb/src/tusb.c \\r
-  ../../tinyusb/src/common/tusb_fifo.c \\r
-  ../../tinyusb/src/class/cdc/cdc_device.c \\r
-  ../../tinyusb/src/device/usbd.c \\r
-  ../../tinyusb/src/device/usbd_control.c \\r
-  ../../tinyusb/src/portable/microchip/samd/dcd_samd.c \\r
-  ../../watch-library/main.c \\r
-  ../../watch-library/startup_saml22.c \\r
-  ../../watch-library/hw/driver_init.c \\r
-  ../../watch-library/watch/watch.c \\r
-  ../../watch-library/hal/src/hal_adc_sync.c \\r
-  ../../watch-library/hal/src/hal_atomic.c \\r
-  ../../watch-library/hal/src/hal_calendar.c \\r
-  ../../watch-library/hal/src/hal_delay.c \\r
-  ../../watch-library/hal/src/hal_ext_irq.c \\r
-  ../../watch-library/hal/src/hal_gpio.c \\r
-  ../../watch-library/hal/src/hal_i2c_m_sync.c \\r
-  ../../watch-library/hal/src/hal_init.c \\r
-  ../../watch-library/hal/src/hal_io.c \\r
-  ../../watch-library/hal/src/hal_pwm.c \\r
-  ../../watch-library/hal/src/hal_slcd_sync.c \\r
-  ../../watch-library/hal/src/hal_sleep.c \\r
-  ../../watch-library/hal/utils/src/utils_assert.c \\r
-  ../../watch-library/hal/utils/src/utils_event.c \\r
-  ../../watch-library/hal/utils/src/utils_list.c \\r
-  ../../watch-library/hal/utils/src/utils_syscalls.c \\r
-  ../../watch-library/hpl/adc/hpl_adc.c \\r
-  ../../watch-library/hpl/core/hpl_core_m0plus_base.c \\r
-  ../../watch-library/hpl/core/hpl_init.c \\r
-  ../../watch-library/hpl/dmac/hpl_dmac.c \\r
-  ../../watch-library/hpl/eic/hpl_eic.c \\r
-  ../../watch-library/hpl/gclk/hpl_gclk.c \\r
-  ../../watch-library/hpl/mclk/hpl_mclk.c \\r
-  ../../watch-library/hpl/osc32kctrl/hpl_osc32kctrl.c \\r
-  ../../watch-library/hpl/oscctrl/hpl_oscctrl.c \\r
-  ../../watch-library/hpl/pm/hpl_pm.c \\r
-  ../../watch-library/hpl/rtc/hpl_rtc.c \\r
-  ../../watch-library/hpl/sercom/hpl_sercom.c \\r
-  ../../watch-library/hpl/slcd/hpl_slcd.c \\r
-  ../../watch-library/hpl/systick/hpl_systick.c \\r
-  ../../watch-library/hpl/tcc/hpl_tcc.c \\r
-  ../../watch-library/hpl/tc/hpl_tc.c\r
-\r
-DEFINES += \\r
-  -D__SAML22J18A__ \\r
-  -DDONT_USE_CMSIS_INIT\r
-\r
-CFLAGS += $(INCLUDES) $(DEFINES)\r
-\r
-OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS))))\r
-\r
-all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 size\r
-\r
-$(BUILD)/$(BIN).elf: $(OBJS)\r
-       @echo LD $@\r
-       @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@\r
-\r
-$(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf\r
-       @echo OBJCOPY $@\r
-       @$(OBJCOPY) -O ihex $^ $@\r
-\r
-$(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf\r
-       @echo OBJCOPY $@\r
-       @$(OBJCOPY) -O binary $^ $@\r
-\r
-$(BUILD)/$(BIN).uf2: $(BUILD)/$(BIN).bin\r
-       @echo UF2CONV $@\r
-       @$(UF2) $^ -co $@\r
-\r
-install:\r
-       @$(UF2) -D $(BUILD)/$(BIN).uf2\r
-\r
-%.o:\r
-       @echo CC $@\r
-       @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@\r
-\r
-directory:\r
-       @$(MKDIR) -p $(BUILD)\r
-\r
-size: $(BUILD)/$(BIN).elf\r
-       @echo size:\r
-       @$(SIZE) -t $^\r
-\r
-clean:\r
-       @echo clean\r
-       @-rm -rf $(BUILD)\r
-\r
--include $(wildcard $(BUILD)/*.d)\r
-\r
+# Leave this line at the top of the file; it has all the watch library sources and includes.
+include ../../make.mk
+
+# If you add any other subdirectories with header files you wish to include, add them after ../
+# Note that you will need to add a backslash at the end of any line you wish to continue, i.e.
+# INCLUDES += \
+#   -I../ \
+#   -I../drivers/ \
+#   -I../utils/
+INCLUDES += \
+  -I../ \
+
+# If you add any other source files you wish to compile, add them after ../app.c
+# Note that you will need to add a backslash at the end of any line you wish to continue, i.e.
+# SRCS += \
+#   ../app.c \
+#   ../drivers/bmp280.c \
+#   ../utils/temperature.c
+SRCS += \
+  ../app.c \
+
+# Leave this line at the bottom of the file; it has all the targets for making your project.
+include ../../rules.mk
diff --git a/make.mk b/make.mk
new file mode 100644 (file)
index 0000000..38dcdf5
--- /dev/null
+++ b/make.mk
@@ -0,0 +1,113 @@
+##############################################################################
+BUILD = ./build
+BIN = watch
+
+##############################################################################
+.PHONY: all directory clean size
+
+CC = arm-none-eabi-gcc
+OBJCOPY = arm-none-eabi-objcopy
+SIZE = arm-none-eabi-size
+UF2 = python ../../utils/uf2conv.py
+
+ifeq ($(OS), Windows_NT)
+  MKDIR = gmkdir
+else
+  MKDIR = mkdir
+endif
+
+CFLAGS += -W -Wall --std=gnu99 -Os
+CFLAGS += -fno-diagnostics-show-caret
+CFLAGS += -fdata-sections -ffunction-sections
+CFLAGS += -funsigned-char -funsigned-bitfields
+CFLAGS += -mcpu=cortex-m0plus -mthumb
+CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d
+
+LDFLAGS += -mcpu=cortex-m0plus -mthumb
+LDFLAGS += -Wl,--gc-sections
+LDFLAGS += -Wl,--script=../../watch-library/linker/saml22j18.ld
+
+# If you add any additional directories with headers, add them to this list, e.g.
+# ../drivers/
+INCLUDES += \
+  -I../../tinyusb/src \
+  -I../../watch-library/include \
+  -I../../watch-library/hal/ \
+  -I../../watch-library/hal/documentation/ \
+  -I../../watch-library/hal/include/ \
+  -I../../watch-library/hal/src/ \
+  -I../../watch-library/hal/utils/ \
+  -I../../watch-library/hal/utils/include/ \
+  -I../../watch-library/hal/utils/src/ \
+  -I../../watch-library/hpl/ \
+  -I../../watch-library/hpl/adc/ \
+  -I../../watch-library/hpl/core/ \
+  -I../../watch-library/hpl/dmac/ \
+  -I../../watch-library/hpl/eic/ \
+  -I../../watch-library/hpl/gclk/ \
+  -I../../watch-library/hpl/mclk/ \
+  -I../../watch-library/hpl/osc32kctrl/ \
+  -I../../watch-library/hpl/oscctrl/ \
+  -I../../watch-library/hpl/pm/ \
+  -I../../watch-library/hpl/port/ \
+  -I../../watch-library/hpl/rtc/ \
+  -I../../watch-library/hpl/sercom/ \
+  -I../../watch-library/hpl/slcd/ \
+  -I../../watch-library/hpl/systick/ \
+  -I../../watch-library/hpl/tcc/ \
+  -I../../watch-library/hpl/tc/ \
+  -I../../watch-library/hri/ \
+  -I../../watch-library/config/ \
+  -I../../watch-library/hw/ \
+  -I../../watch-library/watch/ \
+  -I../../watch-library
+
+# If you add any additional C files to your project, add them each to this list, e.g.
+# ../drivers/st25dv.c
+SRCS += \
+  ../../tinyusb/src/tusb.c \
+  ../../tinyusb/src/common/tusb_fifo.c \
+  ../../tinyusb/src/class/cdc/cdc_device.c \
+  ../../tinyusb/src/device/usbd.c \
+  ../../tinyusb/src/device/usbd_control.c \
+  ../../tinyusb/src/portable/microchip/samd/dcd_samd.c \
+  ../../watch-library/main.c \
+  ../../watch-library/startup_saml22.c \
+  ../../watch-library/hw/driver_init.c \
+  ../../watch-library/watch/watch.c \
+  ../../watch-library/hal/src/hal_adc_sync.c \
+  ../../watch-library/hal/src/hal_atomic.c \
+  ../../watch-library/hal/src/hal_calendar.c \
+  ../../watch-library/hal/src/hal_delay.c \
+  ../../watch-library/hal/src/hal_ext_irq.c \
+  ../../watch-library/hal/src/hal_gpio.c \
+  ../../watch-library/hal/src/hal_i2c_m_sync.c \
+  ../../watch-library/hal/src/hal_init.c \
+  ../../watch-library/hal/src/hal_io.c \
+  ../../watch-library/hal/src/hal_pwm.c \
+  ../../watch-library/hal/src/hal_slcd_sync.c \
+  ../../watch-library/hal/src/hal_sleep.c \
+  ../../watch-library/hal/utils/src/utils_assert.c \
+  ../../watch-library/hal/utils/src/utils_event.c \
+  ../../watch-library/hal/utils/src/utils_list.c \
+  ../../watch-library/hal/utils/src/utils_syscalls.c \
+  ../../watch-library/hpl/adc/hpl_adc.c \
+  ../../watch-library/hpl/core/hpl_core_m0plus_base.c \
+  ../../watch-library/hpl/core/hpl_init.c \
+  ../../watch-library/hpl/dmac/hpl_dmac.c \
+  ../../watch-library/hpl/eic/hpl_eic.c \
+  ../../watch-library/hpl/gclk/hpl_gclk.c \
+  ../../watch-library/hpl/mclk/hpl_mclk.c \
+  ../../watch-library/hpl/osc32kctrl/hpl_osc32kctrl.c \
+  ../../watch-library/hpl/oscctrl/hpl_oscctrl.c \
+  ../../watch-library/hpl/pm/hpl_pm.c \
+  ../../watch-library/hpl/rtc/hpl_rtc.c \
+  ../../watch-library/hpl/sercom/hpl_sercom.c \
+  ../../watch-library/hpl/slcd/hpl_slcd.c \
+  ../../watch-library/hpl/systick/hpl_systick.c \
+  ../../watch-library/hpl/tcc/hpl_tcc.c \
+  ../../watch-library/hpl/tc/hpl_tc.c
+
+DEFINES += \
+  -D__SAML22J18A__ \
+  -DDONT_USE_CMSIS_INIT
diff --git a/rules.mk b/rules.mk
new file mode 100644 (file)
index 0000000..cc442f6
--- /dev/null
+++ b/rules.mk
@@ -0,0 +1,41 @@
+CFLAGS += $(INCLUDES) $(DEFINES)
+
+OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS))))
+
+all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 size
+
+$(BUILD)/$(BIN).elf: $(OBJS)
+       @echo LD $@
+       @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
+
+$(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf
+       @echo OBJCOPY $@
+       @$(OBJCOPY) -O ihex $^ $@
+
+$(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf
+       @echo OBJCOPY $@
+       @$(OBJCOPY) -O binary $^ $@
+
+$(BUILD)/$(BIN).uf2: $(BUILD)/$(BIN).bin
+       @echo UF2CONV $@
+       @$(UF2) $^ -co $@
+
+install:
+       @$(UF2) -D $(BUILD)/$(BIN).uf2
+
+%.o:
+       @echo CC $@
+       @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@
+
+directory:
+       @$(MKDIR) -p $(BUILD)
+
+size: $(BUILD)/$(BIN).elf
+       @echo size:
+       @$(SIZE) -t $^
+
+clean:
+       @echo clean
+       @-rm -rf $(BUILD)
+
+-include $(wildcard $(BUILD)/*.d)