bsd.README revision 1.49
1#	$NetBSD: bsd.README,v 1.49 1999/07/01 20:19:18 itojun 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 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
61The following variables that control how things are made/installed that
62are not set by default. These should not be set by Makefiles; they're for
63the user to define in MAKECONF (see bsd.own.mk, below) or on the make(1)
64command line:
65
66BUILD 		If defined, 'make install' checks that the targets in the
67		source directories are up-to-date and remakes them if they
68                are out of date, instead of blindly trying to install
69                out of date or non-existant targets.
70
71UPDATE 		If defined, 'make install' only installs targets that are
72		more recently modified in the source directories that their
73		installed counterparts.
74
75MKCATPAGES	If "no", don't build or install the catman pages.
76
77MKDOC		If "no", don't build or install the documentation.
78
79MKINFO		If "no", don't build or install Info documentation from
80		Texinfo source files.
81
82MKLINT		If "no", don't build or install the lint libraries.
83
84MKMAN		If "no", don't build or install the man or catman pages.
85		Also acts as "MKCATPAGES=no"
86
87MKNLS		If "no", don't build or install the NLS files.
88
89MKOBJ		If "no", don't create objdirs.
90
91MKPIC		If "no", don't build or install shared libraries.
92
93MKPICINSTALL	If "no", don't install the *_pic.a libraries.
94
95MKPROFILE	If "no", don't build or install the profiling libraries.
96
97MKSHARE		If "no", act as "MKCATPAGES=no MKDOC=no MKINFO=no MKMAN=no
98		MKNLS=no".  I.e, don't build catman pages, documentation,
99		Info documentation, man pages, NLS files, ...
100
101=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
102
103The include file <sys.mk> has the default rules for all makes, in the BSD
104environment or otherwise.  You probably don't want to touch this file.
105
106=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
107
108The include file <bsd.man.mk> handles installing manual pages and their
109links.
110
111It has a two targets:
112
113	maninstall:
114		Install the manual page sources and their links.
115	catinstall:
116		Install the preformatted manual pages and their links.
117
118It sets/uses the following variables:
119
120MANDIR		Base path for manual installation.
121
122MANGRP		Manual group.
123
124MANOWN		Manual owner.
125
126MANMODE		Manual mode.
127
128MANSUBDIR	Subdirectory under the manual page section, i.e. "/vax"
129		or "/tahoe" for machine specific manual pages.
130
131MAN		The manual pages to be installed (use a .1 - .9 suffix).
132
133MLINKS		List of manual page links (using a .1 - .9 suffix).  The
134		linked-to file must come first, the linked file second,
135		and there may be multiple pairs.  The files are soft-linked.
136
137The include file <bsd.man.mk> includes a file named "../Makefile.inc" if
138it exists.
139
140=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
141
142The include file <bsd.own.mk> contains source tree configuration parameters,
143such as the owners, groups, etc. for both manual pages and binaries, and
144a few global "feature configuration" parameters.
145
146It has no targets.
147
148To get system-specific configuration parameters, bsd.own.mk will try to
149include the file specified by the "MAKECONF" variable.  If MAKECONF is not
150set, or no such file exists, the system make configuration file, /etc/mk.conf
151is included.  These files may define any of the variables described below.
152
153bsd.own.mk sets the following variables, if they are not already defined
154(defaults are in brackets):
155
156BSDSRCDIR	The real path to the system sources, so that 'make obj'
157		will work correctly. [/usr/src]
158
159BSDOBJDIR	The real path to the system 'obj' tree, so that 'make obj'
160		will work correctly. [/usr/obj]
161
162BINGRP		Binary group. [wheel]
163
164BINOWN		Binary owner. [root]
165
166BINMODE		Binary mode. [555]
167
168NONBINMODE	Mode for non-executable files. [444]
169
170MANDIR		Base path for manual installation. [/usr/share/man/cat]
171
172MANGRP		Manual group. [wheel]
173
174MANOWN		Manual owner. [root]
175
176MANMODE		Manual mode. [${NONBINMODE}]
177
178MANINSTALL	Manual installation type: maninstall, catinstall, or both
179
180LIBDIR		Base path for library installation. [/usr/lib]
181
182LINTLIBDIR	Base path for lint(1) library installation. [/usr/libdata/lint]
183
184LIBGRP		Library group. [${BINGRP}]
185
186LIBOWN		Library owner. [${BINOWN}]
187
188LIBMODE		Library mode. [${NONBINMODE}]
189
190DOCDIR		Base path for system documentation (e.g. PSD, USD, etc.)
191	        installation. [/usr/share/doc]
192
193DOCGRP		Documentation group. [wheel]
194
195DOCOWN		Documentation owner. [root]
196
197DOCMODE		Documentation mode. [${NONBINMODE}]
198
199NLSDIR		Base path for National Language Support files installation.
200		[/usr/share/nls]
201
202NLSGRP		National Language Support files group. [wheel]
203
204NLSOWN		National Language Support files owner. [root]
205
206NLSMODE		National Language Support files mode. [${NONBINMODE}]
207
208STRIPFLAG	The flag passed to the install program to cause the binary
209		to be stripped.  This is to be used when building your
210		own install script so that the entire system can be made
211		stripped/not-stripped using a single knob. [-s]
212
213COPY		The flag passed to the install program to cause the binary
214		to be copied rather than moved.  This is to be used when
215		building our own install script so that the entire system
216		can either be installed with copies, or with moves using
217		a single knob. [-c]
218
219Additionally, the following variables may be set by bsd.own.mk or in a
220make configuration file to modify the behaviour of the system build
221process (default values are in brackets along with comments, if set by
222bsd.own.mk):
223
224EXPORTABLE_SYSTEM
225		Do not build /usr/src/domestic, even if it is present.
226
227SKEY		Compile in support for S/key authentication. [yes, set
228		unconditionally]
229
230KERBEROS	Compile in support for Kerberos 4 authentication.
231
232KERBEROS5	Compile in support for Kerberos 5 authentication.
233
234MANZ		Compress manual pages at installation time.
235
236SYS_INCLUDE	Copy or symlink kernel include files into /usr/include.
237		Possible values are "symlinks" or "copies" (which is
238		the same as the variable being unset).
239
240NOPROFILE	Do not build profiled versions of system libraries
241
242NOPIC		Do not build PIC versions of system libraries, and
243		do not build shared libraries.  [set if ${MACHINE_ARCH}
244		is "sparc64", unset otherwise.]
245
246NOLINT		Do not build lint libraries.
247
248OBJECT_FMT	Object file format. [set to "ELF" on  ports that use
249		ELF -- currently if ${MACHINE_ARCH} is "alpha", "mips"
250		or "powerpc" or  set to "a.out" on other ports].
251
252
253bsd.own.mk is generally useful when building your own Makefiles so that
254they use the same default owners etc. as the rest of the tree.
255
256=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
257
258The include file <bsd.prog.mk> handles building programs from one or
259more source files, along with their manual pages.  It has a limited number
260of suffixes, consistent with the current needs of the BSD tree.
261
262It has eight targets:
263
264	all:
265		build the program and its manual page
266	clean:
267		remove the program, any object files and the files a.out,
268		Errs, errs, mklog, and ${PROG}.core.
269	cleandir:
270		remove all of the files removed by the target clean, as
271		well as .depend, tags, and any manual pages.
272		`distclean' is a synonym for `cleandir'.
273	depend:
274		make the dependencies for the source files, and store
275		them in the file .depend.
276	includes:
277		install any header files.
278	install:
279		install the program and its manual pages; if the Makefile
280		does not itself define the target install, the targets
281		beforeinstall and afterinstall may also be used to cause
282		actions immediately before and after the install target
283		is executed.
284	lint:
285		run lint on the source files
286	tags:
287		create a tags file for the source files.
288
289It sets/uses the following variables:
290
291BINGRP		Binary group.
292
293BINOWN		Binary owner.
294
295BINMODE		Binary mode.
296
297CLEANFILES	Additional files to remove for the clean and cleandir targets.
298
299COPTS		Additional flags to the compiler when creating C objects.
300
301CPPFLAGS	Additional flags to the C pre-processor
302
303LDADD		Additional loader objects.  Usually used for libraries.
304		For example, to load with the compatibility and utility
305		libraries, use:
306
307			LDADD+=-lutil -lcompat
308
309LDFLAGS		Additional loader flags.
310
311LINKS		The list of binary links; should be full pathnames, the
312		linked-to file coming first, followed by the linked
313		file.  The files are hard-linked.  For example, to link
314		/bin/test and /bin/[, use:
315
316			LINKS=	${DESTDIR}/bin/test ${DESTDIR}/bin/[
317
318SYMLINKS	The list of symbolic links; should be full pathnames.
319                Syntax is identical to LINKS. Note that DESTDIR is not
320		automatically included in the link.
321
322MAN		Manual pages (should end in .1 - .9).  If no MAN variable is
323		defined, "MAN=${PROG}.1" is assumed.
324
325PROG		The name of the program to build.  If not supplied, nothing
326		is built.
327
328PROGNAME	The name that the above program will be installed as, if
329		different from ${PROG}.
330
331SRCS		List of source files to build the program.  If SRCS is not
332		defined, it's assumed to be ${PROG}.c.
333
334DPADD		Additional dependencies for the program.  Usually used for
335		libraries.  For example, to depend on the compatibility and
336		utility libraries use:
337
338			DPADD+=${LIBCOMPAT} ${LIBUTIL}
339
340		The following libraries are predefined for DPADD:
341
342		LIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
343		LIBC?=		${DESTDIR}/usr/lib/libc.a
344		LIBC_PIC?=	${DESTDIR}/usr/lib/libc_pic.a
345		LIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
346		LIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
347		LIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
348		LIBDBM?=	${DESTDIR}/usr/lib/libdbm.a
349		LIBDES?=	${DESTDIR}/usr/lib/libdes.a
350		LIBEDIT?=	${DESTDIR}/usr/lib/libedit.a
351		LIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
352		LIBGNUMALLOC?=	${DESTDIR}/usr/lib/libgnumalloc.a
353		LIBIPSEC?=	${DESTDIR}/usr/lib/libipsec.a
354		LIBKDB?=	${DESTDIR}/usr/lib/libkdb.a
355		LIBKRB?=	${DESTDIR}/usr/lib/libkrb.a
356		LIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
357		LIBL?=		${DESTDIR}/usr/lib/libl.a
358		LIBM?=		${DESTDIR}/usr/lib/libm.a
359		LIBMP?=		${DESTDIR}/usr/lib/libmp.a
360		LIBNTP?=	${DESTDIR}/usr/lib/libntp.a
361		LIBPC?=		${DESTDIR}/usr/lib/libpc.a
362		LIBPCAP?=	${DESTDIR}/usr/lib/libpcap.a
363		LIBPLOT?=	${DESTDIR}/usr/lib/libplot.a
364		LIBPOSIX?=	${DESTDIR}/usr/lib/libposix.a
365		LIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
366		LIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
367		LIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
368		LIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
369		LIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
370		LIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
371		LIBWRAP?=	${DESTDIR}/usr/lib/libwrap.a
372		LIBY?=		${DESTDIR}/usr/lib/liby.a
373		LIBZ?=		${DESTDIR}/usr/lib/libz.a
374
375
376SHAREDSTRINGS	If defined, a new .c.o rule is used that results in shared
377		strings, using xstr(1). Note that this will not work with
378		parallel makes.
379
380STRIP		The flag passed to the install program to cause the binary
381		to be stripped.
382
383SUBDIR		A list of subdirectories that should be built as well.
384		Each of the targets will execute the same target in the
385		subdirectories.
386
387SCRIPTS		A list of interpreter scripts [file.{sh,csh,pl,awk,...}].
388		These are installed exactly like programs.
389
390SCRIPTSNAME	The name that the above program will be installed as, if
391		different from ${SCRIPTS}. These can be further specialized
392		by setting SCRIPTSNAME_<script>.
393
394FILES		A list of files to install. The installation is controlled
395		by the FILESNAME, FILESOWN, FILESGRP, FILESMODE, FILESDIR
396		variables that can be further specialized by FILES<VAR>_<file>
397
398The include file <bsd.prog.mk> includes the file named "../Makefile.inc"
399if it exists, as well as the include file <bsd.man.mk>.
400
401Some simple examples:
402
403To build foo from foo.c with a manual page foo.1, use:
404
405	PROG=	foo
406
407	.include <bsd.prog.mk>
408
409To build foo from foo.c with a manual page foo.2, add the line:
410
411	MAN=	foo.2
412
413If foo does not have a manual page at all, add the line:
414
415	NOMAN=	noman
416
417If foo has multiple source files, add the line:
418
419	SRCS=	a.c b.c c.c d.c
420
421=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
422
423The include file <bsd.subdir.mk> contains the default targets for building
424subdirectories.  It has the same eight targets as <bsd.prog.mk>: all, 
425clean, cleandir, depend, includes, install, lint, and tags.  For all of
426the directories listed in the variable SUBDIRS, the specified directory 
427will be visited and the target made.  There is also a default target which
428allows the command "make subdir" where subdir is any directory listed in
429the variable SUBDIRS.
430
431=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
432
433The include file <bsd.links.mk> handles the LINKS and SYMLINKS variables
434and is included from from bsd.lib.mk and bsd.prog.mk.
435
436=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
437
438The include file <bsd.files.mk> handles the FILES variables and is included
439from bsd.lib.mk and bsd.prog.mk.
440
441=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
442
443The include file <bsd.inc.mk> defines the includes target and uses two
444variables:
445
446INCS	The list of include files
447
448INCSDIR	The location to install the include files.
449
450=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
451
452The include file <bsd.kinc.mk> defines the many targets (includes,
453subdirectories, etc.), and is used by kernel makefiles to handle
454include file installation.  It is intended to be included alone, by
455kernel Makefiles.  Please see bsd.kinc.mk for more details, and keep
456the documentation in that file up to date.
457
458=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
459
460The include file <bsd.info.mk> is used to generate and install GNU Info
461documentation from respective Texinfo source files.  It defines three
462implicit targets (.txi.info, .texi.info, and .texinfo.info), and uses the
463following variables:
464
465TEXINFO		List of Texinfo source files.  Info documentation will
466		consist of single files with the extension replaced by
467		.info.
468
469INFOFLAGS	Flags to pass to makeinfo.  []
470
471INSTALL_INFO	Name of install-info program.  [install-info]
472
473MAKEINFO	Name of makeinfo program.  [makeinfo]
474
475=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
476
477The include file <bsd.sys.mk> is used by <bsd.prog.mk> and
478<bsd.lib.mk>.  It contains overrides that are used when building
479the NetBSD source tree.  For instance, if "PARALLEL" is defined by
480the program/library Makefile, it includes a set of rules for lex and
481yacc that allow multiple lex and yacc targets to be built in parallel.
482
483=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
484
485The include file <bsd.lib.mk> has support for building libraries.  It has
486the same eight targets as <bsd.prog.mk>: all, clean, cleandir, depend,
487includes, install, lint, and tags.  Additionally, it has a checkver target
488which checks for installed shared object libraries whose version is greater
489that the version of the source. It has a limited number of suffixes,
490consistent with the current needs of the BSD tree.
491
492It sets/uses the following variables:
493
494LIB		The name of the library to build.
495
496LIBDIR		Target directory for libraries.
497
498LINTLIBDIR	Target directory for lint libraries.
499
500LIBGRP		Library group.
501
502LIBOWN		Library owner.
503
504LIBMODE		Library mode.
505
506LDADD		Additional loader objects.
507
508MAN		The manual pages to be installed (use a .1 - .9 suffix).
509
510MKLINKLIB	If "no", act as "MKPICINSTALL=no MKPROFILE=no".
511		Also:
512			- don't install the .a libraries
513			- don't install _pic.a libraries on PIC systems
514			- don't build .a libraries on PIC systems
515			- don't install the .so symlink on ELF systems
516		I.e, only install the shared library (and the .so.major
517		symlink on ELF).
518
519NOCHECKVER_<library>
520NOCHECKVER	If set, disables checking for installed shared object
521		libraries with versions greater than the source.  A
522		particular library name, without the "lib" prefix, may
523		be appended to the variable name to disable the check for
524		only that library.
525
526SRCS		List of source files to build the library.  Suffix types
527		.s, .c, and .f are supported.  Note, .s files are preferred
528		to .c files of the same name.  (This is not the default for
529		versions of make.)
530
531The include file <bsd.lib.mk> includes the file named "../Makefile.inc"
532if it exists, as well as the include file <bsd.man.mk>.
533
534It has rules for building profiled objects; profiled libraries are
535built by default.
536
537Libraries are ranlib'd when made.
538
539=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
540