aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Arnout Vandecappelle <arnout@mind.be>2017-07-03 10:41:06 +0200
committerGravatar Peter Korsgaard <peter@korsgaard.com>2017-07-25 23:52:36 +0200
commitb65e90afe3951bfeb50c6e472792c0ab7b246e63 (patch)
tree83a99c99df42f2aca2e095201959536453382582
parentc4ae64c3074bf34f45ecfde4fc0733c2f0bcbd58 (diff)
downloadbuildroot-b65e90afe3951bfeb50c6e472792c0ab7b246e63.tar.gz
buildroot-b65e90afe3951bfeb50c6e472792c0ab7b246e63.tar.bz2
package/Makefile.in: add host-cc-option macro
This macro allows to test if HOSTCC supports a specific option. It is needed to pass '-no-pie' on recent Debian, Ubuntu and Gentoo hosts. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> (cherry picked from commit 91a08ecc998ae232ea6f3525540ed129d8176d18) Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
-rw-r--r--package/Makefile.in21
1 files changed, 21 insertions, 0 deletions
diff --git a/package/Makefile.in b/package/Makefile.in
index c1dc714331..b32ad8e447 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -223,6 +223,27 @@ HOST_CFLAGS += $(HOST_CPPFLAGS)
HOST_CXXFLAGS += $(HOST_CFLAGS)
HOST_LDFLAGS += -L$(HOST_DIR)/lib -L$(HOST_DIR)/usr/lib -Wl,-rpath,$(HOST_DIR)/usr/lib
+# The macros below are taken from linux 4.11 and adapted slightly.
+# Copy more when needed.
+
+# try-run
+# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
+# Exit code chooses option. "$$TMP" is can be used as temporary file and
+# is automatically cleaned up.
+try-run = $(shell set -e; \
+ TMP="$$(tempfile)"; \
+ if ($(1)) >/dev/null 2>&1; \
+ then echo "$(2)"; \
+ else echo "$(3)"; \
+ fi; \
+ rm -f "$$TMP")
+
+# host-cc-option
+# Usage: HOST_FOO_CFLAGS += $(call host-cc-option,-no-pie,)
+host-cc-option = $(call try-run,\
+ $(HOSTCC) $(HOST_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
+
+
# host-intltool should be executed with the system perl, so we save
# the path to the system perl, before a host-perl built by Buildroot
# might get installed into $(HOST_DIR)/usr/bin and therefore appears