-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
68 lines (52 loc) · 1.79 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
66
67
68
# --------------------------------------------------------
# Custom M2 Makefile
# written by: Jonathan Bohren & Jonathan Fiene
# updated: July 6, 2011
# --------------------------------------------------------
# --------------------------------------------------------
# if you write separate C files to include in main
# add their .o targets to the OBJECTS line below
# (e.g. "OBJECTS = main.o myfile.o")
# --------------------------------------------------------
OBJECTS = main.o m_usb.o m_rf.o m_bus.o
#OBJECTS = main.o
# --------------------------------------------------------
# if you need to use one of our pre-compiled libraries,
# add it to the line below (e.g. "LIBRARIES = libsaast.a")
# --------------------------------------------------------
LIBRARIES =
# --------------------------------------------------------
# Default settings for the M2:
# --------------------------------------------------------
DEVICE = atmega32u4
CLOCK = 16000000
# --------------------------------------------------------
# you shouldn't change anything below here,
# unless you really know what you're doing
# --------------------------------------------------------
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
# symbolic targets:
all: main.hex
.c.o:
$(COMPILE) -c $< -o $@
.S.o:
$(COMPILE) -x assembler-with-cpp -c $< -o $@
.c.s:
$(COMPILE) -S $< -o $@
install: flash
flash: all
dfu-programmer atmega32u4 erase
dfu-programmer atmega32u4 flash main.hex
clean:
rm -f main.hex main.elf $(OBJECTS)
# file targets:
main.elf: $(OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS) $(LIBRARIES)
main.hex: main.elf
rm -f main.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
# Targets for code debugging and analysis:
disasm: main.elf
avr-objdump -d main.elf
cpp:
$(COMPILE) -E main.c