forked from inaxeon/rotarydial
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
76 lines (58 loc) · 1.85 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
69
70
71
72
73
74
75
76
##############################################################################
# Title : AVR Makefile for Windows
#
# Created : Matthew Millman 2018-05-29
# http://tech.mattmillman.com/
#
# This code is distributed under the GNU Public License
# which can be found at http://www.gnu.org/licenses/gpl.txt
#
##############################################################################
# Fixes clash between windows and coreutils mkdir. Comment out the below line to compile on Linux
COREUTILS = C:/Projects/coreutils/bin/
DEVICE = attiny85
CLOCK = 4000000
PROGRAMMER = -c stk500 -P COM10
SRCS = main.c dtmf.c
OBJS = $(SRCS:.c=.o)
FUSES = -U lfuse:w:0xFD:m -U hfuse:w:0xDF:m -U efuse:w:0xFF:m
DEPDIR = deps
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
RM = rm
MV = mv
MKDIR = $(COREUTILS)mkdir
POSTCOMPILE = $(MV) $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os $(DEPFLAGS) -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
all: rotarydial.hex
.c.o: $(DEPDIR)/%.d
@$(MKDIR) -p $(DEPDIR)
$(COMPILE) -c $< -o $@
@$(POSTCOMPILE)
.S.o: $(DEPDIR)/%.d
@$(MKDIR) -p $(DEPDIR)
$(COMPILE) -x assembler-with-cpp -c $< -o $@
@$(POSTCOMPILE)
.c.s: $(DEPDIR)/%.d
@$(MKDIR) -p $(DEPDIR)
$(COMPILE) -S $< -o $@
@$(POSTCOMPILE)
flash: all
$(AVRDUDE) -U flash:w:rotarydial.hex:i
fuse:
$(AVRDUDE) $(FUSES)
install: flash fuse
clean:
$(RM) -f rotarydial.hex rotarydial.elf $(OBJS)
$(RM) -rf deps
rotarydial.elf: $(OBJS)
$(COMPILE) -o rotarydial.elf $(OBJS)
rotarydial.hex: rotarydial.elf
avr-objcopy -j .text -j .data -O ihex rotarydial.elf rotarydial.hex
disasm: rotarydial.elf
avr-objdump -d rotarydial.elf
cpp:
$(COMPILE) -E $(SRCS)
$(DEPDIR)/%.d:
.PRECIOUS: $(DEPDIR)/%.d
include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS))))