MAKERULES(1)

NAME
makerules - default nmake base rules

SYNOPSIS
rules "makerules"

DESCRIPTION
makerules are the default nmake base rules. The nmake engine is described in nmake(1).

Base rules define the local nmake operating environment. Base rules files are like normal nmake makefiles in most respects, with the exception that they are explicitly written to be shared among a varied group of users. makerules defines a collection of options, operators, common target atoms, metarules and variables suitable for the UNIX programming environment.

  Operators
In the following descriptions, lhs and rhs are the lists of atoms appearing on the left and the right side of the operator, and action is the action following the operator.

::  The main source dependency operator. lhs is a single command or archive target that is built from the source files in rhs. If the lhs is an archive then $(LIBDIR) :INSTALLDIR: lhs is asserted, otherwise $(BINDIR) :INSTALLDIR: lhs is asserted (see Directories). If the lhs is not given, then the rhs is appended to the list of files for the save-oriented common actions, such as cpio, tar, etc. (see Common Actions).

:ALL:
    Causes the rhs targets and all :: targets to be made when no command line targets are specified.

:COMMAND:
    The lhs is a variable whose value is the result of shell command substitution on the action with respect to prerequisites on the rhs.

:COPY:
    The lhs is a copy of the rhs file.

:FUNCTION:
    The lhs is a functional variable, whose value is determined by the action during the execution time. For example,
        a :FUNCTION: b
        action
    is the same as
        a : b .SPECIAL .FUNCTION
        action

:INSTALL:
    If the lhs is omitted then the rhs is added to the list of targets made by the install common action. Otherwise the lhs is installed by the install common action by copying the file on the rhs. If the rhs is omitted then the lhs is installed from the file named by the base and suffix of the lhs file name. If both the lhs and rhs are omitted and an action is specified then this overrides the default install action. The default install action saves old install targets in target.old.

:INSTALLDIR:
    The files in the rhs are installed into the directory on the lhs by the install common action.

:INSTALLMAP:
    The files which match the edit operation specified on the rhs are installed in the directory specified on the lhs. For example,
    $(FORMDIR) :INSTALLMAP: A=.SQLFORM:T=G
    will install all generated files with the user-defined attribute .SQLFORM in $(FORMDIR).

:INSTALLPROTO:
    This assertion operator installs $(PROTO) output of rhs into lhs directory by the install common action. The program $(PROTO) converts a prototyped C file to a single file that is compatible with the ANSI, K&R and C++ dialects of C. rhs files must have #pragma prototyped as the first line and must be valid ANSI C.

:JOINT:
    The action jointly builds all targets on the lhs with respect to prerequisites on the rhs.

:LIBRARY:
    This operator creates a library from the specified source files. The syntax is:
    name [ major.minor [required-libraries]] :LIBRARY: source
    where name is the name of the library (e.g., x for libx.a), major.minor is the version number for shared libraries if the compiler of the specific machine supports it, required-libraries are the libraries that have to be linked in conjunction with the current target library, if there are any (see .REQUIRE.pattern of nmake(1)), and source is the list of source files. If required-libraries are specified, nmake will generate a file $(LIBDIR)/lib/name, containing the names of the required-libraries for the target library. For example,
        cs 1.0 nsl socket :LIBRARY: standalone.c
    Here cs is name, 1.0 is major.minor, nsl socket are required-libraries, and standalone.c is source. $(CCFLAGS) controls the file name of the archive. If $(CCFLAGS) is set to -g, then the library is named libname-g.a (e.g., libx-g.a). If $(CCFLAGS) is set to -p, then the library is named libname-p.a (e.g., libx-p.a). If $(CCFLAGS) is set to -pg, then the library is named libname-pg.a (e.g., libx-pg.a). If $(CC.PIC) is in $(CCFLAGS), then both libname.a and libname.so.major.minor are created. :LIBRARY: makes .a only by default, even if CCFLAGS+=$$(CC.PIC) is on. The all or install common actions also generate the shared library (.so on SVR4).

:LINK:
    The lhs files are hard links to the rhs file. Works properly with the install common action.

