aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/gemini/image/copy-kernel/Makefile
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2019-09-10 02:19:05 +0000
committerYousong Zhou <yszhou4tech@gmail.com>2019-09-11 01:31:53 +0000
commit6d819fae5343dc4666762f359bb57a6fbe60a968 (patch)
tree3d08614274eedab65455fd44c37b506efde8f34d /target/linux/gemini/image/copy-kernel/Makefile
parent7bed9bf10fc8d05df34c7efc66e8b4ade37a1a0c (diff)
downloadupstream-6d819fae5343dc4666762f359bb57a6fbe60a968.tar.gz
upstream-6d819fae5343dc4666762f359bb57a6fbe60a968.tar.bz2
upstream-6d819fae5343dc4666762f359bb57a6fbe60a968.zip
gemini: image: fix race condition when building copy-kernel.bin
Make treat copy-kernel.o as intermediate and delete it when it's no longer needed. This can fail when the same submake was triggered multiple times for different devices. arm-openwrt-linux-muslgnueabi-as -k -o copy-kernel.o copy-kernel.S export MAKEFLAGS= ;make -w -C copy-kernel CROSS_COMPILE=arm-openwrt-linux-muslgnueabi- arm-openwrt-linux-muslgnueabi-objcopy -O binary -S copy-kernel.o copy-kernel.bin make[5]: Entering directory '/builder/shared-workdir/build/target/linux/gemini/image/copy-kernel' arm-openwrt-linux-muslgnueabi-objcopy -O binary -S copy-kernel.o copy-kernel.bin rm copy-kernel.o make[5]: Leaving directory '/builder/shared-workdir/build/target/linux/gemini/image/copy-kernel' # "App" partition is the rootfs arm-openwrt-linux-muslgnueabi-objcopy: 'copy-kernel.o': No such file Makefile:27: recipe for target 'copy-kernel.bin' failed make[5]: Leaving directory '/builder/shared-workdir/build/target/linux/gemini/image/copy-kernel' make[5]: *** [copy-kernel.bin] Error 1 Makefile:244: recipe for target '/builder/shared-workdir/build/build_dir/target-arm_fa526_musl_eabi/linux-gemini/tmp/openwrt-gemini-storlink_sl93512r-ext4-factory.bin' failed make[4]: *** [/builder/shared-workdir/build/build_dir/target-arm_fa526_musl_eabi/linux-gemini/tmp/openwrt-gemini-storlink_sl93512r-ext4-factory.bin] Error 2 With this change, output files are directed to $(KDIR) Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'target/linux/gemini/image/copy-kernel/Makefile')
-rw-r--r--target/linux/gemini/image/copy-kernel/Makefile14
1 files changed, 10 insertions, 4 deletions
diff --git a/target/linux/gemini/image/copy-kernel/Makefile b/target/linux/gemini/image/copy-kernel/Makefile
index 155c35968c..9ba283bb01 100644
--- a/target/linux/gemini/image/copy-kernel/Makefile
+++ b/target/linux/gemini/image/copy-kernel/Makefile
@@ -13,20 +13,26 @@ OBJCOPY := $(CROSS_COMPILE)objcopy
BIN_FLAGS := -O binary -S
-all: copy-kernel.bin
+SRC_DIR := $(CURDIR)/
+OUT_DIR := $(if $(O),$(if $(patsubst %/,,$(O)),$(O)/,$(O)),$(SRC_DIR))
+
+all: $(OUT_DIR)copy-kernel.bin
# Don't build dependencies, this may die if $(CC) isn't gcc
dep:
install:
-%.o : %.S
+$(OUT_DIR):
+ mkdir -p $(OUT_DIR)
+
+$(OUT_DIR)%.o : $(SRC_DIR)%.S | $(OUT_DIR)
$(AS) $(ASFLAGS) -k -o $@ $<
-%.bin: %.o
+$(OUT_DIR)%.bin: $(OUT_DIR)%.o
$(OBJCOPY) $(BIN_FLAGS) $< $@
mrproper: clean
clean:
- rm -f copy-kernel.bin copy-kernel.o
+ rm -f $(OUT_DIR)copy-kernel.bin $(OUT_DIR)copy-kernel.o