


 MMAAKKEEDDEEPPEENNDD((11))                   XX VVeerrssiioonn 1111                  MMAAKKEEDDEEPPEENNDD((11))
                                  RReelleeaassee 44



 NNAAMMEE
      makedepend - create dependencies in makefiles

 SSYYNNOOPPSSIISS
      mmaakkeeddeeppeenndd [ --DDnnaammee==ddeeff ] [ --DDnnaammee ] [ --IIiinncclluuddeeddiirr ] [ --ffmmaakkeeffiillee ] [
      --oooobbjjssuuffffiixx ] [ --ssssttrriinngg ] [ --wwwwiiddtthh ] [ - - ootthheerrooppttiioonnss - - ]
      sourcefile ...

 DDEESSCCRRIIPPTTIIOONN
      MMaakkeeddeeppeenndd reads each _s_o_u_r_c_e_f_i_l_e in sequence and parses it like a C-
      preprocessor, processing all _#_i_n_c_l_u_d_e_, _#_d_e_f_i_n_e_, _#_u_n_d_e_f_, _#_i_f_d_e_f_,
      _#_i_f_n_d_e_f_, _#_e_n_d_i_f_, _#_i_f and _#_e_l_s_e directives so that it can correctly
      tell which _#_i_n_c_l_u_d_e_, directives would be used in a compilation.  Any
      _#_i_n_c_l_u_d_e_, directives can reference files having other _#_i_n_c_l_u_d_e
      directives, and parsing will occur in these files as well.

      Every file that a _s_o_u_r_c_e_f_i_l_e includes, directly or indirectly, is what
      mmaakkeeddeeppeenndd calls a "dependency".  These dependencies are then written
      to a _m_a_k_e_f_i_l_e in such a way that mmaakkee((11)) will know which object files
      must be recompiled when a dependency has changed.

      By default, mmaakkeeddeeppeenndd places its output in the file named _m_a_k_e_f_i_l_e if
      it exists, otherwise _M_a_k_e_f_i_l_e_.  An alternate makefile may be specified
      with the _-_f option.  It first searches the makefile for the line

          # DO NOT DELETE THIS LINE -- make depend depends on it.

      or one provided with the _-_s option, as a delimiter for the dependency
      output.  If it finds it, it will delete everything following this to
      the end of the makefile and put the output after this line.  If it
      doesn't find it, the program will append the string to the end of the
      makefile and place the output following that.  For each _s_o_u_r_c_e_f_i_l_e
      appearing on the command line, mmaakkeeddeeppeenndd puts lines in the makefile
      of the form

           sourcefile.o: dfile ...

      Where "sourcefile.o" is the name from the command line with its suffix
      replaced with ".o", and "dfile" is a dependency discovered in a
      _#_i_n_c_l_u_d_e directive while parsing _s_o_u_r_c_e_f_i_l_e or one of the files it
      included.

 EEXXAAMMPPLLEE
      Normally, mmaakkeeddeeppeenndd will be used in a makefile target so that typing
      "make depend" will bring the dependencies up to date for the makefile.
      For example,
          SRCS = file1.c file2.c ...
          CFLAGS = -O -DHACK -I../foobar -xyz
          depend:
                  makedepend -- $(CFLAGS) -- $(SRCS)




                                    - 1 -           Formatted:  March 24, 99






 MMAAKKEEDDEEPPEENNDD((11))                   XX VVeerrssiioonn 1111                  MMAAKKEEDDEEPPEENNDD((11))
                                  RReelleeaassee 44



 OOPPTTIIOONNSS
      MMaakkeeddeeppeenndd will ignore any option that it does not understand so that
      you may use the same arguments that you would for cccc((11))..

      --DDnnaammee==ddeeff oorr --DDnnaammee
           Define.  This places a definition for _n_a_m_e in mmaakkeeddeeppeenndd''ss symbol
           table.  Without _=_d_e_f the symbol becomes defined as "1".

      --IIiinncclluuddeeddiirr
           Include directory.  This option tells mmaakkeeddeeppeenndd to prepend
           _i_n_c_l_u_d_e_d_i_r to its list of directories to search when it
           encounters a _#_i_n_c_l_u_d_e directive.  By default, mmaakkeeddeeppeenndd only
           searches /usr/include.

      --ffmmaakkeeffiillee
           Filename.  This allows you to specify an alternate makefile in
           which mmaakkeeddeeppeenndd can place its output.

      --oooobbjjssuuffffiixx
           Object file suffix.  Some systems may have object files whose
           suffix is something other than ".o".  This option allows you to
           specify another suffix, such as ".b" with _-_o_._b or ":obj" with
           _-_o_:_o_b_j and so forth.

      --ssssttrriinngg
           Starting string delimiter.  This option permits you to specify a
           different string for mmaakkeeddeeppeenndd to look for in the makefile.

      --wwwwiiddtthh
           Line width.  Normally, mmaakkeeddeeppeenndd will ensure that every output
           line that it writes will be no wider than 78 characters for the
           sake of readability.  This option enables you to change this
           width.

      -- -- ooppttiioonnss -- --
           If mmaakkeeddeeppeenndd encounters a double hyphen (- -) in the argument
           list, then any unrecognized argument following it will be
           silently ignored; a second double hyphen terminates this special
           treatment.  In this way, mmaakkeeddeeppeenndd can be made to safely ignore
           esoteric compiler arguments that might normally be found in a
           CFLAGS mmaakkee macro (see the EEXXAAMMPPLLEE section above).  All options
           that mmaakkeeddeeppeenndd recognizes and appear between the pair of double
           hyphens are processed normally.

 AALLGGOORRIITTHHMM
      The approach used in this program enables it to run an order of
      magnitude faster than any other "dependency generator" I have ever
      seen.  Central to this performance are two assumptions: that all files
      compiled by a single makefile will be compiled with roughly the same
      _-_I and _-_D options; and that most files in a single directory will
      include largely the same files.



                                    - 2 -           Formatted:  March 24, 99






 MMAAKKEEDDEEPPEENNDD((11))                   XX VVeerrssiioonn 1111                  MMAAKKEEDDEEPPEENNDD((11))
                                  RReelleeaassee 44



      Given these assumptions, mmaakkeeddeeppeenndd expects to be called once for each
      makefile, with all source files that are maintained by the makefile
      appearing on the command line.  It parses each source and include file
      exactly once, maintaining an internal symbol table for each.  Thus,
      the first file on the command line will take an amount of time
      proportional to the amount of time that a normal C preprocessor takes.
      But on subsequent files, if it encounter's an include file that it has
      already parsed, it does not parse it again.

      For example, imagine you are compiling two files, _f_i_l_e_1_._c and _f_i_l_e_2_._c_,
      they each include the header file _h_e_a_d_e_r_._h_, and the file _h_e_a_d_e_r_._h in
      turn includes the files _d_e_f_1_._h and _d_e_f_2_._h_.  When you run the command

          makedepend file1.c file2.c

      mmaakkeeddeeppeenndd will parse _f_i_l_e_1_._c and consequently, _h_e_a_d_e_r_._h and then
      _d_e_f_1_._h and _d_e_f_2_._h_.  It then decides that the dependencies for this
      file are

          file1.o: header.h def1.h def2.h

      But when the program parses _f_i_l_e_2_._c and discovers that it, too,
      includes _h_e_a_d_e_r_._h_, it does not parse the file, but simply adds
      _h_e_a_d_e_r_._h_, _d_e_f_1_._h and _d_e_f_2_._h to the list of dependencies for _f_i_l_e_2_._o_.

 SSEEEE AALLSSOO
      cc(1), make(1)

 BBUUGGSS
      If you do not have the source for cpp, the Berkeley C preprocessor,
      then mmaakkeeddeeppeenndd will be compiled in such a way that all _#_i_f directives
      will evaluate to "true" regardless of their actual value.  This may
      cause the wrong _#_i_n_c_l_u_d_e directives to be evaluated.  MMaakkeeddeeppeenndd
      should simply have its own parser written for _#_i_f expressions.

      Imagine you are parsing two files, say _f_i_l_e_1_._c and _f_i_l_e_2_._c_, each
      includes the file _d_e_f_._h_.  The list of files that _d_e_f_._h includes might
      truly be different when _d_e_f_._h is included by _f_i_l_e_1_._c than when it is
      included by _f_i_l_e_2_._c_.  But once mmaakkeeddeeppeenndd arrives at a list of
      dependencies for a file, it is cast in concrete.

 AAUUTTHHOORR
      Todd Brunhoff, Tektronix, Inc. and MIT Project Athena











                                    - 3 -           Formatted:  March 24, 99



