Subject: Re: ufs includes in src/tools/compat
To: Darrin B. Jewell <dbj@netbsd.org>
From: Luke Mewburn <lukem@netbsd.org>
List: tech-toolchain
Date: 05/08/2003 14:36:49
On Wed, May 07, 2003 at 10:36:44PM -0400, Darrin B. Jewell wrote:
  | 
  | While building our toolchain for cross compiling from MacOS X,
  | I discovered a bug in the December Dev Tools supplied by apple.
  | [* see the end of this mail for a description of the bug]
  | 
  | I include patches below which work around this bug and which I think
  | are a cleaner construct than that which is currently in our
  | src/tools makefiles.  Instead of symlinking the ufs include files
  | into the build directory when building nbinstallboot and nbmakefs,
  | I added reachover include files in src/tools/compat/ufs.
  | 
  | Could someone please review and comment on the following patch before
  | I commit it?  (It creates new directories under src/tools/compat/ufs
  | in the cvs repository, so it can't be trivially backed out if its the
  | wrong thing.)

I haven't had a chance to look at this fully, but what are the
implications of using #includes like this unless the source files are
explicitly in the same "relative" location?
Does this work for objdirs which are done with MAKEOBJDIRPREFIX or
MAKEOBJDIR (instead of symlinks or local builds)?

An alternative is to have the tools/compat Makefile populate the
objdir of tools/compat/include with a subdir heirarchy and symlinks
to only the files that you want to pull in that way.



  | 
  | Darrin
  | 
  | --- /dev/null	Thu May  8 01:00:27 2003
  | +++ src/tools/compat/ufs/ffs/fs.h	Fri May  2 16:14:19 2003
  | @@ -0,1 +1,4 @@
  | +/*	$NetBSD: $	*/
  | +
  | +#include "../../../../sys/ufs/ffs/fs.h"
  | --- /dev/null	Thu May  8 01:00:27 2003
  | +++ src/tools/compat/ufs/ffs/ffs_extern.h	Fri May  2 16:14:14 2003
  | @@ -0,1 +1,4 @@
  | +/*	$NetBSD: $	*/
  | +
  | +#include "../../../../sys/ufs/ffs/ffs_extern.h"
  | --- /dev/null	Thu May  8 01:00:27 2003
  | +++ src/tools/compat/ufs/ufs/ufs_bswap.h	Fri May  2 16:14:04 2003
  | @@ -0,1 +1,4 @@
  | +/*	$NetBSD: $	*/
  | +
  | +#include "../../../../sys/ufs/ufs/ufs_bswap.h"
  | --- /dev/null	Thu May  8 01:00:27 2003
  | +++ src/tools/compat/ufs/ufs/dinode.h	Fri May  2 16:13:41 2003
  | @@ -0,1 +1,4 @@
  | +/*	$NetBSD: $	*/
  | +
  | +#include "../../../../sys/ufs/ufs/dinode.h"
  | --- /dev/null	Thu May  8 01:00:27 2003
  | +++ src/tools/compat/ufs/ufs/dir.h	Fri May  2 16:13:58 2003
  | @@ -0,0 +1,3 @@
  | +/*	$NetBSD: $	*/
  | +
  | +#include "../../../../sys/ufs/ufs/dir.h"
  | Index: src/tools/installboot/Makefile
  | ===================================================================
  | RCS file: /cvsroot/src/tools/installboot/Makefile,v
  | retrieving revision 1.7
  | diff -u -u -r1.7 Makefile
  | --- src/tools/installboot/Makefile	2002/12/08 20:20:01	1.7
  | +++ src/tools/installboot/Makefile	2003/05/08 00:48:01
  | @@ -3,15 +3,7 @@
  |  HOSTPROGNAME=	${_TOOL_PREFIX}installboot
  |  HOST_SRCDIR=	usr.sbin/installboot
  |  
  | -DPSRCS+=	ufs.stamp
  |  HOST_CPPFLAGS+=	-I. -I${.CURDIR} -I${.CURDIR}/../mips-elf2ecoff
  | -CLEANFILES+=	ufs
  |  
  |  .include "${.CURDIR}/../Makefile.host"
  |  
  | -$(OBJS): ufs.stamp
  | -
  | -ufs.stamp:
  | -	-rm -f ufs
  | -	ln -f -s ${.CURDIR}/../../sys/ufs ufs
  | -	@touch $@
  | Index: src/tools/makefs/Makefile
  | ===================================================================
  | RCS file: /cvsroot/src/tools/makefs/Makefile,v
  | retrieving revision 1.6
  | diff -u -u -r1.6 Makefile
  | --- src/tools/makefs/Makefile	2002/12/08 20:20:02	1.6
  | +++ src/tools/makefs/Makefile	2003/05/08 00:48:01
  | @@ -3,15 +3,7 @@
  |  HOSTPROGNAME=	${_TOOL_PREFIX}makefs
  |  HOST_SRCDIR=	usr.sbin/makefs
  |  
  | -DPSRCS+=	ufs.stamp
  |  HOST_CPPFLAGS+=	-I.
  | -CLEANFILES+=	ufs
  |  
  |  .include "${.CURDIR}/../Makefile.host"
  |  
  | -$(OBJS): ufs.stamp
  | -
  | -ufs.stamp:
  | -	-rm -f ufs
  | -	ln -f -s ${.CURDIR}/../../sys/ufs ufs
  | -	@touch $@
  | 
  | 
  | 
  | [*] When using cc -no-cpp-precomp, apple's dev tools will
  | prefer subdirectories of /usr/include over directories
  | symlinked into the current directory, even with -I.
  | 
  | The bug in apple's compiler can be demonstrated as such:
  | 
  | $ mkdir foo
  | $ touch foo/time.h
  | $ ln -s foo sys
  | $ echo "#include <sys/time.h>" > testme.c
  | $ cc -E -no-cpp-precomp -I. testme.c
  | 
  | You will notice from the resulting output that it is including
  | /usr/include/sys/time.h rather than ./sys/time.h.
  | Invoking the compiler without -no-cpp-precomp does not
  | produce the problem.
  | 
  | Darrin