diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-10-24 02:26:10 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-10-24 15:46:53 +0300 |
commit | 0dbd928ceefed09d65276211c70d0137b4734011 (patch) | |
tree | 27ae07b46c07da5185d3023b2e788bb102915f54 | |
parent | 9a334d41e3c20dfde053cd95b9f80c384c51c2a9 (diff) | |
download | micropython-0dbd928ceefed09d65276211c70d0137b4734011.tar.gz micropython-0dbd928ceefed09d65276211c70d0137b4734011.zip |
Makefiles: Remove duplicate object files when linking.
Scenario: module1 depends on some common file from lib/, so specifies it
in its SRC_MOD, and the same situation with module2, then common file
from lib/ eventually ends up listed twice in $(OBJ), which leads to link
errors.
Make is equipped to deal with such situation easily, quoting the manual:
"The value of $^ omits duplicate prerequisites, while $+ retains them and
preserves their order." So, just use $^ consistently in all link targets.
-rw-r--r-- | bare-arm/Makefile | 2 | ||||
-rw-r--r-- | esp8266/Makefile | 2 | ||||
-rw-r--r-- | minimal/Makefile | 2 | ||||
-rw-r--r-- | pic16bit/Makefile | 2 | ||||
-rw-r--r-- | py/mkrules.mk | 4 | ||||
-rw-r--r-- | qemu-arm/Makefile | 4 | ||||
-rw-r--r-- | stmhal/Makefile | 2 | ||||
-rw-r--r-- | teensy/Makefile | 2 |
8 files changed, 10 insertions, 10 deletions
diff --git a/bare-arm/Makefile b/bare-arm/Makefile index dc17eed4d9..a57ccfd196 100644 --- a/bare-arm/Makefile +++ b/bare-arm/Makefile @@ -42,7 +42,7 @@ all: $(BUILD)/firmware.elf $(BUILD)/firmware.elf: $(OBJ) $(ECHO) "LINK $@" - $(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) + $(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(SIZE) $@ include ../py/mkrules.mk diff --git a/esp8266/Makefile b/esp8266/Makefile index b06f6787a3..7db5a76d35 100644 --- a/esp8266/Makefile +++ b/esp8266/Makefile @@ -124,7 +124,7 @@ $(BUILD)/firmware-combined.bin: $(BUILD)/firmware.elf $(BUILD)/firmware.elf: $(OBJ) $(ECHO) "LINK $@" - $(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) + $(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(SIZE) $@ #MAKE_PINS = boards/make-pins.py diff --git a/minimal/Makefile b/minimal/Makefile index ddddebbe2e..619d249526 100644 --- a/minimal/Makefile +++ b/minimal/Makefile @@ -59,7 +59,7 @@ all: $(BUILD)/firmware.elf $(BUILD)/firmware.elf: $(OBJ) $(ECHO) "LINK $@" - $(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) + $(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(SIZE) $@ # Run emulation build on a POSIX system with suitable terminal settings diff --git a/pic16bit/Makefile b/pic16bit/Makefile index 98fcf07fd9..309b47b797 100644 --- a/pic16bit/Makefile +++ b/pic16bit/Makefile @@ -57,7 +57,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf $(BUILD)/firmware.elf: $(OBJ) $(ECHO) "LINK $@" - $(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) + $(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)size $@ $(PY_BUILD)/gc.o: CFLAGS += -O1 diff --git a/py/mkrules.mk b/py/mkrules.mk index 18bfd98471..26afdf227c 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -81,14 +81,14 @@ all: $(PROG) $(PROG): $(OBJ) $(ECHO) "LINK $@" - $(Q)$(CC) $(COPT) -o $@ $(OBJ) $(LIB) $(LDFLAGS) + $(Q)$(CC) $(COPT) -o $@ $^ $(LIB) $(LDFLAGS) ifndef DEBUG $(Q)$(STRIP) $(STRIPFLAGS_EXTRA) $(PROG) endif $(Q)$(SIZE) $(PROG) lib: $(OBJ) - $(AR) rcs libmicropython.a $(OBJ) + $(AR) rcs libmicropython.a $^ clean: clean-prog clean-prog: diff --git a/qemu-arm/Makefile b/qemu-arm/Makefile index a81dd67cf1..31ba6baa26 100644 --- a/qemu-arm/Makefile +++ b/qemu-arm/Makefile @@ -74,11 +74,11 @@ $(BUILD)/tinytest.o: ## `$(LD)` doesn't seem to like `--specs` for some reason, but we can just use `$(CC)` here. $(BUILD)/firmware.elf: $(OBJ) - $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) + $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(SIZE) $@ $(BUILD)/firmware-test.elf: $(OBJ_TEST) - $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ_TEST) $(LIBS) + $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(SIZE) $@ include ../py/mkrules.mk diff --git a/stmhal/Makefile b/stmhal/Makefile index e50bf3b0f2..222e19b321 100644 --- a/stmhal/Makefile +++ b/stmhal/Makefile @@ -285,7 +285,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf $(BUILD)/firmware.elf: $(OBJ) $(ECHO) "LINK $@" - $(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) + $(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(SIZE) $@ MAKE_PINS = boards/make-pins.py diff --git a/teensy/Makefile b/teensy/Makefile index dece6ce003..32f753b3eb 100644 --- a/teensy/Makefile +++ b/teensy/Makefile @@ -156,7 +156,7 @@ deploy: post_compile reboot $(BUILD)/micropython.elf: $(OBJ) $(ECHO) "LINK $@" - $(Q)$(CC) $(LDFLAGS) -o "$@" -Wl,-Map,$(@:.elf=.map) $(OBJ) $(LIBS) + $(Q)$(CC) $(LDFLAGS) -o "$@" -Wl,-Map,$(@:.elf=.map) $^ $(LIBS) $(Q)$(SIZE) $@ ifeq ($(MEMZIP_DIR),) |