From 694755867a4adf61191bc065541888ad6828cfc6 Mon Sep 17 00:00:00 2001
From: FURUSO Shinichi <Shinichi.Furuso@jp.sony.com>
Date: Mon, 8 Aug 2011 14:01:03 +0900
Subject: [PATCH 1/2] rename KERNELSRC with KERNELDIR for sles10

---
 Makefile     |  136 +++++++++++++++++++++++++++++-----------------------------
 Makefile.inc |   12 +++---
 Makefile.top |   10 ++--
 3 files changed, 79 insertions(+), 79 deletions(-)

diff --git a/Makefile b/Makefile
index 462bd77..1973524 100644
--- a/Makefile
+++ b/Makefile
@@ -31,10 +31,10 @@ def:
 	@echo "Commonly used build commands:"
 	@echo
 	@echo "When using KLIPS:"
-	@echo " make KERNELSRC=/usr/src/linux-2.6.36 module minstall programs install"
+	@echo " make KERNELDIR=/usr/src/linux-2.6.36 module minstall programs install"
 	@echo
 	@echo "When using KLIPS with OCF:"
-	@echo " make KERNELSRC=/usr/src/linux-2.6.36-ocf/ MODULE_DEF_INCLUDE=$${LIBRESWANSRCDIR}/packaging/ocf/config-all.hmodules module minstall programs install"
+	@echo " make KERNELDIR=/usr/src/linux-2.6.36-ocf/ MODULE_DEF_INCLUDE=$${LIBRESWANSRCDIR}/packaging/ocf/config-all.hmodules module minstall programs install"
 	@echo
 	@echo "When using NETKEY:"
 	@echo " make programs install"
@@ -47,7 +47,7 @@ include ${LIBRESWANSRCDIR}/Makefile.top
 
 # kernel details
 # what variant of our patches should we use, and where is it
-KERNELREL=$(shell ${KVSHORTUTIL} ${KERNELSRC}/Makefile)
+KERNELREL=$(shell ${KVSHORTUTIL} ${KERNELDIR}/Makefile)
 
 # directories visited by all recursion
 
@@ -70,37 +70,37 @@ npatch: unapplynpatch applynpatch
 sarefpatch: unapplysarefpatch applysarefpatch
 
 unapplypatch:
-	@echo "info: making unapplypatch in `pwd` and KERNELSRC=\"${KERNELSRC}\";"
-	-@if [ -f ${KERNELSRC}/libreswan.patch ]; then \
+	@echo "info: making unapplypatch in `pwd` and KERNELDIR=\"${KERNELDIR}\";"
+	-@if [ -f ${KERNELDIR}/libreswan.patch ]; then \
 		echo Undoing previous patches; \
-		cat ${KERNELSRC}/libreswan.patch | (cd ${KERNELSRC} && patch -p1 -R --force -E -z .preipsec --reverse --ignore-whitespace ); \
+		cat ${KERNELDIR}/libreswan.patch | (cd ${KERNELDIR} && patch -p1 -R --force -E -z .preipsec --reverse --ignore-whitespace ); \
 	fi
 
 applypatch:
 	@echo "info: Now performing forward patches in `pwd`";
-	${MAKE} kernelpatch${KERNELREL} | tee ${KERNELSRC}/libreswan.patch | (cd ${KERNELSRC} && patch -p1 -b -z .preipsec --forward --ignore-whitespace )
+	${MAKE} kernelpatch${KERNELREL} | tee ${KERNELDIR}/libreswan.patch | (cd ${KERNELDIR} && patch -p1 -b -z .preipsec --forward --ignore-whitespace )
 
 unapplynpatch:
 	@echo "info: making unapplynpatch (note the second N) in `pwd`";
-	-@if [ -f ${KERNELSRC}/natt.patch ]; then \
+	-@if [ -f ${KERNELDIR}/natt.patch ]; then \
 		echo Undoing previous NAT patches; \
