MAKE(1) UNIX Reference Manual MAKE(1) NNAAMMEE mmaakkee - maintain program dependencies SSYYNNOOPPSSIISS mmaakkee [--eeiikknnqqrrssttvv] [--DD _v_a_r_i_a_b_l_e] [--dd _f_l_a_g_s] [--ff _m_a_k_e_f_i_l_e] [--II _d_i_r_e_c_t_o_r_y] [--jj _m_a_x__j_o_b_s] [_v_a_r_i_a_b_l_e=_v_a_l_u_e] [_t_a_r_g_e_t ...] DDEESSCCRRIIPPTTIIOONN MMaakkee is a program designed to simplify the maintenance of other programs. Its input is a ``makefile'' which specifies files that programs and other files are dependent upon. This manual page is intended as a reference document only. For a more thorough description of mmaakkee and makefiles, please refer to _M_a_k_e -- _A _T_u_t_o_r_i_a_l. The options are as follows: --_v_a_r_i_a_b_l_e Define _v_a_r_i_a_b_l_e to be 1, in the global context. --dd_f_l_a_g_s Turn on debugging, and specify which portions of mmaakkee are to print debugging information. _F_l_a_g_s is one or more of the following: AA Print all possible debugging information; equivalent to specifying all of the debugging flags. aa Print debugging information about archive searching and cach- ing. cc Print debugging information about conditional evaluation. dd Print debugging information about directory searching and caching. gg11 Print the input graph before making anything. gg22 Print the input graph after making everything, or before ex- iting on error. jj Print debugging information about running multiple shells. mm Print debugging information about making targets, including modification dates. ss Print debugging information about suffix-transformation rules. tt Print debugging information about target list maintenance. vv Print debugging information about variable assignment. --ff_m_a_k_e_f_i_l_e Specify a makefile to read. If no makefile is specified, the files ``makefile'' and ``Makefile'' are searched for, in that order. If _m_a_k_e_f_i_l_e is ``-'', standard input is read. Multiple makefile's may be specified, and are read in the order specified. --II_d_i_r_e_c_t_o_r_y Specify a directory in which to search for makefiles and included makefiles. The system makefile directory is automatically included as part of this list. --ii Ignore non-zero exit of shell commands in the makefile. Equivalent to specifying ``-'' before each command line in the makefile. --jj_m_a_x__j_o_b_s Specify the maximum number of jobs that mmaakkee may have running at any one time. --kk Continue processing after errors are encountered, but only on those targets that do not depend on the target whose creation caused the error. --nn Display the commands that would have been executed, but do not ac- tually execute them. --qq Do not execute any commands, but exit 0 if the specified targets are up-to-date and 1, otherwise. --rr Do not use the built-in rules specified in the system makefile. --ss Do not echo any commands as they are executed. Equivalent to specifying ``@'' before each command line in the makefile. --tt Rather than re-building a target as specified in the makefile, create it or update its modification time to make it appear up-to- date. _v_a_r_i_a_b_l_e=_v_a_l_u_e Set the value of the variable _v_a_r_i_a_b_l_e to _v_a_l_u_e. There are six different types of lines in a makefile: file dependency specifications, shell commands, variable assignments, include statements, conditional directives, and comments. In general, lines may be continued from one line to the next by ending them with a backslash (``\''). The trailing newline character and ini- tial whitespace on the following line are compressed into a single space. FFIILLEE DDEEPPEENNDDEENNCCYY SSPPEECCIIFFIICCAATTIIOONNSS Dependency lines consist of one or more targets, an operator, and zero or more sources. This creates a relationship where the targets ``depend'' on the sources and are usually created from them. The exact relationship between the target and the source is determined by the operator that separates them. The three operators are as follows: :: A target is considered out-of-date if its modification time is less than those of any of its sources. Sources for a target accumulate over dependency lines when this operator is used. The target is removed if mmaakkee is interrupted. !! Targets are always re-created, but not until all sources have been examined and re-created as necessary. Sources for a target accumu- late over dependency lines when this operator is used. The target is removed if mmaakkee is interrupted. :::: If no sources are specified, the target is always re-created. Oth- erwise, a target is considered out-of-date if any of its sources has been modified more recently than the target. Sources for a target do not accumulate over dependency lines when this operator is used. The target will not be removed if mmaakkee is interrupted. Targets and sources may contain the shell wildcard values ``?'', ``*'', ``[]'' and ``{}''. The values ``?'', ``*'' and ``[]'' may only be used as part of the final component of the target or source, and must be used to describe existing files. The value ``{}'' need not necessarily be used to describe existing files. Expansion is in directory order, not alphabetically as done in the shell. SSHHEELLLL CCOOMMMMAANNDDSS Each target may have associated with it a series of shell commands, normally used to create the target. Each of the commands in this script _m_u_s_t be preceded by a tab. While any target may appear on a dependency line, only one of these dependencies may be followed by a creation script, unless the ``::'' operator is used. If the first or first two characters of the command line are ``@'' and/or ``-'', the command is treated specially. A ``@'' causes the command not to be echoed before it is executed. A ``-'' causes any non-zero exit status of the command line to be ignored. VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS Variables in make are much like variables in the shell, and, by tradi- tion, consist of all upper-case letters. The five operators that can be used to assign values to variables are as follows: == Assign the value to the variable. Any previous value is overrid- den. ++== Append the value to the current value of the variable. ??== Assign the value to the variable if it is not already defined. ::== Assign with expansion, i.e. expand the value before assigning it to the variable. Normally, expansion is not done until the variable is referenced. !!== Expand the value and pass it to the shell for execution and assign the result to the variable. Any newlines in the result are re- placed with spaces. Any white-space before the assigned _v_a_l_u_e is removed; if the value is be- ing appended, a single space is inserted between the previous contents of the variable and the appended value. Variables are expanded by surrounding the variable name with either curly braces (``{}'') or parenthesis (``()'') and preceding it with a dollar sign (``$''). If the variable name contains only a single letter, the surrounding braces or parenthesis are not required. This shorter form is not recommended. Variable substitution occurs at two distinct times, depending on where the variable is being used. Variables in dependency lines are expanded as the line is read. Variables in shell commands are expanded when the shell command is executed. The four different classes of variables (in order of increasing pre- cedence) are: environment variables Variables defined as part of mmaakkee's environment. global variables Variables defined in the makefile or in included makefiles. command line variables Variables defined as part of the command line. local variables Variables that are defined specific to a certain target. The seven local variables are as follows: ._A_L_L_S_R_C The list of all sources for this target; also known as ``>''. ._A_R_C_H_I_V_E The name of the archive file. ._I_M_P_S_R_C The name/path of the source from which the target is to be transformed (the ``implied'' source); also known as ``<''. ._M_E_M_B_E_R The name of the archive member. ._O_O_D_A_T_E The list of sources for this target that were deemed out-of- date; also known as ``?''. ._P_R_E_F_I_X The file prefix of the file, containing only the file por- tion, no suffix or preceding directory components; also known as ``*'. ._T_A_R_G_E_T The name of the target; also known as ``@''. The shorter forms ``@'', ``?'', ``>'' and ``*'' are permitted for backward compatibility with historical makefiles and are not recom- mended. The six variables ``@F'', ``@D'', ``<F'', ``<D'', ``*F'' and ``*D'' are permitted for compatibility with System V makefiles and are not recommended. Four of the local variables may be used in sources on dependency lines because they expand to the proper value for each target on the line. These variables are ``.TARGET'', ``.PREFIX'', ``.AR- CHIVE'', and ``.MEMBER''. In addition, mmaakkee sets or knows about the following variables: $ A single dollar sign (``$''), i.e. ``$$'' expands to a single dollar sign. ._M_A_K_E The name that mmaakkee was executed with (_a_r_g_v) [0] ._C_U_R_D_I_R A path to the directory where mmaakkee was executed. _M_A_K_E_F_L_A_G_S The environment variable ``MAKEFLAGS'' may contain any- thing that may be specified on mmaakkee's command line. Anything specified on mmaakkee's command line is appended to the ``MAKEFLAGS'' variable which is then entered into the environment for all programs which mmaakkee exe- cutes. Variable expansion may be modified to select or modify each word of the variable (where a ``word'' is white-space delimited sequence of characters). The general format of a variable expansion is as fol- lows: {variable[:modifier[:...]]} Each modifier begins with a colon and one of the following special characters. The colon may be escaped with a backslash (``\''). EE Replaces each word in the variable with its suffix. HH Replaces each word in the variable with everything but the last component. MM_p_a_t_t_e_r_n Select only those words that match the rest of the modifier. The standard shell wildcard characters (``*'', ``?'', and ``[]'') may be used. The wildcard characters may be escaped with a backslash (``\''). NN_p_a_t_t_e_r_n This is identical to ``M'', but selects all words which do not match the rest of the modifier. RR Replaces each word in the variable with everything but its suffix. SS/_o_l_d__p_a_t_t_e_r_n/_n_e_w__p_a_t_t_e_r_n/[gg] Modify the first occurrence of _o_l_d__p_a_t_t_e_r_n in each word to be re- placed with _n_e_w__p_a_t_t_e_r_n. If a ``g'' is appended to the last slash of the pattern, all occurrences in each word are replaced. If _o_l_d__p_a_t_t_e_r_n begins with a carat (``^''), _o_l_d__p_a_t_t_e_r_n is anchored at the beginning of each word. If _o_l_d__p_a_t_t_e_r_n ends with a dollar sign (``$''), it is anchored at the end of each word. Inside _n_e_w__s_t_r_i_n_g, an ampersand (``&'') is replaced by _o_l_d__p_a_t_t_e_r_n. Any character may be used as a delimiter for the parts of the modifier string. The anchoring, ampersand and delimiter characters may be escaped with a backslash (``\''). Variable expansion occurs in the normal fashion inside both _o_l_d__s_t_r_i_n_g and _n_e_w__s_t_r_i_n_g with the single exception that a backslash is used to prevent the expansion of a dollar sign (``$''), not a preceding dollar sign as is usual. TT Replaces each word in the variable with its last component. _o_l_d__s_t_r_i_n_g=_n_e_w__s_t_r_i_n_g This is the System V style variable substitution. It must be the last modifier specified. _O_l_d__s_t_r_i_n_g is anchored at the end of each word, so only suffixes or entire words may be replaced. IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS AANNDD CCOONNDDIITTIIOONNAALLSS Makefile inclusion and conditional structures reminiscent of the C pro- gramming language are provided in mmaakkee. All such structures are identi- fied by a line beginning with a single dot (``.'') character. Files are included with either ``.include <file>'' or ``.include "file"''. Vari- ables between the angle brackets or double quotes are expanded to form the file name. If angle brackets are used, the included makefile is ex- pected to be in the system makefile directory. If double quotes are used, the including makefile's directory and any directories specified using the --II option are searched before the system makefile directory. Conditional expressions are also preceded by a single dot as the first chraracter of a line. The possible conditionals are as follows: ..uunnddeeff _v_a_r_i_a_b_l_e Un-define the specified global variable. Only global variables may be un-defined. ..iiff [!] _e_x_p_r_e_s_s_i_o_n [_o_p_e_r_a_t_o_r _e_x_p_r_e_s_s_i_o_n ...] Test the value of an expression. ..iiffddeeff [!]_v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e ...] Test the value of an variable. ..iiffnnddeeff [!] _v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e ...] Test the value of an variable. ..iiffmmaakkee [!] _t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t ...] Test the the target being built. ..iiffnnmmaakkee [!]_t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t ...] Test the target being built. ..eellssee Reverse the sense of the last conditional. ..eelliiff [!] _e_x_p_r_e_s_s_i_o_n [_o_p_e_r_a_t_o_r _e_x_p_r_e_s_s_i_o_n ...] A combination of ``.else'' followed by ``.if''. ..eelliiffddeeff [!] _v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e ...] A combination of ``.else'' followed by ``.ifdef''. ..eelliiffnnddeeff [!] _v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e ...] A combination of ``.else'' followed by ``.ifndef''. ..eelliiffmmaakkee [!] _t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t ...] A combination of ``.else'' followed by ``.ifmake''. ..eelliiffnnmmaakkee [!] _t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t ...] A combination of ``.else'' followed by ``.ifnmake''. ..eennddiiff End the body of the conditional. The _o_p_e_r_a_t_o_r may be any one of the following: |||| logical OR &&&& Logical AND; of higher precedence than ``''. As in C, mmaakkee will only evaluate a conditional as far as is necessary to determine its value. Parenthesis may be used to change the order of evaluation. The boolean operator ``!'' may be used to logically negate an entire conditional. It is of higher precendence than ``&&''. The value of _e_x_p_r_e_s_s_i_o_n may be any of the following: ddeeffiinneedd Takes a variable name as an argument and evaluates to true if the variable has been defined. mmaakkee Takes a target name as an argument and evaluates to true if the target was specified as part of mmaakkee's command line or was declared the default target (either implicitly or explicitly, see .MAIN) before the line containing the conditional. eemmppttyy Takes a variable, with possible modifiers, and evalutes to true if the expansion of the variable would result in an empty string. eexxiissttss Takes a file name as an argument and evaluates to true if the file exists. The file is searched for on the system search path (see .PATH). ttaarrggeett Takes a target name as an argument and evaluates to true if the target has been defined. _E_x_p_r_e_s_s_i_o_n may also be an arithmetic or string comparison, with the left-hand side being a variable expansion. The standard C relational operators are all supported, and the usual number/base conversion is per- formed. Note, octal numbers are not supported. If the righthand value of a ``=='' or ``!='' operator begins with a quotation mark (``"'') a string comparison is done between the expanded variable and the text between the quotation marks. If no relational operator is given, it is assumed that the expanded variable is being compared against 0. When mmaakkee is evaluating one of these conditional expression, and it en- counters a word it doesn't recognize, either the ``make'' or ``defined'' expression is applied to it, depending on the form of the conditional. If the form is ``.ifdef'' or ``.ifndef'', the ``defined'' expression is applied. Similarly, if the form is ``.ifmake'' or ``.ifnmake'', the ``make'' expression is applied. If the conditional evaluates to true the parsing of the makefile contin- ues as before. If it evaluates to false, the following lines are skipped. In both cases this continues until a ``.else'' or ``.endif'' is found. CCOOMMMMEENNTTSS Comments begin with a hash (``#'') character, anywhere but in a shell command line, and continue to the end of the line. SSPPEECCIIAALL SSOOUURRCCEESS ..IIGGNNOORREE Ignore any errors from the commands associated with this tar- get, exactly as if they all were preceded by a dash (``-''). ..MMAAKKEE Execute the commands associated with this target even if the -n or -t options were specified. Normally used to mark recursive mmaakkee's. ..NNOOTTMMAAIINN Normally mmaakkee selects the first target it encounters as the de- fault target to be built if no target was specified. This source prevents this target from being selected. ..OOPPTTIIOONNAALL If a target is marked with this attribute and mmaakkee can't figure out how to create it, it will ignore this fact and assume the file isn't needed or already exists. ..PPRREECCIIOOUUSS When mmaakkee is interrupted, it removes any partially made tar- gets. This source prevents the target from being removed. ..SSIILLEENNTT Do not echo any of the commands associated with this target, exactly as if they all were preceded by an at sign (``@''). ..UUSSEE Turn the target into mmaakkee's. version of a macro. When the target is used as a source for another target, the other target acquires the commands, sources, and attributes (except for .USE) of the source. If the target already has commands, the .USE target's commands are appended to them. SSPPEECCIIAALL TTAARRGGEETTSS Special targets may not be included with other targets, i.e. they must be the only target specified. ..BBEEGGIINN Any command lines attached to this target are executed before anything else is done. ..DDEEFFAAUULLTT This is sort of a .USE rule for any target (that was used only as a source) that mmaakkee can't figure out any other way to create. Only the shell script is used. The .IMPSRC variable of a target that inherits .DEFAULT's commands is set to the target's own name. ..EENNDD Any command lines attached to this target are executed after everything else is done. ..IIGGNNOORREE Mark each of the sources with the .IGNORE attribute. If no sources are specified, this is the equivalent of specifying the -i option. ..IINNTTEERRRRUUPPTT If mmaakkee is interrupted, the commands for this target will be executed. ..MMAAIINN If no target is specified when mmaakkee is invoked, this target will be built. ..MMAAKKEEFFLLAAGGSS This target provides a way to specify flags for mmaakkee when the makefile is used. The flags are as if typed to the shell, though the -f option will have no effect. ..PPAATTHH The sources are directories which are to be searched for files not found in the current directory. If no sources are speci- fied, any previously specified directories are deleted. ..PPRREECCIIOOUUSS Apply the .PRECIOUS attribute to any specified sources. If no sources are specified, the .PRECIOUS attribute is applied to every target in the file. ..SSIILLEENNTT Apply the .SILENT attribute to any specified sources. If no sources are specified, the .SILENT attribute is applied to every command in the file. ..SSUUFFFFIIXXEESS Each source specifies a suffix to mmaakkee. If no sources are specified, any previous specifies suffices are deleted. EENNVVIIRROONNMMEENNTT MMaakkee utilizes the following environment variables, if they exist: MAKE, MAKEFLAGS and MAKEOBJDIR. FFIILLEESS /_u_s_r/_s_h_a_r_e/_m_k system makefile directory _s_y_s._m_k include system makefile _b_s_d._m_k BSD source tree template _s_u_b_d_i_r._m_k BSD source tree subdirectory template SSEEEE AALLSSOO HHIISSTTOORRYY MMaakkee appeared in Version 7 AT&T UNIX. The mmaakkee this man page describes is derived from code contributed by Adam de Boor.