-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (65 loc) · 1.86 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
##############################################################################
# DDS Funktion Genorator - DDS Gen Firmware
#
# Copyright 2017 Tim Savage
##############################################################################
##############################################################################
# Setup
PROJECT=ddsGen
# Target hardward
MCU=atmega328p
PROGRAMMER=usbtiny
# Includes and source files
INCLUDES=./include
SRCS=dds.S
# Fuses
LFUSE=0xf7
HFUSE=0xdf
# Flags for compilation stages
ASFLAGS=-mmcu=$(MCU) -Wa,-I$(INCLUDES) -Wall
LDFLAGS=
##############################################################################
# Vars
HEX_FILE=$(PROJECT).hex
ELF_FILE=$(PROJECT).elf
OBJS=$(SRCS:.S=.o)
##############################################################################
# Executables
CC=avr-gcc
OBJCOPY=avr-objcopy
OBJDUMP=avr-objdump
SIZE=avr-size
AVRDUDE=avrdude -c $(PROGRAMMER) -p $(MCU)
REMOVE=rm -f
##############################################################################
# Rules
all: hex size
hex: $(HEX_FILE)
up: all
$(AVRDUDE) -U flash:w:$(HEX_FILE)
fuse:
$(AVRDUDE) -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m
size: $(ELF_FILE)
$(SIZE) --mcu $(MCU) -C $<
dump: $(ELF_FILE)
$(OBJDUMP) -S $< | less
clean:
$(REMOVE) *.o
$(REMOVE) *.elf
$(REMOVE) *.hex
$(HEX_FILE): $(ELF_FILE)
$(OBJCOPY) -j .text -j .data -O ihex $< $@
$(ELF_FILE): $(OBJS)
$(CC) $(LDFLAGS) $< -o $@
$(OBJS): $(SRCS)
$(CC) $(ASFLAGS) -c $< -o $@
help:
echo "Available rules:"
echo "make [all] - Build hex file and report size"
echo "make hex - Build hex file"
echo "make up - Build and upload hex file to MCU"
echo "make fuse - Set fuses on MCU"
echo "make size - Output size report of assembled file"
echo "make dump - Output a dump of assembled file to less"
echo "make clean - Clean up all generated files"
echo "make help - Output this report"