-		cat ${KERNELSRC}/natt.patch | (cd ${KERNELSRC} && patch -p1 -R --force -E -z .preipsec --reverse --ignore-whitespace ); \
+		cat ${KERNELDIR}/natt.patch | (cd ${KERNELDIR} && patch -p1 -R --force -E -z .preipsec --reverse --ignore-whitespace ); \
 	fi
 
 applynpatch:
 	@echo "info: Now performing forward NAT patches in `pwd`"; 
-	${MAKE} nattpatch${KERNELREL} | tee ${KERNELSRC}/natt.patch | (cd ${KERNELSRC} && patch -p1 -b -z .preipsec --forward --ignore-whitespace )
+	${MAKE} nattpatch${KERNELREL} | tee ${KERNELDIR}/natt.patch | (cd ${KERNELDIR} && patch -p1 -b -z .preipsec --forward --ignore-whitespace )
 
 unapplysarefpatch:
 	@echo "info: making unapplysarefpatch in `pwd`";
-	-@if [ -f ${KERNELSRC}/saref.patch ]; then \
+	-@if [ -f ${KERNELDIR}/saref.patch ]; then \
 		echo Undoing previous saref patches; \
-		cat ${KERNELSRC}/saref.patch | (cd ${KERNELSRC} && patch -p1 -R --force -E -z .preng --reverse --ignore-whitespace ); \
+		cat ${KERNELDIR}/saref.patch | (cd ${KERNELDIR} && patch -p1 -R --force -E -z .preng --reverse --ignore-whitespace ); \
 	fi
 
 applysarefpatch:
 	@echo "info: Now performing SAref patches in `pwd`";
-	${MAKE} sarefpatch${KERNELREL} | tee ${KERNELSRC}/klipsng.patch | (cd ${KERNELSRC} && patch -p1 -b -z .preng --forward --ignore-whitespace )
+	${MAKE} sarefpatch${KERNELREL} | tee ${KERNELDIR}/klipsng.patch | (cd ${KERNELDIR} && patch -p1 -b -z .preng --forward --ignore-whitespace )
 
 # patch kernel
 PATCHER=packaging/utils/patcher
@@ -111,36 +111,36 @@ patches:
 
 _patches:
 	echo "===============" >>out.kpatch
-	echo "`date` `cd $(KERNELSRC) ; pwd`" >>out.kpatch
+	echo "`date` `cd $(KERNELDIR) ; pwd`" >>out.kpatch
 	$(MAKE) __patches$(KERNELREL) >>out.kpatch
 
 # Linux-2.4.0 version
 PATCHES22=klips/patches2.2
 __patches2.3 __patches2.4:
-	@$(PATCHER) -v -c $(KERNELSRC) Documentation/Configure.help \
+	@$(PATCHER) -v -c $(KERNELDIR) Documentation/Configure.help \
 		'CONFIG_KLIPS' $(PATCHES)/Documentation/Configure.help.fs2_2.patch
-	@$(PATCHER) -v $(KERNELSRC) net/Config.in \
+	@$(PATCHER) -v $(KERNELDIR) net/Config.in \
 		'CONFIG_KLIPS' $(PATCHES)/net/Config.in.fs2_4.patch
-	@$(PATCHER) -v $(KERNELSRC) net/Makefile \
+	@$(PATCHER) -v $(KERNELDIR) net/Makefile \
 		'CONFIG_KLIPS' $(PATCHES)/net/Makefile.fs2_4.patch
-	@$(PATCHER) -v $(KERNELSRC) net/ipv4/af_inet.c \
+	@$(PATCHER) -v $(KERNELDIR) net/ipv4/af_inet.c \
 		'CONFIG_KLIPS' $(PATCHES)/net/ipv4/af_inet.c.fs2_4.patch
