bsd.README revision 1.135
1#	$NetBSD: bsd.README,v 1.135 2003/09/03 05:38:09 lukem Exp $
2#	@(#)bsd.README	8.2 (Berkeley) 4/2/94
3
4This is the README file for the new make "include" files for the BSD
5source tree.  The files are installed in /usr/share/mk, and are, by
6convention, named with the suffix ".mk".
7
8Note, this file is not intended to replace reading through the .mk
9files for anything tricky.
10
11=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
12
13RANDOM THINGS WORTH KNOWING:
14
15The files are simply C-style #include files, and pretty much behave like
16you'd expect.  The syntax is slightly different in that a single '.' is
17used instead of the hash mark, i.e. ".include <bsd.prog.mk>".
18
19One difference that will save you lots of debugging time is that inclusion
20of the file is normally done at the *end* of the Makefile.  The reason for
21this is because .mk files often modify variables and behavior based on the
22values of variables set in the Makefile.  To make this work, remember that
23the FIRST target found is the target that is used, i.e. if the Makefile has:
24
25	a:
26		echo a
27	a:
28		echo a number two
29
30the command "make a" will echo "a".  To make things confusing, the SECOND
31variable assignment is the overriding one, i.e. if the Makefile has:
32
33	a=	foo
34	a=	bar
35
36	b:
37		echo ${a}
38
39the command "make b" will echo "bar".  This is for compatibility with the
40way the V7 make behaved.
41
42It's fairly difficult to make the BSD .mk files work when you're building
43multiple programs in a single directory.  It's a lot easier to split up the
44programs than to deal with the problem.  Most of the agony comes from making
45the "obj" directory stuff work right, not because we switched to a new version
46of make.  So, don't get mad at us, figure out a better way to handle multiple
47architectures so we can quit using the symbolic link stuff.  (Imake doesn't
48count.)
49
50The file .depend in the source directory is expected to contain dependencies
51for the source files.  This file is read automatically by make after reading
52the Makefile.
53
54The variable DESTDIR works as before.  It's not set anywhere but will change
55the tree where the file gets installed.
56
57The profiled libraries are no longer built in a different directory than
58the regular libraries.  A new suffix, ".po", is used to denote a profiled
59object, and ".so" denotes a shared (position-independent) object.
60
61There are various make variables used during the build.  Basic rule for
62the variable naming scheme is as follows:
63
64MKxxx		Can be set to "no" to disable functionality, or
65		"yes" to enable it.
66		Usually defaults to "yes", although some variables
67		default to "no".
68		Due to make(1) implementation issues, if a temporary
69		command-line override of a mk.conf or <bsd.own.mk> setting
70		is required whilst still honouring a particular
71		Makefile's setting of MKxxx, use
72			env MKxxx=value make
73		instead of
74			make MKxxx=value
75
76NOxxx		If defined, disables a feature.
77		Not intended for users.
78		This is to allow Makefiles to disable functionality
79		that they don't support (such as missing man pages).
80		NOxxx variables must be defined before <bsd.own.mk>
81		is included.
82
83The following variables that control how things are made/installed that
84are not set by default. These should not be set by Makefiles; they're for
85the user to define in MAKECONF (see <bsd.own.mk>, below) or on the make(1)
86command line:
87
88BUILD 		If defined, 'make install' checks that the targets in the
89		source directories are up-to-date and remakes them if they
90                are out of date, instead of blindly trying to install
91                out of date or non-existent targets.
92
93MKBFD		If "no", don't build libbfd, libiberty, or any of the things
94		that depend on them (binutils/gas/ld, gdb, dbsym, mdsetimage).
95		Default: yes
96
97MKCATPAGES	If "no", don't build or install the catman pages.
98		Default: yes
99
100MKCRYPTO	If "no", no cryptography support will be built into the system,
101		and also acts as MKKERBEROS=no MKKERBEROS4=no.
102		Default: yes
103
104MKCRYPTO_IDEA	If not "no", IDEA support will be built into libcrypto_idea.a.
105		Default: no
106
107MKCRYPTO_MDC2	If not "no", MDC2 support will be built into libcrypto_mdc2.a
108		Default: no
109
110MKCRYPTO_RC5	If not "no", RC5 support will be built into libcrypto_rc5.a.
111		Default: no
112
113MKDOC		If "no", don't build or install the documentation.
114		Default: yes
115
116MKDYNAMICROOT	If "no", build programs in /bin and /sbin statically,
117		don't install certain libraries in /lib, and don't
118		install the shared linker into /libexec.
119		Default: yes
120
121MKGCC		If "no", don't build gcc or any of the gcc-related
122		libraries (libg2c, libgcc, libobjc, libstdc++).
123		Default: yes
124
125MKGDB		If "no", don't build gdb.
126		Default: yes
127
128MKHESIOD	If "no", disables building of Hesiod infrastructure
129		(libraries and support programs).
130		Default: yes
131
132MKHOSTOBJ	If "yes", for programs intended to be run on the compile host,
133		the name, release, and architecture of the host operating
134		system will be suffixed to the name of the object directory
135		created by "make obj".
136		Default: no
137
138MKHTML		If "no", don't build or install the html man pages.
139		Default: yes
140
141MKIEEEFP	If "no", don't add code for IEEE754/IEC60559 conformance.
142		Has no effect on most platforms.
143		Default: yes
144
145MKINFO		If "no", don't build or install Info documentation from
146		Texinfo source files.
147		Default: yes
148
149MKKERBEROS4	If "no", disables building of Kerberos v4
150		infrastructure (libraries and support programs).
151		Default: yes
152
153MKKERBEROS	If "no", disables building of Kerberos v5
154		infrastructure (libraries and support programs).
155		Default: yes
156
157MKLINKLIB	If "no", act as "MKPICINSTALL=no MKPROFILE=no".
158		Also:
159			- don't install the .a libraries
160			- don't install _pic.a libraries on PIC systems
161			- don't build .a libraries on PIC systems
162			- don't install the .so symlink on ELF systems
163		I.e, only install the shared library (and the .so.major
164		symlink on ELF).
165		Default: yes
166
167MKLINT		If "no", don't build or install the lint libraries.
168		Default: yes
169
170MKMAN		If "no", don't build or install the man or catman pages,
171		and also acts as "MKCATPAGES=no MKHTML=no"
172		Default: yes
173
174MKMANZ		If not "no", compress manual pages at installation time.
175		Default: no
176
177MKNLS		If "no", don't build or install the NLS files and locale
178		definition files.
179		Default: yes
180
181MKOBJ		If "no", don't enable the rule which creates objdirs,
182		and also acts as "MKOBJDIRS=no"
183		Default: yes
184
185MKOBJDIRS	If "no", don't create objdirs during a "make build".
186		Default: no
187
188MKPIC		If "no", don't build or install shared libraries, and
189		also acts as "MKPICLIB=no"
190		Default: yes, except for ${MACHINE_ARCH} == "sh3"
191
192MKPICINSTALL	If "no", don't install the *_pic.a libraries.
193		Default: yes
194
195MKPICLIB	If "no", don't build *_pic.a libraries, and build the
196		shared object libraries from the .a libraries.
197		A symlink is installed in ${DESTDIR}/usr/lib for the
198		_pic.a library pointing to the .a library.
199		Default: yes
200
201MKPROFILE	If "no", don't build or install the profiling libraries.
202		Default: yes
203
204MKSHARE		If "no", act as "MKCATPAGES=no MKDOC=no MKHTML=no MKINFO=no
205		MKMAN=no MKNLS=no".
206		I.e, don't build catman pages, documentation, Info
207		documentation, man pages, NLS files, ...
208		Default: yes
209
210MKSKEY		If "no", disables building of S/key authentication
211		infrastructure (libraries and support programs).
212		Default: yes
213
214MKSOFTFLOAT	If not "no", build with options to enable the compiler to
215		generate output containing library calls for floating
216		point and possibly soft-float library support.
217		Default: no
218
219MKUNPRIVED	If not "no", don't set the owner/group/mode when installing
220		files or directories, and keep a metadata log of what
221		the owner/group/mode should be.  This allows a
222		non-root "make install".
223		Default: no
224
225MKUPDATE 	If not "no", 'make install' only installs targets that are
226		more recently modified in the source directories that their
227		installed counterparts.
228		Default: no
229
230MKYP		If "no", disables building of YP (NIS)
231		infrastructure (libraries and support programs).
232		Default: yes
233
234USE_HESIOD	If "no", disables building Hesiod support into
235		various system utilities/libraries that support it.
236		If MKHESIOD is "no", USE_HESIOD will also be
237		forced to "no".
238
239USE_KERBEROS4	If "no", disables building Kerberos v4
240		support into various system utilities/libraries that
241		support it.  If MKKERBEROS4 is "no", USE_KERBEROS4
242		will also be forced to "no".
243
244USE_KERBEROS	If "no", disables building Kerberos v4 or v5)
245		support into various system utilities/libraries that
246		support it.  If MKKERBEROS is "no", USE_KERBEROS
247		will also be forced to "no".
248
249USE_SKEY	If "no", disables building S/key authentication
250		support into various system utilities/libraries that
251		support it.  If MKSKEY is "no", USE_SKEY will
252		also be forced to "no".
253
254USE_YP		If "no", disables building YP (NIS) support into
255		various system utilities/libraries that support it.
256		If MKYP is "no", USE_YP will also be forced to "no".
257
258
259=-=-=-=-=   sys.mk   =-=-=-=-=
260
261The include file <sys.mk> has the default rules for all makes, in the BSD
262environment or otherwise.  You probably don't want to touch this file.
263
264=-=-=-=-=   bsd.own.mk   =-=-=-=-=
265
266The include file <bsd.own.mk> contains source tree configuration parameters,
267such as the owners, groups, etc. for both manual pages and binaries, and
268a few global "feature configuration" parameters.
269
270It has no targets.
271
272To get system-specific configuration parameters, <bsd.own.mk> will try to
273include the file specified by the "MAKECONF" variable.  If MAKECONF is not
274set, or no such file exists, the system make configuration file, /etc/mk.conf
275is included.  These files may define any of the variables described below.
276
277<bsd.own.mk> sets the following variables, if they are not already defined
278(defaults are in brackets):
279
280NETBSDSRCDIR	Top of the NetBSD source tree.
281		If _SRC_TOP_ != "", that will be used as the default,
282		otherwise BSDSRCDIR will be used as the default.
283		Various makefiles within the NetBSD source tree will
284		use this to reference the top level of the source tree.
285
286_SRC_TOP_	Top of the system source tree, as determined by <bsd.own.mk>
287		based on the presence of tools/ and build.sh.  This variable
288		is "internal" to <bsd.own.mk>, although its value is only
289		determined once and then propagated to all sub-makes.
290
291BSDSRCDIR	The real path to the system sources, so that 'make obj'
292		will work correctly.  [/usr/src]
293
294BSDOBJDIR	The real path to the system 'obj' tree, so that 'make obj'
295		will work correctly.  [/usr/obj]
296
297BINGRP		Binary group.  [wheel]
298
299BINOWN		Binary owner.  [root]
300
301BINMODE		Binary mode.  [555]
302
303NONBINMODE	Mode for non-executable files.  [444]
304
305MANDIR		Base path for manual installation.  [/usr/share/man/cat]
306
307MANGRP		Manual group.  [wheel]
308
309MANOWN		Manual owner.  [root]
310
311MANMODE		Manual mode.  [${NONBINMODE}]
312
313MANINSTALL	Manual installation type: maninstall, catinstall, or both
314
315LDSTATIC	Control program linking; if set blank, link everything
316		dynamically.  If set to "-static", link everything statically.
317		If not set, programs link according to their makefile.
318
319LIBDIR		Base path for library installation.  [/usr/lib]
320
321LINTLIBDIR	Base path for lint(1) library installation.  [/usr/libdata/lint]
322
323LIBGRP		Library group.  [${BINGRP}]
324
325LIBOWN		Library owner.  [${BINOWN}]
326
327LIBMODE		Library mode.  [${NONBINMODE}]
328
329DOCDIR		Base path for system documentation (e.g. PSD, USD, etc.)
330	        installation.  [/usr/share/doc]
331
332HTMLDOCDIR	Base path for html system documentation installation.
333		[/usr/share/doc/html]
334
335DOCGRP		Documentation group.  [wheel]
336
337DOCOWN		Documentation owner.  [root]
338
339DOCMODE		Documentation mode.  [${NONBINMODE}]
340
341NLSDIR		Base path for Native Language Support files installation.
342		[/usr/share/nls]
343
344NLSGRP		Native Language Support files group.  [wheel]
345
346NLSOWN		Native Language Support files owner.  [root]
347
348NLSMODE		Native Language Support files mode.  [${NONBINMODE}]
349
350STRIPFLAG	The flag passed to the install program to cause the binary
351		to be stripped.  This is to be used when building your
352		own install script so that the entire system can be made
353		stripped/not-stripped using a single knob.  [-s]
354
355COPY		The flag passed to the install program to cause the binary
356		to be copied rather than moved.  This is to be used when
357		building our own install script so that the entire system
358		can either be installed with copies, or with moves using
359		a single knob.  [-c]
360
361Additionally, the following variables may be set by <bsd.own.mk> or in a
362make configuration file to modify the behaviour of the system build
363process (default values are in brackets along with comments, if set by
364<bsd.own.mk>):
365
366OBJECT_FMT	Object file format.  [set to "ELF" on architectures that
367		use ELF -- currently if ${MACHINE_ARCH} is "alpha",
368		"mipsel", "mipseb", "powerpc", "sparc", "sparc64",
369		"i386" and some m68k machines, or set to "a.out" on
370		other architectures].
371
372TOOLCHAIN_MISSING
373		If "yes", this indicates that the platform being built
374		does not have a working in-tree toolchain.  If the
375		MACHINE_ARCH in question falls into this category, the
376		variable is conditionally assigned the value "yes".
377		Otherwise, the variable is unconditionally assigned the
378		value "no".
379
380		If TOOLCHAIN_MISSING is "yes", the variables MKBFD, MKGCC,
381		and MKGDB are unconditionally assigned the value "no".
382
383EXTERNAL_TOOLCHAIN
384		This variable is not directly set by <bsd.own.mk>, but
385		including <bsd.own.mk> is the canonical way to gain
386		access to this variable.  The variable should be defined
387		either in the user's environment or in the user's mk.conf
388		file.  If defined, this variable indicates the root of
389		an external toolchain which will be used to build the
390		tree.  For example, if a platform is a TOOLCHAIN_MISSING
391		platform, EXTERNAL_TOOLCHAIN can be used to re-enable the
392		cross-compile framework.
393
394		If EXTERNAL_TOOLCHAIN is defined, the variable MKGCC is
395		unconditionally assigned the value "no", since the external
396		version of the compiler may not be able to build the library
397		components of the in-tree compiler.
398
399		NOTE: This variable is not yet used in as many places as
400		it should be.  Expect the exact semantics of this variable
401		to change in the short term as parts of the cross-compile
402		framework continue to be cleaned up.
403
404<bsd.own.mk> is generally useful when building your own Makefiles so that
405they use the same default owners etc. as the rest of the tree.
406
407
408=-=-=-=-=   bsd.dep.mk   =-=-=-=-=
409
410The include file <bsd.dep.mk> contains the default targets for building
411.depend files.  It creates .d files from entries in SRCS and DPSRCS
412that are C, C++, or Objective C source files, and builds .depend from the
413.d files.  All other files in SRCS and all of DPSRCS will be used as
414dependencies for the .d files.  In order for this to function correctly,
415it should be .included after all other .mk files and directives that may
416modify SRCS or DPSRCS.  It uses the following variables:
417
418SRCS		List of source files to build the program.
419
420DPSRCS		List of source files which are needed for generating
421		dependencies, but are not needed in ${SRCS}.
422
423
424=-=-=-=-=   bsd.files.mk   =-=-=-=-=
425
426The include file <bsd.files.mk> handles the FILES variables and is included
427from <bsd.lib.mk> and <bsd.prog.mk>, and uses the following variables:
428
429FILES		The list of files to install.
430
431FILESOWN	File owner.  [${BINOWN}]
432
433FILESGRP	File group.  [${BINGRP}]
434
435FILESMODE	File mode.  [${BINMODE}]
436
437FILESDIR	The location to install the files.
438
439FILESNAME	Optional name to install each file as.
440
441FILESDIR.<fn>	The location to install the specific file <fn>.
442
443FILESNAME.<fn>	Optional name to install <fn> as.
444
445LNFILES		List of two word items:
446			lnsrc lntgt
447		For each lnsrc item, create a symlink named lntgt.
448		The lntgt symlinks are removed by the cleandir target.
449
450
451=-=-=-=-=   bsd.gcc.mk   =-=-=-=-=
452
453The include file <bsd.gcc.mk> computes various parameters related to GCC
454support libraries.  It defines no targets.  <bsd.own.mk> MUST be included
455before <bsd.gcc.mk>.
456
457The primary users of <bsd.gcc.mk> are <bsd.prog.mk> and <bsd.lib.mk>, each
458of which need to know where to find certain GCC support libraries.
459
460The behavior of <bsd.gcc.mk> is influenced by the EXTERNAL_TOOLCHAIN variable,
461which is generally set by the user.  If EXTERNAL_TOOLCHAIN it set, then
462the compiler is asked where to find the support libraries, otherwise the
463support libraries are found in ${DESTDIR}/usr/lib.
464
465<bsd.gcc.mk> sets the following variables:
466
467_GCC_CRTBEGIN	The full path name to crtbegin.o.
468
469_GCC_CRTBEGINS	The full path name to crtbeginS.o.
470
471_GCC_CRTEND	The full path name to crtend.o.
472
473_GCC_CRTENDS	The full path name to crtendS.o.
474
475_GCC_LIBGCCDIR	The directory where libgcc.a is located.
476
477
478=-=-=-=-=   bsd.inc.mk   =-=-=-=-=
479
480The include file <bsd.inc.mk> defines the includes target and uses the
481variables:
482
483INCS		The list of include files.
484
485INCSDIR		The location to install the include files.
486
487INCSNAME	Target name of the include file, if only one; same as
488		FILESNAME, but for include files.
489
490INCSYMLINKS	Similar to SYMLINKS in <bsd.links.mk>, except that these
491		are installed in the 'includes' target and not the
492		(much later) 'install' target.
493
494INCSNAME_<file>	The name file <file> should be installed as, if not <file>,
495		same as FILESNAME_<file>, but for include files.
496
497
498=-=-=-=-=   bsd.info.mk   =-=-=-=-=
499
500The include file <bsd.info.mk> is used to generate and install GNU Info
501documentation from respective Texinfo source files.  It defines three
502implicit targets (.txi.info, .texi.info, and .texinfo.info), and uses the
503following variables:
504
505TEXINFO		List of Texinfo source files.  Info documentation will
506		consist of single files with the extension replaced by
507		.info.
508
509INFOFLAGS	Flags to pass to makeinfo.  []
510
511
512=-=-=-=-=   bsd.kernobj.mk   =-=-=-=-=
513
514The include file <bsd.kernobj.mk> defines variables related to the
515location of kernel sources and object directories.
516
517KERNSRCDIR	Is the location of the top of the kernel src.
518		[${_SRC_TOP_}/sys]
519
520KERNARCHDIR	Is the location of the machine dependent kernel sources.
521		[arch/${MACHINE}]
522
523KERNCONFDIR	Is where the configuration files for kernels are found.
524		[${KERNSRCDIR}/${KERNARCHDIR}/conf]
525
526KERNOBJDIR	Is the kernel build directory.  The kernel GENERIC for
527		instance will be compiled in ${KERNOBJDIR}/GENERIC.
528		The default value is
529		${MAKEOBJDIRPREFIX}${KERNSRCDIR}/${KERNARCHDIR}/compile
530		if it exists or the target 'obj' is being made.
531		Otherwise the default is
532		${KERNSRCDIR}/${KERNARCHDIR}/compile.
533
534It is important that Makefiles (such as those under src/distrib) that
535wish to find compiled kernels use <bsd.kernobj.mk> and ${KERNOBJDIR}
536rather than make assumptions about the location of the compiled kernel.
537
538
539=-=-=-=-=   bsd.kinc.mk   =-=-=-=-=
540
541The include file <bsd.kinc.mk> defines the many targets (includes,
542subdirectories, etc.), and is used by kernel makefiles to handle
543include file installation.  It is intended to be included alone, by
544kernel Makefiles.  It uses similar variables to <bsd.inc.mk>.
545Please see <bsd.kinc.mk> for more details, and keep the documentation
546in that file up to date.
547
548
549=-=-=-=-=   bsd.lib.mk   =-=-=-=-=
550
551The include file <bsd.lib.mk> has support for building libraries.  It has
552the same eight targets as <bsd.prog.mk>: all, clean, cleandir, depend,
553includes, install, lint, and tags.  Additionally, it has a checkver target
554which checks for installed shared object libraries whose version is greater
555that the version of the source. It has a limited number of suffixes,
556consistent with the current needs of the BSD tree.  <bsd.lib.mk> includes
557<bsd.shlib.mk> to get shared library parameters.
558
559It sets/uses the following variables:
560
561LIB		The name of the library to build.
562
563LIBDIR		Target directory for libraries.
564
565SHLIBINSTALLDIR	Target directory for shared libraries if ${USE_SHLIBDIR}
566		is "yes".
567
568USE_SHLIBDIR	If "yes", use ${SHLIBINSTALLDIR} instead of ${LIBDIR}
569		as the path to install shared libraries to.
570		USE_SHLIBDIR must be defined before <bsd.own.mk> is included.
571		Default: no
572
573LINTLIBDIR	Target directory for lint libraries.
574
575LIBGRP		Library group.
576
577LIBOWN		Library owner.
578
579LIBMODE		Library mode.
580
581LDADD		Additional loader objects.
582
583MAN		The manual pages to be installed (use a .1 - .9 suffix).
584
585NOCHECKVER_<library>
586NOCHECKVER	If set, disables checking for installed shared object
587		libraries with versions greater than the source.  A
588		particular library name, without the "lib" prefix, may
589		be appended to the variable name to disable the check for
590		only that library.
591
592SRCS		List of source files to build the library.  Suffix types
593		.s, .c, and .f are supported.  Note, .s files are preferred
594		to .c files of the same name.  (This is not the default for
595		versions of make.)
596
597The include file <bsd.lib.mk> includes the file named "../Makefile.inc"
598if it exists, as well as the include file <bsd.man.mk>.
599
600It has rules for building profiled objects; profiled libraries are
601built by default.
602
603Libraries are ranlib'd when made.
604
605
606=-=-=-=-=   bsd.links.mk   =-=-=-=-=
607
608The include file <bsd.links.mk> handles the LINKS and SYMLINKS variables
609and is included from from <bsd.lib.mk> and <bsd.prog.mk>.
610
611LINKS		The list of hard links, consisting of pairs of paths:
612			source-file target-file
613		${DESTDIR} is prepended to both paths before linking.
614		For example, to link /bin/test and /bin/[, use:
615			LINKS=/bin/test /bin/[
616
617SYMLINKS	The list of symbolic links, consisting of pairs of paths:
618			source-file target-file
619		${DESTDIR} is only prepended to target-file before linking.
620		For example, to symlink /usr/bin/tar to /bin/tar resulting
621		in ${DESTDIR}/usr/bin/tar -> /bin/tar:
622			SYMLINKS=/bin/tar /usr/bin/tar
623
624
625=-=-=-=-=   bsd.man.mk   =-=-=-=-=
626
627The include file <bsd.man.mk> handles installing manual pages and their
628links.
629
630It has a two targets:
631
632	maninstall:
633		Install the manual page sources and their links.
634	catinstall:
635		Install the preformatted manual pages and their links.
636
637It sets/uses the following variables:
638
639MANDIR		Base path for manual installation.
640
641MANGRP		Manual group.
642
643MANOWN		Manual owner.
644
645MANMODE		Manual mode.
646
647MANSUBDIR	Subdirectory under the manual page section, i.e. "/vax"
648		or "/tahoe" for machine specific manual pages.
649
650MAN		The manual pages to be installed (use a .1 - .9 suffix).
651
652MLINKS		List of manual page links (using a .1 - .9 suffix).  The
653		linked-to file must come first, the linked file second,
654		and there may be multiple pairs.  The files are soft-linked.
655
656The include file <bsd.man.mk> includes a file named "../Makefile.inc" if
657it exists.
658
659
660=-=-=-=-=   bsd.obj.mk   =-=-=-=-=
661
662The include file <bsd.obj.mk> defines targets related to the creation
663and use of separated object and source directories.
664
665If an environment variable named MAKEOBJDIRPREFIX is set, make(1) uses
666${MAKEOBJDIRPREFIX}${.CURDIR} as the name of the object directory if
667it exists.  Otherwise make(1) looks for the existence of a
668subdirectory (or a symlink to a directory) of the source directory
669into which built targets should be placed.  If an environment variable
670named MAKEOBJDIR is set, make(1) uses its value as the name of the
671object directory; failing that, make first looks for a subdirectory
672named "obj.${MACHINE}", and if that doesn't exist, it looks for "obj".
673
674Object directories are not created automatically by make(1) if they
675don't exist; you need to run a separate "make obj".  (This will happen
676during a top-level build if "MKOBJDIRS" is set to a value other than
677"no").  When the source directory is a subdirectory of ${BSDSRCDIR} --
678and this is determined by a simple string prefix comparison -- object
679directories are created in a separate object directory tree, and a
680symlink to the object directory in that tree is created in the source
681directory; otherwise, "make obj" assumes that you're not in the main
682source tree and that it's not safe to use a separate object tree.
683
684Several variables used by <bsd.obj.mk> control exactly what
685directories and links get created during a "make obj":
686
687MAKEOBJDIR	If set, this is the component name of the object
688		directory.
689
690OBJMACHINE	If this is set but MAKEOBJDIR is not set, creates
691		object directories or links named "obj.${MACHINE}";
692		otherwise, just creates ones named "obj".
693
694USR_OBJMACHINE  If set, and the current directory is a subdirectory of
695		${BSDSRCDIR}, create object directory in the
696		corresponding subdirectory of ${BSDOBJDIR}.${MACHINE};
697		otherwise, create it in the corresponding subdirectory
698		of ${BSDOBJDIR}
699
700BUILDID		If set, the contents of this variable are appended
701		to the object directory name.  If OBJMACHINE is also
702		set, ".${BUILDID}" is added after ".${MACHINE}".
703
704
705=-=-=-=-=   bsd.prog.mk   =-=-=-=-=
706
707The include file <bsd.prog.mk> handles building programs from one or
708more source files, along with their manual pages.  It has a limited number
709of suffixes, consistent with the current needs of the BSD tree. 
710<bsd.prog.mk> includes <bsd.shlib.mk> to get shared library parameters.
711
712It has eight targets:
713
714	all:
715		build the program and its manual page.  This also
716		creates a GDB initialization file (.gdbinit) in
717		the objdir.  The .gdbinit file sets the shared library
718		prefix to ${DESTDIR} to facilitate cross-debugging.
719	clean:
720		remove the program, any object files and the files a.out,
721		Errs, errs, mklog, and ${PROG}.core.
722	cleandir:
723		remove all of the files removed by the target clean, as
724		well as .depend, tags, and any manual pages.
725		`distclean' is a synonym for `cleandir'.
726	depend:
727		make the dependencies for the source files, and store
728		them in the file .depend.
729	includes:
730		install any header files.
731	install:
732		install the program and its manual pages; if the Makefile
733		does not itself define the target install, the targets
734		beforeinstall and afterinstall may also be used to cause
735		actions immediately before and after the install target
736		is executed.
737	lint:
738		run lint on the source files
739	tags:
740		create a tags file for the source files.
741
742It sets/uses the following variables:
743
744BINGRP		Binary group.
745
746BINOWN		Binary owner.
747
748BINMODE		Binary mode.
749
750CLEANFILES	Additional files to remove for the clean and cleandir targets.
751
752COPTS		Additional flags to the compiler when creating C objects.
753
754COPTS.<fn>	Additional flags to the compiler when creating the
755		C objects for <fn>.
756		For <fn>.[ly], "<fn>.c" must be used.
757
758CPUFLAGS	Additional flags to the compiler/assembler to select
759		CPU instruction set options, CPU tuning options, etc.
760
761CPUFLAGS.<fn>	Additional flags to the compiler/assembler for <fn>.
762		For <fn>.[ly], "<fn>.c" must be used.
763
764CPPFLAGS	Additional flags to the C pre-processor.
765
766CPPFLAGS.<fn>	Additional flags to the C pre-processor for <fn>.
767		For <fn>.[ly], "<fn>.c" must be used.
768
769GDBINIT		List of GDB initialization files to add to "source"
770		directives in the .gdbinit file that is created in the
771		objdir.
772
773LDADD		Additional loader objects.  Usually used for libraries.
774		For example, to load with the compatibility and utility
775		libraries, use:
776
777			LDADD+=-lutil -lcompat
778
779LDFLAGS		Additional loader flags.
780
781LINKS		See <bsd.links.mk>
782
783SYMLINKS	See <bsd.links.mk>
784
785MAN		Manual pages (should end in .1 - .9).  If no MAN variable is
786		defined, "MAN=${PROG}.1" is assumed.
787
788PROG		The name of the program to build.  If not supplied, nothing
789		is built.
790
791PROG_CXX	If defined, the name of the program to build.  Also
792		causes <bsd.prog.mk> to link the program with the C++
793		compiler rather than the C compiler.  PROG_CXX overrides
794		the value of PROG if PROG is also set.
795
796PROGNAME	The name that the above program will be installed as, if
797		different from ${PROG}.
798
799SRCS		List of source files to build the program.  If SRCS is not
800		defined, it's assumed to be ${PROG}.c.
801
802DPSRCS		List of source files which are needed for generating
803		dependencies, but are not needed in ${SRCS}.
804
805DPADD		Additional dependencies for the program.  Usually used for
806		libraries.  For example, to depend on the compatibility and
807		utility libraries use:
808
809			DPADD+=${LIBCOMPAT} ${LIBUTIL}
810
811		The following libraries are predefined for DPADD:
812
813		LIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
814		LIBBZ2?=	${DESTDIR}/usr/lib/libbz2.a
815		LIBC?=		${DESTDIR}/usr/lib/libc.a
816		LIBC_PIC?=	${DESTDIR}/usr/lib/libc_pic.a
817		LIBCDK?=	${DESTDIR}/usr/lib/libcdk.a
818		LIBCOM_ERR?=	${DESTDIR}/usr/lib/libcom_err.a
819		LIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
820		LIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
821		LIBCRYPTO?=	${DESTDIR}/usr/lib/libcrypto.a
822		LIBCRYPTO_IDEA?=${DESTDIR}/usr/lib/libcrypto_idea.a
823		LIBCRYPTO_MDC2?=${DESTDIR}/usr/lib/libcrypto_mdc2.a
824		LIBCRYPTO_RC5?=	${DESTDIR}/usr/lib/libcrypto_rc5.a
825		LIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
826		LIBDBM?=	${DESTDIR}/usr/lib/libdbm.a
827		LIBDES?=	${DESTDIR}/usr/lib/libdes.a
828		LIBEDIT?=	${DESTDIR}/usr/lib/libedit.a
829		LIBEVENT?=	${DESTDIR}/usr/lib/libevent.a
830		LIBFORM?=	${DESTDIR}/usr/lib/libform.a
831		LIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
832		LIBGNUMALLOC?=	${DESTDIR}/usr/lib/libgnumalloc.a
833		LIBGSSAPI?=	${DESTDIR}/usr/lib/libgssapi.a
834		LIBHDB?=	${DESTDIR}/usr/lib/libhdb.a
835		LIBINTL?=	${DESTDIR}/usr/lib/libintl.a
836		LIBIPSEC?=	${DESTDIR}/usr/lib/libipsec.a
837		LIBKADM?=	${DESTDIR}/usr/lib/libkadm.a
838		LIBKADM5CLNT?=	${DESTDIR}/usr/lib/libkadm5clnt.a
839		LIBKADM5SRV?=	${DESTDIR}/usr/lib/libkadm5srv.a
840		LIBKAFS?=	${DESTDIR}/usr/lib/libkafs.a
841		LIBKDB?=	${DESTDIR}/usr/lib/libkdb.a
842		LIBKRB?=	${DESTDIR}/usr/lib/libkrb.a
843		LIBKRB5?=	${DESTDIR}/usr/lib/libkrb5.a
844		LIBKSTREAM?=	${DESTDIR}/usr/lib/libkstream.a
845		LIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
846		LIBL?=		${DESTDIR}/usr/lib/libl.a
847		LIBM?=		${DESTDIR}/usr/lib/libm.a
848		LIBMENU?=	${DESTDIR}/usr/lib/libmenu.a
849		LIBMP?=		${DESTDIR}/usr/lib/libmp.a
850		LIBNTP?=	${DESTDIR}/usr/lib/libntp.a
851		LIBOBJC?=	${DESTDIR}/usr/lib/libobjc.a
852		LIBOSSAUDIO?=	${DESTDIR}/usr/lib/libossaudio.a
853		LIBPC?=		${DESTDIR}/usr/lib/libpc.a
854		LIBPCAP?=	${DESTDIR}/usr/lib/libpcap.a
855		LIBPCI?=	${DESTDIR}/usr/lib/libpci.a
856		LIBPLOT?=	${DESTDIR}/usr/lib/libplot.a
857		LIBPMC?=	${DESTDIR}/usr/lib/libpmc.a
858		LIBPOSIX?=	${DESTDIR}/usr/lib/libposix.a
859		LIBPTHREAD?=	${DESTDIR}/usr/lib/libpthread.a
860		LIBPTHREAD_DBG?=${DESTDIR}/usr/lib/libpthread_dbg.a
861		LIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
862		LIBRMT?=	${DESTDIR}/usr/lib/librmt.a
863		LIBROKEN?=	${DESTDIR}/usr/lib/libroken.a
864		LIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
865		LIBRT?=		${DESTDIR}/usr/lib/librt.a
866		LIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
867		LIBSS?=		${DESTDIR}/usr/lib/libss.a
868		LIBSSL?=	${DESTDIR}/usr/lib/libssl.a
869		LIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
870		LIBSL?=		${DESTDIR}/usr/lib/libsl.a
871		LIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
872		LIBUSBHID?=	${DESTDIR}/usr/lib/libusbhid.a
873		LIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
874		LIBWRAP?=	${DESTDIR}/usr/lib/libwrap.a
875		LIBY?=		${DESTDIR}/usr/lib/liby.a
876		LIBZ?=		${DESTDIR}/usr/lib/libz.a
877
878SHAREDSTRINGS	If defined, a new .c.o rule is used that results in shared
879		strings, using xstr(1). Note that this will not work with
880		parallel makes.
881
882STRIPFLAG	The flag passed to the install program to cause the binary
883		to be stripped.
884
885SUBDIR		A list of subdirectories that should be built as well.
886		Each of the targets will execute the same target in the
887		subdirectories.
888
889SCRIPTS		A list of interpreter scripts [file.{sh,csh,pl,awk,...}].
890		These are installed exactly like programs.
891
892SCRIPTSNAME	The name that the above program will be installed as, if
893		different from ${SCRIPTS}. These can be further specialized
894		by setting SCRIPTSNAME_<script>.
895
896FILES		See description of <bsd.files.mk>.
897
898SHLINKDIR	Target directory for shared linker.  See description of
899		<bsd.own.mk> for additional information about this variable.
900
901USE_LIBSTDCXX	If "no", the support libraries needed for C++ programs
902		are set to `-lsupc++ -lm', rather than `-lstdc++ -lm'.
903		Default: yes
904
905The include file <bsd.prog.mk> includes the file named "../Makefile.inc"
906if it exists, as well as the include file <bsd.man.mk>.
907
908Some simple examples:
909
910To build foo from foo.c with a manual page foo.1, use:
911
912	PROG=	foo
913
914	.include <bsd.prog.mk>
915
916To build foo from foo.c with a manual page foo.2, add the line:
917
918	MAN=	foo.2
919
920If foo does not have a manual page at all, add the line:
921
922	MKMAN=	no
923
924If foo has multiple source files, add the line:
925
926	SRCS=	a.c b.c c.c d.c
927
928
929=-=-=-=-=   bsd.rpc.mk   =-=-=-=-=
930
931The include file <bsd.rpc.mk> contains a makefile fragment used to
932construct source files built by rpcgen.
933
934The following macros may be defined in makefiles which include
935<bsd.rpc.mk> in order to control which files get built and how they
936are to be built:
937
938RPC_INCS:	construct .h file from .x file
939RPC_XDRFILES:	construct _xdr.c from .x file
940		(for marshalling/unmarshalling data types)
941RPC_SVCFILES:	construct _svc.c from .x file
942		(server-side stubs)
943RPC_SVCFLAGS:	Additional flags passed to builds of RPC_SVCFILES.
944
945RPC_XDIR:	Directory containing .x/.h files
946
947
948=-=-=-=-=   bsd.shlib.mk   =-=-=-=-=
949
950The include file <bsd.shlib.mk> computes parameters for shared library
951installation and use.  It defines no targets.  <bsd.own.mk> MUST be
952included before <bsd.shlib.mk>.
953
954<bsd.own.mk> sets the following variables, if they are not already defined
955(defaults are in brackets):
956
957SHLIBINSTALLDIR	If ${USE_SHLIBDIR} is "yes", use ${SHLIBINSTALLDIR} instead of
958		${LIBDIR} as the base path for shared library installation.
959		[/lib]
960
961SHLIBDIR	The path to USE_SHLIBDIR shared libraries to use when building
962		a program.  [/lib for programs in /bin and /sbin, /usr/lib
963		for all others.]
964
965_LIBSODIR	Set to ${SHLIBINSTALLDIR} if ${USE_SHLIBDIR} is "yes",
966		otherwise set to ${LIBDIR}
967
968SHLINKINSTALLDIR Base path for shared linker.  [/libexec]
969
970SHLINKDIR	Path to use for shared linker when building a program.
971		[/libexec for programs in /bin and /sbin, /usr/libexec for
972		all others.]
973
974
975=-=-=-=-=   bsd.subdir.mk   =-=-=-=-=
976
977The include file <bsd.subdir.mk> contains the default targets for building
978subdirectories.  It has the same eight targets as <bsd.prog.mk>: all,
979clean, cleandir, depend, includes, install, lint, and tags.  For all of
980the directories listed in the variable SUBDIR, the specified directory
981will be visited and the target made.  There is also a default target which
982allows the command "make subdir" where subdir is any directory listed in
983the variable SUBDIR.
984
985As a special case, the use of a token .WAIT as an entry in SUBDIR acts
986as a synchronization barrier when multiple make jobs are run; subdirs
987before the .WAIT must complete before any subdirs after .WAIT are
988started.  See make(1) for some caveats on use of .WAIT and other
989special sources.
990
991
992=-=-=-=-=   bsd.sys.mk   =-=-=-=-=
993
994The include file <bsd.sys.mk> is used by <bsd.prog.mk> and
995<bsd.lib.mk>.  It contains overrides that are used when building
996the NetBSD source tree.
997
998The following variables control how various files are compiled/built.
999(Note that these may be overridden in <bsd.own.mk> if USETOOLS=yes):
1000
1001AR		Create, modify, and extract from archives.  [ar]
1002
1003ARFLAGS		Options to ${AR}.  [rl]
1004
1005CC		C compiler.  [cc]
1006
1007CFLAGS		Options to ${CC}.  [Usually -O or -O2]
1008
1009CPP		C Pre-Processor.  [cpp]
1010
1011CPPFLAGS	Options to ${CPP}.  []
1012
1013CPUFLAGS	Optimization flags for ${CC}
1014
1015CXX		C++ compiler.  [c++]
1016
1017CXXFLAGS	Options to ${CXX}.  [${CFLAGS}]
1018
1019ELF2ECOFF	Convert ELF-format executable to ECOFF.  [elf2ecoff]
1020
1021FC		Fortran compiler.  [f77]
1022
1023FFLAGS		Options to {$FC}.  [-O]
1024
1025INSTALL		install(1) command.  [install]
1026
1027LEX		Lexical analyzer.  [lex]
1028
1029LFLAGS		Options to ${LEX}.  []
1030
1031LD		Linker.  [ld]
1032
1033LDFLAGS		Options to ${LD}.  []
1034
1035LINT		C program verifier.  [lint]
1036
1037LINTFLAGS	Options to ${LINT}.  [-chapbxzF]
1038
1039LORDER		List dependencies for object files.  [lorder]
1040
1041MAKE		make(1).  [make]
1042
1043MKDEP		Construct Makefile dependency list.  [mkdep]
1044
1045NM		List symbols from object files.  [nm]
1046
1047PC		Pascal compiler.  [pc]  (Not present)
1048
1049PFLAGS		Options to ${PC}.  []
1050
1051OBJC		Objective C compiler.  [${CC}]
1052
1053OBJCFLAGS	Options to ${OBJC}.  [${CFLAGS}]
1054
1055OBJCOPY		Copy and translate object files.  [objcopy]
1056
1057RANLIB		Generate index to archive.  [ranlib]
1058
1059SHELL		Shell.  [sh]
1060
1061SIZE		List section sizes and total size.  [size]
1062
1063STRIP		Discard symbols from object files.  [strip]
1064
1065TSORT		Topological sort of a directed graph.  [tsort -q]
1066
1067YACC		LALR(1) parser generator.  [yacc]
1068
1069YFLAGS		Options to ${YACC}.  []
1070
1071YHEADER		If defined, add "-d" to YFLAGS, and add dependencies
1072		from <file>.y to <file>.h and <file>.c, and add
1073		<foo>.h to CLEANFILES.
1074
1075YPREFIX		If defined, add "-p ${YPREFIX}" to YFLAGS.
1076
1077
1078The following variables are defined to commands to perform the
1079appropriate operation, with the default in [brackets].
1080(Note that these are overridden in <bsd.own.mk> if USETOOLS=yes):
1081
1082TOOL_ASN1_COMPILE	ASN1 compiler.  [asn1_compile]
1083
1084TOOL_CAP_MKDB		Create capability database.  [cap_mkdb]
1085
1086TOOL_CAT		Concatenate and print files.  [cat]
1087
1088TOOL_CKSUM		Display file checksums.  [cksum]
1089
1090TOOL_COMPILE_ET		Error table compiler.  [compile_et]
1091
1092TOOL_CONFIG		Build kernel compilation directories.  [config]
1093
1094TOOL_CRUNCHGEN		Generate crunched binary build environment.  [crunchgen]
1095
1096TOOL_CTAGS		Create a tags file.  [ctags]
1097
1098TOOL_DB			Manipulate db(3) databases.  [db]
1099
1100TOOL_EQN		Format equations for groff.  [eqn]
1101
1102TOOL_FGEN		IEEE 1275 Open Firmware FCode Tokenizer.  [fgen]
1103
1104TOOL_GENCAT		Generate NLS message catalogs.  [gencat]
1105
1106TOOL_GROFF		Front end for groff document formatting system.  [groff]
1107
1108TOOL_HEXDUMP		Ascii, decimal, hexadecimal, octal dump.  [hexdump]
1109
1110TOOL_INDXBIB		Make bibliographic database's inverted index.  [indxbib]
1111
1112TOOL_INSTALLBOOT	Install disk bootstrap software.  [installboot]
1113
1114TOOL_INSTALL_INFO	Update info/dir entries.  [install-info]
1115
1116TOOL_M4			M4 macro language processor.  [m4]
1117
1118TOOL_MAKEFS		Create file system image from directory tree.  [makefs]
1119
1120TOOL_MAKEINFO		Translate Texinfo documents.  [makeinfo]
1121
1122TOOL_MAKEWHATIS		Create a whatis.db database.  [makewhatis]
1123
1124TOOL_MDSETIMAGE		Set kernel RAM disk image.  [mdsetimage]
1125
1126TOOL_MENUC		Menu compiler.  [menuc]
1127
1128TOOL_MKCSMAPPER		Make charset mapping table.  [mkcsmapper]
1129
1130TOOL_MKESDB		Make encoding scheme database.  [mkesdb]
1131
1132TOOL_MKLOCALE		Make LC_CTYPE locale files.  [mklocale]
1133
1134TOOL_MKMAGIC		Create database for file(1).  [file]
1135
1136TOOL_MKTEMP		Make (unique) temporary file name.  [mktemp]
1137
1138TOOL_MSGC		Simple message list compiler.  [msgc]
1139
1140TOOL_MTREE		Map a directory hierarchy.  [mtree]
1141
1142TOOL_PAX		Manipulate file archives and copy directories.  [pax]
1143
1144TOOL_PIC		Compile pictures for groff.  [pic]
1145
1146TOOL_PREPMKBOOTIMAGE	prep-mkbootimage (XXXBUILDSH).  [prep-mkbootimage]
1147
1148TOOL_PWD_MKDB		Generate the password databases.  [pwd_mkdb]
1149
1150TOOL_REFER		Preprocess bibliographic references for groff.  [refer]
1151
1152TOOL_ROFF_ASCII		Generate ASCII groff output.  [nroff]
1153
1154TOOL_ROFF_DVI		Generate DVI groff output.  [${TOOL_GROFF} -Tdvi]
1155
1156TOOL_ROFF_HTML		Generate HTML groff output.
1157			[${TOOL_GROFF} -Tlatin1 -mdoc2html]
1158
1159TOOL_ROFF_PS		Generate PS groff output.  [${TOOL_GROFF} -Tps]
1160
1161TOOL_ROFF_RAW		Generate "raw" groff output.  [${TOOL_GROFF} -Z]
1162
1163TOOL_RPCGEN		Remote Procedure Call (RPC) protocol compiler.  [rpcgen]
1164
1165TOOL_SOELIM		Eliminate .so's from groff input.  [soelim]
1166
1167TOOL_STAT		Display file status.  [stat]
1168
1169TOOL_SUNLABEL		Read or modify a SunOS disk label.  [sunlabel]
1170
1171TOOL_TBL		Format tables for groff.  [tbl]
1172
1173TOOL_UUDECODE		Uudecode a binary file.  [uudecode]
1174
1175TOOL_VGRIND		Grind nice listings of programs.  [vgrind -f]
1176
1177TOOL_ZIC		Time zone compiler.  [zic]
1178
1179
1180Other variables of note (incomplete list):
1181
1182WARNS		Crank up gcc warning options; the distinct levels are:
1183			WARNS=1
1184			WARNS=2
1185			WARNS=3
1186
1187FORMAT_AUDIT	If FORMAT_AUDIT is set, and WFORMAT is set and > 1, turn on
1188WFORMAT 	-Wnetbsd-format-audit for extra-stringent format checking.
1189		WFORMAT belongs in individual makefiles and/or
1190		Makefile.inc files.  (set WFORMAT=1 in individual
1191		makefiles if a program is not security critical and is
1192		doing bizarre things with format strings which would
1193		be even uglier if rewritten) FORMAT_AUDIT should go in
1194		mk.conf if you're doing format-string auditing.
1195		FORMAT_AUDIT may go away in time.
1196
1197=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1198