[2/2] Makefile: create symlink to non-default HOST_DIR

Message ID 20170804163130.15772-2-arnout@mind.be
State Accepted
Headers show

Commit Message

Arnout Vandecappelle Aug. 4, 2017, 4:31 p.m.
If BR2_HOST_DIR is not the default, it can be difficult to find the
host directory (i.e., HOST_DIR always has to be passed explicitly in
addition to the output directory). For example, the Eclipse plugin
assumes that HOST_DIR=BASE_DIR/host.

Create a symlink from $(BASE_DIR)/host to $(HOST_DIR) if it is not the
default. Also remove it in the clean target.

When BR2_HOST_DIR is the default, HOST_DIR_SYMLINK will be empty so
there will be no additional dependency to dirs and nothing to remove
in clean.

Fixes https://bugs.busybox.net/show_bug.cgi?id=10151

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This depends on the previous patch, otherwise there are two rules for
the $(BASE_DIR)/host target.

Note that this implementation assumes that HOST_DIR is an absolute
path, but that assumption is made in dozens of other places as well.
Perhaps an abspath should be added to it.
 Makefile | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)


diff --git a/Makefile b/Makefile
index 6ca5d835f4..77684b5b60 100644
--- a/Makefile
+++ b/Makefile
@@ -430,6 +430,12 @@  TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
 # packages compiled for the host go here
 HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
+ifneq ($(HOST_DIR),$(BASE_DIR)/host)
+	ln -snf $(HOST_DIR) $(BASE_DIR)/host
 # Quotes are needed for spaces and all in the original PATH content.
 BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(PATH)"
@@ -533,7 +539,7 @@  endif
 .PHONY: dirs
 $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
@@ -955,7 +961,7 @@  printvars:
 .PHONY: clean
 		$(BUILD_DIR) $(BASE_DIR)/staging \