kbuild: introduce ld-option
authorSam Ravnborg <sam@ravnborg.org>
Sat, 19 Sep 2009 08:31:45 +0000 (10:31 +0200)
committerSam Ravnborg <sam@ravnborg.org>
Sun, 20 Sep 2009 10:27:42 +0000 (12:27 +0200)
ld-option is used to check if $(LD) supports a specific option.

Based on patch from Andi Kleen.

Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
First use is to check if option -X is supported (upcoming patch).
Theis is ne

Documentation/kbuild/makefiles.txt
scripts/Kbuild.include

index 7847fce13bd679919970f39d17e20dab4585f214..71c602d61680d422694a81c08b0cd4f802e18e7c 100644 (file)
@@ -18,6 +18,7 @@ This document describes the Linux kernel Makefiles.
           --- 3.9 Dependency tracking
           --- 3.10 Special Rules
           --- 3.11 $(CC) support functions
+          --- 3.12 $(LD) support functions
 
        === 4 Host Program support
           --- 4.1 Simple Host Program
@@ -570,6 +571,19 @@ more details, with real examples.
                        endif
                endif
 
+--- 3.12 $(LD) support functions
+
+    ld-option
+       ld-option is used to check if $(LD) supports the supplied option.
+       ld-option takes two options as arguments.
+       The second argument is an optional option that can be used if the
+       first option is not supported by $(LD).
+
+       Example:
+               #Makefile
+               LDFLAGS_vmlinux += $(call really-ld-option, -X)
+
+
 === 4 Host Program support
 
 Kbuild supports building executables on the host for use during the
index 94a4f682f385480300d2b9cc61200e84bd8fb2c6..b3452601b0b1303f81bb93a8cdb3c36f43e1c775 100644 (file)
@@ -83,11 +83,12 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
 # is automatically cleaned up.
 try-run = $(shell set -e;              \
        TMP="$(TMPOUT).$$$$.tmp";       \
+       TMPO="$(TMPOUT).$$$$.o";        \
        if ($(1)) >/dev/null 2>&1;      \
        then echo "$(2)";               \
        else echo "$(3)";               \
        fi;                             \
-       rm -f "$$TMP")
+       rm -f "$$TMP" "$$TMPO")
 
 # as-option
 # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
@@ -135,6 +136,11 @@ cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3))
 cc-ldoption = $(call try-run,\
        $(CC) $(1) -nostdlib -xc /dev/null -o "$$TMP",$(1),$(2))
 
+# ld-option
+# Usage: LDFLAGS += $(call ld-option, -X)
+ld-option = $(call try-run,\
+       $(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
+
 ######
 
 ###