UPDATING revision 1.134
1$NetBSD: UPDATING,v 1.134 2005/01/09 07:31:31 christos Exp $
2
3This file (UPDATING) is intended to be a brief reference to recent
4changes that might cause problems in the build process, and a guide for
5what to do if something doesn't work.
6
7For a more detailed description of the recommended way to build NetBSD
8using build.sh, see the BUILDING file.
9
10Note that much of the advice in this UPDATING file was written before
11build.sh existed.  Nevertheless, the advice here may be useful for
12working around specific problems with build.sh.
13
14See also: BUILDING, build.sh, Makefile.
15
16Recent changes:
17^^^^^^^^^^^^^^^
1820050109:
19	Since su is using pam by default now, make sure that you have
20	/etc/pam.d populated (postinstall will do that automatically
21	for you). Otherwise su will fail open (i.e. will not require
22	a password).
23
2420041229:
25	Make had a path resolution bug that manifested itself as not
26	being able to install openpam.3. This bug has been fixed, but
27	you might need to rebuild make manually first to get through
28	the build.
29
3020041201:
31	Userland programs have been changed to use /dev/bpf instead of
32	/dev/bpfX. You need to create that device by installing a new
33	MAKEDEV and running it, or mv /dev/bpf0 /dev/bpf && rm /dev/bpf[0-9]*
34
3520041006:
36
37	A bug was introduced into /bin/sh (var.c rev 1.35) which causes
38	variables to not export correctly to subshells in all cases. This
39	will cause builds to break if that version of /bin/sh is installed
40	on the system. The proper version of /bin/sh can be verified with:
41
42        ident /bin/sh | grep var
43
44	Any /bin/sh w. version 1.35 will not work and needs to be updated
45	before attempting a build.
46	
4720041001:
48	The ipfilter kernel sources moved from sys/netinet to
49	dist/sys/ipf/netinet. Due to the move some Makefile
50	dependencies are now dangling requiring a make cleandir
51	before they work again (kdump, ktruss, rescue, ipf, and
52	ftp-proxy are the victims).
53
5420040715:
55	The rc.d/sendmail script now uses a heuristic to determine
56	if sendmail should be started at boot time.  It checks the
57	contents of /etc/mailer.conf, /etc/mail/submit.cf, and the
58	owner and mode of the sendmail binary to see if any changes
59	to the mail infrastructure have been made.  If no changes
60	are detected, it will start an SMTP listener.
61
62	Setting sendmail=NO in /etc/rc.conf will override this.
63
64	If you are only using sendmail by default and only for
65	local delivery, it is important that you also update your
66	sendmail.cf so that the SMTP listener only listens on the
67	loopback interface.
68
6920040715:
70	The method by which athhal-elf.o gets pulled into i386
71	kernel builds has been changed again.  The latest version
72	of bsd.files.mk is no longer required.
73
7420040621:
75	Due to the recent rototill of tools/compat it's crucial one starts
76	from a clean objdir under tools/*.
77
78	This is mostly due to generated files (yacc and lex sources) needing
79	to be generated with new rules from bsd.hostprog.mk.
80
81	The safest course is to rm -rf all objects under tools before building.
82
8320040516:
84	The end-user modifiable X11 configuration has been moved
85	from /usr/X11R6/lib/X11/<dir> to /etc/X11/<dir>.
86	Ensure that src and xsrc is up to date, and run
87	"make cleandir" in src/x11 before your next build.
88
89	postinstall currently doesn't migrate the files from
90	/usr/X11R6/lib/X11/* to /etc/X11/* although it does
91	detect that this needs to occur, so you'll have to
92	manually move these files yourself.
93
9420040426:
95	Support for the original dynamic sysctl node structure has
96	been removed in favor of the newer layout.  This affects
97	consumers of the create and delete interface, as well as
98	the dynamic discovery mechanism.  This is believed only to
99	be the sysctl(8) binary itself, at this point in time, so
100	the only effect of this should be that a sysctl binary
101	built from sources dated between 2003/12/04 and 2004/03/24
102	will not work on a kernel built from sources dated after
103	2004/04/25.  If you need a new sysctl binary but build.sh
104	does not work, make sure that your revision of
105	src/sys/sys/sysctl.h is 1.112 (or later), and then the
106	do the following:
107
108	cd /usr/src (or wherever your source tree is)
109	make USETOOLS=no includes
110	cd lib/libc
111	make USETOOLS=no dependall install
112	cd ../../sbin/sysctl
113	make USETOOLS=no dependall install
114
115	If you are using older sysctl binary, GNU autoconf would fail to
116	identify your machine architecture, and tries to build binary for
117	"unknown-unknown-netbsd20F" or something like that.  if that happens,
118	make sure to follow the above steps.
119
12020040425:
121	The ffs superblock issues listed below under 20040109 and 20030402
122	are now automatically addressed by the /etc/rc.d/fixsb script or by
123	sysinst when it checks a a filesystem. The manual fsck_ffs -b16 -c4
124	invocation mentioned below will continue to work and is now
125	automated by those scripts.  Note that under certain circumstances,
126	affected filesystems upgraded to a -current kernel first before
127	upgrading their userland with the fixsb and fsck_ffs fixes may
128	encounter a 'freeing free inode' panic when writing to the affected
129	filesystem, so it is a good idea to repair the filesystem as soon as
130	possible.  For more details on the fixsb script, see pr install/25138.
131
13220040418:
133	statfs(2) and friends have been replaced with statvfs(2). Before
134	installing a newly build userland make sure that you are running
135	a newly built kernel with COMPAT_20 set. In addition your libc
136	build might not work (undefined SYS_statfs symbol) because make
137	clean does not know how to remove files it does not know about
138	anymore. Manually remove all generated .S sources and objects
139	from the libc build directory.
140
14120040326:
142	The method by which athhal-elf.o gets pulled into i386 kernel builds
143	has been changed. The file is now stored as a uuencoded file in CVS
144	and the generated Makefile will use the new .uue rules from bsd.file.mk
145	to build it.
146
147	This means you must have the latest bsd.files.mk installed when
148	building a kernel without USETOOLS=yes.
149
15020040318:
151	A bug in the cgd(4) blowfish code was corrected, without
152	provision of backwards compatibility, after several public
153	notices over several months. Users of cgd with blowfish cipher
154	ONLY must dump their data before updating their kernels, and
155	recreate cgd's and restore data using the new kernel. See
156	(recent message to current-users, URL when mail-index has updated)
157
15820040313:
159	On acorn32, the opms and qms drivers have been withdrawn, and
160	the old wsqms driver is now called qms.  Kernel config files
161	will need updating.  See the ones in sys/arch/acorn32/conf
162	for examples.
163
16420040125:
165	On acorn32, the beep and sysbeep devices are no longer
166	needed, and will need to be deleted from kernel configuration
167	files.
168
16920040109:
170	Compatibility for old ffs superblock layouts has been
171	added, and the restrictive fsck checks have been reenabled
172	when using those layouts.  If you have been using -current
173	since 20030402, you may find that fsck again signals fatal
174	superblock mismatches.  To repair, make sure you have
175	an updated fsck_ffs and then you can use fsck_ffs -b 16 -c 4
176	to complete the filesystem upgrade.  A message has
177	been added to the kernel which should detect this problem.
178	See the following discussion for more information:
179	http://mail-index.NetBSD.org/current-users/2004/01/11/0022.html
180
18120031203:
182	New binutils builds may fail due to old dependencies.
183	It's necessary to "make cleandir" to ensure that
184	the dependencies will be rebuilt correctly.
185
18620031111:
187	A newer mkdep is needed.  Error noting that is
188		cc: Ambiguous abbreviation --
189
19020031008:
191	/usr/include/sys/disklabel_mbr.h was removed.
192	It's necessary to "make cleandir" to ensure that
193	the dependencies will be rebuilt correctly.
194
19520031007:
196	A sign exension bug was fixed which set all the high bits
197	of our newly expanded ffs fs_flags.  This should only
198	affect users who installed or upgraded in September of 2003.
199	A small utility program was posted to tech-kern which
200	should fix this problem, and a warning message was added
201	to the kernel which should discover and warn about it.  See
202	http://mail-index.NetBSD.org/tech-kern/2003/10/07/0005.html
203
20420030906:
205	With the addition of siginfo support the old signal trampoline
206	code has been deprecated to COMPAT_16. Make sure that your running
207	kernel has COMPAT_16 enabled before building userland.
208
20920030801:
210	With the new openssl, there is some header and library shuffling.
211	rm -f /usr/include/des.h /usr/include/kerberosIV/* /lib/libdes* \
212	/usr/lib/libdes* before building.
213
21420030703:
215	Texinfo was updated to 4.6.  To avoid failures when trying to
216	build the included texinfo files, do:
217
218	cd src/gnu/usr.bin/texinfo
219	make MKINFO=no dependall install
220
22120030630:
222	Groff was updated to 1.19; it's probably necessary to do
223		cd share/mk && make install
224		cd src/gnu/usr.bin/groff
225		make MKMAN=no dependall install
226	(untested).
227
22820030516:
229	Due to bugs in the export handling code, invalid export lines
230	were accepted before and caused the kernel to panic when
231	mountd got restarted because it freed memory that had already
232	been freed. This has been fixed and the kernel checks
233	export addresses very strictly. If you upgrade your kernel,
234	make sure you also upgrade mountd, because if your export
235	file contains lines with an old inet4 address syntax (i.e.
236	a.b.c or a.b or a), they will get rejected by the new kernel.
237
23820030402:
239	The superblock layout for FFS was changed.  If you have 1.6
240	fsck binaries, they will signal a fatal superblock mismatch
241	with the first alternate, because they compare too many
242	fields (even ones that aren't useful).  If possible, upgrade
243	your fsck_ffs binary before using a new kernel.
244	None of this signals actual filesystem damage.
245
24620030324:
247	sendmail version 8.12.8 was imported.  Since sendmail is
248	now setgid to the smmsp group, and runs in "collection"
249	mode for most common activities, there is a new config
250	file called submit.cf that needs to live in /etc/mail.
251	The generic submit.cf sample in /usr/share/sendmail/cf
252	is named netbsd-msp.cf.  Upgrading your regular sendmail
253	configuration file is also strongly advised.
254
255	See the section named "MESSAGE SUBMISSION PROGRAM" in
256	the updated /usr/share/sendmail/README file for more
257	information.
258
25920030117:
260	Texinfo was updated to 4.3.  To avoid failures when trying to
261	build the included texinfo files, do:
262
263	cd src/gnu/usr.bin/texinfo
264	make MKINFO=no dependall install
265
26620021223:
267	The METALOG format changed slightly, to remove the leading
268	"${DESTDIR}" from path names.
269	This only affects people building with UNPRIVED.
270	For complete safety, remove the DESTDIR entirely and
271	update tools/mtree, before running make build.
272
27320021219:
274	CVS repository layout was changed.  See the following for details
275	if you are using (anonymous) cvs to update your tree.
276
277	http://mail-index.NetBSD.org/netbsd-announce/2002/12/19/0000.html
278
27920021219:
280	install(1) had a '-N dbdir' option added, to specify an
281	alternate location to look up users & groups (instead
282	of the host system passwd(5) and group(5) databases).
283
284	The build system was modified to take advantage of
285	this option (using ${NETBSDSRCDIR}/etc), so if you
286	use USETOOLS==no, you may have to rebuild and
287	reinstall usr.bin/xinstall first.
288
28920021130:
290	fparseln(3) moved from libutil to libc.
291	If building to DESTDIR=/, reinstall the includes
292	and rebuild libc:
293		make includes
294		make do-lib-libc
295	If using build.sh, "cd tools/compat && make clean"
296	before rebuilding the tools.
297
29820021126:
299	The mk.conf(5) variable SYS_INCLUDE has been deprecated,
300	including the optional "SYS_INCLUDE=symlinks" support.
301	All header files, including <sys/*.h> are copied into
302	/usr/include.
303
30420021121:
305	The C run-time support files crtbegin.o and crtend.o
306	(and their companions crtbeginS.o and crtendS.o) were
307	split up, with new crti.o and crtn.o files resulting.
308	This means that libtool needs to be rebuilt once the
309	new libraries are installed.  The process of rebuilding
310	libtool will cause it to automatically notice the new
311	required files, but it *must* be rebuilt in order to
312	do this.
313
314	An out-of-date libtool will result in shared libraries
315	which lack _init() and _fini() routines, which means that
316	their global contructors/destructors will not be invoked.
317
31820021121:
319	A bug related to how ARM ELF objects were tagged has been
320	corrected.
321
322	NetBSD ARM ELF uses the soft-VFP floating point model by
323	default.  However, the assembler lacked support for marking
324	objects as using the VFP floating point format, and the
325	compiler was not properly passing the flag indicating "soft-VFP"
326	to the assembler.
327
328	Unfortunately, this means that the linker will now consider
329	old (i.e. not marked "softvfp") NetBSD ARM ELF objects to be
330	incompatible with new (properly marked) objects.
331
332	The problem will only manifest itself if you attempt to compile
333	a new program using the fixed toolchain, and link that program
334	against old libraries which do not have the proper "softvfp"
335	markings.  ALL OF YOUR EXISTING BINARIES AND SHARED LIBRARIES
336	WILL CONTINUE TO WORK PROPERLY.
337
338	The only work-around for the problem is to recompile all of
339	the libraries on the system.  The easiest way to do this for
340	system libraries is to install a binary snapshot; they are
341	generally available on releng.NetBSD.org.  Any packages you
342	have installed which supply libraries will have to be recompiled
343	if you wish to link new programs against those libraries.
344
345	If you have questions about this matter, please contact
346	port-arm@NetBSD.org.
347
34820021011:
349	Systrace has been improved to support privilege elevation.
350	Updating the kernel requires the userland part of systrace
351	to be rebuilt.
352
35320021010:
354	The config(8) grammar was changed to allow options to register
355	dependencies on attributes, as well as other options.  Users
356	must update and reinstall usr.sbin/config before building a new
357	kernel.
358
35920021009:
360	A new attribute dependency syntax was introduced to config(8),
361	which is now used by the SCSI configuration description.  Users
362	must update and reinstall usr.sbin/config before building a new
363	kernel.
364
36520021003:
366	Several changes have been made to the autoconfiguration
367	framework.  Users must update and reinstall usr.sbin/config
368	before building a new kernel.
369
37020021001:
371	The i386mp branch has been merged.  To compile a kernel, users
372	will need to add the option 'cpu* at mainbus?' to their configuration
373	file.  Multiprocessor kernels will need
374	ioapic*		at mainbus? apid ?
375	options		MULTIPROCESSOR
376	options		COM_MPLOCK
377
37820020922:
379	MKDYNAMICROOT=yes enabled by default, which means that
380	certain shared libraries are installed into /lib, the shared
381	linker is installed into /libexec, and all programs in /bin
382	and /sbin are dynamically linked.
383	If you do not use "make build", you should ensure that
384	you have the libraries and shared linker in the new locations,
385	with:
386		make do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.elf_so
387
38820020917:
389	USE_NEW_TOOLCHAIN has been replaced with:
390	    -	TOOLCHAIN_MISSING -- set to "yes" on platforms for which
391		there is no working in-tree toolchain (hppa, ns32k, sh5,
392		x86_64).
393	    -	EXTERNAL_TOOLCHAIN -- if defined by the user, points to the
394		root of an external toolchain (e.g. /usr/local/gnu).  This
395		enables the cross-build framework even for TOOLCHAIN_MISSING
396		platforms.
397
39820020906:
399	gehenna-devsw has been merged into the trunk. Need to update and
400	reinstall usr.sbin/config before building the kernel.
401
40220020822:
403	Crunched rescue tools (contents of /bin and /sbin, plus others)
404	are now provided in /rescue.
405
406	To ensure that these are built statically linked (no matter
407	what the setting of LDSTATIC is), use a crunchgen(1) built
408	from sources newer than 20020820 (see the next entry).
409
41020020820:
411	crunchgen(1) changed to ensure that the generated program
412	is statically linked.
413
414	Solution: update and reinstall usr.bin/crunch
415
41620020605:
417	smmsp user/group has been added for sendmail.
418
419	Add the following into /etc/group:
420
421	smmsp:*:17:
422
423	and the following to /etc/master.passwd (via vipw):
424
425	smmsp:*:17:17::0:0:Sendmail Message Submission Program:/nonexistent:/sbin/nologin
426
42720020515:
428	sshd user/group has been added.  Need to hand add this in, or sshd
429	will not let you log in (with default, or UsePrivlegeSeparation=yes)
430
431	Add the following into /etc/group:
432
433	sshd:*:16:
434
435	and the following to /etc/master.passwd (via vipw):
436
437	sshd:*:16:16::0:0:& pseudo-user:/var/chroot/sshd:/sbin/nologin
438	
439	Also /var/chroot/sshd directory needs to be present (digged as part of
440	the build process).
441
44220020426:
443	NBUILDJOBS obsoleted in favor of just using -j.
444
44520020426:
446	etc/postinstall added, which performs various checks for 
447	configuration file updates and changes, and can fix most of
448	the problems identified.
449	This should make it much easier to upgrade a system's
450	configuration from earlier systems (as far back as NetBSD 1.5).
451
45220020320:
453	<bsd.lib.mk> needs a new install(1) for its "-a cmd" support.
454	Build and install at usr.bin/xinstall before the build.
455
45620020319:
457	Raw IPv6 socket now makes strict checking for sa_family and sa_len
458	on send(2) operation.  Be sure to have sbin/rtsol and usr.sbin/rtsold
459	newer than November 2001 when you upgrade the kernel.
460
46120020311:
462	ssh configuration files were moved from /etc to /etc/ssh.  Beware
463	if you restart your machine from remote.  Note that sshd.conf needs
464	to be changed (due to the use of "/etc" inside).
465
46620020223:
467	Users of the VAX port will need to rebuild and install gas
468	so it deal with the now present register prefix used in all
469	the VAX assembly files.
470
47120020118:
472	ntpd user/group has been added.  Need to hand add this in or builds
473	will break as mtree aborts early.
474
475	Add the following into /etc/group:
476
477	ntpd:*:15:
478
479	and the following to /etc/master.passwd (via vipw):
480
481	ntpd:*:15:15::0:0:Ntpd pseudo-user:/var/chroot/ntpd:/sbin/nologin
482
48320011207:
484	If you're attempting to build a snapshot on sparc64 and are getting
485	reloc errors from the toolchain groff binary this means your native
486	toolchain has some broken C++ bits.
487
488	To fix:
489
490	Build a new toolchain (i.e. build.sh -t)
491	Use the new toolchain to build and install natively (i.e. /usr/lib)
492
493	gnu/lib/libgcc
494	gnu/lib/libstdc++
495
496	After this a snapshot will be able to be built.
497
49820011201:
499	In order for a sparc64 build to work you must have a working awk. If
500	you've built and installed a system with the new toolchain up to this
501	point you do not have a working awk as its ability to do floating
502	point is broken. 
503
504	To build:
505
506	remake and install gnu/lib/libgcc
507	remake and install gnu/usr.bin/gawk into /usr/bin (make sure it links
508	against the new libgcc.a)
509
51020011128:
511	Kernel config information was changed to use defflag in
512	the various "files" files.  Bug fixes to config(8) are
513	required in order for this to work properly.  Make sure
514	to build and install in usr.sbin/config before attempting
515	to build a new kernel.
516
51720011030:
518	libc/locale/wcstod.c now needs new lint(1). Update lint(1)
519	before building libc.
520
52120011029:
522	The new document BUILDING.mdoc (view with nroff | more, or
523	see pre-generated .txt and .html versions) describes the build
524	procedure in great detail.  BUILDING, and the USE_NEW_TOOLCHAIN
525	build process, are intended in the long run to replace this
526	manual update log.
527
528	Users building a USE_NEW_TOOLCHAIN system should read the
529	BUILDING document for caveats.  Generally, BUILDING supersedes
530	UPDATING for these systems, as tool updating is taken care of
531	by the new build system.
532
53320011028:
534	src/etc/Makefile now needs install to be able to handle
535	symlinks that point to nowhere. A bug in install that
536	prevented this was corrected.
537
538	Solution: update and reinstall usr.bin/xinstall
539	Better Solution: Use the new toolchain and it will just work
540	for you.
541
54220011006:
543	/etc/mtree/NetBSD.dist has been updated to take advantage of
544	absolute path support added to mtree(8). Older mtree(8)s don't
545	understand the format.
546
547	Solution: update and reinstall usr.sbin/mtree
548
54920011004:
550	Crunchgen has been updated to work via reach-over makefiles. Updating
551	is suggested before running a snapshot build
552
55320010915:
554	The new "ubcperf" code committed by Chuck Silvers removed
555	a header file, uvm/uvm_vnode.h.  There may be stale .depend
556	files that still reference this file.
557
558	Solution: "make cleandir && make dependall" in affected
559	directories.
560
56120010803:
562	grep.info is now built from grep.texi using makeinfo.  Since it
563	requires makeinfo v4.0, you need to install new texinfo before
564	building gnu/usr.bin/grep.  To install new texinfo, please follow
565	the instruction described in 20010726 entry.
566
56720010803: 
568	(i386 only): i386 kernel now uses new instructions like
569	`fxsave' which old gas doesn't understand.  To build the
570	kernel successfully, you need to build and install a new toolchain, 
571	(i.e., build.sh -t) or 	(temporarily) comment out "options I686_CPU" 
572	from your kernel configuration until you rebuild your userland.
573	See 20011029 above and BUILDING file in this directory for more information.
574	[updated 20020630 since i386 gas moved when USE_NEW_TOOLCHAIN enabled]
575
57620010731:
577	Bootloader update on ELF platforms.  DDB in kernels from before
578	this will be unable to read symbol tables provided by newer
579	bootloaders.
580
58120010726:
582	Texinfo was updated to 4.0.  To avoid failures when trying to
583	build the included texinfo files, do:
584
585	cd src/gnu/usr.bin/texinfo
586	make MKINFO=no dependall install
587
58820010718:
589	Enabled correct .init/.fini processing in crt0.  The way this
590	was done was to change a -I directive to cc(1), which means
591	make(1) will have a stale dependency (it will be checking the
592	timestamp on the wrong "dot_init.h").
593
594	The symptom you will see is that new programs die with SIGSEGV
595	if you have a stale dependency.
596
597	Solution: "make cleandir" in both lib/csu and libexec/ld.elf_so
598	before starting your build.
599
60020010628:
601	A construct was added to uvm_page.h that uncovered a bug
602	in lint(1).  If you get a warning/error about a non-portable
603	bitfield, update your lint(1) before proceeding.
604
60520010226:
606	Added named user/group to system. Need to hand add this in or builds
607	will break as mtree aborts early.
608
609	To work around add by hand:
610
611	named:*:14:
612
613	to /etc/group and add:
614
615	named:*:14:14::0:0:Named pseudo-user:/var/named:/sbin/nologin
616
617	to master.passwd (use vipw for instance if doing by hand).
618
619	Now a make build should progress.
620
62120010219:
622	get/setprogname() added. Any hostprogs that may use this will need
623	to be bootstrapped manually until the host system is current.
624
625	Known problems: sys/arch/macppc/stand/fixcoff
626			usr.sbin/config (adding -DMAKE_BOOTSTRAP to
627			  CFLAGS and rebuilding should work)
628			usr.sbin/mdsetimage - Build a static copy if
629			  building a snapshot before fully bootstrapped.
630
63120010204:
632	prepare the code to compile with stricter gcc flags. in
633	particular start eliminating redundant declarations. Yacc
634	needs to be installed before make build.
635
63620010114:
637	introduce .if commands(target) in make(1). You need to
638	bring everything up-to-date first, then without installing
639	anything make and install in usr.bin/make, then proceed
640	with make build.
641
64220010101:
643	bsd.subdir.mk committed 20001230 had a bug which caused
644	afterinstall targets to run too soon; update again.
645
64620001230:
647	New share/mk files needed to support .WAIT in SUBDIR variables.
648	If you get make errors, 
649		(cd share/mk; make install)
650	Also, PRINTOBJDIR has changed and is now used more heavily.
651
65220001019:
653	The `ca' device driver has been replaced by `ld'; although the
654	major and minor numbers haven't changed, you should update your /dev
655	directory.
656
65720000929:
658	The following make directives are obsoleted.
659	MKCRYPTO_RSA NOCRYPTO_RSA NOCRYPTO_RC5 NOCRYPTO_IDEA 
660	By default, RSA is built into libcrypto.  IDEA and RC5 will not be
661	built into libcrypto.  By using MKCRYPTO_{RC5,IDEA}, you can build
662	additional library libcrypto_{idea,rc5}.
663
664
665Hints for a more successful build:
666^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
667    Use build.sh, but do not use its "expert mode":
668	This will automatically build the tools in the
669	   correct order, and it will keep the tools and the
670	   new build products from interfering with the running
671	   system.  This will allow you to ignore most of the
672	   other advice in this file.
673    Build a new kernel first:
674	This makes sure that any new system calls or features
675	   expected by the new userland will be present.  This
676	   helps to avoid critical errors when upgrading.
677    Use object directories:
678	This helps to keep stale object
679	   files from polluting the build if a Makefile "forgets"
680	   about one.  It also makes it easier to clean up after
681	   a build.  It's also necessary if you want to use the
682	   same source tree for multiple machines.
683	   To use object directories with build.sh:
684	    a) invoke build.sh with the "-M" or "-O" options.
685	   To use object directories without using build.sh:
686	    a) cd /usr/src ; make cleandir
687	    b) Add "OBJMACHINE=yes" to /etc/mk.conf
688	    c) Add "MKOBJDIRS=yes" to /etc/mk.conf
689	    d) cd /usr/src ; make build
690	   Note that running "make obj" in a directory will create
691	   in obj.$MACHINE directory.
692    Build to a DESTDIR:
693	This helps to keep old installed files (especially libraries)
694	   from interfering with the new build.
695	   To build to a DESTDIR with build.sh, use the "-D" option.
696	   To build to a DESTDIR without using build.sh, set the DESTDIR
697	   environment variable before running make build.  It should be
698	   set to the pathname of an initially empty directory.
699	   Problems: if you do not use build.sh, you might need to
700		update critical utilities without using DESTDIR since
701		nothing is executed from what is installed in DESTDIR.
702		(See critical utils, below.)
703    Build often:
704	This keeps critical utilities current enough to not choke
705	on any other part of the source tree that depends on up to
706	date functionality.  If you use build.sh, you should not have
707	this problem.
708 
709What to do if things don't work:
710^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
711When things don't work there is usually a few things that commonly
712should be done.
713    1)	make includes
714	This should be done automatically by make build.
715    2)  cd share/mk && make install
716	Again, automatically done by make build.
717
718Failsafe rebuild of a small part of the tree:
719^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
720To make sure you rebuild something correctly you want to do
721something like the following:
722    1)  Make sure the includes and .mk files are up to date.
723    2)  Make sure any program used to build the particular
724	utility is up to date.  (yacc, lex, etc...)
725    3)  cd ...path/to/util...
726	make cleandir
727	rm ...all obj directories...
728	make cleandir			# yes, again
729	make obj
730	make depend && make
731
732Failsafe rebuild of the entire tree:
733^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
734If you really want to make sure the source tree is clean and
735ready for a build try the following.  Note that sourcing /etc/mk.conf
736(a make(1) Makefile) in this manner is not right, and will not work
737for anyone who uses any make(1) features in /etc/mk.conf.
738
739---cut here---
740#!/bin/sh
741. /etc/mk.conf
742
743if [ -z $NETBSDSRCDIR ] ; then
744    NETBSDSRCDIR=/usr/src
745fi
746if [ \! -d $NETBSDSRCDIR ] ; then
747    echo Unable to find sources
748    exit 1
749fi
750find $NETBSDSRCDIR -name \*.o -o -name obj.\* -o -name obj -exec rm \{\} \;
751
752if [ -z $BSDOBJDIR ] ; then
753    BSDOBJDIR=/usr/obj
754fi
755if [ -d $BSDOBJDIR ] ; then
756    rm -rf $BSDOBJDIR
757fi
758
759cd $NETBSDSRCDIR && make cleandir
760
761---cut here---
762
763Critical utilities:
764^^^^^^^^^^^^^^^^^^^
765	gnu/usr.bin/egcs
766	usr.bin/compile_et
767	usr.bin/make
768	usr.bin/yacc
769	usr.bin/lex
770	usr.bin/xlint
771	usr.sbin/config
772
773Other problems and possible solutions:
774^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
775Symptom:Unreasonable compiler errors.
776Fix:	Rebuild gnu/usr.bin/egcs
777
778Symptom:Complaints involving a Makefile.
779Fix:	Rebuild usr.bin/make:
780	cd usr.bin/make && make && make install
781	Or, a failsafe method if that doesn't work:
782	cd usr.bin/make && cc *.c */*.c -I . -o make && mv make /usr/bin
783
784Fix:	Make sure .mk files are up to date.
785	cd share/mk && make install
786
787Symptom:Kernel `config' fails to configure any kernel, including GENERIC.
788Fix:	Rebuild usr.sbin/config
789
790Symptom:
791Fix:	Rebuild usr.bin/yacc
792
793Symptom:
794Fix:	Rebuild usr.bin/lex
795
796Symptom:
797Fix:	rm /usr/lib/libbfd.a
798
799Symptom:Obsolete intermediate files are used during compilation
800Fix:	Try the following sequence of commands in the directory in question.
801	make cleandir; rm `make print-objdir`; make cleandir; make obj
802	(If you built the tree without "make obj" in the past, obsolete files
803	may remain.  The command tries to clean everything up)
804
805Symptom:.../sysinst/run.c:xx: warning: initialization from incompatible pointer type
806Fix:	Rebuild and install usr.bin/menuc
807
808Symptom:mklocale not found during build in share/locale/ctype
809Fix:	Build and install usr.bin/mklocale
810
811Symptom:undefined reference to `__assert13' or `__unsetenv13'
812Fix:    Rebuild and install lib/libc
813
814Symptom:usr.sbin/config fails to build.
815Fix:	Try building with -DMAKE_BOOTSTRAP added to CFLAGS in Makefile.
816
817Symptom:undefined reference to `getprogname' or `setprogname'
818Fix:    Rebuild and install lib/libc
819
820Symptom:lint does not understand the '-X' option
821Fix:    May need to build & install libs with NOLINT=1 before rebuilding lint
822