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