Skip to content

Instantly share code, notes, and snippets.

@joy4eg
Last active March 30, 2020 12:16
Show Gist options
  • Save joy4eg/68526c6911bbcf1312ee6f8a7b415dd0 to your computer and use it in GitHub Desktop.
Save joy4eg/68526c6911bbcf1312ee6f8a7b415dd0 to your computer and use it in GitHub Desktop.
buildroot toolchain fix for make 4.3+
diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 996cc70d44..8cd12f8a61 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -122,9 +122,9 @@ copy_toolchain_sysroot = \
if [ "$${target}" == "$${target\#/}" ] ; then \
continue ; \
fi ; \
- relpath="$(call relpath_prefix,$${target\#/})" ; \
+ relpath="$(call relpath_prefix,$${target$(NUM_CHAR)/})" ; \
echo "Fixing symlink $${link} from $${target} to $${relpath}$${target\#/}" ; \
- ln -sf $${relpath}$${target\#/} $${link} ; \
+ ln -sf $${relpath}$${target$(NUM_CHAR)/} $${link} ; \
done ; \
relpath="$(call relpath_prefix,$${ARCH_LIB_DIR})" ; \
if [ "$${relpath}" != "" ]; then \
diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk
index 1c43409514..2362defe8c 100644
--- a/toolchain/toolchain-external/pkg-toolchain-external.mk
+++ b/toolchain/toolchain-external/pkg-toolchain-external.mk
@@ -109,6 +109,20 @@ define TOOLCHAIN_EXTERNAL_MOVE
endef
endif
+# make 4.3:
+# https://lwn.net/Articles/810071/
+# Number signs (#) appearing inside a macro reference or function invocation
+# no longer introduce comments and should not be escaped with backslashes:
+# thus a call such as:
+# foo := $(shell echo '#')
+# is legal. Previously the number sign needed to be escaped, for example:
+# foo := $(shell echo '\#')
+# Now this latter will resolve to "\#". If you want to write makefiles
+# portable to both versions, assign the number sign to a variable:
+# H := \#
+# foo := $(shell echo '$H')
+NUM_CHAR := \#
+
#
# Definitions of the list of libraries that should be copied to the target.
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment