From 0143199175cd69d34ed1e832cf94dfbbd467de2a Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 3 Feb 2022 17:23:34 -0500 Subject: [PATCH] Makefile: Improve handling of board symbolic link creation Running "make" directly after a "make distclean" can lead to a corrupt out/board symbolic link. Rework the make rules so that the board symbolic link is created in a new make instance that has the updated definition of CONFIG_BOARD_DIRECTORY. Signed-off-by: Kevin O'Connor --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index af74951a..1bdcd155 100644 --- a/Makefile +++ b/Makefile @@ -85,17 +85,21 @@ $(OUT)compile_time_request.o: $(patsubst %.c, $(OUT)src/%.o.ctr,$(src-y)) ./scri ################ Auto generation of "board/" include file link -$(OUT)board-link: $(KCONFIG_CONFIG) +create-board-link: @echo " Creating symbolic link $(OUT)board" $(Q)mkdir -p $(addprefix $(OUT), $(dirs-y)) - $(Q)echo "#$(CONFIG_BOARD_DIRECTORY)" > $@.temp - $(Q)if ! cmp -s $@.temp $@; then rm -f $(OUT)*.d $(patsubst %,$(OUT)%/*.d,$(dirs-y)) ; mv $@.temp $@ ; fi + $(Q)rm -f $(OUT)*.d $(patsubst %,$(OUT)%/*.d,$(dirs-y)) $(Q)rm -f $(OUT)board $(Q)ln -sf $(CURDIR)/src/$(CONFIG_BOARD_DIRECTORY) $(OUT)board $(Q)mkdir -p $(OUT)board-generic $(Q)rm -f $(OUT)board-generic/board $(Q)ln -sf $(CURDIR)/src/generic $(OUT)board-generic/board +# Hack to rebuild OUT directory and reload make dependencies on Kconfig change +$(OUT)board-link: $(KCONFIG_CONFIG) + $(Q)mkdir -p $(OUT) + $(Q)echo "# Makefile board-link rule" > $@ + $(Q)$(MAKE) create-board-link include $(OUT)board-link ################ Kconfig rules @@ -114,7 +118,7 @@ menuconfig: ################ Generic rules # Make definitions -.PHONY : all clean distclean olddefconfig menuconfig FORCE +.PHONY : all clean distclean olddefconfig menuconfig create-board-link FORCE .DELETE_ON_ERROR: all: $(target-y)