-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (49 loc) · 1.54 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Makefile to build and flash thermidity.
#
# Simplified version from: https://github.com/hexagon5un/AVR-Programming
MCU = atmega328p
F_CPU = 8000000
BAUD = 9600
PROGRAMMER_TYPE = avrispmkII
PROGRAMMER_ARGS =
MAIN = avrink.c
SRC = bitmaps.c cmd.c dejavu.c display.c eink.c font.c spi.c sram.c \
unifont.c usart.c
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
AVRSIZE = avr-size
AVRDUDE = avrdude
CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU)UL -DBAUD=$(BAUD)
CFLAGS += -O2 -I.
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -Wall -Wstrict-prototypes
CFLAGS += -g -ggdb
CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections -mrelax
CFLAGS += -std=gnu99
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
CFLAGS += --param=min-pagesize=0
TARGET = $(strip $(basename $(MAIN)))
SRC += $(TARGET).c
OBJ = $(SRC:.c=.o)
OBJ = $(SRC:.S=.o)
$(TARGET).elf: bitmaps.h cmd.h dejavu.h display.h eink.h font.h pins.h \
spi.h sram.h types.h unifont.h usart.h utils.h Makefile
all: $(TARGET).hex
%.hex: %.elf
$(OBJCOPY) -R .eeprom -O ihex $< $@
%.elf: $(SRC)
$(CC) $(CFLAGS) $(SRC) --output $@
disasm: $(TARGET).lst
eeprom: $(TARGET).eeprom
%.lst: %.elf
$(OBJDUMP) -S $< > $@
size: $(TARGET).elf
$(AVRSIZE) -G $(TARGET).elf
clean:
rm -f $(TARGET).elf $(TARGET).hex $(TARGET).obj \
$(TARGET).o $(TARGET).d $(TARGET).eep $(TARGET).lst \
$(TARGET).lss $(TARGET).sym $(TARGET).map $(TARGET)~ \
$(TARGET).eeprom
flash: $(TARGET).hex
$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U flash:w:$<