Annotation of src/share/mk/bsd.README, Revision 1.72
1.72 ! schwarze 1: # $OpenBSD: bsd.README,v 1.71 2017/07/10 11:25:44 schwarze Exp $
1.8 deraadt 2: # $NetBSD: bsd.README,v 1.17 1996/04/13 02:08:08 thorpej Exp $
1.1 deraadt 3: # @(#)bsd.README 5.1 (Berkeley) 5/11/90
4:
1.71 schwarze 5: This is the README file for the make "include" files for the BSD
1.1 deraadt 6: source tree. The files are installed in /usr/share/mk, and are, by
7: convention, named with the suffix ".mk".
1.17 espie 8:
9: bsd.dep.mk - handle Makefile dependencies
10: bsd.lib.mk - support for building libraries
11: bsd.man.mk - installing manual pages and their links
12: bsd.obj.mk - creating 'obj' directories and cleaning up
13: bsd.own.mk - define common variables
14: bsd.port.mk - building ports
1.46 espie 15: bsd.port.arch.mk - glue for building ports with MD stuff
1.17 espie 16: bsd.port.subdir.mk - targets for building subdirectories for ports
17: bsd.prog.mk - building programs from source files
1.30 provos 18: bsd.regress.mk - regression tests
19: bsd.subdir.mk - targets for building subdirectories
1.17 espie 20: bsd.sys.mk - building bsd from the source tree
1.1 deraadt 21:
22: Note, this file is not intended to replace reading through the .mk
23: files for anything tricky.
24:
25: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
26:
27: RANDOM THINGS WORTH KNOWING:
28:
29: The files are simply C-style #include files, and pretty much behave like
30: you'd expect. The syntax is slightly different in that a single '.' is
31: used instead of the hash mark, i.e. ".include <bsd.prog.mk>".
32:
33: One difference that will save you lots of debugging time is that inclusion
34: of the file is normally done at the *end* of the Makefile. The reason for
35: this is because .mk files often modify variables and behavior based on the
36: values of variables set in the Makefile. To make this work, remember that
37: the FIRST target found is the target that is used, i.e. if the Makefile has:
38:
39: a:
40: echo a
41: a:
42: echo a number two
43:
44: the command "make a" will echo "a". To make things confusing, the SECOND
45: variable assignment is the overriding one, i.e. if the Makefile has:
46:
47: a= foo
48: a= bar
49:
50: b:
51: echo ${a}
52:
53: the command "make b" will echo "bar". This is for compatibility with the
54: way the V7 make behaved.
55:
1.23 espie 56: To make things even more confusing, make uses lazy evaluation. All
57: variables are expanded only when needed. Which means that, in
58:
59: a= foo
60:
61: b: $(a)
62: echo $(.ALLSRC)
63: echo $(a)
64:
65: foo:
66: touch foo
67:
68: a= bar
69:
1.68 espie 70: the command "make b" will echo "foo"; echo "bar". The first $(a) means
71: "foo", because it's needed to generate the dependency rule when it's read,
1.23 espie 72: but the second $(a) is only expanded when needed, at which point a contains
73: bar.
74:
1.1 deraadt 75: It's fairly difficult to make the BSD .mk files work when you're building
1.16 espie 76: multiple programs in a single directory. It's a lot easier to split up the
1.1 deraadt 77: programs than to deal with the problem. Most of the agony comes from making
1.16 espie 78: the "obj" directory stuff work right, not because we switched to a new version
1.1 deraadt 79: of make. So, don't get mad at us, figure out a better way to handle multiple
80: architectures so we can quit using the symbolic link stuff. (Imake doesn't
81: count.)
82:
1.66 espie 83: Dependencies are handled using the compiler's -M* options, resulting in
1.68 espie 84: lots of .d files. These are manually included through <bsd.dep.mk>.
85:
86: <bsd.dep.mk> also provides an empty depend target to <bsd.prog.mk> and
87: <bsd.lib.mk>, for backward compatibility.
1.1 deraadt 88:
89: The variable DESTDIR works as before. It's not set anywhere but will change
90: the tree where the file gets installed.
91:
92: The profiled libraries are no longer built in a different directory than
93: the regular libraries. A new suffix, ".po", is used to denote a profiled
94: object.
95:
96: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
97:
98: The include file <sys.mk> has the default rules for all makes, in the BSD
99: environment or otherwise. You probably don't want to touch this file.
100:
101: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
102:
1.72 ! schwarze 103: The include file <bsd.sys.mk> is used by <bsd.prog.mk> and
! 104: <bsd.lib.mk>. It overrides parts of <sys.mk> for building the
! 105: OpenBSD source tree. For example, it contains a better yacc(1)
! 106: rule assigning the proper names to all output files.
! 107:
! 108: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
! 109:
1.1 deraadt 110: The include file <bsd.man.mk> handles installing manual pages and their
111: links.
112:
113: It has a single target:
114:
115: maninstall:
116: Install the manual pages and their links.
117:
118: It sets/uses the following variables:
119:
120: MANDIR Base path for manual installation.
121:
122: MANGRP Manual group.
123:
124: MANOWN Manual owner.
125:
126: MANMODE Manual mode.
127:
1.64 deraadt 128: MANSUBDIR Subdirectory under the manual page section, i.e. "amd64"
129: or "sparc64" for machine specific manual pages.
1.1 deraadt 130:
1.4 niklas 131: MAN The manual pages to be installed (use a .1 - .9 suffix).
1.1 deraadt 132:
1.4 niklas 133: MLINKS List of manual page links (using a .1 - .9 suffix). The
1.1 deraadt 134: linked-to file must come first, the linked file second,
135: and there may be multiple pairs. The files are soft-linked.
1.40 espie 136:
1.68 espie 137: BEFOREMAN List of extra targets that must be already built before the
1.40 espie 138: man target can be run. Those targets must be real files (and
139: not .PHONY targets).
1.1 deraadt 140:
141: The include file <bsd.man.mk> includes a file named "../Makefile.inc" if
142: it exists.
143:
144: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
145:
1.8 deraadt 146: The include file <bsd.own.mk> contains source tree configuration parameters,
147: such as the owners, groups, etc. for both manual pages and binaries, and
148: a few global "feature configuration" parameters.
1.1 deraadt 149:
150: It has no targets.
151:
1.8 deraadt 152: To get system-specific configuration parameters, bsd.own.mk will try to
153: include the file specified by the "MAKECONF" variable. If MAKECONF is not
154: set, or no such file exists, the system make configuration file, /etc/mk.conf
155: is included. These files may define any of the variables described below.
156:
157: bsd.own.mk sets the following variables, if they are not already defined
158: (defaults are in brackets):
1.4 niklas 159:
160: BSDSRCDIR The real path to the system sources, so that 'make obj'
161: will work correctly. [/usr/src]
162:
163: BSDOBJDIR The real path to the system 'obj' tree, so that 'make obj'
164: will work correctly. [/usr/obj]
165:
166: BINGRP Binary group. [bin]
167:
1.10 deraadt 168: BINOWN Binary owner. [root]
1.4 niklas 169:
170: BINMODE Binary mode. [555]
171:
172: NONBINMODE Mode for non-executable files. [444]
173:
1.23 espie 174: DIRMODE Mode for new directories. [755]
175:
1.45 schwarze 176: MANDIR Base path for manual installation. [/usr/share/man/man]
1.4 niklas 177:
178: MANGRP Manual group. [bin]
179:
1.18 millert 180: MANOWN Manual owner. [root]
1.4 niklas 181:
182: MANMODE Manual mode. [${NONBINMODE}]
183:
184: LIBDIR Base path for library installation. [/usr/lib]
185:
186: LIBGRP Library group. [${BINGRP}]
187:
188: LIBOWN Library owner. [${BINOWN}]
189:
190: LIBMODE Library mode. [${NONBINMODE}]
191:
1.44 jmc 192: DOCDIR Base path for system documentation
1.4 niklas 193: installation. [/usr/share/doc]
194:
195: DOCGRP Documentation group. [bin]
196:
1.18 millert 197: DOCOWN Documentation owner. [root]
1.4 niklas 198:
199: DOCMODE Documentation mode. [${NONBINMODE}]
1.1 deraadt 200:
1.15 millert 201: INSTALL_STRIP The flag passed to the install program to cause the binary
1.1 deraadt 202: to be stripped. This is to be used when building your
203: own install script so that the entire system can be made
1.15 millert 204: stripped/not-stripped using a single knob. Note that
205: INSTALL_STRIP is not set if ${DEBUG} is defined. [-s]
1.1 deraadt 206:
1.15 millert 207: INSTALL_COPY The old usage of this flag is obsolescent since install(1)
208: now copies by default. However, it can also be used to
209: specify that a file not be copied unless it is different
210: (via the -p option). See install(1) for details. This
211: is to be used when building our own install script so
212: that the entire system can either be installed with copies,
213: or copy-if-different using a single knob. [-c]
1.4 niklas 214:
1.8 deraadt 215: Additionally, the following variables may be set by bsd.own.mk or in a
216: make configuration file to modify the behaviour of the system build
217: process (default values are in brackets along with comments, if set by
218: bsd.own.mk):
1.23 espie 219:
1.4 niklas 220: SKEY Compile in support for S/key authentication. [yes, set
221: unconditionally]
222:
223: SYS_INCLUDE Copy or symlink kernel include files into /usr/include.
224: Possible values are "symlinks" or "copies" (which is
225: the same as the variable being unset).
1.1 deraadt 226:
1.28 brad 227: NOPROFILE Do not build profiled versions of system libraries.
1.1 deraadt 228:
1.4 niklas 229: NOPIC Do not build PIC versions of system libraries, and
1.28 brad 230: do not build shared libraries.
1.48 pascal 231:
232: NOPIE Do not build PIE objects or executables.
1.1 deraadt 233:
1.22 niklas 234: DEBUG Add -g to assembly, C compiler and linking passes. Also
235: doesn't set STRIP to -s per default if defined.
1.27 espie 236:
237: WARNINGS Adds appropriate warning flags (defined in CDIAGFLAGS,
238: e.g., -Wall...) to compiles. [no]
1.19 millert 239:
240: SUDO Command to run when doing "make install" portion of
1.63 gsoares 241: "make build". If set to /usr/bin/doas, this allows one
242: to run "make build" as a user other than root (assuming
243: doas is setup for that user).
1.19 millert 244:
245: PIPE If set to "-pipe" gcc will be given the -pipe option
246: which can speed up compiles on machines with memory
247: to spare. Instead of using temp files, gcc uses pipes
248: for the temporary data.
1.20 kstailey 249:
250: GLOBAL_AUTOCONF_CACHE
251: Set to the name of a file that all cached GNU autoconf
252: test results will be saved in. Reduces redundant tests.
1.23 espie 253: Be careful! Redundant tests may not be redundant if you
254: are installing substantially updated gnu programs.
1.1 deraadt 255:
1.8 deraadt 256: bsd.own.mk is generally useful when building your own Makefiles so that
1.1 deraadt 257: they use the same default owners etc. as the rest of the tree.
258:
259: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
260:
261: The include file <bsd.prog.mk> handles building programs from one or
262: more source files, along with their manual pages. It has a limited number
263: of suffixes, consistent with the current needs of the BSD tree.
264:
1.68 espie 265: It has six targets:
1.1 deraadt 266:
267: all:
268: build the program and its manual page
269: clean:
270: remove the program, any object files and the files a.out,
271: Errs, errs, mklog, and core.
272: cleandir:
273: remove all of the files removed by the target clean, as
274: well as .depend, tags, and any manual pages.
1.8 deraadt 275: includes:
276: install any header files.
1.1 deraadt 277: install:
278: install the program and its manual pages; if the Makefile
279: does not itself define the target install, the targets
280: beforeinstall and afterinstall may also be used to cause
281: actions immediately before and after the install target
282: is executed.
283: tags:
284: create a tags file for the source files.
285:
1.71 schwarze 286: It uses the following variables:
1.1 deraadt 287:
288: BINGRP Binary group.
289:
290: BINOWN Binary owner.
291:
292: BINMODE Binary mode.
293:
1.66 espie 294: BUILDFIRST Stuff that needs to be built before anything else, in
295: terms of dependencies.
296:
1.70 espie 297: BUILDAFTER Stuff that comes later (usually don't touch, defined correctly
1.66 espie 298: by <bsd.prog.mk> and <bsd.lib.mk>)
299:
1.1 deraadt 300: CLEANFILES Additional files to remove for the clean and cleandir targets.
301:
302: COPTS Additional flags to the compiler when creating C objects.
303:
304: LDADD Additional loader objects. Usually used for libraries.
1.53 deraadt 305: For example, to load with the crypto and utility
1.1 deraadt 306: libraries, use:
307:
1.53 deraadt 308: LDADD+=-lutil -lcrypto
1.1 deraadt 309:
310: LDFLAGS Additional loader flags.
311:
312: LINKS The list of binary links; should be full pathnames, the
313: linked-to file coming first, followed by the linked
314: file. The files are hard-linked. For example, to link
315: /bin/test and /bin/[, use:
316:
317: LINKS= ${DESTDIR}/bin/test ${DESTDIR}/bin/[
318:
1.4 niklas 319: MAN Manual pages (should end in .1 - .9). If no MAN variable is
1.1 deraadt 320: defined, "MAN=${PROG}.1" is assumed.
321:
322: PROG The name of the program to build. If not supplied, nothing
323: is built.
324:
1.6 mickey 325: SRCS List of source files to build the program. If it's not
1.1 deraadt 326: defined, it's assumed to be ${PROG}.c.
327:
328: DPADD Additional dependencies for the program. Usually used for
1.53 deraadt 329: libraries. For example, to depend on the crypto and
1.1 deraadt 330: utility libraries use:
331:
1.53 deraadt 332: DPADD+=${LIBCRYPTO} ${LIBUTIL}
1.1 deraadt 333:
334: The following libraries are predefined for DPADD:
335:
1.31 espie 336: LIBC /usr/lib/libc.a
337: LIBCRYPTO /usr/lib/libcrypto.a
1.1 deraadt 338: LIBCURSES /usr/lib/libcurses.a
1.26 millert 339: LIBEDIT /usr/lib/libedit.a
1.32 millert 340: LIBEVENT /usr/lib/libevent.a
1.42 miod 341: LIBEXPAT /usr/lib/libexpat.a
342: LIBFORM /usr/lib/libform.a
343: LIBFORMW /usr/lib/libformw.a
1.26 millert 344: LIBKEYNOTE /usr/lib/libkeynote.a
1.1 deraadt 345: LIBKVM /usr/lib/libkvm.a
1.26 millert 346: LIBL /usr/lib/libl.a
1.1 deraadt 347: LIBM /usr/lib/libm.a
1.42 miod 348: LIBMENU /usr/lib/libmenu.a
349: LIBMENUW /usr/lib/libmenuw.a
1.60 yasuoka 350: LIBRADIUS /usr/lib/libradius.a
1.42 miod 351: LIBOSSAUDIO /usr/lib/libossaudio.a
352: LIBPANEL /usr/lib/libpanel.a
353: LIBPANELW /usr/lib/libpanelw.a
1.31 espie 354: LIBPCAP /usr/lib/libpcap.a
1.21 millert 355: LIBPERL /usr/lib/libperl.a
1.42 miod 356: LIBPTHREAD /usr/lib/libpthread.a
1.26 millert 357: LIBRPCSVC /usr/lib/librpcsvc.a
358: LIBSKEY /usr/lib/libskey.a
1.42 miod 359: LIBSNDIO /usr/lib/libsndio.a
1.26 millert 360: LIBSSL /usr/lib/libssl.a
1.9 tholo 361: LIBTERMCAP /usr/lib/libtermcap.a
362: LIBTERMLIB /usr/lib/libtermlib.a
1.59 jsing 363: LIBTLS /usr/lib/libtls.a
1.31 espie 364: LIBUSB /usr/lib/libusbhid.a
1.1 deraadt 365: LIBUTIL /usr/lib/libutil.a
1.31 espie 366: LIBY /usr/lib/liby.a
1.13 deraadt 367: LIBZ /usr/lib/libz.a
1.31 espie 368: LIBARCH arch-dependent stuff
1.1 deraadt 369:
370: STRIP The flag passed to the install program to cause the binary
371: to be stripped.
372:
373: SUBDIR A list of subdirectories that should be built as well.
374: Each of the targets will execute the same target in the
375: subdirectories.
376:
377: The include file <bsd.prog.mk> includes the file named "../Makefile.inc"
378: if it exists, as well as the include file <bsd.man.mk>.
379:
380: Some simple examples:
381:
382: To build foo from foo.c with a manual page foo.1, use:
383:
384: PROG= foo
385:
386: .include <bsd.prog.mk>
387:
388: To build foo from foo.c with a manual page foo.2, add the line:
389:
390: MAN= foo.2
391:
392: If foo does not have a manual page at all, add the line:
393:
394: NOMAN= noman
395:
396: If foo has multiple source files, add the line:
397:
398: SRCS= a.c b.c c.c d.c
399:
1.68 espie 400: SRCS may contain lex and yacc files, in which case the framework will
401: convert these files to C and header files first, before building anything
402: else.
403:
404: SRCS may contain C++ files, in which case the C++ compiler will be used
405: for linking.
406:
407: If YFLAGS contains -d, the header file will be named like the C file,
408: and a proper rule tying both together will be generated. For instance, if
409: SRCS contains grammar.y, then effectively you will have
410:
411: grammar.c grammar.h: grammar.y
412: ${YACC.Y} -o grammar.c grammar.y
1.69 espie 413:
414:
415: <bsd.prog.mk> may be used to build several programs in a single directory.
416: Just define the list of programs as PROGS instead of using PROG.
417: For instance PROGS = foo bar
418:
419: Each program of the list, for instance foo, will use SRCS_foo instead
420: of SRCS to find its sources. SRCS_foo still defaults to foo.c, and
421: MAN still defaults to section 1 manpages: MAN = foo.1 bar.1.
422:
423: Each program can have its separate LDADD_foo and DPADD_foo definitions.
424: If not defined, these default to LDADD/DPADD.
425:
426: Some simple examples:
427: To build foo from foo.c and bar from bar.c with manual pages foo.1 and bar.1:
428:
429: PROGS = foo bar
430:
431: .include <bsd.prog.mk>
432:
433: If bar has manual page bar.8 instead, add the line:
434: MAN = foo.1 bar.8
435:
436: If bar has multiple source files, add the line:
437: SRCS_bar = a.c b.c c.c d.c
438:
439: Note that foo and bar may share some source files, like so:
440: SRCS_foo = foo.c common.c
441: SRCS_bar = bar.c common.c
1.68 espie 442:
1.1 deraadt 443: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
444:
445: The include file <bsd.subdir.mk> contains the default targets for building
1.68 espie 446: subdirectories. It has the same six targets as <bsd.prog.mk>: all,
447: clean, cleandir, includes, install, and tags. For all of
448: the directories listed in the variable SUBDIR, the specified directory
1.8 deraadt 449: will be visited and the target made. There is also a default target which
450: allows the command "make subdir" where subdir is any directory listed in
1.41 jmc 451: the variable SUBDIR.
1.2 deraadt 452:
1.1 deraadt 453:
454: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
455:
456: The include file <bsd.lib.mk> has support for building libraries. It has
1.71 schwarze 457: the same six targets as <bsd.prog.mk>: all, clean, cleandir,
1.47 jsg 458: includes, install, and tags. It has a limited number of suffixes,
1.8 deraadt 459: consistent with the current needs of the BSD tree.
1.1 deraadt 460:
1.71 schwarze 461: It uses the following variables:
1.66 espie 462:
1.71 schwarze 463: BUILDFIRST/BUILDAFTER
464: See <bsd.prog.mk>.
1.1 deraadt 465:
466: LIB The name of the library to build.
467:
468: LIBDIR Target directory for libraries.
469:
470: LIBGRP Library group.
471:
472: LIBOWN Library owner.
473:
474: LIBMODE Library mode.
475:
476: LDADD Additional loader objects.
477:
1.4 niklas 478: MAN The manual pages to be installed (use a .1 - .9 suffix).
1.1 deraadt 479:
480: SRCS List of source files to build the library. Suffix types
481: .s, .c, and .f are supported. Note, .s files are preferred
482: to .c files of the same name. (This is not the default for
1.68 espie 483: POSIX make without bsd.lib.mk).
484:
485: The same support for yacc and lex files as <bsd.prog.mk>
486: is provided.
1.1 deraadt 487:
488: The include file <bsd.lib.mk> includes the file named "../Makefile.inc"
489: if it exists, as well as the include file <bsd.man.mk>.
490:
491: It has rules for building profiled objects; profiled libraries are
492: built by default.
493:
494: Libraries are ranlib'd when made.
1.52 guenther 495:
496: In addition, a reduced version of a library, including just specific
497: objects that are compiled with additional options to reduce their
498: size may be built. This is used by the distrib/ tree and crunchgen
499: when building ramdisks. This sets/uses the following variables:
500:
501: DIST_LIB The path of the library to build. [lib${LIB}_d.a]
502:
503: DIST_OBJS The (sub)set of .o files to include in ${DIST_LIB}. [${OBJS}]
504:
505: DIST_CFLAGS Additional flags for the C compiler and assembler.
506: [-Os]
1.6 mickey 507: