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