summaryrefslogtreecommitdiff
path: root/makefile
blob: 2cd372dc64d71725b224c2f86a172e22519de6a2 (plain)
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
TOOLCHAIN_DIR=/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64
CC=$(TOOLCHAIN_DIR)/bin/avr-gcc
INC=$(TOOLCHAIN_DIR)/avr/include
OUT=payload.elf
SRCFILES := $(wildcard *.c)
OBJFILES := $(patsubst %.c,build/%.o,$(SRCFILES))

DEVICE=atmega165pa
F_CPU=8000000 #uses internal 8mhz RC clock
#F_CPU=10000000 #uses external 10mhz crystal to ensure accuracy. 10mhz is weird but I just had this one laying around

CCOPTS := -Wall -Wextra -I $(INC) -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) -O1


make: $(OBJFILES)
	$(CC) $(CCOPTS) -o $(OUT) $(OBJFILES)

build/%.o: %.c
	if [ ! -d "build" ]; then mkdir -p build; fi
	$(CC) $(CCOPTS) -c -o $@ $<

install: $(OUT)
	doas avrdude -v -c usbtiny -p atmega165pa -U flash:w:payload.elf:e

clean:
	rm -f *.o *.elf build/*