xref: /netbsd-src/share/mk/bsd.README (revision a93ea220fcb3e34cdfdcd4d7a5d391e0b2b4f2ba)
1#	$NetBSD: bsd.README,v 1.132 2003/07/31 13:47:32 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.
263If you intend to run a cross build, you will need to supply the following
264host tools, and configure the following variables properly:
265
266OBJCOPY		objcopy - copy and translate object files
267
268STRIP		strip - Discard symbols from object files
269
270
271=-=-=-=-=   bsd.own.mk   =-=-=-=-=
272
273The include file <bsd.own.mk> contains source tree configuration parameters,
274such as the owners, groups, etc. for both manual pages and binaries, and
275a few global "feature configuration" parameters.
276
277It has no targets.
278
279To get system-specific configuration parameters, bsd.own.mk will try to
280include the file specified by the "MAKECONF" variable.  If MAKECONF is not
281set, or no such file exists, the system make configuration file, /etc/mk.conf
282is included.  These files may define any of the variables described below.
283
284bsd.own.mk sets the following variables, if they are not already defined
285(defaults are in brackets):
286
287NETBSDSRCDIR	Top of the NetBSD source tree.
288		If _SRC_TOP_ != "", that will be used as the default,
289		otherwise BSDSRCDIR will be used as the default.
290		Various makefiles within the NetBSD source tree will
291		use this to reference the top level of the source tree.
292
293_SRC_TOP_	Top of the system source tree, as determined by <bsd.own.mk>
294		based on the presence of tools/ and build.sh.  This variable
295		is "internal" to <bsd.own.mk>, although its value is only
296		determined once and then propagated to all sub-makes.
297
298BSDSRCDIR	The real path to the system sources, so that 'make obj'
299		will work correctly.  [/usr/src]
300
301BSDOBJDIR	The real path to the system 'obj' tree, so that 'make obj'
302		will work correctly.  [/usr/obj]
303
304BINGRP		Binary group.  [wheel]
305
306BINOWN		Binary owner.  [root]
307
308BINMODE		Binary mode.  [555]
309
310NONBINMODE	Mode for non-executable files.  [444]
311
312MANDIR		Base path for manual installation.  [/usr/share/man/cat]
313
314MANGRP		Manual group.  [wheel]
315
316MANOWN		Manual owner.  [root]
317
318MANMODE		Manual mode.  [${NONBINMODE}]
319
320MANINSTALL	Manual installation type: maninstall, catinstall, or both
321
322LDSTATIC	Control program linking; if set blank, link everything
323		dynamically.  If set to "-static", link everything statically.
324		If not set, programs link according to their makefile.
325
326LIBDIR		Base path for library installation.  [/usr/lib]
327
328LINTLIBDIR	Base path for lint(1) library installation.  [/usr/libdata/lint]
329
330LIBGRP		Library group.  [${BINGRP}]
331
332LIBOWN		Library owner.  [${BINOWN}]
333
334LIBMODE		Library mode.  [${NONBINMODE}]
335
336DOCDIR		Base path for system documentation (e.g. PSD, USD, etc.)
337	        installation.  [/usr/share/doc]
338
339HTMLDOCDIR	Base path for html system documentation installation.
340		[/usr/share/doc/html]
341
342DOCGRP		Documentation group.  [wheel]
343
344DOCOWN		Documentation owner.  [root]
345
346DOCMODE		Documentation mode.  [${NONBINMODE}]
347
348NLSDIR		Base path for Native Language Support files installation.
349		[/usr/share/nls]
350
351NLSGRP		Native Language Support files group.  [wheel]
352
353NLSOWN		Native Language Support files owner.  [root]
354
355NLSMODE		Native Language Support files mode.  [${NONBINMODE}]
356
357STRIPFLAG	The flag passed to the install program to cause the binary
358		to be stripped.  This is to be used when building your
359		own install script so that the entire system can be made
360		stripped/not-stripped using a single knob.  [-s]
361
362COPY		The flag passed to the install program to cause the binary
363		to be copied rather than moved.  This is to be used when
364		building our own install script so that the entire system
365		can either be installed with copies, or with moves using
366		a single knob.  [-c]
367
368Additionally, the following variables may be set by bsd.own.mk or in a
369make configuration file to modify the behaviour of the system build
370process (default values are in brackets along with comments, if set by
371bsd.own.mk):
372
373OBJECT_FMT	Object file format.  [set to "ELF" on architectures that
374		use ELF -- currently if ${MACHINE_ARCH} is "alpha",
375		"mipsel", "mipseb", "powerpc", "sparc", "sparc64",
376		"i386" and some m68k machines, or set to "a.out" on
377		other architectures].
378
379TOOLCHAIN_MISSING
380		If "yes", this indicates that the platform being built
381		does not have a working in-tree toolchain.  If the
382		MACHINE_ARCH in question falls into this category, the
383		variable is conditionally assigned the value "yes".
384		Otherwise, the variable is unconditionally assigned the
385		value "no".
386
387		If TOOLCHAIN_MISSING is "yes", the variables MKBFD, MKGCC,
388		and MKGDB are unconditionally assigned the value "no".
389
390EXTERNAL_TOOLCHAIN
391		This variable is not directly set by <bsd.own.mk>, but
392		including <bsd.own.mk> is the canonical way to gain
393		access to this variable.  The variable should be defined
394		either in the user's environment or in the user's mk.conf
395		file.  If defined, this variable indicates the root of
396		an external toolchain which will be used to build the
397		tree.  For example, if a platform is a TOOLCHAIN_MISSING
398		platform, EXTERNAL_TOOLCHAIN can be used to re-enable the
399		cross-compile framework.
400
401		If EXTERNAL_TOOLCHAIN is defined, the variable MKGCC is
402		unconditionally assigned the value "no", since the external
403		version of the compiler may not be able to build the library
404		components of the in-tree compiler.
405
406		NOTE: This variable is not yet used in as many places as
407		it should be.  Expect the exact semantics of this variable
408		to change in the short term as parts of the cross-compile
409		framework continue to be cleaned up.
410
411bsd.own.mk is generally useful when building your own Makefiles so that
412they use the same default owners etc. as the rest of the tree.
413
414
415=-=-=-=-=   bsd.dep.mk   =-=-=-=-=
416
417The include file <bsd.dep.mk> contains the default targets for building
418.depend files.  It creates .d files from entries in SRCS and DPSRCS,
419and builds .depend from those.  In order for this to function correctly,
420it should be .included after all other .mk files and directives that may
421modify SRCS or DPSRCS.  It uses the following variables:
422
423SRCS		List of source files to build the program.
424
425DPSRCS		List of source files which are needed for generating
426		dependencies, but are not needed in ${SRCS}.
427		These are automatically added to CLEANFILES.
428
429
430It sets the following variables:
431
432DEPENDSRCS	.depend and all the .d files for this target.
433		If this variable is to used as a target, the rule
434		must appear after all of the bsd.*.mk includes
435		to function correctly.
436
437
438=-=-=-=-=   bsd.files.mk   =-=-=-=-=
439
440The include file <bsd.files.mk> handles the FILES variables and is included
441from bsd.lib.mk and bsd.prog.mk, and uses the following variables:
442
443FILES		The list of files to install.
444
445FILESOWN	File owner.  [${BINOWN}]
446
447FILESGRP	File group.  [${BINGRP}]
448
449FILESMODE	File mode.  [${BINMODE}]
450
451FILESDIR	The location to install the files.
452
453FILESNAME	Optional name to install each file as.
454
455FILESDIR.<fn>	The location to install the specific file <fn>.
456
457FILESNAME.<fn>	Optional name to install <fn> as.
458
459
460=-=-=-=-=   bsd.gcc.mk   =-=-=-=-=
461
462The include file <bsd.gcc.mk> computes various parameters related to GCC
463support libraries.  It defines no targets.  <bsd.own.mk> MUST be included
464before bsd.gcc.mk.
465
466The primary users of bsd.gcc.mk are <bsd.prog.mk> and <bsd.lib.mk>, each
467of which need to know where to find certain GCC support libraries.
468
469The behavior of bsd.gcc.mk is influenced by the EXTERNAL_TOOLCHAIN variable,
470which is generally set by the user.  If EXTERNAL_TOOLCHAIN it set, then
471the compiler is asked where to find the support libraries, otherwise the
472support libraries are found in ${DESTDIR}/usr/lib.
473
474bsd.gcc.mk sets the following variables:
475
476_GCC_CRTBEGIN	The full path name to crtbegin.o.
477
478_GCC_CRTBEGINS	The full path name to crtbeginS.o.
479
480_GCC_CRTEND	The full path name to crtend.o.
481
482_GCC_CRTENDS	The full path name to crtendS.o.
483
484_GCC_LIBGCCDIR	The directory where libgcc.a is located.
485
486
487=-=-=-=-=   bsd.inc.mk   =-=-=-=-=
488
489The include file <bsd.inc.mk> defines the includes target and uses two
490variables:
491
492INCS		The list of include files.
493
494INCSDIR		The location to install the include files.
495
496INCSNAME	Target name of the include file, if only one; same as
497		FILESNAME, but for include files.
498
499INCSNAME_<file>	The name file <file> should be installed as, if not <file>,
500		same as FILESNAME_<file>, but for include files.
501
502
503=-=-=-=-=   bsd.info.mk   =-=-=-=-=
504
505The include file <bsd.info.mk> is used to generate and install GNU Info
506documentation from respective Texinfo source files.  It defines three
507implicit targets (.txi.info, .texi.info, and .texinfo.info), and uses the
508following variables:
509
510TEXINFO		List of Texinfo source files.  Info documentation will
511		consist of single files with the extension replaced by
512		.info.
513
514INFOFLAGS	Flags to pass to makeinfo.  []
515
516
517=-=-=-=-=   bsd.kernobj.mk   =-=-=-=-=
518
519The include file <bsd.kernobj.mk> defines variables related to the
520location of kernel sources and object directories.
521
522KERNSRCDIR	Is the location of the top of the kernel src.
523		[${_SRC_TOP_}/sys]
524
525KERNARCHDIR	Is the location of the machine dependent kernel sources.
526		[arch/${MACHINE}]
527
528KERNCONFDIR	Is where the configuration files for kernels are found.
529		[${KERNSRCDIR}/${KERNARCHDIR}/conf]
530
531KERNOBJDIR	Is the kernel build directory.  The kernel GENERIC for
532		instance will be compiled in ${KERNOBJDIR}/GENERIC.
533		The default value is
534		${MAKEOBJDIRPREFIX}${KERNSRCDIR}/${KERNARCHDIR}/compile
535		if it exists or the target 'obj' is being made.
536		Otherwise the default is
537		${KERNSRCDIR}/${KERNARCHDIR}/compile.
538
539It is important that Makefiles (such as those under src/distrib) that
540wish to find compiled kernels use bsd.kernobj.mk and ${KERNOBJDIR}
541rather than make assumptions about the location of the compiled kernel.
542
543
544=-=-=-=-=   bsd.kinc.mk   =-=-=-=-=
545
546The include file <bsd.kinc.mk> defines the many targets (includes,
547subdirectories, etc.), and is used by kernel makefiles to handle
548include file installation.  It is intended to be included alone, by
549kernel Makefiles.  Please see bsd.kinc.mk for more details, and keep
550the documentation in that file up to date.
551
552
553=-=-=-=-=   bsd.lib.mk   =-=-=-=-=
554
555The include file <bsd.lib.mk> has support for building libraries.  It has
556the same eight targets as <bsd.prog.mk>: all, clean, cleandir, depend,
557includes, install, lint, and tags.  Additionally, it has a checkver target
558which checks for installed shared object libraries whose version is greater
559that the version of the source. It has a limited number of suffixes,
560consistent with the current needs of the BSD tree.  bsd.lib.mk includes
561<bsd.shlib.mk> to get shared library parameters.
562
563It sets/uses the following variables:
564
565LIB		The name of the library to build.
566
567LIBDIR		Target directory for libraries.
568
569SHLIBINSTALLDIR	Target directory for shared libraries if ${USE_SHLIBDIR}
570		is "yes".
571
572USE_SHLIBDIR	If "yes", use ${SHLIBINSTALLDIR} instead of ${LIBDIR}
573		as the path to install shared libraries to.
574		USE_SHLIBDIR must be defined before <bsd.own.mk> is included.
575		Default: no
576
577LINTLIBDIR	Target directory for lint libraries.
578
579LIBGRP		Library group.
580
581LIBOWN		Library owner.
582
583LIBMODE		Library mode.
584
585LDADD		Additional loader objects.
586
587MAN		The manual pages to be installed (use a .1 - .9 suffix).
588
589NOCHECKVER_<library>
590NOCHECKVER	If set, disables checking for installed shared object
591		libraries with versions greater than the source.  A
592		particular library name, without the "lib" prefix, may
593		be appended to the variable name to disable the check for
594		only that library.
595
596SRCS		List of source files to build the library.  Suffix types
597		.s, .c, and .f are supported.  Note, .s files are preferred
598		to .c files of the same name.  (This is not the default for
599		versions of make.)
600
601The include file <bsd.lib.mk> includes the file named "../Makefile.inc"
602if it exists, as well as the include file <bsd.man.mk>.
603
604It has rules for building profiled objects; profiled libraries are
605built by default.
606
607Libraries are ranlib'd when made.
608
609
610=-=-=-=-=   bsd.links.mk   =-=-=-=-=
611
612The include file <bsd.links.mk> handles the LINKS and SYMLINKS variables
613and is included from from bsd.lib.mk and bsd.prog.mk.
614
615
616=-=-=-=-=   bsd.man.mk   =-=-=-=-=
617
618The include file <bsd.man.mk> handles installing manual pages and their
619links.
620
621It has a two targets:
622
623	maninstall:
624		Install the manual page sources and their links.
625	catinstall:
626		Install the preformatted manual pages and their links.
627
628It sets/uses the following variables:
629
630MANDIR		Base path for manual installation.
631
632MANGRP		Manual group.
633
634MANOWN		Manual owner.
635
636MANMODE		Manual mode.
637
638MANSUBDIR	Subdirectory under the manual page section, i.e. "/vax"
639		or "/tahoe" for machine specific manual pages.
640
641MAN		The manual pages to be installed (use a .1 - .9 suffix).
642
643MLINKS		List of manual page links (using a .1 - .9 suffix).  The
644		linked-to file must come first, the linked file second,
645		and there may be multiple pairs.  The files are soft-linked.
646
647The include file <bsd.man.mk> includes a file named "../Makefile.inc" if
648it exists.
649
650
651=-=-=-=-=   bsd.obj.mk   =-=-=-=-=
652
653The include file <bsd.obj.mk> defines targets related to the creation
654and use of separated object and source directories.
655
656If an environment variable named MAKEOBJDIRPREFIX is set, make(1) uses
657${MAKEOBJDIRPREFIX}${.CURDIR} as the name of the object directory if
658it exists.  Otherwise make(1) looks for the existence of a
659subdirectory (or a symlink to a directory) of the source directory
660into which built targets should be placed.  If an environment variable
661named MAKEOBJDIR is set, make(1) uses its value as the name of the
662object directory; failing that, make first looks for a subdirectory
663named "obj.${MACHINE}", and if that doesn't exist, it looks for "obj".
664
665Object directories are not created automatically by make(1) if they
666don't exist; you need to run a separate "make obj".  (This will happen
667during a top-level build if "MKOBJDIRS" is set to a value other than
668"no").  When the source directory is a subdirectory of ${BSDSRCDIR} --
669and this is determined by a simple string prefix comparison -- object
670directories are created in a separate object directory tree, and a
671symlink to the object directory in that tree is created in the source
672directory; otherwise, "make obj" assumes that you're not in the main
673source tree and that it's not safe to use a separate object tree.
674
675Several variables used by <bsd.obj.mk> control exactly what
676directories and links get created during a "make obj":
677
678MAKEOBJDIR	If set, this is the component name of the object
679		directory.
680
681OBJMACHINE	If this is set but MAKEOBJDIR is not set, creates
682		object directories or links named "obj.${MACHINE}";
683		otherwise, just creates ones named "obj".
684
685USR_OBJMACHINE  If set, and the current directory is a subdirectory of
686		${BSDSRCDIR}, create object directory in the
687		corresponding subdirectory of ${BSDOBJDIR}.${MACHINE};
688		otherwise, create it in the corresponding subdirectory
689		of ${BSDOBJDIR}
690
691BUILDID		If set, the contents of this variable are appended
692		to the object directory name.  If OBJMACHINE is also
693		set, ".${BUILDID}" is added after ".${MACHINE}".
694
695
696=-=-=-=-=   bsd.prog.mk   =-=-=-=-=
697
698The include file <bsd.prog.mk> handles building programs from one or
699more source files, along with their manual pages.  It has a limited number
700of suffixes, consistent with the current needs of the BSD tree.  bsd.prog.mk
701includes <bsd.shlib.mk> to get shared library parameters.
702
703It has eight targets:
704
705	all:
706		build the program and its manual page.  This also
707		creates a GDB initialization file (.gdbinit) in
708		the objdir.  The .gdbinit file sets the shared library
709		prefix to ${DESTDIR} to facilitate cross-debugging.
710	clean:
711		remove the program, any object files and the files a.out,
712		Errs, errs, mklog, and ${PROG}.core.
713	cleandir:
714		remove all of the files removed by the target clean, as
715		well as .depend, tags, and any manual pages.
716		`distclean' is a synonym for `cleandir'.
717	depend:
718		make the dependencies for the source files, and store
719		them in the file .depend.
720	includes:
721		install any header files.
722	install:
723		install the program and its manual pages; if the Makefile
724		does not itself define the target install, the targets
725		beforeinstall and afterinstall may also be used to cause
726		actions immediately before and after the install target
727		is executed.
728	lint:
729		run lint on the source files
730	tags:
731		create a tags file for the source files.
732
733It sets/uses the following variables:
734
735BINGRP		Binary group.
736
737BINOWN		Binary owner.
738
739BINMODE		Binary mode.
740
741CLEANFILES	Additional files to remove for the clean and cleandir targets.
742
743COPTS		Additional flags to the compiler when creating C objects.
744
745COPTS.<fn>	Additional flags to the compiler when creating the
746		C objects for <fn>.
747		For <fn>.[ly], "<fn>.c" must be used.
748
749CPUFLAGS	Additional flags to the compiler/assembler to select
750		CPU instruction set options, CPU tuning options, etc.
751
752CPUFLAGS.<fn>	Additional flags to the compiler/assembler for <fn>.
753		For <fn>.[ly], "<fn>.c" must be used.
754
755CPPFLAGS	Additional flags to the C pre-processor.
756
757CPPFLAGS.<fn>	Additional flags to the C pre-processor for <fn>.
758		For <fn>.[ly], "<fn>.c" must be used.
759
760GDBINIT		List of GDB initialization files to add to "source"
761		directives in the .gdbinit file that is created in the
762		objdir.
763
764LDADD		Additional loader objects.  Usually used for libraries.
765		For example, to load with the compatibility and utility
766		libraries, use:
767
768			LDADD+=-lutil -lcompat
769
770LDFLAGS		Additional loader flags.
771
772LINKS		The list of binary links; should be full pathnames, the
773		linked-to file coming first, followed by the linked
774		file.  The files are hard-linked.  For example, to link
775		/bin/test and /bin/[, use:
776
777			LINKS=	${DESTDIR}/bin/test ${DESTDIR}/bin/[
778
779SYMLINKS	The list of symbolic links; should be full pathnames.
780                Syntax is identical to LINKS. Note that DESTDIR is not
781		automatically included in the link.
782
783MAN		Manual pages (should end in .1 - .9).  If no MAN variable is
784		defined, "MAN=${PROG}.1" is assumed.
785
786PROG		The name of the program to build.  If not supplied, nothing
787		is built.
788
789PROG_CXX	If defined, the name of the program to build.  Also
790		causes <bsd.prog.mk> to link the program with the C++
791		compiler rather than the C compiler.  PROG_CXX overrides
792		the value of PROG if PROG is also set.
793
794PROGNAME	The name that the above program will be installed as, if
795		different from ${PROG}.
796
797SRCS		List of source files to build the program.  If SRCS is not
798		defined, it's assumed to be ${PROG}.c.
799
800DPSRCS		List of source files which are needed for generating
801		dependencies, but are not needed in ${SRCS}.
802
803DPADD		Additional dependencies for the program.  Usually used for
804		libraries.  For example, to depend on the compatibility and
805		utility libraries use:
806
807			DPADD+=${LIBCOMPAT} ${LIBUTIL}
808
809		The following libraries are predefined for DPADD:
810
811		LIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
812		LIBBZ2?=	${DESTDIR}/usr/lib/libbz2.a
813		LIBC?=		${DESTDIR}/usr/lib/libc.a
814		LIBC_PIC?=	${DESTDIR}/usr/lib/libc_pic.a
815		LIBCDK?=	${DESTDIR}/usr/lib/libcdk.a
816		LIBCOM_ERR?=	${DESTDIR}/usr/lib/libcom_err.a
817		LIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
818		LIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
819		LIBCRYPTO?=	${DESTDIR}/usr/lib/libcrypto.a
820		LIBCRYPTO_IDEA?=${DESTDIR}/usr/lib/libcrypto_idea.a
821		LIBCRYPTO_MDC2?=${DESTDIR}/usr/lib/libcrypto_mdc2.a
822		LIBCRYPTO_RC5?=	${DESTDIR}/usr/lib/libcrypto_rc5.a
823		LIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
824		LIBDBM?=	${DESTDIR}/usr/lib/libdbm.a
825		LIBDES?=	${DESTDIR}/usr/lib/libdes.a
826		LIBEDIT?=	${DESTDIR}/usr/lib/libedit.a
827		LIBEVENT?=	${DESTDIR}/usr/lib/libevent.a
828		LIBFORM?=	${DESTDIR}/usr/lib/libform.a
829		LIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
830		LIBGNUMALLOC?=	${DESTDIR}/usr/lib/libgnumalloc.a
831		LIBGSSAPI?=	${DESTDIR}/usr/lib/libgssapi.a
832		LIBHDB?=	${DESTDIR}/usr/lib/libhdb.a
833		LIBINTL?=	${DESTDIR}/usr/lib/libintl.a
834		LIBIPSEC?=	${DESTDIR}/usr/lib/libipsec.a
835		LIBKADM?=	${DESTDIR}/usr/lib/libkadm.a
836		LIBKADM5CLNT?=	${DESTDIR}/usr/lib/libkadm5clnt.a
837		LIBKADM5SRV?=	${DESTDIR}/usr/lib/libkadm5srv.a
838		LIBKAFS?=	${DESTDIR}/usr/lib/libkafs.a
839		LIBKDB?=	${DESTDIR}/usr/lib/libkdb.a
840		LIBKRB?=	${DESTDIR}/usr/lib/libkrb.a
841		LIBKRB5?=	${DESTDIR}/usr/lib/libkrb5.a
842		LIBKSTREAM?=	${DESTDIR}/usr/lib/libkstream.a
843		LIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
844		LIBL?=		${DESTDIR}/usr/lib/libl.a
845		LIBM?=		${DESTDIR}/usr/lib/libm.a
846		LIBMENU?=	${DESTDIR}/usr/lib/libmenu.a
847		LIBMP?=		${DESTDIR}/usr/lib/libmp.a
848		LIBNTP?=	${DESTDIR}/usr/lib/libntp.a
849		LIBOBJC?=	${DESTDIR}/usr/lib/libobjc.a
850		LIBOSSAUDIO?=	${DESTDIR}/usr/lib/libossaudio.a
851		LIBPC?=		${DESTDIR}/usr/lib/libpc.a
852		LIBPCAP?=	${DESTDIR}/usr/lib/libpcap.a
853		LIBPCI?=	${DESTDIR}/usr/lib/libpci.a
854		LIBPLOT?=	${DESTDIR}/usr/lib/libplot.a
855		LIBPMC?=	${DESTDIR}/usr/lib/libpmc.a
856		LIBPOSIX?=	${DESTDIR}/usr/lib/libposix.a
857		LIBPTHREAD?=	${DESTDIR}/usr/lib/libpthread.a
858		LIBPTHREAD_DBG?=${DESTDIR}/usr/lib/libpthread_dbg.a
859		LIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
860		LIBRMT?=	${DESTDIR}/usr/lib/librmt.a
861		LIBROKEN?=	${DESTDIR}/usr/lib/libroken.a
862		LIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
863		LIBRT?=		${DESTDIR}/usr/lib/librt.a
864		LIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
865		LIBSS?=		${DESTDIR}/usr/lib/libss.a
866		LIBSSL?=	${DESTDIR}/usr/lib/libssl.a
867		LIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
868		LIBSL?=		${DESTDIR}/usr/lib/libsl.a
869		LIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
870		LIBUSBHID?=	${DESTDIR}/usr/lib/libusbhid.a
871		LIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
872		LIBWRAP?=	${DESTDIR}/usr/lib/libwrap.a
873		LIBY?=		${DESTDIR}/usr/lib/liby.a
874		LIBZ?=		${DESTDIR}/usr/lib/libz.a
875
876SHAREDSTRINGS	If defined, a new .c.o rule is used that results in shared
877		strings, using xstr(1). Note that this will not work with
878		parallel makes.
879
880STRIPFLAG	The flag passed to the install program to cause the binary
881		to be stripped.
882
883SUBDIR		A list of subdirectories that should be built as well.
884		Each of the targets will execute the same target in the
885		subdirectories.
886
887SCRIPTS		A list of interpreter scripts [file.{sh,csh,pl,awk,...}].
888		These are installed exactly like programs.
889
890SCRIPTSNAME	The name that the above program will be installed as, if
891		different from ${SCRIPTS}. These can be further specialized
892		by setting SCRIPTSNAME_<script>.
893
894FILES		See description of <bsd.files.mk>.
895
896SHLINKDIR	Target directory for shared linker.  See description of
897		<bsd.own.mk> for additional information about this variable.
898
899USE_LIBSTDCXX	If "no", the support libraries needed for C++ programs
900		are set to `-lsupc++ -lm', rather than `-lstdc++ -lm'.
901		Default: yes
902
903The include file <bsd.prog.mk> includes the file named "../Makefile.inc"
904if it exists, as well as the include file <bsd.man.mk>.
905
906Some simple examples:
907
908To build foo from foo.c with a manual page foo.1, use:
909
910	PROG=	foo
911
912	.include <bsd.prog.mk>
913
914To build foo from foo.c with a manual page foo.2, add the line:
915
916	MAN=	foo.2
917
918If foo does not have a manual page at all, add the line:
919
920	MKMAN=	no
921
922If foo has multiple source files, add the line:
923
924	SRCS=	a.c b.c c.c d.c
925
926
927=-=-=-=-=   bsd.rpc.mk   =-=-=-=-=
928
929The include file <bsd.rpc.mk> contains a makefile fragment used to
930construct source files built by rpcgen.
931
932The following macros may be defined in makefiles which include
933<bsd.rpc.mk> in order to control which files get built and how they
934are to be built:
935
936RPC_INCS:	construct .h file from .x file
937RPC_XDRFILES:	construct _xdr.c from .x file
938		(for marshalling/unmarshalling data types)
939RPC_SVCFILES:	construct _svc.c from .x file
940		(server-side stubs)
941RPC_SVCFLAGS:	Additional flags passed to builds of RPC_SVCFILES.
942
943RPC_XDIR:	Directory containing .x/.h files
944
945
946=-=-=-=-=   bsd.shlib.mk   =-=-=-=-=
947
948The include file <bsd.shlib.mk> computes parameters for shared library
949installation and use.  It defines no targets.  <bsd.own.mk> MUST be
950included before bsd.shlib.mk.
951
952bsd.own.mk sets the following variables, if they are not already defined
953(defaults are in brackets):
954
955SHLIBINSTALLDIR	If ${USE_SHLIBDIR} is "yes", use ${SHLIBINSTALLDIR} instead of
956		${LIBDIR} as the base path for shared library installation.
957		[/lib]
958
959SHLIBDIR	The path to USE_SHLIBDIR shared libraries to use when building
960		a program.  [/lib for programs in /bin and /sbin, /usr/lib
961		for all others.]
962
963_LIBSODIR	Set to ${SHLIBINSTALLDIR} if ${USE_SHLIBDIR} is "yes",
964		otherwise set to ${LIBDIR}
965
966SHLINKINSTALLDIR Base path for shared linker.  [/libexec]
967
968SHLINKDIR	Path to use for shared linker when building a program.
969		[/libexec for programs in /bin and /sbin, /usr/libexec for
970		all others.]
971
972
973=-=-=-=-=   bsd.subdir.mk   =-=-=-=-=
974
975The include file <bsd.subdir.mk> contains the default targets for building
976subdirectories.  It has the same eight targets as <bsd.prog.mk>: all,
977clean, cleandir, depend, includes, install, lint, and tags.  For all of
978the directories listed in the variable SUBDIR, the specified directory
979will be visited and the target made.  There is also a default target which
980allows the command "make subdir" where subdir is any directory listed in
981the variable SUBDIR.
982
983As a special case, the use of a token .WAIT as an entry in SUBDIR acts
984as a synchronization barrier when multiple make jobs are run; subdirs
985before the .WAIT must complete before any subdirs after .WAIT are
986started.  See make(1) for some caveats on use of .WAIT and other
987special sources.
988
989
990=-=-=-=-=   bsd.sys.mk   =-=-=-=-=
991
992The include file <bsd.sys.mk> is used by <bsd.prog.mk> and
993<bsd.lib.mk>.  It contains overrides that are used when building
994the NetBSD source tree.  For instance, if "PARALLEL" is defined by
995the program/library Makefile, it includes a set of rules for lex and
996yacc that allow multiple lex and yacc targets to be built in parallel.
997
998The following variables are defined to commands to perform the
999appropriate operation, with the default in [brackets].
1000(Note that these are overridden in <bsd.own.mk> if USETOOLS=yes):
1001
1002TOOL_ASN1_COMPILE	ASN1 compiler.  [asn1_compile]
1003
1004TOOL_CAP_MKDB		Create capability database.  [cap_mkdb]
1005
1006TOOL_CAT		Concatenate and print files.  [cat]
1007
1008TOOL_CKSUM		Display file checksums.  [cksum]
1009
1010TOOL_COMPILE_ET		Error table compiler.  [compile_et]
1011
1012TOOL_CONFIG		Build kernel compilation directories.  [config]
1013
1014TOOL_CRUNCHGEN		Generate crunched binary build environment.  [crunchgen]
1015
1016TOOL_CTAGS		Create a tags file.  [ctags]
1017
1018TOOL_DB			Manipulate db(3) databases.  [db]
1019
1020TOOL_EQN		Format equations for groff.  [eqn]
1021
1022TOOL_FGEN		IEEE 1275 Open Firmware FCode Tokenizer.  [fgen]
1023
1024TOOL_GENCAT		Generate NLS message catalogs.  [gencat]
1025
1026TOOL_GROFF		Front end for groff document formatting system.  [groff]
1027
1028TOOL_HEXDUMP		Ascii, decimal, hexadecimal, octal dump.  [hexdump]
1029
1030TOOL_INDXBIB		Make bibliographic database's inverted index.  [indxbib]
1031
1032TOOL_INSTALLBOOT	Install disk bootstrap software.  [installboot]
1033
1034TOOL_INSTALL_INFO	Update info/dir entries.  [install-info]
1035
1036TOOL_M4			M4 macro language processor.  [m4]
1037
1038TOOL_MAKEFS		Create file system image from directory tree.  [makefs]
1039
1040TOOL_MAKEINFO		Translate Texinfo documents.  [makeinfo]
1041
1042TOOL_MAKEWHATIS		Create a whatis.db database.  [makewhatis]
1043
1044TOOL_MDSETIMAGE		Set kernel RAM disk image.  [mdsetimage]
1045
1046TOOL_MENUC		Menu compiler.  [menuc]
1047
1048TOOL_MKCSMAPPER		Make charset mapping table.  [mkcsmapper]
1049
1050TOOL_MKESDB		Make encoding scheme database.  [mkesdb]
1051
1052TOOL_MKLOCALE		Make LC_CTYPE locale files.  [mklocale]
1053
1054TOOL_MKMAGIC		Create database for file(1).  [file]
1055
1056TOOL_MKTEMP		Make (unique) temporary file name.  [mktemp]
1057
1058TOOL_MSGC		Simple message list compiler.  [msgc]
1059
1060TOOL_MTREE		Map a directory hierarchy.  [mtree]
1061
1062TOOL_PAX		Manipulate file archives and copy directories.  [pax]
1063
1064TOOL_PIC		Compile pictures for groff.  [pic]
1065
1066TOOL_PREPMKBOOTIMAGE	prep-mkbootimage (XXXBUILDSH).  [prep-mkbootimage]
1067
1068TOOL_PWD_MKDB		Generate the password databases.  [pwd_mkdb]
1069
1070TOOL_REFER		Preprocess bibliographic references for groff.  [refer]
1071
1072TOOL_ROFF_ASCII		Generate ASCII groff output.  [nroff]
1073
1074TOOL_ROFF_DVI		Generate DVI groff output.  [${TOOL_GROFF} -Tdvi]
1075
1076TOOL_ROFF_HTML		Generate HTML groff output.
1077			[${TOOL_GROFF} -Tlatin1 -mdoc2html]
1078
1079TOOL_ROFF_PS		Generate PS groff output.  [${TOOL_GROFF} -Tps]
1080
1081TOOL_ROFF_RAW		Generate "raw" groff output.  [${TOOL_GROFF} -Z]
1082
1083TOOL_RPCGEN		Remote Procedure Call (RPC) protocol compiler.  [rpcgen]
1084
1085TOOL_SOELIM		Eliminate .so's from groff input.  [soelim]
1086
1087TOOL_STAT		Display file status.  [stat]
1088
1089TOOL_SUNLABEL		Read or modify a SunOS disk label.  [sunlabel]
1090
1091TOOL_TBL		Format tables for groff.  [tbl]
1092
1093TOOL_UUDECODE		Uudecode a binary file.  [uudecode]
1094
1095TOOL_VGRIND		Grind nice listings of programs.  [vgrind -f]
1096
1097TOOL_ZIC		Time zone compiler.  [zic]
1098
1099
1100Other variables of note (incomplete list):
1101
1102WARNS		Crank up gcc warning options; the distinct levels are:
1103			WARNS=1
1104			WARNS=2
1105			WARNS=3
1106
1107FORMAT_AUDIT	If FORMAT_AUDIT is set, and WFORMAT is set and > 1, turn on
1108WFORMAT 	-Wnetbsd-format-audit for extra-stringent format checking.
1109		WFORMAT belongs in individual makefiles and/or
1110		Makefile.inc files.  (set WFORMAT=1 in individual
1111		makefiles if a program is not security critical and is
1112		doing bizarre things with format strings which would
1113		be even uglier if rewritten) FORMAT_AUDIT should go in
1114		mk.conf if you're doing format-string auditing.
1115		FORMAT_AUDIT may go away in time.
1116
1117=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1118