File:  [MW Coherent from dump] / coherent / a / usr / man / MULTI / make
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:34 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent



make                         Command                         make




Program building discipline

mmaakkee [_o_p_t_i_o_n ...] [_a_r_g_u_m_e_n_t ...] [_t_a_r_g_e_t ...]

mmaakkee 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  iinncclluuddee files,  which  can also  be
changed.   Some  programs may  be  generated from  specifications
given  to  program  generators,  such  as yyaacccc.  Recompiling  and
relinking complicated programs can be difficult and tedious.

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

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

A  mmaakkeeffiillee  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
mmaakkeeffiillee; 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 FFIILLEESS to name the object modules used to build the
program eexxaammppllee.  Likewise, the dependency definition








COHERENT Lexicon                                           Page 1




make                         Command                         make



        file1.o:  file1.c macros.h


defines  the object  module ffiillee11.oo as  consisting of  the source
file ffiillee11.cc and the header file mmaaccrrooss.hh.

Finally, a command line  details an action that mmaakkee 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 cccc command needed to build the program eexxaammppllee.  The cccc
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  `-', mmaakkee will
ignore errors  in the action.  If the action  is prefixed by `@',
it tells  mmaakkee to be silent  about the action --  that is, do not
echo the command to the standard output.

Finally,  you  can   embed  comments  within  a  mmaakkeeffiillee.   mmaakkee
recognizes any line that begins with  a pound sign `#' as being a
comment, and ignores it.

mmaakkee  searches for  mmaakkeeffiillee first  in  directories named  in the
environmental variable PPAATTHH, and then in the current directory.

***** Dependencies *****

The mmaakkeeffiillee  specifies which files depend  upon other files, and
how to recreate the  dependent files.  For example, if the target
file tteesstt  depends upon the object  module tteesstt.oo, the dependency
is as follows:


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


mmaakkee knows about  common dependencies, e.g., that .oo files depend
upon  .cc files  with the  same base  name.  The  target .SSUUFFFFIIXXEESS
contains the suffixes that mmaakkee recognizes.

mmaakkee also has a set  of rules to regenerate dependent files.  For
example, for  a source file  with suffix .cc and  a dependent file
with the suffix .oo, the target .cc.oo gives the regeneration rule:








COHERENT Lexicon                                           Page 2




make                         Command                         make



        .c.o:
                cc -c $<


The -cc  option to the cccc  commands tells cccc not  to link or erase
the compiled object module.  $<  is a macro that mmaakkee defines; it
stands for  the name of the file that  causes the current action.
The   default  suffixes   and  rules  are   kept  in   the  files
/uussrr/lliibb/mmaakkeemmaaccrrooss and /uussrr/lliibb/mmaakkeeaaccttiioonnss.

***** Macros *****

To simplify the  writing of complex dependencies, mmaakkee provides a
_m_a_c_r_o facility.  To define a macro, write


        NNAAMMEE = ssttrriinngg


_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:


        $(NNAAMMEE)


If  the  macro   name  is  one  character,  parentheses  are  not
necessary.  mmaakkee 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 sshh.

You  can  specify  macro  definitions  in  the mmaakkeeffiillee,  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 mmaakkeeffiillee.  Normally, a
definition in a mmaakkeeffiillee 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 mmaakkeeffiillee.

***** Options *****

The following lists the options that can be passed to mmaakkee on its
command line.

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

-ee   Force macro definitions  in environment to override those in
     the mmaakkeeffiillee.

-ff _f_i_l_e
     _f_i_l_e contains  the mmaakkee specification.  If  this option does
     not  appear, mmaakkee  uses the file  mmaakkeeffiillee, which  is sought
     first  in the  directories named  in the  PPAATTHH environmental
     variable, and then in  the current directory.  If _f_i_l_e is `-
     ',  mmaakkee uses  the standard input;  note, however,  that the
     standard input can be used _o_n_l_y if it is piped.

-ii   Ignore  all errors from  commands, and  continue processing.
     Normally, mmaakkee exits if a command returns an error.

-nn   Test only; suppresses actual execution of commands.

-pp   Print all macro definitions and target descriptions.

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

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

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

-tt   (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 `/', mmaakkee first looks for the file in the current directory.
If the file is not  found in the current directory, mmaakkee searches
for it in the  list of directories specified by macro $(SSRRCCPPAATTHH).
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
mmaakkeeffiillee and  sources in /uussrr/ssrrcc/llooccaall/mmee. 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 $(SSRRCCPPAATTHH).

Note that  $(SSRRCCPPAATTHH) 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 ppaatthh().

***** Files *****

mmaakkeeffiillee
MMaakkeeffiillee -- List of dependencies and commands
/uussrr/lliibb/mmaakkeeaaccttiioonnss -- Default actions
/uussrr/lliibb/mmaakkeemmaaccrrooss -- Default macros

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

aass, cccc, ccoommmmaannddss, lldd, ssrrccppaatthh, ttoouucchh
_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 *****

mmaakkee  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 mmaakkeemmaaccrrooss/.SSUUFFFFIIXXEESS  is significant.  The
consequent  of  a  default  rule  (e.g.,  .oo)  must  _p_r_e_c_e_d_e  the
antecedent  (e.g., .cc)  in the  entry .SSUUFFFFIIXXEESS.  Otherwise, mmaakkee
will not work properly.


COHERENT Lexicon                                           Page 5




make                         Command                         make




























































COHERENT Lexicon                                           Page 6



unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.