mkmf



NAME

      mkmf - make a makefile


SYNOPSIS

      mkmf [-acdelLSu] [-f makefile] [-F template] [-M language]
      [macroname=value ...]


DESCRIPTION

      SDE's mkmf creates a makefile that informs the make(1) command how to
      construct and maintain programs and libraries.  SDE's mkmf gathers up
      all source code file names (including header file names) in the
      current working directory and inserts them into the makefile.  SDE's
      mkmf also figures out the filenames of object files that will need to
      be generated, and inserts them too.

      SDE's mkmf does not generate dependency information but leaves that to
      be done by make (which may use cpp -M for this purpose, see SDE's make
      rule files).

      SDE's mkmf is a script which uses /usr/softbench/lib/mkmf to update
      filenames in the makefile, but removes the dependencies generated by
      /usr/softbench/lib/mkmf

      mkmf identifies source code files by their file name suffixes.  mkmf
      recognizes the following suffixes:


           .c        C
           .C        C++
           .cc       C++
           .cxx      C++
           .cpp      C++
           .f        Fortran
           .F        Fortran
           .h        Include files
           .H        Include files
           .hxx      Include files
           .hpp
           .i        Pascal include files
           .l        Lex or Lisp
           .o        Object files
           .p        Pascal
           .r        Ratfor
           .s        Assembler
           .y        Yacc
           .cbl      COBOL
           .cob      COBOL
           .CBL      COBOL
           .GEN      COBOL
           .CHK      COBOL
           .cpy      COBOL COPY files
           .CPY      COBOL COPY files


      mkmf checks for an existing makefile before creating one.  If no -f
      option is present, mkmf tries the makefiles Makefile and makefile,
      respectively.

      After the makefile has been created, arbitrary changes can be made
      using a text editor.  mkmf can also be used to re-edit the macro
      definitions in the makefile, regardless of changes that may have been
      made since it was created.

      By default, mkmf creates a program makefile.  To create a makefile
      that handles libraries, either the -l or -L options must be used.

    Make Requests
      Given a makefile created by mkmf, make recognizes the following
      requests:

           all         Compile and load a program or library.

           clean       Remove all object and core files.

           clobber     Remove all files that can be regenerated.

           depend      Update included file dependencies in a makefile.
                       For COBOL files this updates the COPY File
                       dependencies.

           echo        List the names of the source code files on standard
                       output.

           extract     Extract all object files from the library and place
                       them in the same directory as the source code files.
                       The library is not altered.

           index       Print an index of functions on standard output, for
                       C, Pascal, and Fortran source code files.

           install     Compile and load the program or library and move it
                       to its destination directory.

           print       Print source code files on standard output.

           tags        Create a tags file for the ex(1) editor, for C,
                       Pascal, and Fortran source code files.

      Several requests can be given simultaneously.  For example, to (1)
      compile and link a program, (2) move the program to its destination
      directory, and (3) remove any unnecessary object files, use:

           make install clean

    Macro Definitions
      mkmf understands the following macro definitions:

      CFLAGS         C compiler flags.  After searching for included files
                     in the directory currently being processed, mkmf
                     searches in directories named in -I compiler options
                     and then in the /usr/include directory.

      CXXFLAGS       C++ compiler flags.  After searching for included files
                     in the directory currently being processed, mkmf
                     searches in directories named in -I compiler options
                     and then in the /usr/include/CC directory, followed by
                     the /usr/include directory.

      C++FLAGS       Alternative C++ compiler flags.

      CCFLAGS        Alternative C++ compiler flags.

      DEST           Directory where the program or library is to be
                     installed.

      EXTHDRS        List of included files external to the current
                     directory.  mkmf automatically updates this macro
                     definition in the makefile if dependency information is
                     being generated. If EXTHDRS is omitted from the
                     makefile, mkmf does not generate external included file
                     dependencies.

      FFLAGS         Fortran compiler flags.  After searching for included
                     files in the directory currently being processed, mkmf
                     searches in directories named in -I compiler options,
                     then in the /usr/include directory.

      HDRS           List of included files in the current directory.  mkmf
                     automatically updates this macro definition in the
                     makefile.

      INSTALL        Installation program name.

      LD             Link editor name.

      LDFLAGS        Link editor flags. Before searching for libraries in
                     the /lib and /usr/lib directories, mkmf searches for
                     libraries in directories named by -L link editor
                     options.

      LDOPTS         A default set of link editor options.  mkmf searches
                     for libraries in directories named by -L link editor
                     options defined in LDOPTS before examining the LDFLAGS
                     macro.

      LD_OPTIONS     Similar to the LDOPTS variable. If both variables
                     exist, mkmf uses LDOPTS instead of LD_OPTIONS.

      LD_LIBRARY_PATH
                     After mkmf has searched for libraries in directories
                     defined by LDOPTS, LD_OPTIONS, and LDFLAGS, it searches
                     in a list of colon-separated directories defined by the
                     LD_LIBRARY_PATH environment variable.

      LIBRARY        Library name.  This macro also implies the -l option.

      LIBS           List of libraries needed by the link editor to resolve
                     external references.  Since executable files depend on
                     libraries, mkmf expands each library -lx option to
                     /lib/libx.a or /usr/lib/libx.a.

      LPATH          Environment variable containing a colon-separated list
                     of directories for the link editor to search instead of
                     the default /lib and /usr/lib library directories.

      MAKEFILE       Makefile name.

      MKMFFLAGS      mkmf options that can be set within a makefile.  mkmf
                     recognizes -a, -d, -e, -S, and -u.  MKMFFLAGS can only
                     be set within a makefile or on the command-line. A
                     MKMFFLAGS environment variable has no effect.

      MKMFSTDINCDIRS_C
                     Standard list of directories separated by colons or
                     spaces in which to search for included C files instead
                     of the default /usr/include directory.

      MKMFSTDINCDIRS_CXX
                     Standard list of directories separated by colons or
                     spaces in which to search for included C++ files
                     instead of the default /usr/include/CC and /usr/include
                     directories.

      MKMFSTDINCDIRS_FOR
                     Standard list of directories separated by colons or
                     spaces in which to search for included Fortran files
                     instead of the default /usr/include directory.

      MKMFSTDINCDIRS_PAS
                     Standard list of directories separated by colons or
                     spaces in which to search for included Pascal files
                     instead of the default /usr/include directory.


      MKMFSTDLIBDIRS Standard list of directories separated by colons or
                     spaces in which to search for libraries instead of the
                     default /lib and /usr/lib directories. The LPATH
                     variable overrides MKMFSTDLIBDIRS.

      OBJS           List of object files.  mkmf automatically updates this
                     macro definition in the makefile.

      PFLAGS         Pascal compiler flags.  After searching for included
                     files in the directory currently being processed, mkmf
                     searches in directories named in -I compiler options,
                     then in the /usr/include directory.

      PROGRAM        Program name.

      SRCS           List of source code files.  mkmf automatically updates
                     this macro definition in the makefile.

      SUFFIX         List of additional file name suffixes for mkmf to know
                     about.

      SYSHDRS        List of included files found in the include directory
                     hierarchy defined by the MKMFSTDINCDIRS macros, or the
                     /usr/include directory hierarchy.  mkmf automatically
                     updates this macro definition in the makefile if
                     dependency information is being generated.  If SYSHDRS
                     is omitted from the makefile, mkmf does not generate
                     dependencies on files in the MKMFSTDINCDIRS or
                     /usr/include directories.

      VPATH          List of source code directories separated by colons or
                     spaces.  mkmf will search for files in the current
                     directory, and then in each of the directories defined
                     by VPATH.

      Both these and any other macro definitions already within the makefile
      can be replaced by definitions on the command line in the form
      macroname=value.  For example, to change the C compiler flags and the
      program name, type the following line:

            mkmf  "CFLAGS=-I../include  -O"  PROGRAM=mkmf

      Note that macro definitions such as CFLAGS with blanks in them must be
      enclosed in double quote (") marks.

    Environment
      The environment is read by mkmf.  All variables are assumed to be
      macro definitions with the exception of MKMFFLAGS, HDRS, EXTHDRS,
      SRCS, and OBJS.  Environment variables are processed after command
      line macro definitions and the macro definitions in a makefile.  The
      -e option forces the environment to override the macro definitions in
      a makefile.

    File Name Suffixes
      mkmf can recognize additional file name suffixes or ignore ones that
      it already recognizes by specifying suffix descriptions in the SUFFIX
      macro definition.  Each suffix description takes the form .suffix:tI
      where t is a character indicating the contents of the file (s = source
      file, o = object file, h = header file, x = executable file) and I is
      an optional character indicating the include syntax for header files
      (C = C syntax, C++ = C syntax plus the addition of /usr/include/CC as
      a standard search directory, COB = COBOL "COPY file" syntax, F =
      Fortran and Ratfor syntax, P = Pascal syntax).  The following list
      shows the default configuration for mkmf:


           .c:sC     C
           .C:sC++   C++
           .cc:sC++  C++
           .cxx:sC++ C++
           .cpp:sC++ C++
           .f:sF     Fortran
           .h:h      Include files
           .H:h      Include files
           .hxx:h    Include files
           .hpp:h    Include files
           .i:h      Pascal include files
           .l:sC     Lex or Lisp
           .o:o      Object files
           .p:sP     Pascal
           .r:sF     Ratfor
           .s:s      Assembler
           .y:sC     Yacc
           .cbl:sCOB COBOL
           .cob:sCOB COBOL
           .CBL:sCOB COBOL
           .GEN:sCOB COBOL
           .CHK:sCOB COBOL
           .cpy:h    COBOL COPY files
           .CPY:h    COBOL COPY files


      For example, to change the object file suffix to .obj, undefine the
      Pascal include file suffix, and prevent Fortran files from being
      scanned for included files, the SUFFIX macro definition could be:

           SUFFIX = .obj:o  .i:  .f:s

    Include Statement Syntax
      The syntax of include statements for C, C++, Fortran, and Pascal
      source code are of the form:

      C/C++:
           #include "filename"
           #include <filename>
           where # must be the first non-white space character in the line.

      Fortran:
           #include "filename"
           #include <filename>
           $include 'filename'$
           $INCLUDE 'filename'$
           where $ must be the first non-white space character in the line.
           Alternatively, the $ can be omitted if the include statement
           starts in column 7.  In either case the trailing $ can be
           omitted.

      Pascal:
           #include "filename"
           #include <filename>
           $include 'filename'$
           $INCLUDE 'filename'$
           where $ must be the first non-white space character in the line
           and the trailing $ is optional.

    COPY file Statement Syntax
      The COPY file statement in COBOL has many forms.  To insure that the
      proper expansion has been done on COPY file statement file names a
      query is made of the ".idy", debug information, file instead of
      parsing the COBOL source file directly.  This means that COPY file
      dependencies will only be completed for a COBOL source file after it
      has been compiled debuggable.


    User-Defined Templates
      If mkmf cannot find a makefile within the current directory, it
      normally uses one of SDE's standard makefile templates, C++.p, or
      C++.l, in $SDE_HOME/buildt.
      SoftBench provides a set of templates in /usr/softbench/lib/buildt
      Searching for templates in $PROJECT/lib/mkmf is considered obsolete
      and is not supported.

    Options
      mkmf recognizes the following options:

      -a             Include source files beginning with a .  in the
                     makefile.

      -c             Suppress `creating makefile from ...' message.

      -d             Turn off scanning of source code for include files and
                     checking COBOL ".idy" files for "COPY file"
                     dependencies.  Old dependency information is left
                     untouched in the makefile.

      -e             Environment variables override macro definitions within
                     makefiles.

      -fmakefile     Specify an alternative makefile file name.  The default
                     file name is Makefile.

      -l             Force the makefile to be a library makefile.

      -L             Force the makefile to be a library makefile containing
                     object file names defined as library members.  This is
                     currently not fully supported by SDE; SDE provides no
                     separate template for this but uses the ordinary
                     library makefile template for this purpose.

      -Ftemplate     Specify an alternative makefile template path name.
                     The path name can be relative or absolute.

      -Mlanguage     Specify an alternative language-specific makefile
                     template.  If this option is used, the default language
                     is C and the corresponding program and library makefile
                     templates are C.p, and C.l or C.L, respectively.  mkmf
                     then looks for these templates in
                     /usr/softbench/lib/buildt or $PROJECT/lib/mkmf.

      -S             Symbolically link source code files found in
                     directories listed in the VPATH macro into the current
                     directory. Additionally, if the -S option is repeated,
                     remove any symbolic links to files in directories not
                     listed in the VPATH macro.  This option is retained for
                     backward compatibility, but the use of it in an SDE
                     environment has not been investigated.

      -u             Avoid updating the HDRS and SRCS macros unless they are
                     specified as command-line arguments.  This option makes
                     SDE's mkmf rather useless but is retained for backward
                     compatibility.


DIAGNOSTICS

      The exit status code of mkmf is a masked set of bits.

      Exit status 0 is normal (successful completion).

      Exit status with mask bit 1 set indicates an error (creating/modifying
      the makefile failed).

      Exit status with mask bit 2 set indicates that some included files
      could not be found in some C, C++, Fortran, or Pascal source file (the
      rest of the makefile is complete).

      Exit status with mask bit 4 set indicates that "COPY file" analysis
      could not be accomplished on a COBOL source file (the rest of the
      makefile is complete).

      Exit status with mask bit 8 set indicates that COBOL SoftBench post-
      processing of the makefile failed to update the special macros defined
      for the use with SoftBench (the rest of the makefile is complete).



WARNINGS

      The name of the makefile is included as a macro definition within the
      makefile and must be changed if the makefile is renamed.

      The name of a program or library must not conflict with any predefined
      target names in a makefile.

      SDE's mkmf does not generate any dependencies but expects make to do
      this.


AUTHOR

      mkmf was developed by Version Technology.
      Modifications for SDE have been done by ISY/LKM.


DEPENDENCIES

      Custom makefile template files are shipped with SDE, in the directory
      $SDE_HOME/buildt.  If you use SoftBench Program Builder with SDE's
      default X resources, it will by default use SDE's makefile templates.
      If you run mkmf from a terminal window (shell) and do not use the -F
      or -M option, SDE's makefile templates will also be used.



FILES

      /usr/softbench/lib/mkmf    The 'mkmf' program used by SDE's mkmf.
      $SDE_HOME/buildt           Default directory where SDE's template
                                 files are located.
      $SDE_HOME/buildt/*.p, $SDE_HOME/buildt/*.l
                                 Makefile templates. Filename without suffix
                                 indicates programming language.
      $SDE_HOME/buildt/rules.*.mkf, $SDE_HOME/buildt/oracle.mkf
                                 Make rule files, to be copied to systems
                                 and included in makefiles.
      /usr/softbench/lib/buildt  Default directory where SoftBench template
                                 files are located.
      $PROJECT/lib/mkmf          Alternate directory where user-defined
                                 templates are expected.
      /usr/softbench/lib/buildt/C.p
                                 Standard SoftBench program template
      /usr/softbench/lib/buildt/C.l
                                 Standard SoftBench library template
      /usr/softbench/lib/buildt/COBOL.p
                                 Standard SoftBench COBOL program template

      /usr/softbench/lib/buildt/COBOL.l
                                 Standard SoftBench COBOL library template
      $PROJECT/lib/mkmf/C.p      User-defined program template
      $PROJECT/lib/mkmf/C.l      User-defined library template


SEE ALSO

      ar(1), ctags(1), ld(1), make(1), softbuild(1).

      "Make - A Program for Maintaining Computer Programs",
      Software-Practice and Experience, Feldman, S.I., vol. 9, no. 4, pp.
      255-265, April 1979.

      "Automatic Generation of Make Dependencies", Software-Practice and
      Experience, Walden, K., vol. 14, no. 6, pp. 575-585, June 1984.