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