-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (29 loc) · 993 Bytes
/
Copy pathMakefile
File metadata and controls
41 lines (29 loc) · 993 Bytes
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
# ATmega328P AVR Gameboy Handheld Console
# Build automation: `make` compiles, `make flash` programs via USBasp.
MCU = atmega328p
F_CPU = 20000000UL
PROGRAMMER = usbasp
CC = avr-gcc
OBJCOPY = avr-objcopy
AVRDUDE = avrdude
SIZE = avr-size
CFLAGS = -Wall -Wextra -Os -std=gnu11 -mmcu=$(MCU) -DF_CPU=$(F_CPU)
CFLAGS += -ffunction-sections -fdata-sections
LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections
SRCS = main.c system.c backlight.c display.c input.c audio.c boot.c menu.c snake.c tetris.c bricks.c launcher.c storage.c
OBJS = $(SRCS:.c=.o)
TARGET = firmware
.PHONY: all flash clean size
all: $(TARGET).hex size
$(TARGET).elf: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^
$(TARGET).hex: $(TARGET).elf
$(OBJCOPY) -O ihex -R .eeprom $< $@
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
size: $(TARGET).elf
$(SIZE) --mcu=$(MCU) --format=avr $<
flash: $(TARGET).hex
$(AVRDUDE) -c $(PROGRAMMER) -p $(MCU) -U flash:w:$(TARGET).hex:i
clean:
rm -f $(OBJS) $(TARGET).elf $(TARGET).hex