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