-	@$(PATCHER) -v $(KERNELSRC) net/ipv4/udp.c \
+	@$(PATCHER) -v $(KERNELDIR) net/ipv4/udp.c \
 		'CONFIG_KLIPS' $(PATCHES)/net/ipv4/udp.c.fs2_4.patch
-	@$(PATCHER) -v $(KERNELSRC) include/net/sock.h \
+	@$(PATCHER) -v $(KERNELDIR) include/net/sock.h \
 		'CONFIG_KLIPS' $(PATCHES)/include/net/sock.h.fs2_4.patch
 # Removed patches, will unpatch automatically.
-	@$(PATCHER) -v $(KERNELSRC) include/linux/proc_fs.h
-	@$(PATCHER) -v $(KERNELSRC) net/core/dev.c
-	@$(PATCHER) -v $(KERNELSRC) net/ipv4/protocol.c
-	@$(PATCHER) -v $(KERNELSRC) drivers/net/Space.c
-	@$(PATCHER) -v $(KERNELSRC) include/linux/netlink.h
-	@$(PATCHER) -v $(KERNELSRC) net/netlink/af_netlink.c
-	@$(PATCHER) -v $(KERNELSRC) net/netlink/netlink_dev.c
-	@$(PATCHER) -v $(KERNELSRC) drivers/isdn/isdn_net.c
+	@$(PATCHER) -v $(KERNELDIR) include/linux/proc_fs.h
+	@$(PATCHER) -v $(KERNELDIR) net/core/dev.c
+	@$(PATCHER) -v $(KERNELDIR) net/ipv4/protocol.c
+	@$(PATCHER) -v $(KERNELDIR) drivers/net/Space.c
+	@$(PATCHER) -v $(KERNELDIR) include/linux/netlink.h
+	@$(PATCHER) -v $(KERNELDIR) net/netlink/af_netlink.c
+	@$(PATCHER) -v $(KERNELDIR) net/netlink/netlink_dev.c
+	@$(PATCHER) -v $(KERNELDIR) drivers/isdn/isdn_net.c
 
 klipsdefaults:
-	@KERNELDEFCONFIG=$(KERNELSRC)/arch/$(ARCH)/defconfig ; \
+	@KERNELDEFCONFIG=$(KERNELDIR)/arch/$(ARCH)/defconfig ; \
 	KERNELCONFIG=$(KCFILE) ; \
 	if ! egrep -q 'CONFIG_KLIPS' $$KERNELDEFCONFIG ; \
 	then \
@@ -233,15 +233,15 @@ obsolete_target:
 
 # preliminaries
 precheck:
-	@if test ! -d $(KERNELSRC) -a ! -L $(KERNELSRC) ; \
+	@if test ! -d $(KERNELDIR) -a ! -L $(KERNELDIR) ; \
 	then \
-		echo '*** cannot find directory "$(KERNELSRC)"!!' ; \
+		echo '*** cannot find directory "$(KERNELDIR)"!!' ; \
 		echo '*** may be necessary to add symlink to kernel source' ; \
 		exit 1 ; \
 	fi
-	@if ! cd $(KERNELSRC) ; \
+	@if ! cd $(KERNELDIR) ; \
 	then \
-		echo '*** cannot "cd $(KERNELSRC)"!!' ; \
+		echo '*** cannot "cd $(KERNELDIR)"!!' ; \
 		echo '*** may be necessary to add symlink to kernel source' ; \
 		exit 1 ; \
 	fi
@@ -264,21 +264,21 @@ Makefile: Makefile.ver
 
 # configuring (exit statuses disregarded, something fishy here sometimes)
 xcf:
-	-cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) xconfig
+	-cd $(KERNELDIR) ; $(MAKE) $(KERNMAKEOPTS) xconfig
 mcf:
-	-cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) menuconfig
+	-cd $(KERNELDIR) ; $(MAKE) $(KERNMAKEOPTS) menuconfig
 pcf:
-	-cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) config
+	-cd $(KERNELDIR) ; $(MAKE) $(KERNMAKEOPTS) config
 
 ocf:
