Subject: Re: Problem with make DESTDIR=...
To: None <current-users@NetBSD.ORG>
From: Michael Richardson <mcr@sandelman.ottawa.on.ca>
List: current-users
Date: 01/08/1997 18:27:04
-----BEGIN PGP SIGNED MESSAGE-----


  I needed a self-contained development environment for BSDi and SunOS
for the firewalls that I used to work on when I was at Milkyway
Networks. 
  We used BSD make (I look at GNU make, but decided it was overkill).
  My criteria was:
	- no use of environment variables: I tend to work on multiple
	versions in multiple windows, and always edit with
	emacs. Being able to compile anything under Emacs with M-x
	compile is important. While I think *I* can cope with
	different keys for different versions, some of the junior 
	people could not.
	- be able to build at any point in the tree. I don't know
	special for building lower in the tree. I have since seen
	SSLeay is neat in that a make in the tree goes to the top,
	sets the variables and descends. 
	- be able to avoid lots of #ifdef through use of -I${INCLUDEDIR}/${OS}/${MACHINE} type things.

  All of this is easy with some template's, some use of .include "../Makefile.inc"
and the like. 
  The problem was we wanted to keep the templates within the source
tree in order to keep them under revision control. So, we couldn't
leave the including up the tree to get things from the top to find the
make templates in the make templates!
  We wound up putting a standard file called paths.mk in the
/usr/share/mk equivalent. paths.mk did the right .include, and set a
series of variables pointing at the make templates. A Makefile looked
like:

	PROG=foo	
	SRCS=blah.c

	.include <paths.mk>
	.include "${MILKYWAYPROGMK}"
  
  A top level "configure" program did a "pwd" and stuck the result
into a top level "Makefile.inc". Each "Makefile.inc" included
"../Makefile.inc" except for the top one. 
  ${TOPDIR}/Makefile.inc had something like:
	TOPDIR=/milkyway/devel5/mcr/v2
	DESTDIR=${TOPDIR}/${MACHINE}/export
	OBJDIR=${TOPDIR}/${MACHINE}/obj
	INCLUDEDIR=${TOPDIR}/include

  paths.mk might do:
	MILKYWAYPROGMK=${INCLUDEDIR}/make/${MACHINE}/milkyway.prog.mk

  I modified make to chdir to obj.${MACHINE}. I think NetBSD's make
does this as well. I also enforced use of objdir, which took some
tricks to get rid of /a or /tmp_mnt, etc.. since we use the automounter.
  [in retrospect, it should have been obj.${OS}.${MACHINE} because we
wound up dealing with UnixWare/i386 vs BSDi/i386 and Sparc/SunOS vs
Sparc/Solaris). Also, the makefiles were really OS specific not really
machine specific, but that was two and half years ago...]

   :!mcr!:            |  Network security consulting and 
   Michael Richardson |      contract programming
 WWW: mcr@sandelman.ottawa.on.ca. PGP key available.

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: latin1
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQBVAwUBMtQtO9TTll4efmtZAQFG/wH+I7DbOqz2zZs8xKHhAZ/54Sl5fdB61pZG
qdYiKRb25NLFLuSxVOxLUF8CIJ1gNBIuaTl6uQcBoMsSozw+L4zVGA==
=7EW1
-----END PGP SIGNATURE-----