-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
36 lines (24 loc) · 828 Bytes
/
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
MCU=atmega328p
PORT=$(shell pavr2cmd --prog-port)
CFLAGS=-g -Wall -mcall-prologues -mmcu=$(MCU) -Os --param=min-pagesize=0
LDFLAGS=-Wl,-gc-sections -Wl,-relax
CC=avr-gcc
TARGET=main
all: $(TARGET).hex $(TARGET).s
clean:
rm -f *.o *.elf *.hex *.s tables/* *.out
%.hex: %.elf
avr-objcopy -R .eeprom -O ihex $< $@
tables/saw_tables.c: codegen/make_saw_table.py
python codegen/make_saw_table.py
tables/melody.c: codegen/make_melody.py
python codegen/make_melody.py
tables/midi.c: codegen/make_midi_table.py
python codegen/make_midi_table.py
$(TARGET).c: tables/saw_tables.c tables/melody.c tables/midi.c
$(TARGET).elf: $(TARGET).o
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
$(TARGET).s: $(TARGET).c
$(CC) $(CFLAGS) $(LDFLAGS) -S $^
program: $(TARGET).hex
avrdude -c stk500v2 -P "$(PORT)" -p $(MCU) -U flash:w:$<:i -F