From: Stephan Baerwolf Date: Thu, 12 Sep 2013 14:16:26 +0000 (+0200) Subject: BUGfix and cleanup Makefiles X-Git-Tag: testing-head~13 X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/commitdiff_plain/61085a4540e9abf0d1698396638db7c617d0e48e BUGfix and cleanup Makefiles Signed-off-by: Stephan Baerwolf --- diff --git a/firmware/Makefile b/firmware/Makefile index 486003f..f6b9170 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -4,6 +4,7 @@ # 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) @@ -21,23 +22,19 @@ include ../Makefile.inc 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 -OBJECTS = usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o +DEPENDS = bootloaderconfig.h ../Makefile.inc # symbolic targets: -all: main.hex +all: main.hex $(DEPENDS) -.c.o: - $(CC) $(CFLAGS) -c $< -o $@ +usbdrv/usbdrvasm.o: usbdrv/usbdrvasm.S $(DEPENDS) + $(CC) -x assembler-with-cpp -c usbdrv/usbdrvasm.S -o usbdrv/usbdrvasm.o $(CFLAGS) -.S.o: - $(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@ -# "-x assembler-with-cpp" should not be necessary since this is the default -# file type for the .S (with capital S) extension. However, upper case -# characters are not always preserved on Windows. To ensure WinAVR -# compatibility define the file type manually. +usbdrv/oddebug.o: usbdrv/oddebug.c $(DEPENDS) + $(CC) usbdrv/oddebug.c -c -o usbdrv/oddebug.o $(CFLAGS) -.c.s: - $(CC) $(CFLAGS) -S $< -o $@ +main.o: main.c $(DEPENDS) + $(CC) main.c -c -o main.o $(CFLAGS) flash: all $(ECHO) "." @@ -72,7 +69,7 @@ read_fuses: deepclean: clean $(RM) *~ -clean: +clean: $(RM) main.hex $(RM) main.asm $(RM) main.map @@ -85,13 +82,13 @@ clean: $(RM) usbdrv/usbdrv.s # file targets: -main.elf: $(OBJECTS) bootloaderconfig.h - $(CC) $(CFLAGS) -o main.elf $(OBJECTS) -Wl,-Map,main.map $(LDFLAGS) +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 +main.asm: main.elf $(DEPENDS) $(OBD) -Stdr main.elf > main.asm -main.hex: 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) "." @@ -105,8 +102,8 @@ main.hex: main.elf main.asm $(ECHO) "." $(ECHO) "." -disasm: main.elf +disasm: main.elf $(DEPENDS) $(OBD) -d main.elf -cpp: +cpp: $(DEPENDS) $(CC) $(CFLAGS) -E main.c diff --git a/updater/Makefile b/updater/Makefile index 6c677ed..a1bc14d 100644 --- a/updater/Makefile +++ b/updater/Makefile @@ -11,6 +11,8 @@ include ../Makefile.inc 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) LDFLAGS = -Wl,--relax,--gc-sections +DEPENDS = ../firmware/bootloaderconfig.h ../Makefile.inc + ifneq ($(FLASHADDRESS), 0) ifneq ($(FLASHADDRESS), 00) ifneq ($(FLASHADDRESS), 000) @@ -34,7 +36,7 @@ endif endif endif -all: updater.hex +all: updater.hex $(DEPENDS) flash: all $(ECHO) "." @@ -43,28 +45,28 @@ flash: all $(ECHO) "." -../firmware/main.elf: +../firmware/main.elf: $(DEPENDS) $(MAKE) -C ../firmware main.hex -usbasploader.raw: ../firmware/main.elf +usbasploader.raw: ../firmware/main.elf $(DEPENDS) $(OBC) -j .text -j .data -O binary ../firmware/main.elf usbasploader.raw -usbasploader.o: usbasploader.raw +usbasploader.o: usbasploader.raw $(DEPENDS) $(OBC) -B $(MCUARCH) -I binary -O elf32-avr --rename-section .data=.text --redefine-sym _binary_usbasploader_raw_start=usbasploader usbasploader.raw usbasploader.o -updater.o: updater.c usbasploader.h usbasploader.raw usbasploader.o +updater.o: updater.c usbasploader.h usbasploader.raw usbasploader.o $(DEPENDS) $(CC) updater.c -c -o updater.o -DSIZEOF_new_firmware=$(shell stat -c %s usbasploader.raw) $(CFLAGS) # $(CC) updater.c -c -o updater.o $(CFLAGS) -updater.elf: updater.o usbasploader.o +updater.elf: updater.o usbasploader.o $(DEPENDS) $(CC) updater.o usbasploader.o -o updater.elf -Wl,-Map,updater.map $(CFLAGS) $(LDFLAGS) -updater.asm: updater.elf +updater.asm: updater.elf $(DEPENDS) $(OBD) -Stdr updater.elf > updater.asm -updater.hex: updater.elf updater.asm +updater.hex: updater.elf updater.asm $(DEPENDS) $(OBC) -j .text -j .data -O ihex updater.elf updater.hex $(ECHO) "." $(ECHO) "."