WORKfix: Change condition when to evaluate RAMEND
[pub/USBaspLoader.git] / updater / Makefile
1 # Name: Makefile
2 # Project: USBaspLoader (updater)
3 # Author: Stephan Bärwolf
4 # Creation Date: 2012-09-01
5 # Tabsize: 4
6 # License: GNU GPL v2 (see License.txt)
7
8 include ../Makefile.inc
9
10 # elsewise gcc would complain unnecessary
11 CFLAGS = -Wall -Wno-pointer-to-int-cast -Os -g3 -ggdb -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) -DBOOTLOADER_ADDRESS=$(BOOTLOADER_ADDRESS) -DNEW_BOOTLOADER_ADDRESS=$(NEW_BOOTLOADER_ADDRESS) -DFLASHADDRESS=$(FLASHADDRESS) $(DEFINES)
12 LDFLAGS = -Wl,--relax,--gc-sections
13
14 ifneq ($(FLASHADDRESS), 0)
15 ifneq ($(FLASHADDRESS), 00)
16 ifneq ($(FLASHADDRESS), 000)
17 ifneq ($(FLASHADDRESS), 0000)
18 ifneq ($(FLASHADDRESS), 00000)
19 ifneq ($(FLASHADDRESS), 0x0)
20 ifneq ($(FLASHADDRESS), 0x00)
21 ifneq ($(FLASHADDRESS), 0x000)
22 ifneq ($(FLASHADDRESS), 0x0000)
23 ifneq ($(FLASHADDRESS), 0x00000)
24 FLASHPREAMBLE = 0x0000
25 LDFLAGS += -Wl,--section-start=.text=$(FLASHADDRESS)
26 endif
27 endif
28 endif
29 endif
30 endif
31 endif
32 endif
33 endif
34 endif
35 endif
36
37 all: updater.hex
38
39 flash: all
40 $(ECHO) "."
41 $(AVRDUDE) -D -U flash:w:updater.hex:i
42 $(ECHO) "."
43 $(ECHO) "."
44
45
46 ../firmware/main.elf:
47 $(MAKE) -C ../firmware main.hex
48
49
50 usbasploader.raw: ../firmware/main.elf
51 $(OBC) -j .text -j .data -O binary ../firmware/main.elf usbasploader.raw
52
53 usbasploader.o: usbasploader.raw
54 $(OBC) -B $(MCUARCH) -I binary -O elf32-avr --rename-section .data=.text --redefine-sym _binary_usbasploader_raw_start=usbasploader usbasploader.raw usbasploader.o
55
56
57 updater.o: updater.c usbasploader.h usbasploader.raw usbasploader.o
58 $(CC) updater.c -c -o updater.o -DSIZEOF_new_firmware=$(shell stat -c %s usbasploader.raw) $(CFLAGS)
59 # $(CC) updater.c -c -o updater.o $(CFLAGS)
60
61 updater.elf: updater.o usbasploader.o
62 $(CC) updater.o usbasploader.o -o updater.elf -Wl,-Map,updater.map $(CFLAGS) $(LDFLAGS)
63
64 updater.asm: updater.elf
65 $(OBD) -Stdr updater.elf > updater.asm
66
67 updater.hex: updater.elf updater.asm
68 $(OBC) -j .text -j .data -O ihex updater.elf updater.hex
69 $(ECHO) "."
70 $(ECHO) "."
71 $(SIZ) updater.elf
72 $(ECHO) "."
73
74 deepclean: clean
75 $(RM) *~
76
77 clean:
78 $(RM) usbasploader.o
79 $(RM) updater.o
80 $(RM) usbasploader.raw
81 $(RM) updater.hex
82 $(RM) updater.asm
83 $(RM) updater.elf
84 $(RM) updater.map
85 $(RM) usbasploader.raw