-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
66 lines (48 loc) · 1.63 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Command used for assembling AVR assembly language files (*.asm):
ASM=avr-as
# Command for linking object files (*.o) to ELF binaries:
LINKER=avr-ld
# Command used for extracting binary data from ELF (*.elf) files:
OBJCOPY=avr-objcopy
# Device used for burning:
ISP=usbasp
# Device we're burning to (ATtiny13A):
DEVICE=t13
# AVRDUDE is used to interace with USBasp to burn to ATtiny13A:
BURN=avrdude -c $(ISP) -p $(DEVICE)
# Command for deleting stuff (e.g. during 'clean'):
ifndef HOME
# HOME var not set... Let's assume Windows
RM=del
else
# Got a home directory, so let's assume Unix:
RM=rm -f
endif
# Default build: Produce a binary file, and an Intel HEX file we can burn.
all: ptouchavr.bin ptouchavr.hex
rebuild: clean all
# Do clean, build ptouchavr.hex, and burn it.
rewrite: clean ptouchavr.hex burn
# Burn ptouchavr.hex to an ATtiny13 using avrdude:
burn: ptouchavr.hex
$(BURN) -U flash:w:ptouchavr.hex:i
# Bring up the AVRDUDE terminal:
burnterm:
$(BURN) -t
burntermf:
$(BURN) -t -F
# Generate a HEX file that a burner can use:
ptouchavr.hex: ptouchavr.elf
$(OBJCOPY) --output-target=ihex ptouchavr.elf ptouchavr.hex
# Generate a compiled binary from the compiled ELF:
ptouchavr.bin: ptouchavr.elf
$(OBJCOPY) --output-target=binary ptouchavr.elf ptouchavr.bin
# Generate a compiled ELF from the Object file:
ptouchavr.elf: ptouchavr.o
$(LINKER) ptouchavr.o -o ptouchavr.elf
# Compile the assembly source to an object file:
ptouchavr.o:
$(ASM) ptouchavr.asm -mmcu=attiny13a -o ptouchavr.o
# Delete any of our (possible) output files:
clean:
$(RM) ptouchavr.bin ptouchavr.hex ptouchavr.elf ptouchavr.o