-	-cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) oldconfig 
+	-cd $(KERNELDIR) ; $(MAKE) $(KERNMAKEOPTS) oldconfig 
 
 rcf:
-	cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) ${NONINTCONFIG} </dev/null
-	cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) dep >/dev/null
+	cd $(KERNELDIR) ; $(MAKE) $(KERNMAKEOPTS) ${NONINTCONFIG} </dev/null
+	cd $(KERNELDIR) ; $(MAKE) $(KERNMAKEOPTS) dep >/dev/null
 
 kclean:
-	-cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) clean
+	-cd $(KERNELDIR) ; $(MAKE) $(KERNMAKEOPTS) clean
 
 confcheck:
 	@if test ! -f $(KCFILE) ; \
@@ -309,11 +309,11 @@ kernel:
 	# we run make dep seperately, because there is no point in running ERRCHECK
 	# on the make dep output.
 	# see LKML thread "clean before or after dep?"
-	( cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) $(KERNCLEAN) $(KERNDEP) )
-	( cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) $(KERNEL) ) 2>&1 | tee out.kbuild
+	( cd $(KERNELDIR) ; $(MAKE) $(KERNMAKEOPTS) $(KERNCLEAN) $(KERNDEP) )
+	( cd $(KERNELDIR) ; $(MAKE) $(KERNMAKEOPTS) $(KERNEL) ) 2>&1 | tee out.kbuild
 	@if egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \
 	then set -x ; \
-		( cd $(KERNELSRC) ; \
+		( cd $(KERNELDIR) ; \
 		$(MAKE) $(KERNMAKEOPTS) modules 2>&1 ) | tee -a out.kbuild ; \
 	fi
 	${ERRCHECK} out.kbuild
@@ -347,33 +347,33 @@ ${MOD24BUILDDIR}/Makefile : ${LIBRESWANSRCDIR}/packaging/makefiles/module.make
 	cp ${LIBRESWANSRCDIR}/packaging/makefiles/module.make ${MOD24BUILDDIR}/Makefile
 	echo "# "                        >> ${MOD24BUILDDIR}/Makefile
 	echo "# Local Variables: "       >> ${MOD24BUILDDIR}/Makefile
-	echo "# compile-command: \"${MAKE} LIBRESWANSRCDIR=${LIBRESWANSRCDIR} ARCH=${ARCH} TOPDIR=${KERNELSRC} ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} MODULE_DEFCONFIG=${MODULE_DEFCONFIG} -f Makefile ipsec.o\""         >> ${MOD24BUILDDIR}/Makefile
+	echo "# compile-command: \"${MAKE} LIBRESWANSRCDIR=${LIBRESWANSRCDIR} ARCH=${ARCH} TOPDIR=${KERNELDIR} ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} MODULE_DEFCONFIG=${MODULE_DEFCONFIG} -f Makefile ipsec.o\""         >> ${MOD24BUILDDIR}/Makefile
 	echo "# End: "       >> ${MOD24BUILDDIR}/Makefile
 
 module:
-	@if [ -f ${KERNELSRC}/README.libreswan-2 ] ; then \
-                echo "WARNING: Kernel source ${KERNELSRC} has already been patched with libreswan-2, out of tree build might fail!"; \
+	@if [ -f ${KERNELDIR}/README.libreswan-2 ] ; then \
+                echo "WARNING: Kernel source ${KERNELDIR} has already been patched with libreswan-2, out of tree build might fail!"; \
         fi;
-	@if [ -f ${KERNELSRC}/README.freeswan ] ; then \
-                echo "ERROR: Kernel source ${KERNELSRC} has already been patched with freeswan, out of tree build will fail!"; \
+	@if [ -f ${KERNELDIR}/README.freeswan ] ; then \
+                echo "ERROR: Kernel source ${KERNELDIR} has already been patched with freeswan, out of tree build will fail!"; \
         fi;
-	@if [ -f ${KERNELSRC}/Rules.make ] ; then \
+	@if [ -f ${KERNELDIR}/Rules.make ] ; then \
                 echo "Building module for a 2.4 kernel"; ${MAKE} module24 ; \
         else echo "Building module for a 2.6 kernel"; ${MAKE} module26; \
         fi;
 
 modclean moduleclean:
-	@if [ -f ${KERNELSRC}/Rules.make ] ; then \
+	@if [ -f ${KERNELDIR}/Rules.make ] ; then \
 		echo "Cleaning module for a 2.4 kernel"; ${MAKE} module24clean ; \
 	else echo "Cleaning module for a 2.6 kernel"; ${MAKE} module26clean; \
 	fi;
 
 module24:
-	@if [ ! -f ${KERNELSRC}/Rules.make ] ; then \
+	@if [ ! -f ${KERNELDIR}/Rules.make ] ; then \
                 echo "Warning: Building for a 2.4 kernel in what looks like a 2.6 tree"; \
         fi ; \
         ${MAKE} ${MOD24BUILDDIR}/Makefile
-	${MAKE} -C ${MOD24BUILDDIR}  LIBRESWANSRCDIR=${LIBRESWANSRCDIR} ARCH=${ARCH} V=${V} ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} TOPDIR=${KERNELSRC} -f Makefile ipsec.o
+	${MAKE} -C ${MOD24BUILDDIR}  LIBRESWANSRCDIR=${LIBRESWANSRCDIR} ARCH=${ARCH} V=${V} ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} TOPDIR=${KERNELDIR} -f Makefile ipsec.o
 	@echo 
 	@echo '========================================================='
 	@echo 