:MAKE:
    If the rhs is a directory then a recursive nmake is run in that directory. If rhs is not specified then a recursive nmake is run in all subdirectories containing a makefile from the list $(MAKEFILES:/:/ /G). The lhs can be specified as label targets.

:PACKAGE:
    Facilitates locating the include files and libraries of certain packages. It can also be used with the PACKAGE_ID, PACKAGE_ID_INCLUDE, and PACKAGE_ID_LIB environment variables that add to the list of directories to be searched for include files and libraries. For example, if one owns and builds the X11 tools and libraries, which are installed in /usr/add-on/X11, an nmake makefile with
        :PACKAGE: X11
    will search for include files by adding -I/usr/add-on/X11/include and for libraries by adding -L/usr/add-on/X11/lib and -lX11 to the linker options (see cc(1) and ld(1)). Other X11 versions, e.g. /home/my/X11, can be accessed by exporting the PACKAGE_ID[_INCLUDE|_LIB] environment variable:
        export PACKAGE_X11=/home/my/X11
    :PACKAGE: and PACKAGE_ID[_INCLUDE|_LIB] eliminate the need for many .SOURCE.a and .SOURCE.h makefile assertions.

    Note, :PACKAGE: changes INCLUDEDIR to be $(INSTALLROOT)/include/ID by default. If one uses a third party software package, one should specify it as
        :PACKAGE: - X11
    The "-" at the beginning of the rhs inhibits the INCLUDEDIR redefinition.

    :PACKAGE: can be multiply defined, but the most recent :PACKAGE: assertion takes the highest precedence. A "+" in the rhs will append the package at the end of the package list, which means it will take the lowest precedence.

:READONLY:
    The rhs compilation is to place tables and/or data in a readonly text object section. Only the parse and pattern tables are placed in readonly for yacc(1) and lex(1) files. :READONLY: will become a no-op when enough C compilers properly implement const.

:SAVE:
    The rhs files are generated but are still to be saved by the save-oriented common actions (cpio, pax, etc.).

:cc:
    The rhs files are compiled using $(cc) instead of $(CC). This is useful for compiling C and C++ modules from the same makefile.

  Common Actions
makerules defines several common command line actions. In the following, main-target is the name of the target in the first :: assertion.

all Make all :: targets.

cc- This common action assumes the existence of one or more cc-opt subdirectories, where opt is any valid CCFLAGS value (ex. g, p, pg, etc.). When nmake is invoked with the cc- or cc-opt common action, it will build the executables for each of these compiler options or the specific one specified by opt and place them in the corresponding directory.

ciadag
    Generates a dag(1) input call graph file based on information generated by ciadb.

ciadb
    Generates the database files for the C information abstractor cia(1).

clean
    All generated intermediate files are removed. Command and archive files are retained.

clobber
    All generated files, except the output of the cpio, pax and tar common actions, are removed.

clobber.install
    Removes all of the files installed by the install common action.

cpio
    All source files are copied to the cpio(1) archive named main-target.cpio.

ctags
    ctags(1) is run on all C-related source files.

grind
    The grindex common action and vgrind(1) are run on all C-related source files. The output is sent to $(LPR).

grindex
    A vgrind(1) index file is made in the file index and is sent to $(LPR).

install
    All ::, :INSTALL:, :INSTALLDIR:, :INSTALLPROTO: and :INSTALLMAP: target files are installed in the directory hierarchy rooted at $(INSTALLROOT) (see Directories).

lint
    lint(1) is run on all C-related source files. The proper -D and -I options are propagated to lint.

list.generated
    Lists the files which have been generated.

list.install
    Lists the full path names of all files to be installed under $(INSTALLROOT) by the install common action.

list.source
    Lists the source files.

list.symbols
    Lists the sorted archive symbol names.

official
    All source files in the top view of the viewpath are moved down to the next view.

pax All source files are copied to the pax(1) archive named main-target.pax.

print
    All source files are sent to $(LPR) via $(PR).

recurse
    When using :MAKE:, certain common actions (such as clean, clobber, official) are non-recursive by default. When recurse is asserted before a common action, recursion is forced (e.g., nmake recurse clobber).

shar
    All source files are copied to the shar(1) archive named main-target.shar.

tar All source files are copied to the tar(1) archive named main-target.tar.

