Skip to content

Commit 61085a4

Browse files
committed
BUGfix and cleanup Makefiles
Signed-off-by: Stephan Baerwolf <[email protected]>
1 parent 40fa056 commit 61085a4

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

firmware/Makefile

+16-19
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Creation Date: 2007-12-10
55
# Author: Stephan Bärwolf
66
# Improvement Date: 2012-07-31
7+
# Improvement Date: 2012-09-12
78
# Tabsize: 4
89
# Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
910
# License: GNU GPL v2 (see License.txt)
@@ -21,23 +22,19 @@ include ../Makefile.inc
2122
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)
2223
LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) -Wl,--defsym=nullVector=0
2324

24-
OBJECTS = usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
25+
DEPENDS = bootloaderconfig.h ../Makefile.inc
2526

2627
# symbolic targets:
27-
all: main.hex
28+
all: main.hex $(DEPENDS)
2829

29-
.c.o:
30-
$(CC) $(CFLAGS) -c $< -o $@
30+
usbdrv/usbdrvasm.o: usbdrv/usbdrvasm.S $(DEPENDS)
31+
$(CC) -x assembler-with-cpp -c usbdrv/usbdrvasm.S -o usbdrv/usbdrvasm.o $(CFLAGS)
3132

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.
33+
usbdrv/oddebug.o: usbdrv/oddebug.c $(DEPENDS)
34+
$(CC) usbdrv/oddebug.c -c -o usbdrv/oddebug.o $(CFLAGS)
3835

39-
.c.s:
40-
$(CC) $(CFLAGS) -S $< -o $@
36+
main.o: main.c $(DEPENDS)
37+
$(CC) main.c -c -o main.o $(CFLAGS)
4138

4239
flash: all
4340
$(ECHO) "."
@@ -72,7 +69,7 @@ read_fuses:
7269
deepclean: clean
7370
$(RM) *~
7471

75-
clean:
72+
clean:
7673
$(RM) main.hex
7774
$(RM) main.asm
7875
$(RM) main.map
@@ -85,13 +82,13 @@ clean:
8582
$(RM) usbdrv/usbdrv.s
8683

8784
# file targets:
88-
main.elf: $(OBJECTS) bootloaderconfig.h
89-
$(CC) $(CFLAGS) -o main.elf $(OBJECTS) -Wl,-Map,main.map $(LDFLAGS)
85+
main.elf: usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o $(DEPENDS)
86+
$(CC) $(CFLAGS) -o main.elf usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o -Wl,-Map,main.map $(LDFLAGS)
9087

91-
main.asm: main.elf
88+
main.asm: main.elf $(DEPENDS)
9289
$(OBD) -Stdr main.elf > main.asm
9390

94-
main.hex: main.elf main.asm
91+
main.hex: main.elf main.asm $(DEPENDS)
9592
$(RM) main.hex main.eep.hex
9693
$(OBC) -j .text -j .data -O ihex main.elf main.hex
9794
$(ECHO) "."
@@ -105,8 +102,8 @@ main.hex: main.elf main.asm
105102
$(ECHO) "."
106103
$(ECHO) "."
107104

108-
disasm: main.elf
105+
disasm: main.elf $(DEPENDS)
109106
$(OBD) -d main.elf
110107

111-
cpp:
108+
cpp: $(DEPENDS)
112109
$(CC) $(CFLAGS) -E main.c

updater/Makefile

+10-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ include ../Makefile.inc
1111
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)
1212
LDFLAGS = -Wl,--relax,--gc-sections
1313

14+
DEPENDS = ../firmware/bootloaderconfig.h ../Makefile.inc
15+
1416
ifneq ($(FLASHADDRESS), 0)
1517
ifneq ($(FLASHADDRESS), 00)
1618
ifneq ($(FLASHADDRESS), 000)
@@ -34,7 +36,7 @@ endif
3436
endif
3537
endif
3638

37-
all: updater.hex
39+
all: updater.hex $(DEPENDS)
3840

3941
flash: all
4042
$(ECHO) "."
@@ -43,28 +45,28 @@ flash: all
4345
$(ECHO) "."
4446

4547

46-
../firmware/main.elf:
48+
../firmware/main.elf: $(DEPENDS)
4749
$(MAKE) -C ../firmware main.hex
4850

4951

50-
usbasploader.raw: ../firmware/main.elf
52+
usbasploader.raw: ../firmware/main.elf $(DEPENDS)
5153
$(OBC) -j .text -j .data -O binary ../firmware/main.elf usbasploader.raw
5254

53-
usbasploader.o: usbasploader.raw
55+
usbasploader.o: usbasploader.raw $(DEPENDS)
5456
$(OBC) -B $(MCUARCH) -I binary -O elf32-avr --rename-section .data=.text --redefine-sym _binary_usbasploader_raw_start=usbasploader usbasploader.raw usbasploader.o
5557

5658

57-
updater.o: updater.c usbasploader.h usbasploader.raw usbasploader.o
59+
updater.o: updater.c usbasploader.h usbasploader.raw usbasploader.o $(DEPENDS)
5860
$(CC) updater.c -c -o updater.o -DSIZEOF_new_firmware=$(shell stat -c %s usbasploader.raw) $(CFLAGS)
5961
# $(CC) updater.c -c -o updater.o $(CFLAGS)
6062

61-
updater.elf: updater.o usbasploader.o
63+
updater.elf: updater.o usbasploader.o $(DEPENDS)
6264
$(CC) updater.o usbasploader.o -o updater.elf -Wl,-Map,updater.map $(CFLAGS) $(LDFLAGS)
6365

64-
updater.asm: updater.elf
66+
updater.asm: updater.elf $(DEPENDS)
6567
$(OBD) -Stdr updater.elf > updater.asm
6668

67-
updater.hex: updater.elf updater.asm
69+
updater.hex: updater.elf updater.asm $(DEPENDS)
6870
$(OBC) -j .text -j .data -O ihex updater.elf updater.hex
6971
$(ECHO) "."
7072
$(ECHO) "."

0 commit comments

Comments
 (0)