aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile36
1 files changed, 36 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..6b8f6b4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,36 @@
+# adjust according to your needs
+AS = avr-as
+LD = avr-ld
+OBJ = avr-obj
+MCU ?= atmega328p
+MCUPATH ?= /dev/ttyACM0
+DUDE ?= avrdude
+PROGRAMMER ?= arduino
+LDFLAGS += -m avr5
+DUDEFLAGS += -c $(PROGRAMMER) -p $(MCU) -P $(MCUPATH)
+
+# timer.s file
+TARGET ?= timer
+
+.PHONY: flash dump-timer clean all
+
+all: $(TARGET).hex
+
+flash: $(TARGET).hex
+ test $(shell id -u) = 0
+ $(DUDE) $(DUDEFLAGS) -U flash:w:$<
+
+%.hex: %
+ $(OBJ)copy -O ihex $< $@
+
+%: %.o
+ $(LD) $(LDFLAGS) -o $@ $<
+
+%.o: %.s
+ $(AS) -mmcu=$(MCU) -o $@ $<
+
+dump-%: %
+ $(OBJ)dump -d timer
+
+clean:
+ rm *.o *.hex *.elf *.bin timer