UPDATING revision 1.5
11.5Swiz$NetBSD: UPDATING,v 1.5 2000/10/14 01:06:55 wiz 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.1Sabs
111.4Sitojun20000929:
121.4Sitojun	The following make directives are obsoleted.
131.4Sitojun	MKCRYPTO_RSA NOCRYPTO_RSA NOCRYPTO_RC5 NOCRYPTO_IDEA 
141.4Sitojun	By default, RSA is built into libcrypto.  IDEA and RC5 will not be
151.4Sitojun	bulit into libcrypto.  By using MKCRYPTO_{RC5,IDEA}, you can build
161.4Sitojun	additional library libcrypto_{idea,rc5}.
171.4Sitojun
181.1Sabs20000623:
191.1Sabs	MKCRYPTO and friends added to share/mk/bsd.own.mk.
201.1Sabs	'cd share/mk ; make install' needed before make build.
211.1Sabs
221.1Sabs
231.1SabsHints for a more successful build:
241.1Sabs^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
251.2Smrg    Build a new kernel first:
261.2Smrg	This makes sure that any new system calls or features
271.2Smrg	   expected by the new userland will be present.  This
281.2Smrg	   helps to avoid critical errors when upgrading.
291.1Sabs    Use object directories:
301.1Sabs	This helps to keep stale object
311.1Sabs	   files from polluting the build if a Makefile "forgets"
321.1Sabs	   about one.  It also makes it easier to clean up after
331.1Sabs	   a build.  It's also necessary if you want to use the
341.1Sabs	   same source tree for multiple machines.
351.1Sabs	   To use object directories:
361.1Sabs	    a) cd /usr/src ; make cleandir
371.2Smrg	    b) Add "OBJMACHINE=yes" to /etc/mk.conf
381.2Smrg	    c) Add "MKOBJDIRS=yes" to /etc/mk.conf
391.1Sabs	    d) cd /usr/src ; make build
401.2Smrg	   Note that running "make obj" in a directory will create
411.2Smrg	   in obj.$MACHINE directory.
421.1Sabs    Build to a DESTDIR:
431.1Sabs	This helps to keep old
441.1Sabs	   installed files (especially libraries) from interfering
451.1Sabs	   with the new build.
461.1Sabs	   To build to a DESTDIR, set the DESTDIR environment
471.2Smrg	   variable before running make build.  It should be set to
481.2Smrg	   the pathname of an initially empty directory.
491.1Sabs	   Problems: you might need to update critical utilities
501.1Sabs		without using DESTDIR since nothing is executed
511.1Sabs		from what is installed in DESTDIR.
521.1Sabs		(See critical utils, below)
531.1Sabs    Build often:
541.1Sabs	This keeps critical utilities current enough to not choke
551.1Sabs	on any other part of the source tree that depends on up to
561.1Sabs	date functionality.
571.1Sabs 
581.1SabsWhat to do if things don't work:
591.1Sabs^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
601.1SabsWhen things don't work there is usually a few things that commonly
611.1Sabsshould be done.
621.1Sabs    1)	make includes
631.1Sabs	This should be done automatically by make build.
641.1Sabs    2)  cd share/mk && make install
651.1Sabs	Again, automatically done by make build.
661.1Sabs
671.1SabsFailsafe rebuild of a small part of the tree:
681.1Sabs^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
691.1SabsTo make sure you rebuild something correctly you want to do
701.1Sabssomething like the following:
711.1Sabs    1)  Make sure the includes and .mk files are up to date.
721.1Sabs    2)  Make sure any program used to build the particular
731.1Sabs	utility is up to date.  (yacc, lex, etc...)
741.1Sabs    3)  cd ...path/to/util...
751.1Sabs	make cleandir
761.1Sabs	rm ...all obj directories...
771.1Sabs	make cleandir			# yes, again
781.1Sabs	make obj
791.1Sabs	make depend && make
801.1Sabs
811.1SabsFailsafe rebuild of the entire tree:
821.1Sabs^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
831.1SabsIf you really want to make sure the source tree is clean and
841.2Smrgready for a build try the following.  Note that sourcing /etc/mk.conf
851.2Smrg(a make(1) Makefile) in this manner is not right, and will not work
861.2Smrgfor anyone who uses any make(1) features in /etc/mk.conf.
871.1Sabs
881.1Sabs---cut here---
891.1Sabs#!/bin/sh
901.1Sabs. /etc/mk.conf
911.1Sabs
921.1Sabsif [ -z $BSDSRCDIR ] ; then
931.1Sabs    BSDSRCDIR=/usr/src
941.1Sabsfi
951.1Sabsif [ \! -d $BSDSRCDIR ] ; then
961.1Sabs    echo Unable to find sources
971.1Sabs    exit 1
981.1Sabsfi
991.1Sabsfind $BSDSRCDIR -name \*.o -o -name obj.\* -o -name obj -exec rm \{\} \;
1001.1Sabs
1011.1Sabsif [ -z $BSDOBJDIR ] ; then
1021.1Sabs    BSDOBJDIR=/usr/obj
1031.1Sabsfi
1041.1Sabsif [ -d $BSDOBJDIR ] ; then
1051.1Sabs    rm -rf $BSDOBJDIR
1061.1Sabsfi
1071.1Sabs
1081.1Sabscd $BSDSRCDIR && make cleandir
1091.1Sabs
1101.1Sabs---cut here---
1111.1Sabs
1121.1SabsCritical utilities:
1131.1Sabs^^^^^^^^^^^^^^^^^^^
1141.1Sabs	gnu/usr.bin/egcs
1151.3Sitojun	usr.bin/compile_et
1161.1Sabs	usr.bin/make
1171.1Sabs	usr.bin/yacc
1181.1Sabs	usr.bin/lex
1191.2Smrg	usr.sbin/config
1201.1Sabs
1211.1SabsOther problems and possibly solutions:
1221.1Sabs^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1231.1SabsSymptom:Unreasonable compiler errors.
1241.1SabsFix:	Rebuild gnu/usr.bin/egcs
1251.1Sabs
1261.1SabsSymptom:Complaints involving a Makefile.
1271.1SabsFix:	Make sure .mk files are up to date.
1281.1Sabs	cd share/mk && make install
1291.1SabsFix:	Rebuild usr.bin/make
1301.2Smrg
1311.2SmrgSymptom:Kernel `config' fails to configure any kernel, including GENERIC.
1321.2SmrgFix:	Rebuild usr.sbin/config
1331.1Sabs
1341.1SabsSymptom:
1351.1SabsFix:	Rebuild usr.bin/yacc
1361.1Sabs
1371.1SabsSymptom:
1381.1SabsFix:	Rebuild usr.bin/lex
1391.1Sabs
1401.1SabsSymptom:
1411.1SabsFix:	rm /usr/lib/libbfd.a
1421.4Sitojun
1431.4SitojunSymptom:Obsolete intermediate files are used during compilation
1441.4SitojunFix:	Try the following sequence of commands in the directory in question.
1451.4Sitojun	make cleandir; rm `make print-objdir`; make cleandir; make obj
1461.4Sitojun	(If you built the tree without "make obj" in the past, obsolete files
1471.4Sitojun	may remain.  The command tries to clean everything up)
1481.5Swiz
1491.5SwizSymptom:.../sysinst/run.c:xx: warning: initialization from incompatible pointer type
1501.5SwizFix:	Rebuild and install usr.bin/menuc
151