@@ -394,15 +394,15 @@ mod24clean module24clean:
 #autoodetect 2.4 and 2.6
 module_install: minstall
 minstall:
-	@if [ -f ${KERNELSRC}/Rules.make ] ; then \
+	@if [ -f ${KERNELDIR}/Rules.make ] ; then \
                 ${MAKE} minstall24 ; else ${MAKE} minstall26; \
         fi;
 
 # module-only install, with error checks
 minstall24:
-	( OSMODLIB=`${MAKE} -C $(KERNELSRC) -p dummy | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
+	( OSMODLIB=`${MAKE} -C $(KERNELDIR) -p dummy | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
 	if [ -z "$$OSMODLIB" ] ; then \
-		OSMODLIB=`${MAKE} -C $(KERNELSRC) -n -p modules_install | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
+		OSMODLIB=`${MAKE} -C $(KERNELDIR) -n -p modules_install | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
 	fi ; \
 	if [ -z "$$OSMODLIB" ] ; then \
 		echo "No known place to install module. Aborting." ; \
@@ -441,15 +441,15 @@ ${MODBUILDDIR}/Makefile : ${LIBRESWANSRCDIR}/packaging/makefiles/module26.make
 	cp ${LIBRESWANSRCDIR}/packaging/makefiles/module26.make ${MODBUILDDIR}/Makefile
 	echo "# "                        >> ${MODBUILDDIR}/Makefile
 	echo "# Local Variables: "       >> ${MODBUILDDIR}/Makefile
-	echo "# compile-command: \"${MAKE} -C ${LIBRESWANSRCDIR} ARCH=${ARCH} KERNELSRC=${KERNELSRC} MODBUILDDIR=${MODBUILDDIR} module26\""         >> ${MODBUILDDIR}/Makefile
+	echo "# compile-command: \"${MAKE} -C ${LIBRESWANSRCDIR} ARCH=${ARCH} KERNELDIR=${KERNELDIR} MODBUILDDIR=${MODBUILDDIR} module26\""         >> ${MODBUILDDIR}/Makefile
 	echo "# End: "       >> ${MODBUILDDIR}/Makefile
 	ln -s -f ${LIBRESWANSRCDIR}/linux/net/ipsec/match*.S ${MODBUILDDIR}
 
 module26:
-	@if [ -f ${KERNELSRC}/Rules.make ] ; then \                 echo "Warning: Building for a 2.6 kernel in what looks like a 2.4 tree"; \
+	@if [ -f ${KERNELDIR}/Rules.make ] ; then \                 echo "Warning: Building for a 2.6 kernel in what looks like a 2.4 tree"; \
         fi ; \
         ${MAKE}  ${MODBUILDDIR}/Makefile
-	${MAKE} -C ${KERNELSRC} ${KERNELBUILDMFLAGS} BUILDDIR=${MODBUILDDIR} SUBDIRS=${MODBUILDDIR} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} MODULE_DEFCONFIG=${MODULE_DEFCONFIG}  MODULE_EXTRA_INCLUDE=${MODULE_EXTRA_INCLUDE} ARCH=${ARCH} V=${V} modules
+	${MAKE} -C ${KERNELDIR} ${KERNELBUILDMFLAGS} BUILDDIR=${MODBUILDDIR} SUBDIRS=${MODBUILDDIR} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} MODULE_DEFCONFIG=${MODULE_DEFCONFIG}  MODULE_EXTRA_INCLUDE=${MODULE_EXTRA_INCLUDE} ARCH=${ARCH} V=${V} modules
 	@echo 
 	@echo '========================================================='
 	@echo 
