LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Oleg Verych <olecom@flower.upol.cz>
To: Valdis.Kletnieks@vt.edu, Jan Beulich <jbeulich@novell.com>,
	Oleg Verych <olecom@flower.upol.cz>,
	dsd@gentoo.org, kernel@gentoo.org, draconx@gmail.com,
	jpdenheijer@gmail.com, Andrew Morton <akpm@osdl.org>,
	Sam Ravnborg <sam@ravnborg.org>, Andi Kleen <ak@suse.de>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm] replacement for broken kbuild-dont-put-temp-files-in-the-source-tree.patch
Date: Mon, 30 Oct 2006 22:12:38 +0000	[thread overview]
Message-ID: <slrnekcu6m.2vm.olecom@flower.upol.cz> (raw)
In-Reply-To: <slrnekc8np.2vm.olecom@flower.upol.cz>


On 2006-10-30, <olecom@flower> wrote:
> Fix for roots:
> ,--
>|if [ `id -u` == "0" ]; then echo "Root landed !!!"; ! true; fi
> `--
> More polite fools-protection, with guaranteed permission from the user:
> ,--
>|if [ `id -u` == "0" ]; then useradd bkernel && su bkernel fi;
> `--
> ____

For current state of things, i wish to propose

kbuild-mm-more-option-check-fixes.pre-patch:

Request For Testing.

Interested parties may test this one.
$(ret) is used for debug. In final version it may be removed,
$(objtree)/null must be known for clean targets.

I've replaced one `echo -e' with `printf', because, for example, my shell is
not bash, and built-in `echo' have not `-e' option, `printf' works everywhere.
[trailing spaces killed: +1]

Any comments are appreciated.
____

--- linux-2.6.19-rc3-mm1/scripts/Kbuild.include	2006-10-28 01:26:25.000000000 +0000
+++ linux-2.6.19-rc3-mm1/scripts/Kbuild.include~more-option-check-fixes	2006-10-30 20:39:03.641018805 +0000
@@ -7,6 +7,15 @@ squote  := '
 empty   :=
 space   := $(empty) $(empty)
 
+# Immortal null for mortals and roots
+define null
+  $(shell \
+    if test -L null; \
+      then echo null; \
+      else rm -f null; ln -s /dev/null null; \
+    fi)
+endef
+
 ###
 # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
 dot-target = $(dir $@).$(notdir $@)
@@ -56,30 +65,46 @@ endef
 # gcc support functions
 # See documentation in Documentation/kbuild/makefiles.txt
 
+ret = echo "$(1)" ; echo "$(1)" >> results.txt
 # 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 2>&1; then echo "$(1)"; \
-	     else echo "$(2)"; fi ;)
+define as-option
+  $(shell \
+    if $(CC) $(CFLAGS) $(1) -c -o $(null) -xassembler null >null 2>&1; \
+      then $(call ret,"$(1)"); \
+      else $(call ret,"$(2)"); \
+    fi)
+endef
 
 # as-instr
 # Usage: cflags-y += $(call as-instr, instr, option1, option2)
-
-as-instr = $(shell if echo -e "$(1)" | $(AS) >/dev/null 2>&1 -W -Z -o astest$$$$.out ; \
-		   then echo "$(2)"; else echo "$(3)"; fi; \
-	           rm -f astest$$$$.out)
+define as-instr
+  $(shell \
+    if printf "$(1)" | $(AS) >null 2>&1 -W -o $(null); \
+      then $(call ret,"$(2)"); \
+      else $(call ret,"$(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 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+define cc-option
+  $(shell \
+    if $(CC) $(CFLAGS) $(1) -S -o $(null) -xc null >null 2>&1; \
+      then $(call ret,"$(1)"); \
+      else $(call ret,"$(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 2>&1; then echo "y"; else echo "n"; fi;)
+define cc-option-yn
+  $(shell \
+    if $(CC) $(CFLAGS) $(1) -S -o $(null) -xc null >null 2>&1; \
+      then $(call ret,"y"); \
+      else $(call ret,"n"); \
+    fi)
+endef
 
 # cc-option-align
 # Prefix align with either -falign or -malign
@@ -97,10 +122,13 @@ cc-ifversion = $(shell if [ $(call cc-ve
 
 # ld-option
 # Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both)
-ld-option = $(shell if $(CC) $(1) \
-			     -nostdlib -o ldtest$$$$.out -xc /dev/null \
-             > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi; \
-	     rm -f ldtest$$$$.out)
+define ld-option
+  $(shell \
+    if $(CC) $(1) -nostdlib -o $(null) -xc null >null 2>&1; \
+      then $(call ret,"$(1)"); \
+      else $(call ret,"$(2)"); \
+    fi)
+endef
 
 ###
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
@@ -120,7 +148,7 @@ cmd = @$(echo-cmd) $(cmd_$(1))
 objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
 
 ###
-# 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
 #                   including used config symbols

  reply	other threads:[~2006-10-30 22:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-28 23:07 Horst Schirmeier
2006-10-29  2:07 ` Andi Kleen
2006-10-29 12:08   ` Horst Schirmeier
2006-10-29 16:16     ` Andi Kleen
2006-10-29 17:52       ` Oleg Verych
2006-10-29 22:52         ` Sam Ravnborg
2006-10-30  8:16           ` Jan Beulich
2006-10-30 13:16             ` Oleg Verych
     [not found]               ` <45460E6C.76E4.0078.0@novell.com>
2006-10-30 14:42                 ` Oleg Verych
2006-10-30 15:22                   ` Valdis.Kletnieks
2006-10-30 16:06                     ` Oleg Verych
2006-10-30 22:12                       ` Oleg Verych [this message]
2006-10-31  0:12                         ` Horst Schirmeier
2006-10-31  0:19                           ` Andi Kleen
2006-10-31  1:14                             ` Horst Schirmeier
2006-10-31 13:51                               ` Oleg Verych
2006-11-02 12:46                                 ` Jan Peter den Heijer
2006-11-17  5:17                                 ` kbuild: O= with M= (Re: [PATCH -mm] replacement for broken kbuild-dont-put-temp-files-in-the-source-tree.patch) Oleg Verych
2007-01-23  7:36                                   ` [fix, rfc] " Oleg Verych
2007-01-24  8:54                                 ` [patch] kbuild: improving option checking " Oleg Verych
2007-01-24 16:06                                   ` Randy Dunlap
2007-01-24 19:28                                     ` [patch] spell 4 kbuild: improving option checking Oleg Verych
2006-10-31  0:27                         ` [PATCH -mm] replacement for broken kbuild-dont-put-temp-files-in-the-source-tree.patch Horst Schirmeier
2006-10-31 13:32                           ` Oleg Verych
2006-11-15 14:17                           ` kbuild-mm: $(objtree)/knull vs mktemp (was Re: [PATCH -mm] replacement for broken kbuild-dont-put-temp-files-in-the-source-tree.patch) Oleg Verych

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=slrnekcu6m.2vm.olecom@flower.upol.cz \
    --to=olecom@flower.upol.cz \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=draconx@gmail.com \
    --cc=dsd@gentoo.org \
    --cc=jbeulich@novell.com \
    --cc=jpdenheijer@gmail.com \
    --cc=kernel@gentoo.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.org \
    --subject='Re: [PATCH -mm] replacement for broken kbuild-dont-put-temp-files-in-the-source-tree.patch' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).