kbuild: improving option checking
GNU binutils, root users, tmpfiles, external modules ro builds must
be fixed to do the right thing now.
In safe environment new /dev/null replacement may be use as simply as
`echo null', `gcc -o null'. In aggressive starting with $(null) is
recommended.
Feature: file $(objtree)/null isn't in any clear target (yet).
Cc: Roman Zippel [EMAIL PROTECTED]
Cc: Sam Ravnborg [EMAIL PROTECTED]
Signed-off-by: Oleg Verych [EMAIL PROTECTED]
---
-o--=O`C
#oo'L O
___=E M
--- linux~2.6.20-rc5/scripts/Kbuild.include~blackhole-4-tmpfiles
2007-01-12 19:54:26.0 +0100
+++ linux~2.6.20-rc5/scripts/Kbuild.include 2007-01-24 09:19:01.386426000
+0100
@@ -2,5 +2,5 @@
# kbuild: Generic definitions
-# Convinient variables
+# Convinient constants
comma := ,
squote := '
@@ -8,4 +8,7 @@
space := $(empty) $(empty)
+# Immortal black-hole for mortals and roots
+null = $(shell test -L null || (rm -f null; ln -s /dev/null null); echo null)
+
###
# Name of target with a '.' as filename prefix. foo/bar.o = foo/.bar.o
@@ -57,33 +60,43 @@
# See documentation in Documentation/kbuild/makefiles.txt
-# output directory for tests below
-TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
-
# as-option
# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
-
-as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
--xassembler /dev/null /dev/null 21; then echo $(1); \
-else echo $(2); fi ;)
+define as-option
+ $(shell
+if $(CC) $(CFLAGS) $(1) -c -o $(null) -xassembler null null 21; \
+ then echo $(1); \
+ else echo $(2); \
+fi)
+endef
# as-instr
# Usage: cflags-y += $(call as-instr, instr, option1, option2)
-
-as-instr = $(shell if echo -e $(1) | \
- $(CC) $(AFLAGS) -c -xassembler - \
- -o $(TMPOUT)astest.out /dev/null 21; \
- then rm $(TMPOUT)astest.out; echo $(2); \
- else echo $(3); fi)
+define as-instr
+ $(shell \
+if printf $(1) | $(AS) $(null) 21 -W -o null; \
+ then echo $(2); \
+ else echo $(3); \
+fi)
+endef
# cc-option
# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
-
-cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
- /dev/null 21; then echo $(1); else echo $(2); fi ;)
+define cc-option
+ $(shell \
+if $(CC) $(CFLAGS) $(1) -S -o $(null) -xc null null 21; \
+ then echo $(1); \
+ else echo $(2); \
+fi)
+endef
# cc-option-yn
# Usage: flag := $(call cc-option-yn, -march=winchip-c6)
-cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
- /dev/null 21; then echo y; else echo n; fi;)
+define cc-option-yn
+ $(shell \
+if $(CC) $(CFLAGS) $(1) -S -o $(null) -xc null null 21; \
+ then echo y; \
+ else echo n; \
+fi)
+endef
# cc-option-align
@@ -103,8 +116,11 @@
# ld-option
# Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both)
-ld-option = $(shell if $(CC) $(1) -nostdlib -xc /dev/null \
--o $(TMPOUT)ldtest.out /dev/null 21; \
- then rm $(TMPOUT)ldtest.out; echo $(1); \
- else echo $(2); fi)
+define ld-option
+ $(shell \
+if $(CC) $(1) -nostdlib -o $(null) -xc null null 21; \
+ then echo $(1); \
+ else echo $(2); \
+fi)
+endef
###
@@ -116,4 +132,5 @@
# Prefix -I with $(srctree) if it is not an absolute path
addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)))
$(1)
+
# Find all -I options and call addtree
flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
@@ -126,5 +143,5 @@
###
-# if_changed - execute command if any prerequisite is newer than
+# if_changed - execute command if any prerequisite is newer than
# target, or command line has changed
# if_changed_dep - as if_changed, but uses fixdep to reveal dependencies
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel