MAKE(1) BSD 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 list of specifications as to the files upon which programs and other files depend. If the file `_m_a_k_e_f_i_l_e' exists, it is read for this list of specifications. If it does not exist, the file `_M_a_k_e_f_i_l_e' is read. If the file `_._d_e_p_e_n_d' exists, it is read (see mkdep(1)). 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: --DD _v_a_r_i_a_b_l_e Define Ar variable 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 follow- ing: _A Print all possible debugging information; equivalent to specifying all of the debugging flags. _a Print debugging information about archive searching and caching. _c Print debugging information about conditional evaluation. _d Print debugging information about directory searching and caching. _g_1 Print the input graph before making anything. _g_2 Print the input graph after making everything, or before exiting on error. _j Print debugging information about running multiple shells. _m Print debugging information about making targets, includ- ing modification dates. _s Print debugging information about suffix-transformation rules. _t Print debugging information about target list mainte- nance. _v Print debugging information about variable assignment. --ee Specify that environmental variables override macro assignments within makefiles. --ff _m_a_k_e_f_i_l_e Specify a makefile to read instead of the default `_m_a_k_e_f_i_l_e' and `_M_a_k_e_f_i_l_e'. 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 in- cluded as part of this list. --ii Ignore non-zero exit of shell commands in the makefile. Equiva- lent 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 actually 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 seven different types of lines in a makefile: file dependency specifications, shell commands, variable assignments, include statements, conditional directives, for loops, 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 initial 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 sep- arates 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 ex- isting 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, nor- mally 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 vari- able is referenced. !!== Expand the value and pass it to the shell for execution and as- sign the result to the variable. Any newlines in the result are replaced 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 surround- ing 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 prece- dence) 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 portion, 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 back- ward compatibility with historical makefiles and are not recom- mended. The six variables `_@_F', `_@_D', `_<_F', `_<_D', `_*_F' and `_*_D' are permitted for compatibility with AT&T System V UNIX 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 `_._T_A_R_G_E_T', `_._P_R_E_F_I_X', `_._A_R_C_H_I_V_E', and `_._M_E_M_B_E_R'. In addition, mmaakkee sets or knows about the following variables: _$ A single dollar sign `$', i.e. `$$' expands to a sin- gle 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. MAKEFLAGS 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 executes. Variable expansion may be modified to select or modify each word of the variable (where a ``word'' is white-space delimited se- quence of characters). The general format of a variable expan- sion is as follows: {variable[:modifier[:...]]} Each modifier begins with a colon and one of the following spe- cial 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 char- acters may be escaped with a backslash (`\'). NN_p_a_t_t_e_r_n This is identical to `MM', 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 replaced with _n_e_w___p_a_t_t_e_r_n. If a `g' is ap- pended to the last slash of the pattern, all occur- rences in each word are replaced. If _o_l_d___p_a_t_t_e_r_n be- gins 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 in- side 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 ex- pansion of a dollar sign (`$') not a preceding dollar sign as is usual. TT Replaces each word in the variable with its last com- ponent. _o_l_d___s_t_r_i_n_g_=_n_e_w___s_t_r_i_n_g This is the AT&T System V UNIX style variable substi- tution. 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,, CCOONNDDIITTIIOONNAALLSS AANNDD FFOORR LLOOOOPPSS Makefile inclusion, conditional structures and for loops reminiscent of the C programming language are provided in mmaakkee. All such structures are identified by a line beginning with a single dot (`.') character. Files are included with either `.include ' 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 `..eellssee' followed by `..iiff'. ..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 `..eellssee' followed by `..iiffddeeff'. ..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 `..eellssee' followed by `..iiffnnddeeff'. ..eelliiffmmaakkee [!]_t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t _._._.] A combination of `..eellssee' followed by `..iiffmmaakkee'. ..eelliiffnnmmaakkee [!]_t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t _._._.] A combination of `..eellssee' followed by `..iiffnnmmaakkee'. ..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 explic- itly, see _._M_A_I_N) 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 emp- ty 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 _._P_A_T_H). 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. Variable ex- pansion is performed on both sides of the comparison, after which the in- tegral values are compared. A value is interpreted as hexadecimal if it is preceded by 0x, otherwise it is decimal; octal numbers are not sup- ported. The standard C relational operators are all supported. If after variable expansion, either the left or right hand side of a `====' or `!!==' operator is not an integral value, then string comparison is performed between the expanded variables. 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 `..iiffddeeff' or `..iiffnnddeeff', the ``defined'' expression is ap- plied. Similarly, if the form is `..iiffmmaakkee' or `..iiffnnmmaakkee, tthhee ````mmaakkee''''' 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 `..eellssee' or `..eennddiiff' is found. For loops are typically used to apply a set of rules to a list of files. The syntax of a for loop is: ..ffoorr _v_a_r_i_a_b_l_e iinn _e_x_p_r_e_s_s_i_o_n ..eennddffoorr After the for eexxpprreessssiioonn is evaluated, it is split into words. The itera- tion vvaarriiaabbllee is successively set to each word, and substituted in the mmaakkee--rruulleess inside the body of the for loop. CCOOMMMMEENNTTSS Comments begin with a hash (`#') character, anywhere but in a shell com- mand 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 --nn or --tt options were specified. Normally used to mark re- cursive mmaakkee's. ..NNOOTTMMAAIINN Normally mmaakkee selects the first target it encounters as the default 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 fig- ure 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 tar- get acquires the commands, sources, and attributes (except for ..UUSSEE) of the source. If the target already has commands, the ..UUSSEE 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 ..UUSSEE rule for any target (that was used on- ly as a source) that mmaakkee can't figure out any other way to create. Only the shell script is used. The ..IIMMPPSSRRCC variable of a target that inherits ..DDEEFFAAUULLTT'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 ..IIGGNNOORREE attribute. If no sources are specified, this is the equivalent of specifying the --ii 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 --ff 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 specified, any previously specified directories are deleted. ..PPRREECCIIOOUUSS Apply the ..PPRREECCIIOOUUSS attribute to any specified sources. If no sources are specified, the ..PPRREECCIIOOUUSS attribute is applied to every target in the file. ..SSIILLEENNTT Apply the ..SSIILLEENNTT attribute to any specified sources. If no sources are specified, the ..SSIILLEENNTT 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 .depend list of dependencies Makefile list of dependencies makefile list of dependencies sys.mk system makefile /usr/share/mk system makefile directory SSEEEE AALLSSOO mkdep(1) HHIISSTTOORRYY A MMaakkee command appeared in Version 7 AT&T UNIX. 4.4BSD June 6, 1993 8