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

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

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