UPDATING revision 1.10
1$NetBSD: UPDATING,v 1.10 2001/01/15 15:03:38 christos Exp $
2
3This file is intended to be a brief introduction to the build
4process and a reference on what to do if something doesn't work.
5
6For a more detailed description see Makefile.
7
8Recent changes:
9^^^^^^^^^^^^^^^
10
1120010114:
12	introduce .if commands(target) in make(1). You need to
13	bring everything up-to-date first, then without installing
14	anything make and install in /usr/bin/make, then proceed
15	with make build.
16
1720010101:
18	bsd.subdir.mk committed 20001230 had a bug which caused
19	afterinstall targets to run too soon; update again.
20
2120001230:
22	New share/mk files needed to support .WAIT in SUBDIR variables.
23	If you get make errors, 
24		(cd share/mk; make install)
25	Also, PRINTOBJDIR has changed and is now used more heavily.
26
2720001019:
28	The `ca' device driver has been replaced by `ld'; although the
29	major and minor numbers haven't changed, you should update your /dev
30	directory.
31
3220000929:
33	The following make directives are obsoleted.
34	MKCRYPTO_RSA NOCRYPTO_RSA NOCRYPTO_RC5 NOCRYPTO_IDEA 
35	By default, RSA is built into libcrypto.  IDEA and RC5 will not be
36	bulit into libcrypto.  By using MKCRYPTO_{RC5,IDEA}, you can build
37	additional library libcrypto_{idea,rc5}.
38
3920000623:
40	MKCRYPTO and friends added to share/mk/bsd.own.mk.
41	'cd share/mk ; make install' needed before make build.
42
43
44Hints for a more successful build:
45^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46    Build a new kernel first:
47	This makes sure that any new system calls or features
48	   expected by the new userland will be present.  This
49	   helps to avoid critical errors when upgrading.
50    Use object directories:
51	This helps to keep stale object
52	   files from polluting the build if a Makefile "forgets"
53	   about one.  It also makes it easier to clean up after
54	   a build.  It's also necessary if you want to use the
55	   same source tree for multiple machines.
56	   To use object directories:
57	    a) cd /usr/src ; make cleandir
58	    b) Add "OBJMACHINE=yes" to /etc/mk.conf
59	    c) Add "MKOBJDIRS=yes" to /etc/mk.conf
60	    d) cd /usr/src ; make build
61	   Note that running "make obj" in a directory will create
62	   in obj.$MACHINE directory.
63    Build to a DESTDIR:
64	This helps to keep old
65	   installed files (especially libraries) from interfering
66	   with the new build.
67	   To build to a DESTDIR, set the DESTDIR environment
68	   variable before running make build.  It should be set to
69	   the pathname of an initially empty directory.
70	   Problems: you might need to update critical utilities
71		without using DESTDIR since nothing is executed
72		from what is installed in DESTDIR.
73		(See critical utils, below)
74    Build often:
75	This keeps critical utilities current enough to not choke
76	on any other part of the source tree that depends on up to
77	date functionality.
78 
79What to do if things don't work:
80^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
81When things don't work there is usually a few things that commonly
82should be done.
83    1)	make includes
84	This should be done automatically by make build.
85    2)  cd share/mk && make install
86	Again, automatically done by make build.
87
88Failsafe rebuild of a small part of the tree:
89^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
90To make sure you rebuild something correctly you want to do
91something like the following:
92    1)  Make sure the includes and .mk files are up to date.
93    2)  Make sure any program used to build the particular
94	utility is up to date.  (yacc, lex, etc...)
95    3)  cd ...path/to/util...
96	make cleandir
97	rm ...all obj directories...
98	make cleandir			# yes, again
99	make obj
100	make depend && make
101
102Failsafe rebuild of the entire tree:
103^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104If you really want to make sure the source tree is clean and
105ready for a build try the following.  Note that sourcing /etc/mk.conf
106(a make(1) Makefile) in this manner is not right, and will not work
107for anyone who uses any make(1) features in /etc/mk.conf.
108
109---cut here---
110#!/bin/sh
111. /etc/mk.conf
112
113if [ -z $BSDSRCDIR ] ; then
114    BSDSRCDIR=/usr/src
115fi
116if [ \! -d $BSDSRCDIR ] ; then
117    echo Unable to find sources
118    exit 1
119fi
120find $BSDSRCDIR -name \*.o -o -name obj.\* -o -name obj -exec rm \{\} \;
121
122if [ -z $BSDOBJDIR ] ; then
123    BSDOBJDIR=/usr/obj
124fi
125if [ -d $BSDOBJDIR ] ; then
126    rm -rf $BSDOBJDIR
127fi
128
129cd $BSDSRCDIR && make cleandir
130
131---cut here---
132
133Critical utilities:
134^^^^^^^^^^^^^^^^^^^
135	gnu/usr.bin/egcs
136	usr.bin/compile_et
137	usr.bin/make
138	usr.bin/yacc
139	usr.bin/lex
140	usr.sbin/config
141
142Other problems and possibly solutions:
143^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144Symptom:Unreasonable compiler errors.
145Fix:	Rebuild gnu/usr.bin/egcs
146
147Symptom:Complaints involving a Makefile.
148Fix:	Make sure .mk files are up to date.
149	cd share/mk && make install
150Fix:	Rebuild usr.bin/make
151
152Symptom:Kernel `config' fails to configure any kernel, including GENERIC.
153Fix:	Rebuild usr.sbin/config
154
155Symptom:
156Fix:	Rebuild usr.bin/yacc
157
158Symptom:
159Fix:	Rebuild usr.bin/lex
160
161Symptom:
162Fix:	rm /usr/lib/libbfd.a
163
164Symptom:Obsolete intermediate files are used during compilation
165Fix:	Try the following sequence of commands in the directory in question.
166	make cleandir; rm `make print-objdir`; make cleandir; make obj
167	(If you built the tree without "make obj" in the past, obsolete files
168	may remain.  The command tries to clean everything up)
169
170Symptom:.../sysinst/run.c:xx: warning: initialization from incompatible pointer type
171Fix:	Rebuild and install usr.bin/menuc
172