new feature "HAVE_UNPRECISEWAIT" for save some flash
[pub/USBaspLoader.git] / firmware / Makefile
1 # Name: Makefile
2 # Project: USBaspLoader
3 # Author: Christian Starkjohann
4 # Creation Date: 2007-12-10
5 # Author: Stephan Bärwolf
6 # Improvement Date: 2012-07-31
7 # Tabsize: 4
8 # Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
9 # License: GNU GPL v2 (see License.txt)
10
11 ###############################################################################
12 # Configure the following variables according to your AVR.
13 # Program the device with
14 # make fuse # to set the clock generator, boot section size etc.
15 # make flash # to load the boot loader into flash
16 # make lock # to protect the boot loader from overwriting
17
18 include ../Makefile.inc
19
20 # Remove the -fno-* options when you use gcc 3, it does not understand them
21 CFLAGS = -Wall -Os -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DBOOTLOADER_ADDRESS=$(BOOTLOADER_ADDRESS) -DF_CPU=$(F_CPU) $(DEFINES)
22 LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS)
23
24 OBJECTS = usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
25
26 # symbolic targets:
27 all: main.hex
28
29 .c.o:
30 $(CC) $(CFLAGS) -c $< -o $@
31
32 .S.o:
33 $(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
34 # "-x assembler-with-cpp" should not be necessary since this is the default
35 # file type for the .S (with capital S) extension. However, upper case
36 # characters are not always preserved on Windows. To ensure WinAVR
37 # compatibility define the file type manually.
38
39 .c.s:
40 $(CC) $(CFLAGS) -S $< -o $@
41
42 flash: all
43 $(AVRDUDE) -U flash:w:main.hex:i
44
45 readflash:
46 $(AVRDUDE) -U flash:r:read.hex:i
47
48 fuse:
49 $(AVRDUDE) $(FUSEOPT)
50
51 lock:
52 $(AVRDUDE) $(LOCKOPT)
53
54 read_fuses:
55 $(UISP) --rd_fuses
56
57 deepclean: clean
58 $(RM) *~
59
60 clean:
61 $(RM) main.hex
62 $(RM) main.bin
63 $(RM) main.o
64 $(RM) main.s
65 $(RM) usbdrv/usbdrvasm.o
66 $(RM) usbdrv/oddebug.o
67 $(RM) usbdrv/oddebug.s
68 $(RM) usbdrv/usbdrv.s
69
70 # file targets:
71 main.bin: $(OBJECTS) bootloaderconfig.h
72 $(CC) $(CFLAGS) -o main.bin $(OBJECTS) $(LDFLAGS)
73
74 main.hex: main.bin
75 $(RM) main.hex main.eep.hex
76 $(OBC) -j .text -j .data -O ihex main.bin main.hex
77 $(ECHO) "."
78 $(ECHO) "."
79 $(ECHO) "."
80 $(ECHO) "!!!ATTANTION!!!"
81 $(ECHO) "(data+text) MUST fit into your MCUs bootloader section"
82 $(ECHO) "."
83 $(SIZ) --mcu $(DEVICE) main.bin
84 $(ECHO) "."
85 $(ECHO) "."
86 $(ECHO) "."
87
88 disasm: main.bin
89 $(OBD) -d main.bin
90
91 cpp:
92 $(CC) $(CFLAGS) -E main.c