ucpio
    All source files modified since the last ucpio are copied to the cpio(1) archive named main-target.cpio.

uprint
    All source files modified since the last uprint are sent to $(LPR) via $(PR).

utar
    All source files modified since the last utar are copied to the tar(1) archive named main-target.tar.

  Languages
makerules imposes the use of the new C preprocessor for all C compilations by overloading CCFLAGS with the proper incantations. In some cases the shell script wrapper $(CCC) will be run for compilers that have cpp built in. This ensures that "..." include files follow the local files override non-local files rule. The native C preprocessor can be made the default by placing nativepp=1 in an nmake alias or by exporting nativepp=1 in the environment. Doing this, however, may defeat some or all of the benefits of the .SOURCE* binding rules and/or viewpathing where "..." include files are concerned. Setting nativepp=-1 inhibits the warning message about overriding the nmake C preprocessor.

Metarules perform common language file transformations. nmake can be used to manufacture software applications written in a variety of languages: C, C++, assembler, FORTRAN, yacc, and so on. The language support is: *.c -> *.o, *.y -> { *.c, *.h }, etc.

  Scan Rules
makerules supplies the following default scanning strategies:

.SCAN.x[dynamicattribute]
    Marks an atom (when bound to a file) to be scanned for implicit prerequisites using the .x scan strategy. .ATTRIBUTE.pattern : .SCAN.x is asserted for each of the strategies listed below.

    .SCAN.c
        Scans for C #include file prerequisites and candidate state variable references. Include statements requiring macro substitutions are not recognized. "..." include files are bound using the directories of .SOURCE first and then the directories of .SOURCE.h. This is the opposite of the default directory binding order. <...> include files are bound using only the directories of .SOURCE.h. "..." include files are assigned the .LCL.INCLUDE attribute and <...> include files are assigned the .STD.INCLUDE attribute. .LCL.INCLUDE takes precedence if a file appears as both "..." and <...>.

        To support popular C coding style, if an including file is included as "prefix/includer" then a file "includee" included by "prefix/includer" is first bound using "prefix/includee", and, if that fails, is next bound using "includee".

    .SCAN.f
        FORTRAN include and INCLUDE file prerequisites.

    .SCAN.F
        A combination of the .SCAN.c, .SCAN.f, and .SCAN.sql strategies.

    .SCAN.r
        RATFOR include and INCLUDE file prerequisites. Include statements requiring macro substitutions are not recognized.

    .SCAN.m4
        m4(1) include(...), sinclude(...), and INCLUDE(...) file prerequisites. The INCLUDE(...) form also handles S (statistical analysis package) source file prerequisites. Include statements resulting from macro substitutions are not recognized.

    .SCAN.mk
        nmake include file prerequisites.

    .SCAN.nroff
        nroff(1) and troff(1) .so file prerequisites. Only .so file starting at the beginning of a line is recognized. .so statements requiring macro substitutions are not recognized.

    .SCAN.sh
        Scans for candidate state variable references, i.e., those state variables initialized with the == operator.

    .SCAN.sql
        SQL include file prerequisites of the form EXEC SQL include filename or ## include filename, where filename is "filename", filename;, or filename. SQL include file prerequisites can also be of the form $ include filename, where filename is <filename>, "filename", 'filename', filename;, or filename.

  Directories
Common directories are named by variables. The directory hierarchy is modeled after /usr in System V.

INSTALLROOT = $(HOME)
    The root installation directory used by the :INSTALL: operator and install common action.

BINDIR = $(INSTALLROOT)/bin
    The installation directory for generated commands.

ETCDIR = $(INSTALLROOT)/etc
    The installation directory used for generated miscellaneous system files.

FUNDIR = $(INSTALLROOT)/fun
    The installation directory used for ksh functions.

INCLUDEDIR = $(INSTALLROOT)/include
    The installation directory for generated header files.

LIBDIR = $(INSTALLROOT)/lib
    The installation directory for generated libraries and data files.

MANDIR = $(INSTALLROOT)/man/man
    The installation directory prefix for man(1) pages. *.nnn man page files are installed in the $(MANDIR)nnn directory.