@@ -469,9 +469,9 @@ mod26clean module26clean:
 
 # module-only install, with error checks
 minstall26:
-	( OSMODLIB=`${MAKE} -C $(KERNELSRC) -p help | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
+	( OSMODLIB=`${MAKE} -C $(KERNELDIR) -p help | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
 	if [ -z "$$OSMODLIB" ] ; then \
-		OSMODLIB=`${MAKE} -C $(KERNELSRC) -n -p modules_install | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
+		OSMODLIB=`${MAKE} -C $(KERNELDIR) -n -p modules_install | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
 	fi ; \
 	if [ -z "$$OSMODLIB" ] ; then \
 		echo "No known place to install module. Aborting." ; \
@@ -506,10 +506,10 @@ kinstall:
 	# undocumented kernel folklore: modules_install must precede install (observed on RHL8.0)
 	@if egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \
 	then set -x ; \
-		( cd $(KERNELSRC) ; \
+		( cd $(KERNELDIR) ; \
 		$(MAKE) $(KERNMAKEOPTS) modules_install 2>&1 ) | tee -a out.kinstall ; \
 	fi
-	( cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) install ) 2>&1 | tee -a out.kinstall
+	( cd $(KERNELDIR) ; $(MAKE) $(KERNMAKEOPTS) install ) 2>&1 | tee -a out.kinstall
 	${ERRCHECK} out.kinstall
 
 kernelpatch2.6 kernelpatch:
@@ -525,9 +525,9 @@ kernelpatch2.0:
 	packaging/utils/kernelpatch 2.0
 
 nattpatch:
-	if [ -f ${KERNELSRC}/Makefile ]; then \
+	if [ -f ${KERNELDIR}/Makefile ]; then \
 		${MAKE} nattpatch${KERNELREL}; \
-	else	echo "Cannot determine Linux kernel version. Perhaps you need to set KERNELSRC? (eg: export KERNELSRC=/usr/src/linux-`uname -r`/)"; exit 1; \
+	else	echo "Cannot determine Linux kernel version. Perhaps you need to set KERNELDIR? (eg: export KERNELDIR=/usr/src/linux-`uname -r`/)"; exit 1; \
 	fi;
 
 sarefpatch26:
@@ -553,7 +553,7 @@ unpatch:
 	exit 1
 
 _unpatch:
-	for f in `find $(KERNELSRC)/. -name '*.preipsec' -print` ; \
+	for f in `find $(KERNELDIR)/. -name '*.preipsec' -print` ; \
 	do \
 		echo "restoring $$f:" ; \
 		dir=`dirname $$f` ; \
@@ -592,11 +592,11 @@ ipkg_strip:
 
 ipkg_module:
 	@echo "Moving ipsec.o into temporary location..."
-	KV=$(shell ${KVUTIL} ${KERNELSRC}/Makefile) && \
+	KV=$(shell ${KVUTIL} ${KERNELDIR}/Makefile) && \
 	mkdir -p $(LIBRESWANSRCDIR)/packaging/ipkg/kernel-module/lib/modules/$$KV/net/ipsec
-	KV=$(shell ${KVUTIL} ${KERNELSRC}/Makefile) && \
+	KV=$(shell ${KVUTIL} ${KERNELDIR}/Makefile) && \
 	cp ${LIBRESWANSRCDIR}/modobj*/ipsec.[k]o $(LIBRESWANSRCDIR)/packaging/ipkg/kernel-module/lib/modules/$$KV/net/ipsec/
-	KV=$(shell ${KVUTIL} ${KERNELSRC}/Makefile)
+	KV=$(shell ${KVUTIL} ${KERNELDIR}/Makefile)
 
 ipkg_clean:
 	rm -rf $(LIBRESWANSRCDIR)/packaging/ipkg/kernel-module/
diff --git a/Makefile.inc b/Makefile.inc
index 5ceb09d..19c797e 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -139,19 +139,19 @@ RCDIR?=$(DESTDIR)$(FINALRCDIR)
 
 # this is a hack using the wildcard to look for existence of a file/dir
 ifneq ($(wildcard /usr/src/linux-2.6),)
-KERNELSRC?=/usr/src/linux-2.6
+KERNELDIR?=/usr/src/linux-2.6
 else
 ifneq ($(wildcard /usr/src/linux-2.4),)
-KERNELSRC?=/usr/src/linux-2.4
+KERNELDIR?=/usr/src/linux-2.4
 else
-KERNELSRC?=/lib/modules/$(shell uname -r)/build
+KERNELDIR?=/lib/modules/$(shell uname -r)/build
 endif
 endif
 
 # where kernel configuration outputs are located
-KCFILE=$(KERNELSRC)/.config
-ACFILE=$(KERNELSRC)/include/linux/autoconf.h
-VERFILE=$(KERNELSRC)/include/linux/version.h
+KCFILE=$(KERNELDIR)/.config
+ACFILE=$(KERNELDIR)/include/linux/autoconf.h
+VERFILE=$(KERNELDIR)/include/linux/version.h
 
 # where KLIPS kernel module is install
 OSMOD_DESTDIR?=net/ipsec
diff --git a/Makefile.top b/Makefile.top
index cabbdb2..1094c60 100644
--- a/Makefile.top
+++ b/Makefile.top
@@ -18,11 +18,11 @@
 PATCHES=linux
 # where KLIPS goes in the kernel
 # note, some of the patches know the last part of this path
-KERNELKLIPS=$(KERNELSRC)/net/ipsec
-KERNELCRYPTODES=$(KERNELSRC)/crypto/ciphers/des
-KERNELLIBFREESWAN=$(KERNELSRC)/lib/libfreeswan
-KERNELLIBZLIB=$(KERNELSRC)/lib/zlib
-KERNELINCLUDE=$(KERNELSRC)/include
+KERNELKLIPS=$(KERNELDIR)/net/ipsec
+KERNELCRYPTODES=$(KERNELDIR)/crypto/ciphers/des
+KERNELLIBFREESWAN=$(KERNELDIR)/lib/libfreeswan
+KERNELLIBZLIB=$(KERNELDIR)/lib/zlib
+KERNELINCLUDE=$(KERNELDIR)/include
 
 MAKEUTILS=packaging/utils
 ERRCHECK=${MAKEUTILS}/errcheck
-- 
1.7.6

