Subject: DESTDIR vs. beforeinstall - Battle of the Titans
To: None <current-users@NetBSD.ORG>
From: Greg Earle <earle@isolar.Tujunga.CA.US>
List: current-users
Date: 05/21/1996 20:55:02
Well, I very nearly got a complete -current "make build" to work using
DESTDIR instead of going for it and overwriting ...

As I mentioned before, to get this off and rolling, I had to remove the
"beforeinstall:" target from /usr/src/Makefile and put it inline as the
first rule in the "build:" target instead:

build:
.ifndef DESTDIR
	(cd ${.CURDIR}/etc && ${MAKE} obj && ${MAKE} DESTDIR=/ distrib-dirs)
.else
	(cd ${.CURDIR}/etc && ${MAKE} obj && ${MAKE} distrib-dirs)
.endif
	(cd ${.CURDIR}/share/mk && ${MAKE} obj && ${MAKE} install)
[...]

This ensures that I have a build tree to install the /usr/share/mk files
and all the includes into.  (Also, if your ${DESTDIR}/usr/share/mk is empty
or non-existant, it won't recognize "beforeinstall:").  I could then
run "make -f Makefile.build -m ${DESTDIR}/usr/share/mk build" and off it went.

Or so I thought.  It trips up because without ${DESTDIR}/usr/share/mk full,
it doesn't know to invoke "-nostdinc -idirafter ${DESTDIR}/usr/include ..."
if $DESTDIR is set.  So I had to run that stage manually anyway.

Anyhow, with this out of the way it was smooth sailing ... until I got
to the Kerberos stuff.  It dies with

cc -O -I/usr/src/domestic/lib/libkadm -I/usr/src/domestic/lib/libkadm/../libkrb/
obj -I/usr/src/domestic/lib/libkadm/obj -I/usr/src/domestic/lib/libkadm/../../in
clude -I/usr/src/domestic/lib/libkadm/../../include/kerberosIV -I/usr/src/domest
ic/lib/libkadm/../../include/ss -Werror -nostdinc -idirafter /usr/local/.build/u
sr/include  -c /usr/src/domestic/lib/libkadm/kadm_cli_wrap.c
/usr/src/domestic/lib/libkadm/kadm_cli_wrap.c:37: kerberosIV/krb_err.h: No such file or directory

This is because /usr/src/domestic/lib/{libkadm,libkrb,libss}/Makefile all
contain essentially

beforeinstall:
	-cd ${.OBJDIR}; cmp -s {kadm,krb,ss}_err.h \
	    ${DESTDIR}/usr/include/kerberosIV/{kadm,krb,ss}_err.h || \
	    install -c -o ${BINOWN} -g ${BINGRP} -m 444 {kadm,krb,ss}_err.h \
	    ${DESTDIR}/usr/include/kerberosIV

i.e. these 3 files don't exist in ${DESTDIR}/usr/include/kerberosIV/ at compile
time.  There is a kludge workaround in the "beforedepend:" target to do a
"ln -s . kerberosIV" so references to "<kerberosIV/foo.h>" might work, but
in this case, kadm_cli_wrap.c is referring to an include file that's over
in another directory alongside .../libkadm.

Is there some way of changing things so that these 3 include files
are installed into ${DESTDIR}/usr/include/kerberosIV first, or, barring that,
some way of telling the Makefile in /usr/src/domestic/lib/libkadm that it
needs to include -I [...]/domestic/lib/libkrb as well?  (It already includes,
strangely enough, /usr/src/domestic/lib/libkadm/../libkrb/obj, which is useless
since it doesn't contain any include files)

	- Greg