UPDATING revision 1.6
11.6Sad$NetBSD: UPDATING,v 1.6 2000/10/19 15:02:38 ad Exp $
21.1Sabs
31.1SabsThis file is intended to be a brief introduction to the build
41.1Sabsprocess and a reference on what to do if something doesn't work.
51.1Sabs
61.1SabsFor a more detailed description see Makefile.
71.1Sabs
81.1SabsRecent changes:
91.1Sabs^^^^^^^^^^^^^^^
101.6Sad
111.6Sad20001019:
121.6Sad	The `ca' device driver has been replaced by `lsu'; although the
131.6Sad	major and minor numbers haven't changed, you should update your /dev
141.6Sad	directory.
151.1Sabs
161.4Sitojun20000929:
171.4Sitojun	The following make directives are obsoleted.
181.4Sitojun	MKCRYPTO_RSA NOCRYPTO_RSA NOCRYPTO_RC5 NOCRYPTO_IDEA 
191.4Sitojun	By default, RSA is built into libcrypto.  IDEA and RC5 will not be
201.4Sitojun	bulit into libcrypto.  By using MKCRYPTO_{RC5,IDEA}, you can build
211.4Sitojun	additional library libcrypto_{idea,rc5}.
221.4Sitojun
231.1Sabs20000623:
241.1Sabs	MKCRYPTO and friends added to share/mk/bsd.own.mk.
251.1Sabs	'cd share/mk ; make install' needed before make build.
261.1Sabs
271.1Sabs
281.1SabsHints for a more successful build:
291.1Sabs^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
301.2Smrg    Build a new kernel first:
311.2Smrg	This makes sure that any new system calls or features
321.2Smrg	   expected by the new userland will be present.  This
331.2Smrg	   helps to avoid critical errors when upgrading.
341.1Sabs    Use object directories:
351.1Sabs	This helps to keep stale object
361.1Sabs	   files from polluting the build if a Makefile "forgets"
371.1Sabs	   about one.  It also makes it easier to clean up after
381.1Sabs	   a build.  It's also necessary if you want to use the
391.1Sabs	   same source tree for multiple machines.
401.1Sabs	   To use object directories:
411.1Sabs	    a) cd /usr/src ; make cleandir
421.2Smrg	    b) Add "OBJMACHINE=yes" to /etc/mk.conf
431.2Smrg	    c) Add "MKOBJDIRS=yes" to /etc/mk.conf
441.1Sabs	    d) cd /usr/src ; make build
451.2Smrg	   Note that running "make obj" in a directory will create
461.2Smrg	   in obj.$MACHINE directory.
471.1Sabs    Build to a DESTDIR:
481.1Sabs	This helps to keep old
491.1Sabs	   installed files (especially libraries) from interfering
501.1Sabs	   with the new build.
511.1Sabs	   To build to a DESTDIR, set the DESTDIR environment
521.2Smrg	   variable before running make build.  It should be set to
531.2Smrg	   the pathname of an initially empty directory.
541.1Sabs	   Problems: you might need to update critical utilities
551.1Sabs		without using DESTDIR since nothing is executed
561.1Sabs		from what is installed in DESTDIR.
571.1Sabs		(See critical utils, below)
581.1Sabs    Build often:
591.1Sabs	This keeps critical utilities current enough to not choke
601.1Sabs	on any other part of the source tree that depends on up to
611.1Sabs	date functionality.
621.1Sabs 
631.1SabsWhat to do if things don't work:
641.1Sabs^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
651.1SabsWhen things don't work there is usually a few things that commonly
661.1Sabsshould be done.
671.1Sabs    1)	make includes
681.1Sabs	This should be done automatically by make build.
691.1Sabs    2)  cd share/mk && make install
701.1Sabs	Again, automatically done by make build.
711.1Sabs
721.1SabsFailsafe rebuild of a small part of the tree:
731.1Sabs^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
741.1SabsTo make sure you rebuild something correctly you want to do
751.1Sabssomething like the following:
761.1Sabs    1)  Make sure the includes and .mk files are up to date.
771.1Sabs    2)  Make sure any program used to build the particular
781.1Sabs	utility is up to date.  (yacc, lex, etc...)
791.1Sabs    3)  cd ...path/to/util...
801.1Sabs	make cleandir
811.1Sabs	rm ...all obj directories...
821.1Sabs	make cleandir			# yes, again
831.1Sabs	make obj
841.1Sabs	make depend && make
851.1Sabs
861.1SabsFailsafe rebuild of the entire tree:
871.1Sabs^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
881.1SabsIf you really want to make sure the source tree is clean and
891.2Smrgready for a build try the following.  Note that sourcing /etc/mk.conf
901.2Smrg(a make(1) Makefile) in this manner is not right, and will not work
911.2Smrgfor anyone who uses any make(1) features in /etc/mk.conf.
921.1Sabs
931.1Sabs---cut here---
941.1Sabs#!/bin/sh
951.1Sabs. /etc/mk.conf
961.1Sabs
971.1Sabsif [ -z $BSDSRCDIR ] ; then
981.1Sabs    BSDSRCDIR=/usr/src
991.1Sabsfi
1001.1Sabsif [ \! -d $BSDSRCDIR ] ; then
1011.1Sabs    echo Unable to find sources
1021.1Sabs    exit 1
1031.1Sabsfi
1041.1Sabsfind $BSDSRCDIR -name \*.o -o -name obj.\* -o -name obj -exec rm \{\} \;
1051.1Sabs
1061.1Sabsif [ -z $BSDOBJDIR ] ; then
1071.1Sabs    BSDOBJDIR=/usr/obj
1081.1Sabsfi
1091.1Sabsif [ -d $BSDOBJDIR ] ; then
1101.1Sabs    rm -rf $BSDOBJDIR
1111.1Sabsfi
1121.1Sabs
1131.1Sabscd $BSDSRCDIR && make cleandir
1141.1Sabs
1151.1Sabs---cut here---
1161.1Sabs
1171.1SabsCritical utilities:
1181.1Sabs^^^^^^^^^^^^^^^^^^^
1191.1Sabs	gnu/usr.bin/egcs
1201.3Sitojun	usr.bin/compile_et
1211.1Sabs	usr.bin/make
1221.1Sabs	usr.bin/yacc
1231.1Sabs	usr.bin/lex
1241.2Smrg	usr.sbin/config
1251.1Sabs
1261.1SabsOther problems and possibly solutions:
1271.1Sabs^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1281.1SabsSymptom:Unreasonable compiler errors.
1291.1SabsFix:	Rebuild gnu/usr.bin/egcs
1301.1Sabs
1311.1SabsSymptom:Complaints involving a Makefile.
1321.1SabsFix:	Make sure .mk files are up to date.
1331.1Sabs	cd share/mk && make install
1341.1SabsFix:	Rebuild usr.bin/make
1351.2Smrg
1361.2SmrgSymptom:Kernel `config' fails to configure any kernel, including GENERIC.
1371.2SmrgFix:	Rebuild usr.sbin/config
1381.1Sabs
1391.1SabsSymptom:
1401.1SabsFix:	Rebuild usr.bin/yacc
1411.1Sabs
1421.1SabsSymptom:
1431.1SabsFix:	Rebuild usr.bin/lex
1441.1Sabs
1451.1SabsSymptom:
1461.1SabsFix:	rm /usr/lib/libbfd.a
1471.4Sitojun
1481.4SitojunSymptom:Obsolete intermediate files are used during compilation
1491.4SitojunFix:	Try the following sequence of commands in the directory in question.
1501.4Sitojun	make cleandir; rm `make print-objdir`; make cleandir; make obj
1511.4Sitojun	(If you built the tree without "make obj" in the past, obsolete files
1521.4Sitojun	may remain.  The command tries to clean everything up)
1531.5Swiz
1541.5SwizSymptom:.../sysinst/run.c:xx: warning: initialization from incompatible pointer type
1551.5SwizFix:	Rebuild and install usr.bin/menuc
156