SHAREDIR = $(INSTALLROOT)/share
    The installation directory accessed by all hosts of the local network.

TMPDIR = /usr/tmp
    The temporary file directory.

  Commands
Each command referenced by the base rules has a corresponding command and option variable. For a command cmd the command is named by $(CMD), the options are named by $(CMDFLAGS) and the command is executed by expanding $(CMD) $(CMDFLAGS) arguments.

  Base Rule Variables
The following variables are defined and used by the base rule operators and common targets. $MAKE_OPTIONS can be used to set these variables in the environment.

ancestor
    This variable may be used to specify how many directory levels up from the current directory to look for include and archive directories (eg. ancestor=2 is equivalent to .SOURCE.h : ../include ../../include and .SOURCE.a : ../lib ../../lib).

ancestor_list, ancestor_source
    Determine lib and include directories used with ancestor. The default value of ancestor_list includes the default search directories (i.e. include, lib):
        ancestor_list = $(ancestor_source) .SOURCE.a lib .SOURCE.h include
    The default for ancestor_source is null. ancestor_list can be redefined to any list of .SOURCE.x search_dir_name_for.x pairs. For example, to search for headers only in the directory called hdrs and search for libraries only in the directory called LIB using the ancestor concept, one would redefine ancestor_list to be:
        ancestor_list = .SOURCE.h hdrs .SOURCE.a LIB
    To keep the default directories in the search path, one would redefine ancestor_source only.

cctype
    $(CC) is normally used to determine the probe configuration file to be used. $(cctype) may be used to specify that another C compiler's probe file is to be loaded instead.

cleanignore
    Shell pattern for files that should not be deleted by clean common action.

clobber
    If $(clobber) is non-null the default install action will not move old install target to target.old.

compare
    If $(compare) is 0, then the default install action will not do a cmp -s before installing the target file.

force_shared
    If this variable is set, it will cause the re-link of a.outs with shared libraries (if it is not set, shared libraries time stamps are ignored).

link
    For install targets where the basename matches the pattern in $(link), the install action will attempt to link instead of copy (e.g., link=lib*).

nativepp
    If $(nativepp) is non-null, then the native C preprocessor will be used for compiling C source. The default nmake C preprocessor provides viewpath support.

output
    This variable may be used to override the default common action output file base name.

physical
    This variable is 3D File System related (see 3d(1)). When physical is set, it will limit the recursion to directories which physically exist.

prefixinclude
    This variable is used to support C #include "file.h" compatibility. With prefixinclude=1 (default), the following scenario is valid:
        	Contents of main.c	#include "subdir/file1.h"
        	Contents of file1.h	#include "file2.h"
        	Contents of makefile	.SOURCE.h: dir
        	Both file1.h and file2.h are located in dir/subdir.
    nmake (invoked from the above dir level) looks first in dir/subdir to find file2.h. If file2.h is not found in dir/subdir, the default search rules are used. Note, you do not need to specify dir/subdir as a searching directory for .SOURCE.h to find file2.h, subdir prefix is inherited from the including file file1.h. With prefixinclude=0, nmake relies exclusively on the default search rules. (In this case you need to specify .SOURCE.h: dir dir/subdir to find file2.h.)

preserve
    When set to non-null value, the install common action will rename old install target to filename.#inode. This is useful for installing executables that may be currently running.

instrument
    This variable supports software packages such as purify, sentinel, and insight. When instrument is set to one of these packages, nmake links with the package.

recurse
    This variable specifies the maximum number of recursive makes that may be done concurrently when using the :MAKE: operator. The default is 1. Note that the NPROC environment variable or the jobs command line option determine an upper bound for recurse, meaning that if they are set to a value less than $(recurse), the number of concurrent makes will be bound by this value.

save
    This variable may be set to a list of files that should be saved by the save common actions (in addition to the normal list of source files).

select
    This variable can be set to a string of edit operators that are applied to the list of source files before the save common actions execute (e.g., select=N!=*.c will prevent any .c files from being saved).

tmp
    This variable is set to $COTEMP value (see nmake(1)).

viewverify
    If $(viewverify) is non-null, and there are no views, then an error is issued with a severity level of $(viewverify).

SEE ALSO
nmake(1)