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