


     [7mMAKE(1)[m                                                   [7mMAKE(1)[m



     [7mNAME[m
          make - maintain, update, and regenerate groups of programs

     [7mSYNOPSIS[m
          [7mmake[m [[7m-f[m makefile] [[7m-p[m] [[7m-i[m] [[7m-k[m] [[7m-s[m] [[7m-r[m] [[7m-n[m]  [[7m-b[m]  [[7m-e[m]
          [[7m-t[m] [[7m-d[m] [[7m-q[m] [names]

     [7mHP-UX[m [7mCOMPATIBILITY[m
          Level:    HP-UX/STANDARD

          Origin:   System III

     [7mDESCRIPTION[m
          The following is a brief description of all options and some
          special names.  Options may occur in any order.

          [7m-f[m [4mmakefile[m  Description file name.  [4mMakefile[m is assumed  to  *
                       be the name of a description file.  A file name
                       of [7m-[m denotes the standard input.  The  contents
                       of [4mmakefile[m override the built-in rules if they
                       are present.  Note that the  space  between  [7m-f[m
                       and [4mmakefile[m [7mmust[m be present.

          [7m-p[m           Print out the complete set of macro definitions
                       and target descriptions.

          [7m-i[m           Ignore  error   codes   returned   by   invoked
                       commands.   This  mode  is  also entered if the
                       fake  target  name  [7m.IGNORE[m  appears   in   the
                       description file.

          [7m-k[m           When a command returns nonzero status,  abandon
                       work  on  the  current  entry,  but continue on
                       other branches  that  do  not  depend  on  that
                       entry.

          [7m-s[m           Silent mode.  Do not print command lines before
                       executing.   This  mode  is also entered if the
                       fake  target  name  [7m.SILENT[m  appears   in   the
                       description file.

          [7m-r[m           Do not use the built-in rules.

          [7m-n[m           No execute mode.  Print commands,  but  do  not
                       execute  them.   Even lines beginning with an [7m@[m
                       are printed.

          [7m-b[m           Compatibility  mode   for   old   (Version   7)
                       makefiles.

          [7m-e[m           Environment  variables   override   assignments
                       within makefiles.



     Hewlett-Packard               - 1 -             (printed 3/19/86)






     [7mMAKE(1)[m                                                   [7mMAKE(1)[m



          [7m-t[m           Touch the target files (causing them to be  up-
                       to-date) rather than issue the usual commands.

          [7m-d[m           Debug mode.  Print out detailed information  on
                       files  and  times  examined.  (This is intended
                       for debugging the [4mmake[m command itself.)

          [7m-q[m           Question.  The [4mmake[m command returns a  zero  or
                       non-zero  status  code depending on whether the
                       target file is or is not up-to-date.

          The "built-in" dependency targets are:

          [7m.DEFAULT[m
               If a file must  be  made  but  there  are  no  explicit
               commands  or  relevant  built-in  rules,  the  commands
               associated with  the  name  [7m.DEFAULT[m  are  used  if  it
               exists.

          [7m.PRECIOUS[m
               Dependents of this target will not be removed when quit
               or interrupt are hit.

          [7m.SILENT[m
               Same effect as the [7m-s[m option.

          [7m.IGNORE[m
               Same effect as the [7m-i[m option.

          [4mMake[m executes commands in [4mmakefile[m to  update  one  or  more
          target [4mnames[m.  [4mName[m is typically a program.  If no [7m-f[m option  *
          is present, [7mmakefile[m, [7mMakefile[m, [7ms.makefile[m,  and  [7ms.Makefile[m
          are tried in order.  If [4mmakefile[m is [7m-[m, the standard input is
          taken.  More than one [7m-f[m [4mmakefile[m argument pair may appear.

          [4mMake[m updates a target only if it depends on files  that  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 out of date.

          [4mMakefile[m  contains  a  sequence  of  entries  that   specify
          dependencies.   The  first  line  of  an  entry  is a blank-
          separated, non-null list of targets,  followed  by  a  colon
          ([7m:[m),  followed  by  a  (possibly  null) list of prerequisite
          files or dependencies.  Text following a [7m;[m and all following
          lines  that  begin  with  a  tab  are  shell  commands to be
          executed to update the target.  The first line that does not
          begin  with  a  tab  or  [7m#[m  begins a new dependency or macro
          definition.  Shell commands may be  continued  across  lines
          with the <backslash><new-line> sequence.  Everything printed
          by make (except the initial tab) is passed directly  to  the
          shell as is.  Thus,



     Hewlett-Packard               - 2 -             (printed 3/19/86)






     [7mMAKE(1)[m                                                   [7mMAKE(1)[m



               echo a\
               b

          will produce

               ab

          exactly the same as the shell would.

          Sharp ([7m#[m) and new-line surround comments.

          The following [4mmakefile[m says that [7mpgm[m depends  on  two  files
          [7ma.o[m  and  [7mb.o[m,  and  that  they  in  turn  depend  on  their
          corresponding source files ([7ma.c[m and [7mb.c[m) and a  common  file
          [7mincl.h[m:

               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 first one or two characters in a command can be
          the following: [7m-[m, [7m@[m, [7m-@[m, or [7m@-[m.  If [7m@[m is  present,  printing
          of the command is suppressed.  If [7m-[m is present, [4mmake[m ignores
          an error.  A line is printed when it is executed unless  the
          [7m-s[m  option is present, or the entry [7m.SILENT:[m is in [4mmakefile[m,
          or unless the initial character sequence contains a [7m@[m.   The
          [7m-n[m  option specifies printing without execution; however, if
          the command line has the string [7m$(MAKE)[m in it, the  line  is
          always executed (see discussion of the [7mMAKEFLAGS[m macro under
          [4mEnvironment[m).  Note that this feature does not work if  [7mMAKE[m
          is enclosed in braces, as in [7m${MAKE}[m.  The [7m-t[m (touch) option
          updates the modified date of a file  without  executing  any
          commands.

          Commands returning non-zero status normally terminate  [4mmake[m.
          If  the  [7m-i[m option is present, or the entry [7m.IGNORE:[m appears
          in [4mmakefile[m,  or  the  initial  character  sequence  of  the
          command contains [7m-[m.  the error is ignored.  If the [7m-k[m option
          is present, work is abandoned  on  the  current  entry,  but
          continues  on  other  branches  that  do  not depend on that
          entry.

          The [7m-b[m option allows old makefiles (those  written  for  the
          old  version of [4mmake[m) to run without errors.  The difference
          between the old version of [4mmake[m and  this  version  is  that
          this  version  requires  all  dependency  lines  to  have  a
          (possibly null or implicit) command  associated  with  them.
          The  previous  version  of  [4mmake[m  assumed, if no command was



     Hewlett-Packard               - 3 -             (printed 3/19/86)






     [7mMAKE(1)[m                                                   [7mMAKE(1)[m



          specified explicitly, that the command was null.

          Interrupt and quit cause the target to be deleted unless the
          target depends on the special name [7m.PRECIOUS[m.

        [7mEnvironment[m
          The environment is read by [4mmake[m.  All variables are  assumed
          to   be  macro  definitions  and  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  [7m-e[m  option
          causes  the environment to override the macro assignments in
          a makefile.

          The [7mMAKEFLAGS[m environment variable is processed by  [4mmake[m  as
          containing  any  legal  input option (except [7m-f[m, [7m-p[m, and [7m-d[m)
          defined for the command  line.   Further,  upon  invocation,
          [4mmake[m   ``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,  [7mMAKEFLAGS[m always
          contains the current input options.  This proves very useful
          for  ``super-makes''.   In fact, as noted above, when the [7m-n[m
          option is used, the  command  [7m$(MAKE)[m  is  executed  anyway;
          hence,  one  can  perform  a  [7mmake[m [7m-n[m recursively on a whole
          software system to see what would have been executed.   This
          is  because the [7m-n[m is put in [7mMAKEFLAGS[m and passed to further
          invocations of [7m$(MAKE)[m.  This is one way of debugging all of
          the  makefiles for a software project without actually doing
          anything.

        [7mMacros[m
          Entries of the form [4mstring1[m [7m=[m [4mstring2[m are macro definitions.
          [4mString2[m  is  defined  as  all  characters  up  to  a comment
          character or an unescaped new-line.  Subsequent  appearances
          of  $([4mstring1[m[:[4msubst1[m=  [[4msubst2[m]])  are replaced by [4mstring2[m.
          The parentheses are optional if  a  single  character  macro
          name  is  used  and  there  is  no substitute sequence.  The
          optional :[4msubst1[m=[4msubst2[m is a substitute sequence.  If it  is
          specified,  all non-overlapping occurrences of [4msubst1[m in the
          named macro  are  replaced  by  [4msubst2[m.   Strings  (for  the
          purposes  of  this  type  of  substitution) are delimited by
          blanks, tabs, new-line characters, and beginnings of  lines.
          An  example  of  the use of the substitute sequence is shown
          under [4mLibraries[m.

        [7mInternal[m [7mMacros[m
          There are five internally maintained macros which are useful
          for writing rules for building targets.

          [7m$*[m   The macro [7m$*[m stands for  the  file  name  part  of  the
               current  dependent  with  the  suffix  deleted.   It is
               evaluated only for inference rules.



     Hewlett-Packard               - 4 -             (printed 3/19/86)






     [7mMAKE(1)[m                                                   [7mMAKE(1)[m



          [7m$@[m   The [7m$@[m macro stands for the full  target  name  of  the
               current  target.   It  is evaluated only for explicitly
               named dependencies.

          [7m$<[m   The [7m$<[m macro is only evaluated for inference  rules  or
               the  [7m.DEFAULT[m  rule.  It is the module which is out-of-
               date  with   respect   to   the   target   (i.e.,   the
               ``manufactured''  dependent  file  name).  Thus, in the
               [7m.c.o[m rule, the [7m$<[m macro would evaluate to the [7m.c[m  file.
               An  example for making optimized [7m.o[m files from [7m.c[m files
               is:

                    .c.o:
                         cc -c -O $*.c

               or:

                    .c.o:
                         cc -c -O $<

          [7m$?[m   The [7m$?[m macro is evaluated when explicit rules from  the
               makefile   are   evaluated.    It   is   the   list  of
               prerequisites that are out of date with respect to  the
               target;   essentially,  those  modules  which  must  be
               rebuilt.

          [7m$%[m   The [7m$%[m macro is only evaluated when the  target  is  an
               archive  library  member  of  the form [7mlib(file.o)[m.  In
               this case, [7m$@[m evaluates to [7mlib[m and [7m$%[m evaluates to  the
               library member, [7mfile.o[m.

























     Hewlett-Packard               - 5 -             (printed 3/19/86)






     [7mMAKE(1)[m                                                   [7mMAKE(1)[m



               Four of the five macros  can  have  alternative  forms.
               When  an  upper  case  [7mD[m or [7mF[m is appended to any of the
               four macros, the  meaning  is  changed  to  ``directory
               part''  for  [7mD[m  and  ``file  part'' for [7mF[m.  Thus, [7m$(@D)[m
               refers to the directory part  of  the  string  [7m$@[m.   If
               there  is no directory part, [7m./[m is generated.  The only
               macro excluded from this alternative form is  [7m$?[m.   The
               reasons for this are debatable.

        [7mSuffixes[m
          Certain names (for instance,  those  ending  with  [7m.o[m)  have
          inferable  prerequisites  such as [7m.c[m, [7m.s[m, etc.  If no update
          commands for such a file  appear  in  [4mmakefile[m,  and  if  an
          inferable prerequisite exists, that prerequisite is compiled
          to make the target.  In this case, [4mmake[m has inference  rules
          which 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~ .sh .sh~ .c.o .c~.o .c~.c .s.o .s~.o .y.o  .y~.o
               .l.o .l~.o
               .y.c .y~.c .l.c .c.a .c~.a .s~.a .h~.h

          To print out the rules compiled into the [4mmake[m on any machine
          in  a form suitable for recompilation, the following command
          is used:

               make -fp - 2>/dev/null </dev/null

          The only peculiarity in this output  is  the  ([7mnull[m)  string
          which [4mprintf[m(3S) prints when handed a null string.

          A tilde in the above rules  refers  to  an  SCCS  file  (see
          [4msccsfile[m(5)).   Thus, the rule [7m.c~.o[m would transform an SCCS
          C source file into an object file ([7m.o[m).  Because the  [7ms.[m  of
          the  SCCS  files is a prefix, it is incompatible with [4mmake[m's
          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 (i.e., [7m.c:[m) is the definition of
          how  to  build  [4mx[m  from [4mx[m[7m.c[m.  In effect, the other suffix is
          null.  This is useful for building  targets  from  only  one
          source file (e.g., shell procedures, simple C programs).

          Additional suffixes are given as  the  dependency  list  for
          [7m.SUFFIXES[m.   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:

               [7m.SUFFIXES[m: .o .c .y .l .s



     Hewlett-Packard               - 6 -             (printed 3/19/86)






     [7mMAKE(1)[m                                                   [7mMAKE(1)[m



          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;
          [7m.SUFFIXES:[m with no dependencies clears the list of suffixes.

        [7mInference[m [7mRules[m
          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 is because  [4mmake[m  has  a  set  of  internal  rules  for
          building  files.   The  user  may  add rules to this list by
          simply putting them in the [4mmakefile[m.

          Certain macros are used by the default  inference  rules  to
          permit  the  inclusion  of  optional matter in any resulting
          commands.  For example, [7mCFLAGS[m, [7mLFLAGS[m, and [7mYFLAGS[m are  used
          for   compiler   options  to  [4mcc[m(1),  [4mlex[m(1),  and  [4myacc[m(1),
          respectively.  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 [7m.o[m from a file with suffix [7m.c[m
          is specified as an entry with [7m.c.o:[m as  the  target  and  no
          dependents.   Shell  commands  associated  with  the  target
          define the rule for making a [7m.o[m file from a  [7m.c[m  file.   Any
          target  that  has  no slashes in it and starts with a dot is
          identified as a rule and not a true target.

        [7mLibraries[m
          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
          [7mlib(file.o)[m  and  [7m$(LIB)(file.o)[m  both  refer  to an archive
          library which contains [7mfile.o[m. (This assumes the  [7mLIB[m  macro
          has been previously defined.)  The expression [7m$(LIB)(file1.o[m
          [7mfile2.o)[m  is  not  legal.   Rules  pertaining   to   archive
          libraries  have  the  form  [7m.[m[4mXX[m[7m.a[m where the [4mXX[m is the suffix
          from which the archive member is to be made.  An unfortunate
          byproduct  of  the current implementation requires the [4mXX[m to
          be different from the suffix of the archive  member.   Thus,
          one  cannot  have [7mlib(file.o)[m depend upon [7mfile.o[m 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 rv $@ $*.o



     Hewlett-Packard               - 7 -             (printed 3/19/86)






     [7mMAKE(1)[m                                                   [7mMAKE(1)[m



                    rm -f $*.o

          In fact, the [7m.c.a[m rule listed above is built into  [4mmake[m  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 rv lib $?
                    rm $?  @echo lib is now up-to-date
               .c.a:;

          Here the substitution mode of the macro expansions is  used.
          The  [7m$?[m   list is defined to be the set of object file names
          (inside [7mlib[m) whose C  source  files  are  out-of-date.   The
          substitution  mode translates the [7m.o[m to [7m.c[m.  (Unfortunately,
          one cannot as yet transform to [7m.c~[m; however, this may become
          possible  in  the  future.)  Note also, the disabling of the
          [7m.c.a:[m 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.

     [7mFILES[m
          [Mm]akefile and s[7m.[m[Mm]akefile

     [7mSEE[m [7mALSO[m
          cc(1), cd(1), lex(1), sh(1), yacc(1).

     [7mWARNING[m
          Be wary of any file (such as an include file) whose  access,
          modification, and last change times cannot be altered by the
          [4mmake[m-ing process.  For example, if a program depends  on  an
          include  file which in turn depends on another include file,
          and if one or both of these files are out-of-date, [4mmake[m will
          try  to  update  these  files  each  time  it  is  run, thus
          unnecessarily re-[4mmake[ming up-to-date files dependent  on  the
          include  file.   The  solution  is  to manually update these
          files with the [4mtouch[m(1) command before running [4mmake[m.   (Note
          that  it  is  generally  a  bad idea to include the [4mtouch[m(1)
          command in your makefile,  because  it  can  cause  [4mmake[m  to
          update a program that otherwise did not need to be updated.)

     [7mBUGS[m
          Some commands return non-zero status inappropriately; use [7m-i[m
          to overcome the difficulty.

          File names with the characters [7m=[m [7m:[m [7m@[m will not work.

          Commands that are directly executed by  the  shell,  notably



     Hewlett-Packard               - 8 -             (printed 3/19/86)






     [7mMAKE(1)[m                                                   [7mMAKE(1)[m



          [4mcd[m(1), are ineffectual across new-lines in [4mmake[m.

          The syntax [7mlib(file1.o[m [7mfile2.o[m [7mfile3.o)[m is illegal.

          You cannot build [7mlib(file.o)[m from [7mfile.o[m.

          The macro [7m$(a:.o=.c~)[m does not work.

          There  is  a  limit  of  2500  characters,   including   the
          terminating new-line, for expanded dependency lines.

          [4mMake[m will not properly expand a macro within  another  macro
          when string substitution is involved.










































     Hewlett-Packard               - 9 -             (printed 3/19/86)
