diff options
| author | tslil clingman <> | 2021-09-29 14:33:21 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2021-09-29 14:33:21 -0400 |
| commit | 328474f555ab0958e0921c7d04d8d7dbb1789bc4 (patch) | |
| tree | 422a4afe050471fde632d6075a983f7d588ea829 /code/Makefile | |
Diffstat (limited to 'code/Makefile')
| -rw-r--r-- | code/Makefile | 45 |
1 files changed, 45 insertions, 0 deletions
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) |
