

make                         Command                         make




Program building discipline

mmaakkee [_o_p_t_i_o_n ...] [_a_r_g_u_m_e_n_t ...] [_t_a_r_g_e_t ...]

mmaakkee helps you build programs  that consist of more than one file
of source code.

Complex programs often consist of several _o_b_j_e_c_t _m_o_d_u_l_e_s, each of
which is  the product of  compiling a _s_o_u_r_c_e _f_i_l_e.  A source file
may  refer  to one  or  more  iinncclluuddee files,  which  can also  be
changed.   Some  programs may  be  generated from  specifications
given  to  program  generators,  such  as yyaacccc.  Recompiling  and
relinking complicated programs can be difficult and tedious.

mmaakkee   regenerates   programs   automatically.   It   follows   a
specification of the structure of the program that you write into
a file  called mmaakkeeffiillee. mmaakkee also checks the  date and time that
COHERENT has recorded  for each source file and its corresponding
object  module;  to avoid  unnecessary  recompilation, mmaakkee  will
recompile a  source file  only if it  has been altered  since its
object module was last compiled.

***** The Makefile *****

A  mmaakkeeffiillee  consists  of  three  types  of  instructions:  _m_a_c_r_o
_d_e_f_i_n_i_t_i_o_n_s, _d_e_p_e_n_d_e_n_c_y _d_e_f_i_n_i_t_i_o_n_s, and _c_o_m_m_a_n_d_s.

A macro definition simply  defines a macro for use throughout the
mmaakkeeffiillee; for example, the macro definition


        FILES=file1.o file2.o file3.o


Note the use of the equal sign `='.

A dependency  definition names the  object modules used  to build
the target  program, and source  files used to  build each object
module .  It consists of the  _t_a_r_g_e_t _n_a_m_e, or name of the program
to  be created,  followed by  a colon  `:' and  the names  of the
object modules that build it.  For example, the statement


        example:  $(FILES)


uses the macro FFIILLEESS to name the object modules used to build the
program eexxaammppllee.  Likewise, the dependency definition








COHERENT Lexicon                                           Page 1




make                         Command                         make



        file1.o:  file1.c macros.h


defines  the object  module ffiillee11.oo as  consisting of  the source
file ffiillee11.cc and the header file mmaaccrrooss.hh.

Finally, a command line  details an action that mmaakkee must perform
to build the target program.  Each command line must begin with a
space or tab character.  For example, the command line


                cc -o example $(FILES)


gives the cccc command needed to build the program eexxaammppllee.  The cccc
command  lists the  _o_b_j_e_c_t  _m_o_d_u_l_e_s to  be used,  _n_o_t the  source
files.

Note that  if you prefix an  action with a hyphen  `-', mmaakkee will
ignore errors  in the action.  If the action  is prefixed by `@',
it tells  mmaakkee to be silent  about the action --  that is, do not
echo the command to the standard output.

Finally,  you  can   embed  comments  within  a  mmaakkeeffiillee.   mmaakkee
recognizes any line that begins with  a pound sign `#' as being a
comment, and ignores it.

mmaakkee  searches for  mmaakkeeffiillee first  in  directories named  in the
environmental variable PPAATTHH, and then in the current directory.

***** Dependencies *****

The mmaakkeeffiillee  specifies which files depend  upon other files, and
how to recreate the  dependent files.  For example, if the target
file tteesstt  depends upon the object  module tteesstt.oo, the dependency
is as follows:


        test:   test.o
                cc -o test test.o


mmaakkee knows about  common dependencies, e.g., that .oo files depend
upon  .cc files  with the  same base  name.  The  target .SSUUFFFFIIXXEESS
contains the suffixes that mmaakkee recognizes.

mmaakkee also has a set  of rules to regenerate dependent files.  For
example, for  a source file  with suffix .cc and  a dependent file
with the suffix .oo, the target .cc.oo gives the regeneration rule:








COHERENT Lexicon                                           Page 2




make                         Command                         make



        .c.o:
                cc -c $<


The -cc  option to the cccc  commands tells cccc not  to link or erase
the compiled object module.  $<  is a macro that mmaakkee defines; it
stands for  the name of the file that  causes the current action.
The   default  suffixes   and  rules  are   kept  in   the  files
/uussrr/lliibb/mmaakkeemmaaccrrooss and /uussrr/lliibb/mmaakkeeaaccttiioonnss.

***** Macros *****

To simplify the  writing of complex dependencies, mmaakkee provides a
_m_a_c_r_o facility.  To define a macro, write


        NNAAMMEE = ssttrriinngg


_s_t_r_i_n_g  is terminated  by the  end-of-line  character, so  it can
contain blanks.  To refer to the value of the macro, use a dollar
sign `$'  followed by the macro name enclosed in parentheses:


        $(NNAAMMEE)


