From 328474f555ab0958e0921c7d04d8d7dbb1789bc4 Mon Sep 17 00:00:00 2001 From: tslil clingman <> Date: Wed, 29 Sep 2021 14:33:21 -0400 Subject: Init --- code/Makefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 code/Makefile (limited to 'code/Makefile') diff --git a/code/Makefile b/code/Makefile new file mode 100644 index 0000000..0bc81a8 --- /dev/null +++ b/code/Makefile @@ -0,0 +1,45 @@ +TARGET = main + +MCU = attiny24 +F_CPU = 8000000UL + +CC = avr-gcc +CFLAGS = -Os -Wall -fpack-struct -fshort-enums -funsigned-bitfields -funsigned-char + +LDFLATS = -Wl,-Map,$(TARGET).map +LDFLAGS += -Wl,--gc-sections +TARGET_ARCH = -mmcu=$(MCU) + +OBJCOPY = avr-objcopy +OBJSIZE = avr-size + +AVRDUDE = avrdude +ADFLAGS = -c usbasp -p t24 + +SRC=$(wildcard src/*.c) $(wildcard src/*/*.c) $(wildcard src/*/*/*.c) +OBJ=$(patsubst %.c, %.o, $(SRC)) +ASM=$(patsubst %.c, %.s, $(SRC)) + +all: $(OBJ) $(TARGET).hex summary upload + +%.o: %.c + $(CC) $(CFLAGS) -DF_CPU=$(F_CPU) -mmcu=$(MCU) -c -o $@ $< + +%.s: %.c + $(CC) -S $(CFLAGS) -DF_CPU=$(F_CPU) -mmcu=$(MCU) $< -o $@ + +%.elf: $(OBJ) + $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ -o $@ + +%.hex: %.elf + $(OBJCOPY) -j .text -j .data -O ihex $< $@ + +summary: $(OBJ) $(TARGET).hex + @echo ---------------------------------------------------------------------- + @$(OBJSIZE) $(OBJ) $(TARGET).hex + +upload: $(TARGET).hex + $(AVRDUDE) $(ADFLAGS) -U flash:w:$< + +clean: + rm -f $(OBJ) $(HEX) $(ASM) -- cgit v1.3.1