


MAKESTYLE(1)              User Commands              MAKESTYLE(1)



NAME
     makestyle - print violations of Makefile guidelines

SYNOPSIS
     makestyle [-vishp] filenames

DESCRIPTION
     makestyle finds violations of a  selected  set  of  Makefile
     guidelines  documented  in  "Makefile  Standards  and Guide-
     lines". It issues messages for three types of checks:

     +o    Violations of guidelines which must be fixed. (Default)

     +o    Violations of guidelines which, when fixed, help create
         coherent makefiles. (-p option)

     +o    Possible violations of guidelines. These type of viola-
         tions  are  difficult to catch in a programmatic way and
         human interpretation is required as the  algorithms  are
         complex to implement. (-h option)

OUTPUT
     The script outputs violations of guidelines,  one  violation
     to a line.  Because of the difference in the types of inputs
     available to the utility during the  first  and  the  second
     pass,  the  utility  prints messages of two different types.
     During the first pass it prints line numbers along with  the
     error  message  but  during  the  second pass it only prints
     warning messages.

OVERVIEW
     The script uses two pass algorithm to analyze the  Makefile.
     The  first  pass  does static analysis of the Makefile.  The
     second pass invokes make with -DD option to  create  a  file
     which  contains  all  the  included  files where some of the
     variables and targets  are  resolved.   This  file  is  then
     parsed  to  detect  redefinitions of macros or suffix rules.
     The design of the utility ensures that no  target  from  the
     makefile  is  actually  built during "make -DD" and hence no
     target dependencies are modified.

     The script will exit with an  error  message  during  second
     pass if the makefile contains errors that prevent successful
     invocation of make.

     The categories of violations of  the  guidelines,  based  on
     their importance and complexity in identifying them program-
     matically, is as follows:


          1. Regular checks
          2. Picky checks



SunOS 5.5           Last change: 7 July 1994                    1






MAKESTYLE(1)              User Commands              MAKESTYLE(1)



          3. Heuristic checks

     These guidelines are further divided  depending  on  whether
     the check is made during the first or the second pass.

  Regular Checks
     This is the default mode of the utility. The list of  checks
     made is as follows.

     First pass checks:

          +o    Keyword, copyright and pathname identifiers should
              be  included,  where  a  pathname identifier is the
              name of the makefile with respect to the path  from
              the base of the source.

          +o    No command should be used without macro reference.
              i.e. make instead of $(MAKE).

          +o    Whenever a cd to another directory  is  done,  pwd
              should follow.

          +o    -I and -D should not be specified in CFLAGS  macro
              but only in CPPFLAGS macro.

          +o    -L should appear only in LDFLAGS macro.

          +o    Install target should have no actions.

          +o    INS.dir and INS.file should  be  used  instead  of
              install command.

          +o    sccs command should not be explicitly used.

          +o    Variables like PRINTER,  ENV  which  are  commonly
              used should not be used in makefile.

          +o    Absolute path should not be used.

          +o    Dynamic macro $< should appear only in the actions
              of  percent  and suffix rules. It should not appear
              in an actions list of a regular target.

          +o    Pattern replacement statements should not be  used
              as targets.

          +o    Operator += should be surrounded  by  white  space
              unlike "=".

          +o    INC macro should not be used as in AT&T makefiles.

          +o    Target .KEEP_STATE  should  be  included  in  each



SunOS 5.5           Last change: 7 July 1994                    2






MAKESTYLE(1)              User Commands              MAKESTYLE(1)



              makefile.

          +o    Target all, when present, should be the first reg-
              ular target.

          +o    A statement should not begin  with  space  charac-
              ters.

          +o    No statement should have more than 80 characters.

     Second pass checks:

          +o    Makefile.lib should be included if  a  library  is
              being built.

  Picky checks
     This mode is invoked by -p option of the utility.   Messages
     of  this  type  would  be issued for violations of following
     guidelines.   When  enabled  it  helps  create  better  than
     acceptable type of makefile.

     First pass checks:

          +o    Makefile should not use wildcards. i.e. rm -rf *.o

  Heuristic checks
     This mode is invoked by -h option  of  the  utility.   These
     checks point out POSSIBLE violations of makefile guidelines.
     The messages have to be analyzed to determine  whether  they
     are indeed violations. The guidelines are as follows.

     First pass checks:

          +o    The install target should have the dependencies in
              terms of ROOT instead of actual path.

          +o    Target all should be included in each makefile.

     Second pass checks:

          +o     Predefined suffix rules should be  used  wherever
               possible.

          +o     Predefined macros should be used wherever  possi-
               ble.

USAGE
     makestyle has following options.

          -v   verbose.

          -i   Check included files for duplicate definitions  of



SunOS 5.5           Last change: 7 July 1994                    3






MAKESTYLE(1)              User Commands              MAKESTYLE(1)



               macros and suffix rules.

          -s   Skip second pass.

          -h   Perform heuristic checks that are sometimes wrong.

          -p   Perform some of the more picky checks.

     The typical invocation of the script would be as follows:

          example% makestyle path/of/Makefile

     To catch maximum number of violations, heuristic checks  and
     picky  checks  should  be  made. The usage in that situation
     would be:

          example% makestyle -h -p  path/of/Makefile

  Clean Up
     makestyle cleans up all the intermediate files it creates in
     /tmp. When errors in the makefile result in failure of make,
     the output of the most recent failed run is left in /tmp for
     possible future analysis.

DOCUMENTS
     "Makefile Standards and Guidelines"
               /shared/ON/general_docs/make_std.txt

EXIT CODES
     0         makestyle could run successfully.

     1         makestyle failed due  to  an  erroneous  input  or
               error condition encountered while running make.






















SunOS 5.5           Last change: 7 July 1994                    4



