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