MAKETD(1)                                                            MAKETD(1)



NAME
       maketd - edit a makefile to update transitive dependencies

SYNOPSIS
       maketd [-4Cabcdflnrvx] [-D define] [-e rule] [-L lib.a] [-I includedir]
       [-U undefine] [-j extender] [-m makefile] [-o dir] [-s suffix] [-t tar-
       get] [files]
       maketd -h
       maketd -V


DESCRIPTION
       Maketd  computes  dependencies  for targets that are introduced through
       the C preprocessor's (cpp) #include directive.  The development of this
       program  resulted  from  make(1)'s  inability  to  recognize transitive
       dependencies.  For example, given the following makefile fragment:
              xx.o: xx.c e.h

              e.h: struct.h /usr/include/local/const.h
       Since make will not recognize the target xx.o's dependency on struct.h.

       Maketd generates lines like:
              xx.o: xx.c e.h struct.h $L/const.h
       Thus  making  the  target  xx.o not only dependent on all files that it
       includes, but also recursively on all files  that  the  included  files
       include.   This is achieved by passing the source through the C prepro-
       cessor (via either cc -M or cc -E).

       The directories used in the search for include files are  identical  to
       the  ones  used  by  the C compiler because the C preprocessor is used.
       This also means that #define's, #ifdef's, etc., are evaluated.   It  is
       necessary  to  recompute  the  dependencies  when  any  source has been
       changed.  The generated dependencies will be inserted after a  line  of
       the  form  "# DO NOT DELETE..." (which will be inserted if maketd finds
       the end of file).  Everything after this line may be deleted or changed
       as  maketd  edits the makefile (the portion of the makefile before this
       line is only examined for context).  If no such line exists, a line  of
       the expected form will be emitted, followed by the dependencies.

       By default maketd will search for the makefile to be edited in the same
       way make does; that is by first checking for the  existence  of  "make-
       file",  then  "Makefile".   The -m and -d options override this default
       action (below).  Before it is edited, makefile will be saved in  "make-
       file.extend"  (overwriting any existing file with the same name).  This
       extender on the old version of makefile may be changed by using the  -j
       option (below).

