netns xfrm: fix "ip xfrm state|policy count" misreport
[safe/jmp/linux-2.6] / scripts / mkmakefile
index e0f54b9..67d59c7 100644 (file)
@@ -17,7 +17,9 @@ if test -e $2/Makefile && ! grep -q Automatically $2/Makefile
 then
        exit 0
 fi
-echo "  GEN     $2/Makefile"
+if [ "${quiet}" != "silent_" ]; then
+       echo "  GEN     $2/Makefile"
+fi
 
 cat << EOF > $2/Makefile
 # Automatically generated by $0: don't edit
@@ -25,8 +27,11 @@ cat << EOF > $2/Makefile
 VERSION = $3
 PATCHLEVEL = $4
 
-KERNELSRC    := $1
-KERNELOUTPUT := $2
+lastword = \$(word \$(words \$(1)),\$(1))
+makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
+
+MAKEARGS := -C $1
+MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
 
 MAKEFLAGS += --no-print-directory
 
@@ -35,10 +40,11 @@ MAKEFLAGS += --no-print-directory
 all    := \$(filter-out all Makefile,\$(MAKECMDGOALS))
 
 all:
-       \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$(all)
+       \$(MAKE) \$(MAKEARGS) \$(all)
 
 Makefile:;
 
 \$(all) %/: all
        @:
+
 EOF