[BACK]Return to bsd.README CVS log [TXT][DIR] Up to [local] / src / share / mk

Annotation of src/share/mk/bsd.README, Revision 1.65

1.65    ! guenther    1: #      $OpenBSD: bsd.README,v 1.64 2016/03/09 16:28:47 deraadt 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.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:
                     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,
                     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:
                     83: The file .depend in the source directory is expected to contain dependencies
                     84: for the source files.  This file is read automatically by make after reading
                     85: the Makefile.
                     86:
                     87: The variable DESTDIR works as before.  It's not set anywhere but will change
                     88: the tree where the file gets installed.
                     89:
                     90: The profiled libraries are no longer built in a different directory than
                     91: the regular libraries.  A new suffix, ".po", is used to denote a profiled
                     92: object.
                     93:
                     94: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                     95:
                     96: The include file <sys.mk> has the default rules for all makes, in the BSD
                     97: environment or otherwise.  You probably don't want to touch this file.
                     98:
                     99: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    100:
                    101: The include file <bsd.man.mk> handles installing manual pages and their
                    102: links.
                    103:
                    104: It has a single target:
                    105:
                    106:        maninstall:
                    107:                Install the manual pages and their links.
                    108:
                    109: It sets/uses the following variables:
                    110:
                    111: MANDIR         Base path for manual installation.
                    112:
                    113: MANGRP         Manual group.
                    114:
                    115: MANOWN         Manual owner.
                    116:
                    117: MANMODE                Manual mode.
                    118:
1.64      deraadt   119: MANSUBDIR      Subdirectory under the manual page section, i.e. "amd64"
                    120:                or "sparc64" for machine specific manual pages.
1.1       deraadt   121:
1.4       niklas    122: MAN            The manual pages to be installed (use a .1 - .9 suffix).
1.1       deraadt   123:
1.4       niklas    124: MLINKS         List of manual page links (using a .1 - .9 suffix).  The
1.1       deraadt   125:                linked-to file must come first, the linked file second,
                    126:                and there may be multiple pairs.  The files are soft-linked.
1.40      espie     127:
                    128: BEFOREMAN      List of extra targets that must be already built before the
                    129:                man target can be run. Those targets must be real files (and
                    130:                not .PHONY targets).
1.1       deraadt   131:
                    132: The include file <bsd.man.mk> includes a file named "../Makefile.inc" if
                    133: it exists.
                    134:
                    135: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    136:
1.8       deraadt   137: The include file <bsd.own.mk> contains source tree configuration parameters,
                    138: such as the owners, groups, etc. for both manual pages and binaries, and
                    139: a few global "feature configuration" parameters.
1.1       deraadt   140:
                    141: It has no targets.
                    142:
1.8       deraadt   143: To get system-specific configuration parameters, bsd.own.mk will try to
                    144: include the file specified by the "MAKECONF" variable.  If MAKECONF is not
                    145: set, or no such file exists, the system make configuration file, /etc/mk.conf
                    146: is included.  These files may define any of the variables described below.
                    147:
                    148: bsd.own.mk sets the following variables, if they are not already defined
                    149: (defaults are in brackets):
1.4       niklas    150:
                    151: BSDSRCDIR      The real path to the system sources, so that 'make obj'
                    152:                will work correctly. [/usr/src]
                    153:
                    154: BSDOBJDIR      The real path to the system 'obj' tree, so that 'make obj'
                    155:                will work correctly. [/usr/obj]
                    156:
                    157: BINGRP         Binary group. [bin]
                    158:
1.10      deraadt   159: BINOWN         Binary owner. [root]
1.4       niklas    160:
                    161: BINMODE                Binary mode. [555]
                    162:
                    163: NONBINMODE     Mode for non-executable files. [444]
                    164:
1.23      espie     165: DIRMODE                Mode for new directories. [755]
                    166:
1.45      schwarze  167: MANDIR         Base path for manual installation. [/usr/share/man/man]
1.4       niklas    168:
                    169: MANGRP         Manual group. [bin]
                    170:
1.18      millert   171: MANOWN         Manual owner. [root]
1.4       niklas    172:
                    173: MANMODE                Manual mode. [${NONBINMODE}]
                    174:
                    175: LIBDIR         Base path for library installation. [/usr/lib]
                    176:
                    177: LIBGRP         Library group. [${BINGRP}]
                    178:
                    179: LIBOWN         Library owner. [${BINOWN}]
                    180:
                    181: LIBMODE                Library mode. [${NONBINMODE}]
                    182:
1.44      jmc       183: DOCDIR         Base path for system documentation
1.4       niklas    184:                installation. [/usr/share/doc]
                    185:
                    186: DOCGRP         Documentation group. [bin]
                    187:
1.18      millert   188: DOCOWN         Documentation owner. [root]
1.4       niklas    189:
                    190: DOCMODE                Documentation mode. [${NONBINMODE}]
1.1       deraadt   191:
1.15      millert   192: INSTALL_STRIP  The flag passed to the install program to cause the binary
1.1       deraadt   193:                to be stripped.  This is to be used when building your
                    194:                own install script so that the entire system can be made
1.15      millert   195:                stripped/not-stripped using a single knob.  Note that
                    196:                INSTALL_STRIP is not set if ${DEBUG} is defined. [-s]
1.1       deraadt   197:
1.15      millert   198: INSTALL_COPY   The old usage of this flag is obsolescent since install(1)
                    199:                now copies by default.  However, it can also be used to
                    200:                specify that a file not be copied unless it is different
                    201:                (via the -p option).  See install(1) for details.  This
                    202:                is to be used when building our own install script so
                    203:                that the entire system can either be installed with copies,
                    204:                or copy-if-different using a single knob. [-c]
1.4       niklas    205:
1.8       deraadt   206: Additionally, the following variables may be set by bsd.own.mk or in a
                    207: make configuration file to modify the behaviour of the system build
                    208: process (default values are in brackets along with comments, if set by
                    209: bsd.own.mk):
1.23      espie     210:
1.4       niklas    211: SKEY           Compile in support for S/key authentication. [yes, set
                    212:                unconditionally]
                    213:
                    214: SYS_INCLUDE    Copy or symlink kernel include files into /usr/include.
                    215:                Possible values are "symlinks" or "copies" (which is
                    216:                the same as the variable being unset).
1.1       deraadt   217:
1.28      brad      218: NOPROFILE      Do not build profiled versions of system libraries.
1.1       deraadt   219:
1.4       niklas    220: NOPIC          Do not build PIC versions of system libraries, and
1.28      brad      221:                do not build shared libraries.
1.48      pascal    222:
                    223: NOPIE          Do not build PIE objects or executables.
1.1       deraadt   224:
1.22      niklas    225: DEBUG          Add -g to assembly, C compiler and linking passes.  Also
                    226:                doesn't set STRIP to -s per default if defined.
1.27      espie     227:
                    228: WARNINGS       Adds appropriate warning flags (defined in CDIAGFLAGS,
                    229:                e.g., -Wall...) to compiles. [no]
1.19      millert   230:
                    231: SUDO           Command to run when doing "make install" portion of
1.63      gsoares   232:                "make build".  If set to /usr/bin/doas, this allows one
                    233:                to run "make build" as a user other than root (assuming
                    234:                doas is setup for that user).
1.19      millert   235:
                    236: PIPE           If set to "-pipe" gcc will be given the -pipe option
                    237:                which can speed up compiles on machines with memory
                    238:                to spare.  Instead of using temp files, gcc uses pipes
                    239:                for the temporary data.
1.20      kstailey  240:
                    241: GLOBAL_AUTOCONF_CACHE
                    242:                Set to the name of a file that all cached GNU autoconf
                    243:                test results will be saved in.  Reduces redundant tests.
1.23      espie     244:                Be careful!  Redundant tests may not be redundant if you
                    245:                are installing substantially updated gnu programs.
1.1       deraadt   246:
1.8       deraadt   247: bsd.own.mk is generally useful when building your own Makefiles so that
1.1       deraadt   248: they use the same default owners etc. as the rest of the tree.
                    249:
                    250: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    251:
                    252: The include file <bsd.prog.mk> handles building programs from one or
                    253: more source files, along with their manual pages.  It has a limited number
                    254: of suffixes, consistent with the current needs of the BSD tree.
                    255:
1.58      schwarze  256: It has seven targets:
1.1       deraadt   257:
                    258:        all:
                    259:                build the program and its manual page
                    260:        clean:
                    261:                remove the program, any object files and the files a.out,
                    262:                Errs, errs, mklog, and core.
                    263:        cleandir:
                    264:                remove all of the files removed by the target clean, as
                    265:                well as .depend, tags, and any manual pages.
                    266:        depend:
                    267:                make the dependencies for the source files, and store
                    268:                them in the file .depend.
1.8       deraadt   269:        includes:
                    270:                install any header files.
1.1       deraadt   271:        install:
                    272:                install the program and its manual pages; if the Makefile
                    273:                does not itself define the target install, the targets
                    274:                beforeinstall and afterinstall may also be used to cause
                    275:                actions immediately before and after the install target
                    276:                is executed.
                    277:        tags:
                    278:                create a tags file for the source files.
                    279:
                    280: It sets/uses the following variables:
                    281:
                    282: BINGRP         Binary group.
                    283:
                    284: BINOWN         Binary owner.
                    285:
                    286: BINMODE                Binary mode.
                    287:
                    288: CLEANFILES     Additional files to remove for the clean and cleandir targets.
                    289:
                    290: COPTS          Additional flags to the compiler when creating C objects.
                    291:
                    292: LDADD          Additional loader objects.  Usually used for libraries.
1.53      deraadt   293:                For example, to load with the crypto and utility
1.1       deraadt   294:                libraries, use:
                    295:
1.53      deraadt   296:                        LDADD+=-lutil -lcrypto
1.1       deraadt   297:
                    298: LDFLAGS                Additional loader flags.
                    299:
                    300: LINKS          The list of binary links; should be full pathnames, the
                    301:                linked-to file coming first, followed by the linked
                    302:                file.  The files are hard-linked.  For example, to link
                    303:                /bin/test and /bin/[, use:
                    304:
                    305:                        LINKS=  ${DESTDIR}/bin/test ${DESTDIR}/bin/[
                    306:
1.4       niklas    307: MAN            Manual pages (should end in .1 - .9).  If no MAN variable is
1.1       deraadt   308:                defined, "MAN=${PROG}.1" is assumed.
                    309:
                    310: PROG           The name of the program to build.  If not supplied, nothing
                    311:                is built.
                    312:
1.6       mickey    313: SRCS           List of source files to build the program.  If it's not
1.1       deraadt   314:                defined, it's assumed to be ${PROG}.c.
                    315:
                    316: DPADD          Additional dependencies for the program.  Usually used for
1.53      deraadt   317:                libraries.  For example, to depend on the crypto and
1.1       deraadt   318:                utility libraries use:
                    319:
1.53      deraadt   320:                        DPADD+=${LIBCRYPTO} ${LIBUTIL}
1.1       deraadt   321:
                    322:                The following libraries are predefined for DPADD:
                    323:
1.31      espie     324:                        LIBC            /usr/lib/libc.a
                    325:                        LIBCRYPTO       /usr/lib/libcrypto.a
1.1       deraadt   326:                        LIBCURSES       /usr/lib/libcurses.a
1.26      millert   327:                        LIBEDIT         /usr/lib/libedit.a
1.32      millert   328:                        LIBEVENT        /usr/lib/libevent.a
1.42      miod      329:                        LIBEXPAT        /usr/lib/libexpat.a
                    330:                        LIBFORM         /usr/lib/libform.a
                    331:                        LIBFORMW        /usr/lib/libformw.a
1.26      millert   332:                        LIBKEYNOTE      /usr/lib/libkeynote.a
1.1       deraadt   333:                        LIBKVM          /usr/lib/libkvm.a
1.26      millert   334:                        LIBL            /usr/lib/libl.a
1.1       deraadt   335:                        LIBM            /usr/lib/libm.a
1.42      miod      336:                        LIBMENU         /usr/lib/libmenu.a
                    337:                        LIBMENUW        /usr/lib/libmenuw.a
1.60      yasuoka   338:                        LIBRADIUS       /usr/lib/libradius.a
1.42      miod      339:                        LIBOSSAUDIO     /usr/lib/libossaudio.a
                    340:                        LIBPANEL        /usr/lib/libpanel.a
                    341:                        LIBPANELW       /usr/lib/libpanelw.a
1.31      espie     342:                        LIBPCAP         /usr/lib/libpcap.a
1.21      millert   343:                        LIBPERL         /usr/lib/libperl.a
1.42      miod      344:                        LIBPTHREAD      /usr/lib/libpthread.a
1.26      millert   345:                        LIBRPCSVC       /usr/lib/librpcsvc.a
                    346:                        LIBSKEY         /usr/lib/libskey.a
1.42      miod      347:                        LIBSNDIO        /usr/lib/libsndio.a
1.26      millert   348:                        LIBSSL          /usr/lib/libssl.a
1.9       tholo     349:                        LIBTERMCAP      /usr/lib/libtermcap.a
                    350:                        LIBTERMLIB      /usr/lib/libtermlib.a
1.59      jsing     351:                        LIBTLS          /usr/lib/libtls.a
1.31      espie     352:                        LIBUSB          /usr/lib/libusbhid.a
1.1       deraadt   353:                        LIBUTIL         /usr/lib/libutil.a
1.31      espie     354:                        LIBY            /usr/lib/liby.a
1.13      deraadt   355:                        LIBZ            /usr/lib/libz.a
1.31      espie     356:                        LIBARCH         arch-dependent stuff
1.1       deraadt   357:
                    358: STRIP          The flag passed to the install program to cause the binary
                    359:                to be stripped.
                    360:
                    361: SUBDIR         A list of subdirectories that should be built as well.
                    362:                Each of the targets will execute the same target in the
                    363:                subdirectories.
                    364:
                    365: The include file <bsd.prog.mk> includes the file named "../Makefile.inc"
                    366: if it exists, as well as the include file <bsd.man.mk>.
                    367:
                    368: Some simple examples:
                    369:
                    370: To build foo from foo.c with a manual page foo.1, use:
                    371:
                    372:        PROG=   foo
                    373:
                    374:        .include <bsd.prog.mk>
                    375:
                    376: To build foo from foo.c with a manual page foo.2, add the line:
                    377:
                    378:        MAN=    foo.2
                    379:
                    380: If foo does not have a manual page at all, add the line:
                    381:
                    382:        NOMAN=  noman
                    383:
                    384: If foo has multiple source files, add the line:
                    385:
                    386:        SRCS=   a.c b.c c.c d.c
                    387:
                    388: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    389:
                    390: The include file <bsd.subdir.mk> contains the default targets for building
1.58      schwarze  391: subdirectories.  It has the same seven targets as <bsd.prog.mk>: all,
1.47      jsg       392: clean, cleandir, depend, includes, install, and tags.  For all of
1.41      jmc       393: the directories listed in the variable SUBDIR, the specified directory
1.8       deraadt   394: will be visited and the target made.  There is also a default target which
                    395: allows the command "make subdir" where subdir is any directory listed in
1.41      jmc       396: the variable SUBDIR.
1.2       deraadt   397:
                    398: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    399:
                    400: The include file <bsd.sys.mk> is used by <bsd.prog.mk> and
1.3       deraadt   401: <bsd.lib.mk>.  It contains overrides that are used when building
1.14      millert   402: the OpenBSD source tree.  For instance, if "PARALLEL" is defined by
1.3       deraadt   403: the program/library Makefile, it includes a set of rules for lex and
                    404: yacc that allow multiple lex and yacc targets to be built in parallel.
1.1       deraadt   405:
                    406: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    407:
                    408: The include file <bsd.lib.mk> has support for building libraries.  It has
1.58      schwarze  409: the same seven targets as <bsd.prog.mk>: all, clean, cleandir, depend,
1.47      jsg       410: includes, install, and tags.  It has a limited number of suffixes,
1.8       deraadt   411: consistent with the current needs of the BSD tree.
1.1       deraadt   412:
                    413: It sets/uses the following variables:
                    414:
                    415: LIB            The name of the library to build.
                    416:
                    417: LIBDIR         Target directory for libraries.
                    418:
                    419: LIBGRP         Library group.
                    420:
                    421: LIBOWN         Library owner.
                    422:
                    423: LIBMODE                Library mode.
                    424:
                    425: LDADD          Additional loader objects.
                    426:
1.4       niklas    427: MAN            The manual pages to be installed (use a .1 - .9 suffix).
1.1       deraadt   428:
                    429: SRCS           List of source files to build the library.  Suffix types
                    430:                .s, .c, and .f are supported.  Note, .s files are preferred
                    431:                to .c files of the same name.  (This is not the default for
                    432:                versions of make.)
                    433:
                    434: The include file <bsd.lib.mk> includes the file named "../Makefile.inc"
                    435: if it exists, as well as the include file <bsd.man.mk>.
                    436:
                    437: It has rules for building profiled objects; profiled libraries are
                    438: built by default.
                    439:
                    440: Libraries are ranlib'd when made.
1.52      guenther  441:
                    442: In addition, a reduced version of a library, including just specific
                    443: objects that are compiled with additional options to reduce their
                    444: size may be built.  This is used by the distrib/ tree and crunchgen
                    445: when building ramdisks.  This sets/uses the following variables:
                    446:
                    447: DIST_LIB       The path of the library to build. [lib${LIB}_d.a]
                    448:
                    449: DIST_OBJS      The (sub)set of .o files to include in ${DIST_LIB}. [${OBJS}]
                    450:
                    451: DIST_CFLAGS    Additional flags for the C compiler and assembler.
                    452:                [-Os]
1.6       mickey    453: