[Buildroot] [RFCv1 01/11] Makefile: make $(BUILD_DIR)/.root rule idempotent

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Thu Sep 5 21:27:39 UTC 2013


The $(BUILD_DIR)/.root rule is executed as part of the 'dirs'
target. The 'dirs' target is re-executed at every execution of 'make
external-deps', and make external-deps explicitly tells make to ignore
targets that have already been made (through the -B option). This
means that the $(BUILD_DIR)/.root rule has to be idempotant, which was
not the case this the introduction of the lib32/lib64 symbolic
link.

Running 'make external-deps' three times in a row was sufficient to
trigger an error due to symbolic links being incorrectly created. This
patch fixes that.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
---
This should probably be taken for 2013.08.1 as a fix of 'make
external-deps'.
---
 Makefile | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 09faeba..93fc6ea 100644
--- a/Makefile
+++ b/Makefile
@@ -447,9 +447,13 @@ $(BUILD_DIR)/.root:
 		--exclude .hg --exclude=CVS --exclude '*~' \
 		$(TARGET_SKELETON)/ $(TARGET_DIR)/
 	cp support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE)
-	@ln -s lib $(TARGET_DIR)/$(LIB_SYMLINK)
-	@mkdir -p $(TARGET_DIR)/usr
-	@ln -s lib $(TARGET_DIR)/usr/$(LIB_SYMLINK)
+	$(Q)if [ ! -L $(TARGET_DIR)/$(LIB_SYMLINK) ]; then \
+		ln -s lib $(TARGET_DIR)/$(LIB_SYMLINK) ; \
+	fi
+	$(Q)mkdir -p $(TARGET_DIR)/usr
+	$(Q)if [ ! -L $(TARGET_DIR)/usr/$(LIB_SYMLINK) ]; then \
+		ln -s lib $(TARGET_DIR)/usr/$(LIB_SYMLINK) ; \
+	fi
 	touch $@
 
 $(TARGET_DIR): $(BUILD_DIR)/.root
-- 
1.8.1.2




More information about the buildroot mailing list