If  the  macro   name  is  one  character,  parentheses  are  not
necessary.  mmaakkee uses macros in the definition of default rules:


        .c.o:
                $(CC) $(CFLAGS) -c $<


where the macros are defined as


        CC=cc
        CFLAGS=-V


The other built-in macros are:


          $*   Target name, minus suffix
          $@   Full target name
          $<   List of referred files
          $?   Referred files newer than target


Each command  line _a_r_g_u_m_e_n_t should  be a macro  definition of the
form




COHERENT Lexicon                                           Page 3




make                         Command                         make




     OBJECT=a.o b.o


Arguments  that include  spaces must  be surrounded  by quotation
marks, because blanks are significant to the shell sshh.

You  can  specify  macro  definitions  in  the mmaakkeeffiillee,  in  the
environment, or as a command-line argument.  A macro defined as a
command-line argument  always overrides a definition  of the same
macro name  in the  environment or  in the mmaakkeeffiillee.  Normally, a
definition in a mmaakkeeffiillee overrides a definition of the same macro
name in  the environment; however, with  the -e option (described
below), a definition in the environment overrides a definition in
the mmaakkeeffiillee.

***** Options *****

The following lists the options that can be passed to mmaakkee on its
command line.

-dd   (Debug)   Give  verbose  printout   of  all   decisions  and
     information going into decisions.

-ee   Force macro definitions  in environment to override those in
     the mmaakkeeffiillee.

-ff _f_i_l_e
     _f_i_l_e contains  the mmaakkee specification.  If  this option does
     not  appear, mmaakkee  uses the file  mmaakkeeffiillee, which  is sought
     first  in the  directories named  in the  PPAATTHH environmental
     variable, and then in  the current directory.  If _f_i_l_e is `-
     ',  mmaakkee uses  the standard input;  note, however,  that the
     standard input can be used _o_n_l_y if it is piped.

-ii   Ignore  all errors from  commands, and  continue processing.
     Normally, mmaakkee exits if a command returns an error.

-nn   Test only; suppresses actual execution of commands.

-pp   Print all macro definitions and target descriptions.

-qq   Return a zero exit status if the targets are up to date.  Do
     not execute any commands.

-rr   Do not use the built-in rules that describe dependencies.

-ss   Do not  print command  lines when executing  them.  Commands
     preceded by `@' are not printed, except under the -nn option.

-tt   (Touch option) Force the  dates of targets to be the current
     time, and bypass actual regeneration.





COHERENT Lexicon                                           Page 4




make                         Command                         make



***** Source File Path *****

If a  file is not  specified with an  absolute pathname beginning
with `/', mmaakkee first looks for the file in the current directory.
If the file is not  found in the current directory, mmaakkee searches
for it in the  list of directories specified by macro $(SSRRCCPPAATTHH).
This  allows you  to  compile a  program in  an object  directory
separate from the source directory.  For example


     export SRCPATH=/usr/src/local/me
     make


or alteratively


     make SRCPATH=/usr/src/local/me


builds  objects in  the  current directory  as  specified by  the
mmaakkeeffiillee and  sources in /uussrr/ssrrcc/llooccaall/mmee. To  test changes to a
program built from several  source files, copy only the files you
wish to change to the  current directory; make will use the local
sources and find the other sources on the $(SSRRCCPPAATTHH).

Note that  $(SSRRCCPPAATTHH) can be a single directory,  as in the above
example, or a  `:'-separated list of directories, as described in
the Lexicon entry for the function ppaatthh().

***** Files *****

mmaakkeeffiillee
MMaakkeeffiillee -- List of dependencies and commands
/uussrr/lliibb/mmaakkeeaaccttiioonnss -- Default actions
/uussrr/lliibb/mmaakkeemmaaccrrooss -- Default macros

***** See Also *****

aass, cccc, ccoommmmaannddss, lldd, ssrrccppaatthh, ttoouucchh
_T_h_e _m_a_k_e _P_r_o_g_r_a_m_m_i_n_g _D_i_s_c_i_p_l_i_n_e, tutorial

***** Diagnostics *****

mmaakkee  reports its  exit  status if  it  is interrupted  or if  an
executed command returns  error status.  It replies ``Target _n_a_m_e
not defined''  or ``Don't  know how to  make target _n_a_m_e''  if it
cannot find appropriate rules.

***** Notes *****

The order  of items in mmaakkeemmaaccrrooss/.SSUUFFFFIIXXEESS  is significant.  The
consequent  of  a  default  rule  (e.g.,  .oo)  must  _p_r_e_c_e_d_e  the
antecedent  (e.g., .cc)  in the  entry .SSUUFFFFIIXXEESS.  Otherwise, mmaakkee
will not work properly.


COHERENT Lexicon                                           Page 5




make                         Command                         make




























































COHERENT Lexicon                                           Page 6


