Subject: Success building everything (sans kernel) into $DESTDIR!
To: None <current-users@NetBSD.ORG>
From: Greg Earle <earle@isolar.Tujunga.CA.US>
List: current-users
Date: 06/05/1996 00:51:29
I've posted several messages recently concerning problems doing "make build"
with DESTDIR set. I'm happy to report that I was finally able to get it to
work completely earlier today.
Several people had asked me privately how I was doing it, so I thought I'd
mention what it took (hit "d" or "n" here if not interested ... ):
[This is on a SPARCstation 2 running pk's April 12th 1.1B snapshot (kernel and
userland).]
-------------------- >8 snip ... valuable coupon ... snip 8< -----------------
First, define $DESTDIR. (I used "setenv DESTDIR /usr/local/.build" as that
put it on a disk which wasn't my /usr/src disk, and it wasn't my disk
where I had re-pointed "/usr/obj".)
I then created ${DESTDIR}/usr/share/mk and went to /usr/src/share/mk and did a
"make install" with $DESTDIR set. This pre-populates ${DESTDIR}/usr/share/mk,
which is a necessary preliminary step.
I had to change 4 Makefiles a priori due to hiccups with previous attempts:
/usr/src/domestic/lib/libkadm/Makefile
/usr/src/domestic/lib/libkrb/Makefile
/usr/src/domestic/lib/libss/Makefile
/usr/src/usr.bin/vi/build/Makefile
In the 3 domestic libs, I had to change the "beforeinstall:" target to instead
be "includes:". See my previous post to current-users and replies as to why.
The usr.bin/vi/build/Makefile contained an "afterinstall:" target to install
the catalogs into "$(datadir)/vi/catalog". Unfortunately, "datadir" was
hard-coded to be "/usr/share", so the "make install" phase tried to install
them into /usr/share/vi/catalog, which didn't exist in my 1.1B system.
I changed "datadir= /usr/share" to "datadir= ${DESTDIR}/usr/share"
to work around this (John Kohl told me this has since been fixed).
With that, off we go! I copy /usr/src/Makefile to /usr/src/Makefile.build
and make a few changes:
(1) I use "make obj", so it's peppered with "&& ${MAKE} obj" target additions
(2) Wrap the "beforeinstall:" target inside ".ifnmake build"/".endif"
(3) Replicate the "make distrib-dirs" segment of the "beforeinstall:" target
at the beginning of the "build:" target:
build:
.ifndef DESTDIR
(cd ${.CURDIR}/etc && ${MAKE} obj && ${MAKE} DESTDIR=/ distrib-dirs)
.else
(cd ${.CURDIR}/etc && ${MAKE} obj && ${MAKE} distrib-dirs)
.endif
[...]
With these changes, we're ready to roll. One last thing to remember is that
"make" doesn't automatically pick up on $DESTDIR being set and thus
re-target where it looks for system .mk files (which is probably a Good Thing;
maybe you *don't* want it to look elsewhere). Thus, you have to remember to
use make's "-m" option to make it look in ${DESTDIR}/usr/share/mk for the
.mk files.
In other words, at this stage it's
# cd /usr/src
# make -f Makefile.build -m ${DESTDIR}/usr/share/mk build >& make.out &
and sit back and watch the fireworks.
The only errors (warnings, actually) I got from the whole thing were the same
ol' Kerberos-related "test" errors:
[...]
test -L krb_err.et -a ! -e krb_err.et && rm -f krb_err.et
*** Error code 1 (ignored)
test -L kadm_err.et -a ! -e kadm_err.et && rm -f kadm_err.et
*** Error code 1 (ignored)
test -L ss_err.et -a ! -e ss_err.et && rm -f ss_err.et
*** Error code 1 (ignored)
test -L std_rqs.ct -a ! -e std_rqs.ct && rm -f std_rqs.ct
*** Error code 1 (ignored)
test -L kadmin_cmds.ct -a ! -e kadmin_cmds.ct && rm -f kadmin_cmds.ct
*** Error code 1 (ignored)
These have been discussed previously on "current-users".
There were some warnings in /usr/src/lib/libutil (during the "make depend"
stage) and various other places about "util.h: No such file or directory",
but they weren't fatal. This is because my existing 1.1B system doesn't
have <util.h>, and "mkdep" didn't grok this.
Aside/diversion: I wasn't quite sure why this was, because <bsd.sys.mk> adds a
"-nostdinc -idirafter ${DESTDIR}/usr/include" to CFLAGS if $DESTDIR is set.
And bsd.dep.mk's ".depend" target looked like it's supposed to invoke "mkdep"
with $CFLAGS as an argument ... yet in lib/libutil, it got invoked as
"mkdep -a -DLIBC_SCCS /usr/src/lib/libutil/*.c", essentially. In the libutil
Makefile, we have "CFLAGS+=-DLIBC_SCCS". So, the CFLAGS+= addition due to
$DESTDIR doesn't get picked up. This is presumably because <bsd.dep.mk> is
included/evaluated *before* <bsd.sys.mk> in <bsd.prog.mk>. I don't know what
would break if <bsd.sys.mk> was swapped with <bsd.dep.mk> at the end of
<bsd.prog.mk>. (Chris? Christos? Anyone? Bueller?)
Anyway, that's all she wrote, everything else worked like a champ!
Much thanks to all of you who made it possible to build into ${DESTDIR} this
way! I can now do a "normal" build into the system directories and know
that it will work. VERY very cool.
- Greg
P.S. One pet peeve: I had to do this 3 times, because my SPARCstation crashed
twice (while I wasn't around, natch) during the first 2 attempts.
For some reason, the crash messages aren't surviving to get put into
/var/log/messages, and "dmesg" only shows the post-reboot output. pk?
(Yes, I've now enabled crash dumps *grin*)