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