1 # @(#)bsd.README 8.2 (Berkeley) 4/2/94
3 This is the README file for the new make "include" files for the BSD
4 source tree. The files are installed in /usr/share/mk, and are, by
5 convention, named with the suffix ".mk". Each ".mk" file has a
6 corresponding ".rd" file which is an explanation of the ".mk" file.
8 Note, this file is not intended to replace reading through the .mk
9 files for anything tricky.
11 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
13 RANDOM THINGS WORTH KNOWING:
15 The files are simply C-style #include files, and pretty much behave like
16 you'd expect. The syntax is slightly different in that a single '.' is
17 used instead of the hash mark, i.e. ".include <bsd.prog.mk>".
19 One difference that will save you lots of debugging time is that inclusion
20 of the file is normally done at the *end* of the Makefile. The reason for
21 this is because .mk files often modify variables and behavior based on the
22 values of variables set in the Makefile. To make this work, remember that
23 the FIRST target found is the target that is used, i.e. if the Makefile has:
30 the command "make a" will echo "a". To make things confusing, the SECOND
31 variable assignment is the overriding one, i.e. if the Makefile has:
39 the command "make b" will echo "bar". This is for compatibility with the
40 way the V7 make behaved.
42 It's fairly difficult to make the BSD .mk files work when you're building
43 multiple programs in a single directory. It's a lot easier split up the
44 programs than to deal with the problem. Most of the agony comes from making
45 the "obj" directory stuff work right, not because we switch to a new version
46 of make. So, don't get mad at us, figure out a better way to handle multiple
47 architectures so we can quit using the symbolic link stuff. (Imake doesn't
50 The file .depend in the source directory is expected to contain dependencies
51 for the source files. This file is read automatically by make after reading
54 The variable DESTDIR works as before. It's not set anywhere but will change
55 the tree where the file gets installed.
57 The profiled libraries are no longer built in a different directory than
58 the regular libraries. A new suffix, ".po", is used to denote a profiled
61 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
63 The include file <sys.mk> has the default rules for all makes, in the BSD
64 environment or otherwise. You probably don't want to touch this file.
66 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
68 The include file <bsd.man.mk> handles installing manual pages and their
71 It has a single target:
74 Install the manual pages and their links.
76 It sets/uses the following variables:
78 MANDIR Base path for manual installation.
86 MANSUBDIR Subdirectory under the manual page section, i.e. "/vax"
87 or "/tahoe" for machine specific manual pages.
89 MAN1 ... MAN8 The manual pages to be installed (use a .0 suffix).
91 MLINKS List of manual page links (using a .1 - .8 suffix). The
92 linked-to file must come first, the linked file second,
93 and there may be multiple pairs. The files are soft-linked.
95 The include file <bsd.man.mk> includes a file named "../Makefile.inc" if
98 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
100 The include file <bsd.own.mk> contains the owners, groups, etc. for both
101 manual pages and binaries.
105 It sets/uses the following variables:
113 STRIP The flag passed to the install program to cause the binary
114 to be stripped. This is to be used when building your
115 own install script so that the entire system can be made
116 stripped/not-stripped using a single nob.
118 MANDIR Base path for manual installation.
126 This file is generally useful when building your own Makefiles so that
127 they use the same default owners etc. as the rest of the tree.
129 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
131 The include file <bsd.prog.mk> handles building programs from one or
132 more source files, along with their manual pages. It has a limited number
133 of suffixes, consistent with the current needs of the BSD tree.
135 It has seven targets:
138 build the program and its manual page
140 remove the program, any object files and the files a.out,
141 Errs, errs, mklog, and ${PROG}.core.
143 remove all of the files removed by the target clean, as
144 well as .depend, tags, and any manual pages.
146 make the dependencies for the source files, and store
147 them in the file .depend.
149 install the program and its manual pages; if the Makefile
150 does not itself define the target install, the targets
151 beforeinstall and afterinstall may also be used to cause
152 actions immediately before and after the install target
155 run lint on the source files
157 create a tags file for the source files.
159 It sets/uses the following variables:
167 CLEANFILES Additional files to remove for the clean and cleandir targets.
169 COPTS Additional flags to the compiler when creating C objects.
171 HIDEGAME If HIDEGAME is defined, the binary is installed in
172 /usr/games/hide, and a symbolic link is created to
175 LDADD Additional loader objects. Usually used for libraries.
176 For example, to load with the compatibility and utility
179 LDFILES=-lutil -lcompat
181 LDFLAGS Additional loader flags.
183 LINKS The list of binary links; should be full pathnames, the
184 linked-to file coming first, followed by the linked
185 file. The files are hard-linked. For example, to link
186 /bin/test and /bin/[, use:
188 LINKS= ${DESTDIR}/bin/test ${DESTDIR}/bin/[
190 MAN1...MAN8 Manual pages (should end in .0). If no MAN variable is
191 defined, "MAN1=${PROG}.0" is assumed.
193 PROG The name of the program to build. If not supplied, nothing
196 SRCS List of source files to build the program. If PROG is not
197 defined, it's assumed to be ${PROG}.c.
199 DPADD Additional dependencies for the program. Usually used for
200 libraries. For example, to depend on the compatibility and
201 utility libraries use:
203 SRCLIB=${LIBCOMPAT} ${LIBUTIL}
205 The following libraries are predefined for DPADD:
208 LIBCOMPAT /usr/lib/libcompat.a
209 LIBCURSES /usr/lib/libcurses.a
210 LIBDBM /usr/lib/libdbm.a
211 LIBDES /usr/lib/libdes.a
213 LIBKDB /usr/lib/libkdb.a
214 LIBKRB /usr/lib/libkrb.a
216 LIBMP /usr/lib/libmp.a
217 LIBPC /usr/lib/libpc.a
218 LIBPLOT /usr/lib/libplot.a
219 LIBRPC /usr/lib/sunrpc.a
220 LIBTERMCAP /usr/lib/libtermcap.a
221 LIBUTIL /usr/lib/libutil.a
223 SHAREDSTRINGS If defined, a new .c.o rule is used that results in shared
224 strings, using xstr(1).
226 STRIP The flag passed to the install program to cause the binary
229 SUBDIR A list of subdirectories that should be built as well.
230 Each of the targets will execute the same target in the
233 The include file <bsd.prog.mk> includes the file named "../Makefile.inc"
234 if it exists, as well as the include file <bsd.man.mk>.
236 Some simple examples:
238 To build foo from foo.c with a manual page foo.1, use:
242 .include <bsd.prog.mk>
244 To build foo from foo.c with a manual page foo.2, add the line:
248 If foo does not have a manual page at all, add the line:
252 If foo has multiple source files, add the line:
254 SRCS= a.c b.c c.c d.c
256 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
258 The include file <bsd.subdir.mk> contains the default targets for building
259 subdirectories. It has the same seven targets as <bsd.prog.mk>: all, clean,
260 cleandir, depend, install, lint, and tags. For all of the directories
261 listed in the variable SUBDIRS, the specified directory will be visited
262 and the target made. There is also a default target which allows the
263 command "make subdir" where subdir is any directory listed in the variable
266 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
268 The include file <bsd.lib.mk> has support for building libraries. It has
269 the same seven targets as <bsd.prog.mk>: all, clean, cleandir, depend,
270 install, lint, and tags. It has a limited number of suffixes, consistent
271 with the current needs of the BSD tree.
273 It sets/uses the following variables:
275 LIBDIR Target directory for libraries.
277 LINTLIBDIR Target directory for lint libraries.
279 LIBGRP Library group.
281 LIBOWN Library owner.
283 LIBMODE Library mode.
285 LDADD Additional loader objects.
287 MAN1 ... MAN8 The manual pages to be installed (use a .0 suffix).
289 SRCS List of source files to build the library. Suffix types
290 .s, .c, and .f are supported. Note, .s files are preferred
291 to .c files of the same name. (This is not the default for
294 The include file <bsd.lib.mk> includes the file named "../Makefile.inc"
295 if it exists, as well as the include file <bsd.man.mk>.
297 It has rules for building profiled objects; profiled libraries are
300 Libraries are ranlib'd before installation.