Subject: Fix to allow relative paths to kernel source
To: None <tech-kern@NetBSD.ORG>
From: Greg Hudson <ghudson@MIT.EDU>
List: tech-kern
Date: 09/21/1996 13:14:20
When the last batch of config(8) changes were checked in, the
"Makefile.inc"s for libkern and libcompat were modified to assume that
$S would be an absolute path, and S was canonicalized in the kernel
Makefile if it wasn't an absolute path.

This has presented problems for some of our developers who want to be
able to move kernel source trees around, use automounters, and so
forth.  I've looked into the problem, and I think it's pretty easy to
solve.  I propose the following three changes (the last of which is
just a cleanup) to fix the problem:

	* Modify the "Makefile.inc"s for libkern and libcompat to work
	  with relative paths as long as they begin with '.' (any
	  relative path can be made to begin with '.').  It turns out
	  that this is a lot easier than I thought; I've included a
	  patch at the end of this message.

	* Modify emitdefs() in usr.sbin/config's mkmakefile.c not to
	  canonicalize S if it doesn't begin with a '/'.  Instead,
	  insert a "./" before the value of S if it does not begin
	  with a '/' or a '.'.  I've included a patch for that too.

	* Remove all of the ".ifndef S" "S!= cd ../../../..; pwd"
	  ".endif" lines in the kernel Makefile templates.  They were
	  put there for compatibility with the NetBSD 1.2 config(8),
	  which is no longer necessary.

These changes will not require port maintainers to do anything new.

I'll commit the first two parts of this change myself in a few days if
I don't hear any objections, and send mail to port-maintainers about
the third item.

*** sys/lib/libkern/Makefile.inc	1996/09/21 07:20:26	1.1
--- sys/lib/libkern/Makefile.inc	1996/09/21 16:00:25
***************
*** 14,20 ****
  	    AS='${AS}' AFLAGS='${AFLAGS}' \
  	    LD='${LD}' STRIP='${STRIP}' \
  	    MACHINE='${MACHINE}' MACHINE_ARCH='${MACHINE_ARCH}' \
! 	    KERNCPPFLAGS='${CPPFLAGS:S@^-I.$@-I${.OBJDIR}@}'
  
  ${KERNLIB}:		.NOTMAIN __always_make_kernlib
  	@echo making sure the kern library is up to date...
--- 14,20 ----
  	    AS='${AS}' AFLAGS='${AFLAGS}' \
  	    LD='${LD}' STRIP='${STRIP}' \
  	    MACHINE='${MACHINE}' MACHINE_ARCH='${MACHINE_ARCH}' \
! 	    KERNCPPFLAGS='${CPPFLAGS:S@^-I.@-I../../.@g}'
  
  ${KERNLIB}:		.NOTMAIN __always_make_kernlib
  	@echo making sure the kern library is up to date...
*** sys/compat/common/Makefile.inc	1996/09/21 07:20:58	1.1
--- sys/compat/common/Makefile.inc	1996/09/21 16:00:18
***************
*** 12,18 ****
  	cd ${COMPATDIR} && MAKEOBJDIR=${COMPATDST} ${MAKE} \
  	    CC='${CC}' CFLAGS='${CFLAGS}' \
  	    LD='${LD}' \
! 	    COMPATCPPFLAGS='${CPPFLAGS:S@^-I.$@-I${.OBJDIR}@}'
  
  ${COMPATLIB}:		.NOTMAIN __always_make_compatlib
  	@echo making sure the compat library is up to date...
--- 12,18 ----
  	cd ${COMPATDIR} && MAKEOBJDIR=${COMPATDST} ${MAKE} \
  	    CC='${CC}' CFLAGS='${CFLAGS}' \
  	    LD='${LD}' \
! 	    COMPATCPPFLAGS='${CPPFLAGS:S@^-I.@-I../../.@g}'
  
  ${COMPATLIB}:		.NOTMAIN __always_make_compatlib
  	@echo making sure the compat library is up to date...
*** lib/libkern/Makefile.inc	1996/09/21 07:20:26	1.1
--- lib/libkern/Makefile.inc	1996/09/21 16:00:25
***************
*** 14,20 ****
  	    AS='${AS}' AFLAGS='${AFLAGS}' \
  	    LD='${LD}' STRIP='${STRIP}' \
  	    MACHINE='${MACHINE}' MACHINE_ARCH='${MACHINE_ARCH}' \
! 	    KERNCPPFLAGS='${CPPFLAGS:S@^-I.$@-I${.OBJDIR}@}'
  
  ${KERNLIB}:		.NOTMAIN __always_make_kernlib
  	@echo making sure the kern library is up to date...
--- 14,20 ----
  	    AS='${AS}' AFLAGS='${AFLAGS}' \
  	    LD='${LD}' STRIP='${STRIP}' \
  	    MACHINE='${MACHINE}' MACHINE_ARCH='${MACHINE_ARCH}' \
! 	    KERNCPPFLAGS='${CPPFLAGS:S@^-I.@-I../../.@g}'
  
  ${KERNLIB}:		.NOTMAIN __always_make_kernlib
  	@echo making sure the kern library is up to date...
*** compat/common/Makefile.inc	1996/09/21 07:20:58	1.1
--- compat/common/Makefile.inc	1996/09/21 16:00:18
***************
*** 12,18 ****
  	cd ${COMPATDIR} && MAKEOBJDIR=${COMPATDST} ${MAKE} \
  	    CC='${CC}' CFLAGS='${CFLAGS}' \
  	    LD='${LD}' \
! 	    COMPATCPPFLAGS='${CPPFLAGS:S@^-I.$@-I${.OBJDIR}@}'
  
  ${COMPATLIB}:		.NOTMAIN __always_make_compatlib
  	@echo making sure the compat library is up to date...
--- 12,18 ----
  	cd ${COMPATDIR} && MAKEOBJDIR=${COMPATDST} ${MAKE} \
  	    CC='${CC}' CFLAGS='${CFLAGS}' \
  	    LD='${LD}' \
! 	    COMPATCPPFLAGS='${CPPFLAGS:S@^-I.@-I../../.@g}'
  
  ${COMPATLIB}:		.NOTMAIN __always_make_compatlib
  	@echo making sure the compat library is up to date...