SYSV-MAKE(1) User Commands SYSV-MAKE(1) NNAAMMEE sysV-make - maintain, update, and regenerate groups of programs SSYYNNOOPPSSIISS //uussrr//lliibb//ssvvrr44..mmaakkee [--ff _m_a_k_e_f_i_l_e] [--eeiikknnppqqrrsstt] [_n_a_m_e_s] DDEESSCCRRIIPPTTIIOONN This is the vvaanniillllaa System V version of mmaakkee. If the environment variable UUSSEE__SSVVRR44__MMAAKKEE is set, then the command mmaakkee will invoke this version of mmaakkee. (See also the EENNVVIIRROONNMMEENNTT section.) mmaakkee allows the programmer to maintain, update, and regenerate groups of computer programs. mmaakkee executes commands in _m_a_k_e_f_i_l_e to update one or more target _n_a_m_e_s (_n_a_m_e_s are typically programs). If the --ff option is not present, then mmaakkeeffiillee, MMaakkeeffiillee, and the Source Code Control System (SCCS) files ss..mmaakkeeffiillee and ss..MMaakkeeffiillee are tried in order. If _m_a_k_e_f_i_l_e is `--' the standard input is taken. More than one --ff _m_a_k_e_f_i_l_e argument pair may appear. mmaakkee updates a target only if its dependents are newer than the target. All prerequisite files of a target are added recursively to the list of targets. Missing files are deemed to be outdated. The following list of four directives can be included in _m_a_k_e_f_i_l_e to extend the options provided by mmaakkee. They are used in _m_a_k_e_f_i_l_e as if they were targets: ..DDEEFFAAUULLTT:: If a file must be made but there are no explicit commands or relevant built-in rules, the commands associated with the name ..DDEEFFAAUULLTT are used if it exists. ..IIGGNNOORREE:: Same effect as the --ii option. ..PPRREECCIIOOUUSS:: Dependents of the ..PPRREECCIIOOUUSS entry will not be removed when quit or interrupt are hit. ..SSIILLEENNTT:: Same effect as the --ss option. OOppttiioonnss The options for mmaakkee are listed below: --ee Environment variables override assignments within makefiles. --ff _m_a_k_e_f_i_l_e Description filename (_m_a_k_e_f_i_l_e is assumed to be the name of a description file). --ii Ignore error codes returned by invoked commands. --kk Abandon work on the current entry if it fails, but continue on other branches that do not depend on that entry. --nn No execute mode. Print commands, but do not execute them. Even command lines beginning with an `@@' are printed. --pp Print out the complete set of macro definitions and target descriptions. --qq Question. mmaakkee returns a zero or non-zero status code depending on whether or not the target file has been updated. --rr Do not use the built-in rules. --ss Silent mode. Do not print command lines before executing. --tt Touch the target files (causing them to be updated) rather than issue the usual commands. CCrreeaattiinngg tthhee mmaakkeeffiillee The makefile invoked with the --ff option is a carefully structured file of explicit instructions for updating and regenerating programs, and contains a sequence of entries that specify dependencies. The first line of an entry is a blank-separated, non-null list of targets, then a `::', then a (possibly null) list of prerequisite files or dependencies. Text following a `;;' and all following lines that begin with a tab are shell commands to be executed to update the target. The first non-empty line that does not begin with a tab or `##' begins a new dependency or macro definition. Shell commands may be continued across lines with a backslash-new-line (\\-NEWLINE) sequence. Everything printed by make (except the initial TAB) is passed directly to the shell as is. Thus, echo a\ b will produce aabb exactly the same as the shell would. Number-sign (##) and NNEEWWLLIINNEE surround comments including contained `\\-NEWLINE' sequences. The following makefile says that ppggmm depends on two files aa..oo and bb..oo, and that they in turn depend on their corresponding source files (aa..cc and bb..cc) and a common file iinnccll..hh: pgm: a.o b.o cc a.o b.o -o pgm a.o: incl.h a.c cc -c a.c b.o: incl.h b.c cc -c b.c Command lines are executed one at a time, each by its own shell. The SSHHEELLLL environment variable can be used to specify which shell mmaakkee should use to execute commands. The default is //uussrr//bbiinn//sshh. The first one or two characters in a command can be the following: `@@', `--', `@@--', or `--@@'. If `@@' is present, printing of the command is suppressed. If `--' is present, mmaakkee ignores an error. A line is printed when it is executed unless the --ss option is present, or the entry ..SSIILLEENNTT:: is included in _m_a_k_e_f_i_l_e, or unless the initial character sequence contains a @@. The --nn option specifies printing without execution; however, if the command line has the string $$((MMAAKKEE)) in it, the line is always executed (see the discussion of the MMAAKKEEFFLLAAGGSS macro in the mmaakkee EEnnvviirroonnmmeenntt sub-section below). The --tt (touch) option updates the modified date of a file without executing any commands. Commands returning non-zero status normally terminate mmaakkee. If the --ii option is present, if the entry ..IIGGNNOORREE:: is included in _m_a_k_e_f_i_l_e, or if the initial character sequence of the command contains `--', the error is ignored. If the --kk option is present, work is abandoned on the current entry, but continues on other branches that do not depend on that entry. Interrupt and quit cause the target to be deleted unless the target is a dependent of the directive ..PPRREECCIIOOUUSS. mmaakkee EEnnvviirroonnmmeenntt The environment is read by mmaakkee. All variables are assumed to be macro definitions and are processed as such. The environment variables are processed before any makefile and after the internal rules; thus, macro assignments in a makefile override environment variables. The --ee option causes the environment to override the macro assignments in a makefile. Suffixes and their associated rules in the makefile will override any identical suffixes in the built-in rules. The MMAAKKEEFFLLAAGGSS environment variable is processed by mmaakkee as containing any legal input option (except --ff and --pp) defined for the command line. Further, upon invocation, mmaakkee "invents" the variable if it is not in the environment, puts the current options into it, and passes it on to invocations of commands. Thus, MMAAKKEEFFLLAAGGSS always contains the current input options. This feature proves very useful for "super-makes". In fact, as noted above, when the --nn option is used, the command $$((MMAAKKEE)) is executed anyway; hence, one can perform a mmaakkee --nn recursively on a whole software system to see what would have been executed. This result is possible because the --nn is put in MMAAKKEEFFLLAAGGSS and passed to further invocations of $$((MMAAKKEE)). This usage is one way of debugging all of the makefiles for a software project without actually doing anything. IInncclluuddee FFiilleess If the string _i_n_c_l_u_d_e appears as the first seven letters of a line in a _m_a_k_e_f_i_l_e, and is followed by a blank or a tab, the rest of the line is assumed to be a filename and will be read by the current invocation, after substituting for any macros. MMaaccrrooss Entries of the form _s_t_r_i_n_g_1 == _s_t_r_i_n_g_2 are macro definitions. _s_t_r_i_n_g_2 is defined as all characters up to a comment character or an unescaped NEWLINE. Subsequent appearances of $$(_s_t_r_i_n_g_1[::_s_u_b_s_t_1==[_s_u_b_s_t_2]]) are replaced by _s_t_r_i_n_g_2. The parentheses are optional if a single-character macro name is used and there is no substitute sequence. The optional :_s_u_b_s_t_1=_s_u_b_s_t_2 is a substitute sequence. If it is specified, all non- overlapping occurrences of _s_u_b_s_t_1 in the named macro are replaced by _s_u_b_s_t_2. Strings (for the purposes of this type of substitution) are delimited by BLANKs, TABs, NEWLINE characters, and beginnings of lines. An example of the use of the substitute sequence is shown in the LLiibbrraarriieess sub-section below. IInntteerrnnaall MMaaccrrooss There are five internally maintained macros that are useful for writing rules for building targets. $$** The macro $$** stands for the filename part of the current dependent with the suffix deleted. It is evaluated only for inference rules. $$@@ The $$@@ macro stands for the full target name of the current target. It is evaluated only for explicitly named dependencies. $$<< The $$<< macro is only evaluated for inference rules or the ..DDEEFFAAUULLTT rule. It is the module that is outdated with respect to the target (the "manufactured" dependent file name). Thus, in the ..cc..oo rule, the $$<< macro would evaluate to the ..cc file. An example for making optimized ..oo files from ..cc files is: .c.o: cc c O $*.c or: .c.o: cc c O $< $$?? The $$?? macro is evaluated when explicit rules from the makefile are evaluated. It is the list of prerequisites that are outdated with respect to the target, and essentially those modules that must be rebuilt. $$%% The $$%% macro is only evaluated when the target is an archive library member of the form lliibb((ffiillee..oo)). In this case, $$@@ evaluates to lliibb and $$%% evaluates to the library member, ffiillee..oo. Four of the five macros can have alternative forms. When an upper case DD or FF is appended to any of the four macros, the meaning is changed to "directory part" for DD and "file part" for FF. Thus, $$((@@DD)) refers to the directory part of the string $$@@. If there is no directory part, ..// is generated. The only macro excluded from this alternative form is $$??. SSuuffffiixxeess Certain names (for instance, those ending with ..oo) have inferable prerequisites such as ..cc, ..ss, etc. If no update commands for such a file appear in _m_a_k_e_f_i_l_e, and if an inferable prerequisite exists, that prerequisite is compiled to make the target. In this case, mmaakkee has inference rules that allow building files from other files by examining the suffixes and determining an appropriate inference rule to use. The current default inference rules are: .c .c~ .f .f~ .s .s~ .sh .sh~ .C .C~ .c.a .c.o .c~.a .c~.c .c~.o .f.a .f.o .f~.a .f~.f .f~.o .h~.h .l.c .l.o .l~.c .l~.l .l~.o .s.a .s.o .s~.a .s~.o .s~.s .sh~.sh .y.c .y.o .y~.c .y~.o .y~.y .C.a .C.o .C~.a .C~.C .C~.o .L.C .L.o .L~.C .L~.L .L~.o .Y.C .Y.o .Y~.C .Y~.o .Y~.Y The internal rules for mmaakkee are contained in the source file mmaakkee..rruulleess for the mmaakkee program. These rules can be locally modified. To print out the rules compiled into the mmaakkee on any machine in a form suitable for re-compilation, the following command is used: make -pf -2>/dev/null < /dev/null A tilde in the above rules refers to an SCCS file (see ssccccssffiillee(4)). Thus, the rule ..cc~~..oo would transform an SCCS C source file into an object file (..oo). Because the ss.. of the SCCS files is a prefix, it is incompatible with the mmaakkee suffix point of view. Hence, the tilde is a way of changing any file reference into an SCCS file reference. A rule with only one suffix (for example, ..cc::) is the definition of how to build _x from _x..cc. In effect, the other suffix is null. This feature is useful for building targets from only one source file, for example, shell procedures and simple C programs. Additional suffixes are given as the dependency list for ..SSUUFFFFIIXXEESS. Order is significant: the first possible name for which both a file and a rule exist is inferred as a prerequisite. The default list is: ..SSUUFFFFIIXXEESS:: ..oo ..cc ..cc~~ ..yy ..yy~~ ..ll ..ll~~ ..ss ..ss~~ ..sshh ..sshh~~ ..hh ..hh~~ ..ff ..ff~~ ..CC ..CC~~ ..YY ..YY~~ ..LL ..LL~~ Here again, the above command for printing the internal rules will display the list of suffixes implemented on the current machine. Multiple suffix lists accumulate; ..SSUUFFFFIIXXEESS:: with no dependencies clears the list of suffixes. IInnffeerreennccee RRuulleess The first example can be done more briefly. pgm: a.o b.o cc a.o b.o o pgm a.o b.o: incl.h This abbreviation is possible because mmaakkee has a set of internal rules for building files. The user may add rules to this list by simply putting them in the _m_a_k_e_f_i_l_e. Certain macros are used by the default inference rules to permit the inclusion of optional matter in any resulting commands. Again, the previous method for examining the current rules is recommended. The inference of prerequisites can be controlled. The rule to create a file with suffix ..oo from a file with suffix ..cc is specified as an entry with ..cc..oo:: as the target and no dependents. Shell commands associated with the target define the rule for making a ..oo file from a ..cc file. Any target that has no slashes in it and starts with a dot is identified as a rule and not a true target. LLiibbrraarriieess If a target or dependency name contains parentheses, it is assumed to be an archive library, the string within parentheses referring to a member within the library. Thus, lliibb((ffiillee..oo)) and $$((LLIIBB))((ffiillee..oo)) both refer to an archive library that contains ffiillee..oo. (This example assumes the LLIIBB macro has been previously defined.) The expression $$((LLIIBB))((ffiillee11..oo ffiillee22..oo)) is not legal. Rules pertaining to archive libraries have the form .._X_X..aa where the _X_X is the suffix from which the archive member is to be made. An unfortunate by-product of the current implementation requires the _X_X to be different from the suffix of the archive member. Thus, one cannot have lliibb((ffiillee..oo)) depend upon ffiillee..oo explicitly. The most common use of the archive interface follows. Here, we assume the source files are all C type source: lib: lib(file1.o) lib(file2.o) lib(file3.o) @echo lib is now up-to-date .c.a: $(CC) -c $(CFLAGS) $< $(AR) $(ARFLAGS) $@ $*.o rm -f $*.o In fact, the ..cc..aa rule listed above is built into mmaakkee and is unnecessary in this example. A more interesting, but more limited example of an archive library maintenance construction follows: lib: lib(file1.o) lib(file2.o) lib(file3.o) $(CC) -c $(CFLAGS) $(?:.o=.c) $(AR) $(ARFLAGS) lib $? rm $? @echo lib is now up-to-date .c.a:; Here the substitution mode of the macro expansions is used. The $$?? list is defined to be the set of object filenames (inside lliibb) whose C source files are outdated. The substitution mode translates the ..oo to ..cc. (Unfortunately, one cannot as yet transform to ..cc~~; however, this transformation may become possible in the future.) Also note the disabling of the ..cc..aa:: rule, which would have created each object file, one by one. This particular construct speeds up archive library maintenance considerably. This type of construct becomes very cumbersome if the archive library contains a mix of assembly programs and C programs. EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS UUSSEE__SSVVRR44__MMAAKKEE If this environment variable is set, then the mmaakkee command will invoke this System V version of mmaakkee. If this variable is not set, then the default version of mmaakkee(1S) is invoked. UUSSEE__SSVVRR44__MMAAKKEE can be set as follows (Bourne shell): $$ UUSSEE__SSVVRR44__MMAAKKEE==````'''';; eexxppoorrtt UUSSEE__SSVVRR44__MMAAKKEE or (C shell): %% sseetteennvv UUSSEE__SSVVRR44__MMAAKKEE FFIILLEESS [[MMmm]]aakkeeffiillee ss..[[MMmm]]aakkeeffiillee default makefiles //uussrr//bbiinn//sshh default shell for mmaakkee //uussrr//sshhaarree//lliibb//mmaakkee//mmaakkee..rruulleess default rules for mmaakkee SSEEEE AALLSSOO ccdd(1), mmaakkee(1S), sshh(1), pprriinnttff(3C), ssccccssffiillee(4), aattttrriibbuutteess(5) NNOOTTEESS Some commands return non-zero status inappropriately; use --ii or the `--' command line prefix to overcome the difficulty. Filenames containing the characters ==, ::, and @@ do not work. Commands that are directly executed by the shell, notably ccdd(1), are ineffectual across NNEEWWLLIINNEEss in mmaakkee. The syntax lliibb((ffiillee11..oo ffiillee22..oo ffiillee33..oo)) is illegal. You cannot build lliibb((ffiillee..oo)) from ffiillee..oo. August 24, 2009 SYSV-MAKE(1)