summaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'makefile')
-rw-r--r--makefile26
1 files changed, 26 insertions, 0 deletions
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..2cd372d
--- /dev/null
+++ b/makefile
@@ -0,0 +1,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/*