diff --git a/soft/Makefile b/soft/Makefile index 8d52239..259f110 100644 --- a/soft/Makefile +++ b/soft/Makefile @@ -17,6 +17,14 @@ else SILENCE := endif +# Where and what are we building? +ifeq ($(APPLICATION),) + APPLICATION := sample/blinky +endif +ifeq ($(TARGET_MCU),) + TARGET_MCU := attiny85 +endif + # On Debian/Ubuntu, sudo apt install gcc-avr avr-libc CC := $(SILENCE)avr-gcc OBJCOPY := $(SILENCE)avr-objcopy @@ -25,24 +33,13 @@ OBJSIZE := $(SILENCE)avr-size RMDIR := $(SILENCE)rm -rf # List source files here... -C_SRCS := \ - blinky.c \ - pwm.c \ - task.c \ - twinkle.c \ +C_SRCS := $(wildcard $(APPLICATION)/*.c) \ + $(wildcard lib/*.c) \ # keep this comment to consume final backslash -# Where and what are we building? -ifeq ($(TARGET_MCU),) - TARGET_MCU := attiny85 -endif +# Derive .o and .d filenames from .c OUTPUT_DIR := build-$(TARGET_MCU) OUTPUT_FILE := $(OUTPUT_DIR)/chaserlights.elf - -# Create build directory if not already there -$(shell mkdir $(OUTPUT_DIR) 2>/dev/null) - -# Derive .o and .d filenames from .c OBJS := $(C_SRCS:%.c=$(OUTPUT_DIR)/%.o) C_DEPS := $(C_SRCS:%.c=$(OUTPUT_DIR)/%.d) @@ -54,7 +51,6 @@ all: $(OUTPUT_FILE:.elf=.hex) $(OUTPUT_FILE:.elf=.eep) $(OUTPUT_FILE:.elf=.lss) clean: -$(RMDIR) $(OUTPUT_DIR) - -mkdir $(OUTPUT_DIR) rebuild: clean build @@ -64,9 +60,10 @@ ifeq ($(TARGET_MCU),attiny85) CLOCK_FREQUENCY := 16500000 endif -$(OUTPUT_DIR)/%.o: src/%.c +$(OUTPUT_DIR)/%.o: %.c @echo $< - $(CC) -iquote inc -iquote etc \ + mkdir -p $(dir $@) + $(CC) -iquote inc -iquote $(APPLICATION) \ -x c -funsigned-char -funsigned-bitfields \ -DTARGET_MCU=$(TARGET_MCU) -DF_CPU=$(CLOCK_FREQUENCY)UL \ -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -mmcu=$(TARGET_MCU) \ diff --git a/soft/src/pwm.c b/soft/lib/pwm.c similarity index 100% rename from soft/src/pwm.c rename to soft/lib/pwm.c diff --git a/soft/src/task.c b/soft/lib/task.c similarity index 100% rename from soft/src/task.c rename to soft/lib/task.c diff --git a/soft/src/twinkle.c b/soft/lib/twinkle.c similarity index 100% rename from soft/src/twinkle.c rename to soft/lib/twinkle.c diff --git a/soft/src/blinky.c b/soft/sample/blinky/blinky.c similarity index 100% rename from soft/src/blinky.c rename to soft/sample/blinky/blinky.c diff --git a/soft/etc/pwm.config b/soft/sample/blinky/pwm.config similarity index 100% rename from soft/etc/pwm.config rename to soft/sample/blinky/pwm.config diff --git a/soft/etc/twinkle.config b/soft/sample/blinky/twinkle.config similarity index 100% rename from soft/etc/twinkle.config rename to soft/sample/blinky/twinkle.config diff --git a/soft/test/project.yml b/soft/test/project.yml index 8bfdce6..6959ed7 100644 --- a/soft/test/project.yml +++ b/soft/test/project.yml @@ -33,7 +33,7 @@ :test: - +:unittest/** :source: - - +:../src + - +:../lib :include: - +:stubs - +:../inc