-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (46 loc) · 1.27 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
DEVICE = attiny85
F_CPU = 16500000L
CC = avr-gcc
OBJCOPY = avr-objcopy
OFLAGS = -O ihex -R .eeprom
CFLAGS = -Ilib -Iusbdrv -I. -DF_CPU=$(F_CPU) -mmcu=$(DEVICE) -Os -DDEBUG_LEVEL=0
PROGDIR = commandline
PROG = $(PROGDIR)/micronucleus
PFLAGS = --run --type intel-hex
COMPILE = $(CC) $(CFLAGS)
usbmouse_OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/osccal.o usbmouse.o
blink_OBJECTS = blink.o
OBJECTS = $(usbmouse_OBJECTS) $(main_OBJECTS)
TARGETS = blink usbmouse
HEX_TARGETS = $(addsuffix .hex, $(TARGETS))
OUT_TARGETS = $(addsuffix .out, $(TARGETS))
# Generic rule for compiling C files:
.c.o:
$(COMPILE) -c $< -o $@
# Generic rule for compiling CPP files:
.cpp.o:
$(COMPILE) -c $< -o $@
# Generic rule for assembling Assembler source files:
.S.o:
$(COMPILE) -c $< -o $@
# Generic rule for compiling C to assembler, used for debugging only.
.c.s:
$(COMPILE) -S $< -o $@
.SECONDEXPANSION: %.out
.PHONY: all %.flash clean cleanprog cleanall
%.out: $$($$*_OBJECTS)
$(COMPILE) -o $@ $^
%.hex: $$*.out
rm -f $@
$(OBJCOPY) $(OFLAGS) $*.out $@
avr-size $@
all: $(HEX_TARGETS)
$(PROG):
cd $(PROGDIR) && make
%.flash: $$*.hex $(PROG)
$(PROG) $(PFLAGS) $<
clean:
rm -f $(OUT_TARGETS) $(HEX_TARGETS) $(OBJECTS)
cleanprog:
cd $(PROGDIR) && make clean
cleanall: clean cleanprog