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