forked from baerwolf/USBaspLoader
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathMakefile
119 lines (96 loc) · 2.82 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Name: Makefile
# Project: USBaspLoader
# Author: Christian Starkjohann
# Creation Date: 2007-12-10
# Author: Stephan Bärwolf
# Improvement Date: 2012-07-31
# Improvement Date: 2012-09-12
# Tabsize: 4
# Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
# License: GNU GPL v2 (see License.txt)
###############################################################################
# Configure the following variables according to your AVR.
# Program the device with
# make fuse # to set the clock generator, boot section size etc.
# make flash # to load the boot loader into flash
# make lock # to protect the boot loader from overwriting
include ../Makefile.inc
# Remove the -fno-* options when you use gcc 3, it does not understand them
CFLAGS = -Wall -Os -g3 -ggdb -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DBOOTLOADER_ADDRESS=$(BOOTLOADER_ADDRESS) -DF_CPU=$(F_CPU) $(DEFINES)
LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) -Wl,--defsym=nullVector=0
DEPENDS = bootloaderconfig.h ../Makefile.inc
# symbolic targets:
all: main.hex $(DEPENDS)
usbdrv/usbdrvasm.o: usbdrv/usbdrvasm.S $(DEPENDS)
$(CC) -x assembler-with-cpp -c usbdrv/usbdrvasm.S -o usbdrv/usbdrvasm.o $(CFLAGS)
usbdrv/oddebug.o: usbdrv/oddebug.c $(DEPENDS)
$(CC) usbdrv/oddebug.c -c -o usbdrv/oddebug.o $(CFLAGS)
main.o: main.c $(DEPENDS)
$(CC) main.c -c -o main.o $(CFLAGS)
flash: all
$(ECHO) "."
$(AVRDUDE) -U flash:w:main.hex:i
$(ECHO) "."
$(ECHO) "."
readflash:
$(ECHO) "."
$(AVRDUDE) -U flash:r:read.hex:i
$(ECHO) "."
$(ECHO) "."
fuse:
$(ECHO) "."
$(AVRDUDE) $(FUSEOPT)
$(ECHO) "."
$(ECHO) "."
lock:
$(ECHO) "."
$(AVRDUDE) $(LOCKOPT)
$(ECHO) "."
$(ECHO) "."
read_fuses:
$(UISP) --rd_fuses
deepclean: clean
ifeq ($(HOSTOS), Windows_NT)
else
$(RM) *~
endif
clean:
$(RM) main.hex
$(RM) main.asm
$(RM) main.map
$(RM) main.elf
$(RM) main.o
$(RM) main.s
ifeq ($(HOSTOS), Windows_NT)
$(RM) usbdrv\usbdrvasm.o
$(RM) usbdrv\oddebug.o
$(RM) usbdrv\oddebug.s
$(RM) usbdrv\usbdrv.s
else
$(RM) usbdrv/usbdrvasm.o
$(RM) usbdrv/oddebug.o
$(RM) usbdrv/oddebug.s
$(RM) usbdrv/usbdrv.s
endif
# file targets:
main.elf: usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o $(DEPENDS)
$(CC) $(CFLAGS) -o main.elf usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o -Wl,-Map,main.map $(LDFLAGS)
main.asm: main.elf $(DEPENDS)
$(OBD) -Stdr main.elf > main.asm
main.hex: main.elf main.asm $(DEPENDS)
$(RM) main.hex main.eep.hex
$(OBC) -j .text -j .data -O ihex main.elf main.hex
$(ECHO) "."
$(ECHO) "."
$(ECHO) "."
$(ECHO) "!!!ATTANTION!!!"
$(ECHO) "(data+text) MUST fit into your MCUs bootloader section"
$(ECHO) "."
$(SIZ) --mcu $(DEVICE) main.elf
$(ECHO) "."
$(ECHO) "."
$(ECHO) "."
disasm: main.elf $(DEPENDS)
$(OBD) -d main.elf
cpp: $(DEPENDS)
$(CC) $(CFLAGS) -E main.c