OPTIONS
       Options  and  arguments may be intermixed on the command line to modify
       maketd's behavior on a per file basis.

       -4
              Use m4(1) as the preprocessor rather than cc(1).  This  requires
              that modifications have been made to m4 and that this program be
              compiled with CPP_M defined.  Use "maketd -h" to check this.

       -a
              Normally,  dependencies  on  files  in  "/usr/include"  are  not
              included.   This  option  also  includes  dependencies  on those
              files.  This option should always be used for system level make-
              files.

       -b
              Generate  dependencies  for  binaries  rather than object files.
              This is equivalent to specifying a null  suffix:   the  ".o"  is
              stripped from the target.

       -c
              Use  cc  to generate dependencies (rather than m4).  This is the
              default.

       -d
              Dependencies are written to standard output instead of editing a
              makefile.  The standard header and trailer, "# DO NOT DELETE..."
              are not printed.

       -e rule
              The given rule is output under  each  of  the  following  file's
              dependency  lists.   For  printf-like  percent  (%)  escapes are
              expanded to allow the user to customize the rule.  (This options
              has  been  in  maketd  for many releases, but has not been docu-
              mented.)

              +-------+----------------------------------+
              |markup | expands to                       |
              +-------+----------------------------------+
              |  %    | a literal percent                |
              +-------+----------------------------------+
              |  F    | the source file name             |
              +-------+----------------------------------+
              |  I    | the cpp flags for this file      |
              +-------+----------------------------------+
              |  O    | the source dir                   |
              +-------+----------------------------------+
              |  S    | the source suffix                |
              +-------+----------------------------------+
              |  L    | the library containing this file |
              +-------+----------------------------------+
              |  T    | the source basename              |
              +-------+----------------------------------+
              |  f    | the full target file             |
              +-------+----------------------------------+
              |  o    | the target dir (set by -o)       |
              +-------+----------------------------------+
              |  s    | the target suffix (set by -s)    |
              +-------+----------------------------------+
              |  t    | the target base name (set by -t) |
              +-------+----------------------------------+
       This is most useful for creation of sendmail(8) recipe files.

       -f
              Force printing of header and trailer.  Normally these  are  sup-
              pressed when the output file is the standard output.

       -h
              Only output a usage summary.

       -j extender
              Specify  an  extension  for the backup makefile, rather than the
              default "bak" extender.

       -l
              Turn off the nonlocal object option, and make all targets local.

       -m makefile
              Instead of editing "makefile", makefile is edited.

       -n
              Generate  nonlocal  object  dependency  paths.  These paths will
              match the source paths given.

       -o dir
              Generate nonlocal object  dependencies  in  the  specified  dir.
              This option generates dependencies of the form
                     dir/a.o: a.c
              which is useful for makefiles that produce the objects in a sep-
              arate subdirectory.  The name of the directory must not be empty
              (see -l above).

       -r
              Replace the dependencies for the target(s) mentioned on the com-
              mand line.  Do not alter any other dependencies  that  may  have
              been  in  makefile.  This option is of limited use and unlimited
              misuse: beware.

       -s suffix
              Supply a suffix for the target.  The suffix should start with  a
              ".".   The  target  file  name should have a suffix of some sort
              that is delimited by a "." that is replaced by this suffix.

       -t target
              Supply a new basename for the target rather than using the base-
              name of the source file.

       -v
              Be  verbose.   Extra  output  is  directed to the standard error
              channel.

       -V
              Show which version of maketd is running.

       -x
              Do not shorten include files.  The pathnames "/usr/include"  and
              "/usr/include/sys"  along  with any pathnames specified with the
              -I options, are abbreviated.  Unused  uppercase  single  letters
              are defined in makefile and used to compress pathnames.

       -C
              Cancel  all  previous cpp flags (-D, -I, and -U) and begin a new
              list.  This is useful for generating dependencies for more  than
              one product with only one maketd call.

       -D define
              Specify a cpp (C preprocessor) definition.  See cc(1) for a com-
              plete description.

       -E
              Cancel an explicit rule given by -e.

       -I includedir
              Specify a directory for cpp to search for  include  files.   See
              cc(1)  for a complete description.  Note that includedir is sub-
              ject to abbreviation unless -x is given.

       -L lib.a
              This option produces a dependency that tells  make(1)  that  the
              target is part of lib.a.

       -U name
              Remove  any  initial definition of the (C preprocessor) variable
              name.


EXAMPLES
       A typical application in a makefile might look like:
              L=/usr/include/local
              INCLUDE=  -I$L -I../h
              CDEFS= -DPUCC -DBSD4_2
              CFLAGS= ${DEFS} ${INCLUDE}

              SRC=   a.c b.c c.c
              HDR=   a.h b.h c.h

              . . .
              depend: ${SRC} ${HDR}
                     maketd -a ${CDEFS} ${INCLUDE} ${SRC}

              # DO NOT DELETE THIS LINE - maketd DEPENDS ON IT

              a.o: a.c a.h b.h c.h $L/goop.h

              b.o: b.c b.h $L/goop.h

              c.o: c.c c.h

              # *** Do not add anything here - It will go away. ***


BUGS
       If a single letter macro name is used but never defined (in  the  make-
       file), maketd might still use it for an abbreviation name.  This should
       not effect the makefile as all the dependencies and the redefinition of
       the  macro  will  follow  the  users last usage of it.  This happens in
       DYNIX makefiles that use "P"  to  indicate  that  parallel  compilation
       should be used.  We suggest that Makefiles which use this trick put a
              P=
       in  the  Makefile  (above the all target) to keep maketd from using the
       macro "P"; the command line definition of P="&" will override the Make-
       file's definition.

       Some more path compression could be done.

AUTHORS
       Stephan Bechtolsheim (a shell script), Purdue CS
       Stephen Uitti (a C version), Purdue CC
       Craig Norborg (m4 modifications), Purdue CC
       KS Braunsdorf (intermix options), NPCGuild.org

SEE ALSO
       make(1), cc(1), m4(1), cpp(1), msync(8l), level2s(8l), printf(3)



                                     LOCAL                           MAKETD(1)

NAME | SYNOPSIS | DESCRIPTION | OPTIONS | EXAMPLES | BUGS | AUTHORS | SEE ALSO