bsd.README revision 36188
1#	@(#)bsd.README	8.2 (Berkeley) 4/2/94
2#	$Id: bsd.README,v 1.11 1997/03/09 15:51:07 wosch Exp $
3
4XXX This document is seriously out of date, it is currenly being revised.
5
6This is the README file for the new make "include" files for the BSD
7source tree. The files are installed in /usr/share/mk, and are, by
8convention, named with the suffix ".mk".
9
10bsd.dep.mk		- handle Makefile dependencies
11bsd.doc.mk		- building troff system documents
12bsd.info.mk		- building GNU Info hypertext system
13bsd.kern.mk		- define warning flags for compiling the kernel
14bsd.kmod.mk		- building loadable kernel modules
15bsd.lib.mk		- support for building libraries
16bsd.libnames.mk		- define library names
17bsd.man.mk		- installing manual pages and their links
18bsd.obj.mk		- creating 'obj' directories and cleaning up
19bsd.own.mk		- define common variables
20bsd.port.mk		- building ports
21bsd.port.subdir.mk	- targets for building subdirectories for ports
22bsd.prog.mk		- building programs from source files
23bsd.sgml.mk		- building SGML documents
24bsd.subdir.mk		- targets for building subdirectories
25
26
27Note, this file is not intended to replace reading through the .mk
28files for anything tricky.
29
30See also make(1), mkdep(1) and `PMake - A Tutorial', 
31located in /usr/share/doc/psd/12.make.
32
33=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
34
35RANDOM THINGS WORTH KNOWING:
36
37The files are simply C-style #include files, and pretty much behave like
38you'd expect.  The syntax is slightly different in that a single '.' is
39used instead of the hash mark, i.e. ".include <bsd.prog.mk>".
40
41One difference that will save you lots of debugging time is that inclusion
42of the file is normally done at the *end* of the Makefile.  The reason for
43this is because .mk files often modify variables and behavior based on the
44values of variables set in the Makefile.  To make this work, remember that
45the FIRST target found is the target that is used, i.e. if the Makefile has:
46
47	a:
48		echo a
49	a:
50		echo a number two
51
52the command "make a" will echo "a".  To make things confusing, the SECOND
53variable assignment is the overriding one, i.e. if the Makefile has:
54
55	a=	foo
56	a=	bar
57
58	b:
59		echo ${a}
60
61the command "make b" will echo "bar".  This is for compatibility with the
62way the V7 make behaved.
63
64It's fairly difficult to make the BSD .mk files work when you're building
65multiple programs in a single directory.  It's a lot easier split up the
66programs than to deal with the problem.  Most of the agony comes from making
67the "obj" directory stuff work right, not because we switch to a new version
68of make.  So, don't get mad at us, figure out a better way to handle multiple
69architectures so we can quit using the symbolic link stuff.  (Imake doesn't
70count.)
71
72The file .depend in the source directory is expected to contain dependencies
73for the source files.  This file is read automatically by make after reading
74the Makefile.
75
76The variable DESTDIR works as before.  It's not set anywhere but will change
77the tree where the file gets installed.
78
79The profiled libraries are no longer built in a different directory than
80the regular libraries.  A new suffix, ".po", is used to denote a profiled
81object.
82
83=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
84
85The include file <sys.mk> has the default rules for all makes, in the BSD
86environment or otherwise.  You probably don't want to touch this file.
87
88=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
89
90bsd.locale.mk - a list of location specific parameters (currently this is
91used to list official ports mirrors only)
92
93=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
94
95The include file <bsd.man.mk> handles installing manual pages and their
96links.
97
98It has a single target:
99
100	maninstall:
101		Install the manual pages and their links.
102
103It sets/uses the following variables:
104
105MANDIR		Base path for manual installation.
106
107MANGRP		Manual group.
108
109MANOWN		Manual owner.
110
111MANMODE		Manual mode.
112
113MANSUBDIR	Subdirectory under the manual page section, i.e. "/vax"
114		or "/tahoe" for machine specific manual pages.
115
116MAN1 ... MAN8	The manual pages to be installed (use a .0 suffix).
117
118MLINKS		List of manual page links (using a .1 - .8 suffix).  The
119		linked-to file must come first, the linked file second,
120		and there may be multiple pairs.  The files are soft-linked.
121
122The include file <bsd.man.mk> includes the include file <bsd.inc.mk>.
123
124=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
125
126The include file <bsd.own.mk> contains the owners, groups, etc. for both
127manual pages and binaries.
128
129It has no targets.
130
131It sets/uses the following variables:
132
133BINGRP		Binary group.
134
135BINOWN		Binary owner.
136
137BINMODE		Binary mode.
138
139STRIP		The flag passed to the install program to cause the binary
140		to be stripped.  This is to be used when building your
141		own install script so that the entire system can be made
142		stripped/not-stripped using a single nob.
143
144MANDIR		Base path for manual installation.
145
146MANGRP		Manual group.
147
148MANOWN		Manual owner.
149
150MANMODE		Manual mode.
151
152This file is generally useful when building your own Makefiles so that
153they use the same default owners etc. as the rest of the tree.
154
155=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
156
157The include file <bsd.prog.mk> handles building programs from one or
158more source files, along with their manual pages.  It has a limited number
159of suffixes, consistent with the current needs of the BSD tree.
160
161It has seven targets:
162
163	all:
164		build the program and its manual page
165	clean:
166		remove the program, any object files and the files a.out,
167		Errs, errs, mklog, and ${PROG}.core.
168	cleandir:
169		remove all of the files removed by the target clean, as
170		well as .depend, tags, and any manual pages.
171	depend:
172		make the dependencies for the source files, and store
173		them in the file .depend.
174	install:
175		install the program and its manual pages; if the Makefile
176		does not itself define the target install, the targets
177		beforeinstall and afterinstall may also be used to cause
178		actions immediately before and after the install target
179		is executed.
180	lint:
181		run lint on the source files
182	tags:
183		create a tags file for the source files.
184
185It sets/uses the following variables:
186
187BINGRP		Binary group.
188
189BINOWN		Binary owner.
190
191BINMODE		Binary mode.
192
193CLEANFILES	Additional files to remove and
194CLEANDIRS	additional directories to remove during clean and cleandir
195		targets.  "rm -f" and "rm -rf" used respectively.
196
197COPTS		Additional flags to the compiler when creating C objects.
198
199HIDEGAME	If HIDEGAME is defined, the binary is installed in
200		/usr/games/hide, and a symbolic link is created to
201		/usr/games/dm.
202
203LDADD		Additional loader objects.  Usually used for libraries.
204		For example, to load with the compatibility and utility
205		libraries, use:
206
207			LDFILES=-lutil -lcompat
208
209LDFLAGS		Additional loader flags.
210
211LINKS		The list of binary links; should be full pathnames, the
212		linked-to file coming first, followed by the linked
213		file.  The files are hard-linked.  For example, to link
214		/bin/test and /bin/[, use:
215
216			LINKS=	${DESTDIR}/bin/test ${DESTDIR}/bin/[
217
218MAN1...MAN8	Manual pages (should end in .0).  If no MAN variable is
219		defined, "MAN1=${PROG}.0" is assumed.
220
221PROG		The name of the program to build.  If not supplied, nothing
222		is built.
223
224SRCS		List of source files to build the program.  If PROG is not
225		defined, it's assumed to be ${PROG}.c.
226
227DPADD		Additional dependencies for the program.  Usually used for
228		libraries.  For example, to depend on the compatibility and
229		utility libraries use:
230
231			SRCLIB=${LIBCOMPAT} ${LIBUTIL}
232
233		There is a predefined identifier for each (non-profiled,
234		non-shared) library and object.  Library file names are
235		transformed to identifiers by removing the extension and
236		converting to upper case.
237
238		There are no special identifiers for profiled or shared
239		libraries or objects.  The identifiers for the standard
240		libraries are used in DPADD.  This works correctly iff all
241		the libraries are built at the same time.  Unfortunately,
242		it causes unnecessary relinks to shared libraries when
243		only the static libraries have changed.  Dependencies on
244		shared libraries should be only on the library version
245		numbers.
246
247STRIP		The flag passed to the install program to cause the binary
248		to be stripped.
249
250SUBDIR		A list of subdirectories that should be built as well.
251		Each of the targets will execute the same target in the
252		subdirectories.
253
254The include file <bsd.prog.mk> includes the include files <bsd.inc.mk>
255and <bsd.man.mk>.
256
257Some simple examples:
258
259To build foo from foo.c with a manual page foo.1, use:
260
261	PROG=	foo
262
263	.include <bsd.prog.mk>
264
265To build foo from foo.c with a manual page foo.2, add the line:
266
267	MAN2=	foo.0
268
269If foo does not have a manual page at all, add the line:
270
271	NOMAN=	noman
272
273If foo has multiple source files, add the line:
274
275	SRCS=	a.c b.c c.c d.c
276
277=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
278
279The include file <bsd.subdir.mk> contains the default targets for building
280subdirectories.  It has the same seven targets as <bsd.prog.mk>: all, clean,
281cleandir, depend, install, lint, and tags.  For all of the directories
282listed in the variable SUBDIRS, the specified directory will be visited
283and the target made.  There is also a default target which allows the
284command "make subdir" where subdir is any directory listed in the variable
285SUBDIRS.
286
287=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
288
289The include file <bsd.lib.mk> has support for building libraries.  It has
290the same seven targets as <bsd.prog.mk>: all, clean, cleandir, depend,
291install, lint, and tags.  It has a limited number of suffixes, consistent
292with the current needs of the BSD tree.
293
294It sets/uses the following variables:
295
296LIBDIR		Target directory for libraries.
297
298LINTLIBDIR	Target directory for lint libraries.
299
300LIBGRP		Library group.
301
302LIBOWN		Library owner.
303
304LIBMODE		Library mode.
305
306LDADD		Additional loader objects.
307
308MAN1 ... MAN8	The manual pages to be installed (use a .0 suffix).
309
310SRCS		List of source files to build the library.  Suffix types
311		.s, .c, and .f are supported.  Note, .s files are preferred
312		to .c files of the same name.  (This is not the default for
313		versions of make.)
314
315The include file <bsd.lib.mk> includes the include files <bsd.inc.mk>
316and <bsd.man.mk>.
317
318It has rules for building profiled objects; profiled libraries are
319built by default.
320
321Libraries are ranlib'd before installation.
322