[klibc] Handle KLIBCKERNEL{SRC,OBJ} without final slash

Don't require that KLIBCKERNEL{SRC,OBJ} end in a slash.  On the other
hand, this means that those strings need to exist and be non-empty,
i.e. "." is okay, but not "".

Furthermore, default KLIBCKERNELOBJ to KLIBCKERNELSRC instead of
"linux".

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
diff --git a/Makefile b/Makefile
index 83c5338..563618c 100644
--- a/Makefile
+++ b/Makefile
@@ -7,8 +7,8 @@
 export VERSION := $(shell cat $(srctree)/$(KLIBCSRC)/version)
 export KLIBCINC := usr/include
 export KLIBCOBJ := usr/klibc
-export KLIBCKERNELSRC := linux/
-export KLIBCKERNELOBJ := linux/
+export KLIBCKERNELSRC ?= linux
+export KLIBCKERNELOBJ ?= $(KLIBCKERNELSRC)
 
 export VPATH := $(srctree)
 
diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index 32d49fa..21e521f 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -76,7 +76,7 @@
 KLIBCCFLAGS       :=
 
 # Defaults for arch to override
-KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)arch/$(KLIBCARCH)/include
+KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)/arch/$(KLIBCARCH)/include
 
 # Arch specific definitions for klibc
 include $(srctree)/$(KLIBCSRC)/arch/$(KLIBCARCHDIR)/MCONFIG
@@ -105,9 +105,11 @@
 		    -I$(KLIBCOBJ)/../include		\
                     -I$(KLIBCINC)
 # kernel include paths
-KLIBCKERNELSRC	 ?= $(srctree)/
-KLIBCCPPFLAGS    += -I$(KLIBCKERNELSRC)include		\
-                     $(if $(KBUILD_SRC),-I$(KLIBCKERNELOBJ)include2 -I$(KLIBCKERNELOBJ)include -I$(srctree)/include)    \
+KLIBCKERNELSRC	 ?= $(srctree)
+KLIBCKERNELOBJ	 ?= $(objtree)
+KLIBCCPPFLAGS    += -I$(KLIBCKERNELSRC)/include				    \
+                     $(if $(KBUILD_SRC),-I$(KLIBCKERNELOBJ)/include2 	    \
+		       -I$(KLIBCKERNELOBJ)/include -I$(srctree)/include)    \
 		     $(KLIBCARCHINCFLAGS)
 
 # klibc definitions
diff --git a/usr/include/Kbuild b/usr/include/Kbuild
index 3f20026..0032724 100644
--- a/usr/include/Kbuild
+++ b/usr/include/Kbuild
@@ -2,10 +2,10 @@
 
 $(obj)/asm:
 	@echo '  SYMLINK $@ -> include/asm-$(KLIBCASMARCH)'
-	$(Q)if [ '$(KLIBCKERNELSRC).' -ef '$(obj)/../..' ]; then \
+	$(Q)if [ '$(KLIBCKERNELSRC)/.' -ef '$(obj)/../..' ]; then \
 		ln -fsn ../../include/asm-$(KLIBCASMARCH) $@; \
 	 else \
-		ln -fsn $(KLIBCKERNELSRC)./include/asm-$(KLIBCASMARCH) $@; \
+		ln -fsn $(KLIBCKERNELSRC)/include/asm-$(KLIBCASMARCH) $@; \
 	 fi
 
 clean-files := asm
diff --git a/usr/klibc/arch/ppc/MCONFIG b/usr/klibc/arch/ppc/MCONFIG
index 5530f40..6630df7 100644
--- a/usr/klibc/arch/ppc/MCONFIG
+++ b/usr/klibc/arch/ppc/MCONFIG
@@ -23,7 +23,7 @@
 KLIBCSHAREDFLAGS     = -Ttext 0x0f800200
 
 # The kernel so far has both asm-ppc* and asm-powerpc.
-KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)arch/powerpc/include
+KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)/arch/powerpc/include
 
 # The asm include files live in asm-powerpc
 KLIBCASMARCH	= powerpc
diff --git a/usr/klibc/arch/ppc64/MCONFIG b/usr/klibc/arch/ppc64/MCONFIG
index 32e0281..cb66614 100644
--- a/usr/klibc/arch/ppc64/MCONFIG
+++ b/usr/klibc/arch/ppc64/MCONFIG
@@ -20,7 +20,7 @@
 KLIBCSHAREDFLAGS     = -Ttext 0x0f000200
 
 # The kernel so far has both asm-ppc* and asm-powerpc.
-KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)arch/powerpc/include
+KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)/arch/powerpc/include
 
 # The asm include files live in asm-powerpc
 KLIBCASMARCH	= powerpc
diff --git a/usr/klibc/arch/x86_64/MCONFIG b/usr/klibc/arch/x86_64/MCONFIG
index ff58a18..7d5eea7 100644
--- a/usr/klibc/arch/x86_64/MCONFIG
+++ b/usr/klibc/arch/x86_64/MCONFIG
@@ -36,7 +36,7 @@
 KLIBCSHAREDFLAGS     = -Ttext 0x00200200 -z max-page-size=0x100000
 
 # Asm includes for x86_64 are in the merged x86 tree
-KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)arch/x86/include
+KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)/arch/x86/include
 
 # Additional asm- directories needed during installation
 ASMARCH = asm-i386