mkmf(1)mkmf(1)NAMEmkmf - make a makefile
SYNOPSIS
makefile] template] language] [macroname=value ...]
DESCRIPTION
The command creates a makefile that informs the command how to con‐
struct and maintain programs and libraries (see make(1)). After gath‐
ering up all source code file names in the current working directory
and inserting them into the makefile, scans source code files for
included files and generates dependency information that is appended to
the makefile. Source code files are identified by their file name suf‐
fixes. recognizes the following suffixes:
C
C++
FORTRAN
Include files
Pascal include files
Lex or Lisp
Object files
Pascal
Ratfor
Assembler
Yacc
The command checks for an existing makefile before creating one. If no
option is present, tries the makefiles and respectively.
After the makefile has been created, arbitrary changes can be made
using a text editor. 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, creates a program makefile. To create a makefile that han‐
dles libraries, the option must be used.
Make Requests
Given a makefile created by recognizes the following requests:
Compile and load a program or library.
Remove all object and core files.
Remove all files that can be regenerated.
Update included file dependencies in a makefile.
List the names of the source code files on standard output.
Extract all object files from the library
and place them in the same directory as the source
code files. The library is not altered.
Print an index of functions on standard output.
Compile and load the program or library
and move it to its destination directory.
Print source code files on standard output.
Create a tags file for the
editor (see ex(1) and ctags(1)), for C, Pascal, and
Fortran source code files.
Recompile only if there are source code files
that are newer than the program or library, link and
install the program or library.
Several requests can be given simultaneously. For example, to (1) com‐
pile and link a program, (2) move the program to its destination direc‐
tory, and (3) remove any unnecessary object files, use:
Macro Definitions
understands the following macro definitions:
C compiler flags.
After searching for included files in the direc‐
tory currently being processed, searches in
directories named in compiler options and then in
the directory.
Location of If the macro or environment variable is defined,
searches for included files in instead of
C++ compiler flags.
After searching for included files in the direc‐
tory currently being processed, searches in
directories named in compiler options and then in
the directory, followed by the directory.
Directory where the program or library is to be installed.
List of included files external to the current directory.
automatically updates this macro definition in
the makefile if dependency information is being
generated.
Fortran compiler flags.
After searching for included files in the direc‐
tory currently being processed, searches in
directories named in compiler options, then in
the directory.
List of included files in the current directory.
automatically updates this macro definition in
the makefile.
Installation program name.
Link editor name.
Link editor flags.
Library name. This macro also implies the option.
List of libraries needed by the link editor
to resolve external references.
Makefile name.
List of object files.
automatically updates this macro definition in
the makefile.
Program name.
List of source code files.
automatically updates this macro definition in
the makefile.
List of additional file name suffixes for
to know about.
List of included files found in the
directory hierarchy. automatically updates this
macro definition in the makefile if dependency
information is being generated. If is omitted
from the makefile, does not generate dependen‐
cies.
Both these and any other macro definitions already within the makefile
can be replaced by definitions on the command line in the form For
example, to change the C compiler flags and the program name, type the
following line:
Note that macro definitions such as with blanks in them must be
enclosed in double quote (") marks.
Environment
The environment is read by All variables are assumed to be macro defi‐
nitions with the exception of and Environment variables are processed
after command line macro definitions and the macro definitions in a
makefile. The option forces the environment to override the macro def‐
initions in a makefile.
File Name Suffixes
can recognize additional file name suffixes, or ignore ones that it
already recognizes, by specifying suffix descriptions in the macro def‐
inition. Each suffix description takes the form where t is a character
indicating the contents of the file = source file, = object file, =
header file, = executable file) and I is an optional character indicat‐
ing the include syntax for header files = C syntax, = C syntax plus the
addition of as a standard search directory, = Fortran and Ratfor syn‐
tax, = Pascal syntax). The following list shows the default configura‐
tion for
C
C++
Fortran
Include files
Pascal include files
Lex or Lisp
Object files
Pascal
Ratfor
Assembler
Yacc
For example, to change the object file suffix to undefine the Pascal
include file suffix, and prevent Fortran files from being scanned for
included files, the macro definition could be:
Include Statement Syntax
The syntax of include statements for C, C++, Fortran, and Pascal source
code are of the form:
C/C++:
where must be the first character in the line.
Fortran:
where must be the first 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:
where must be the first character in the line and
the trailing is optional.
User-defined Templates
If cannot find a makefile within the current directory, it normally
uses one of the standard makefile templates, or in unless the user has
alternative or template files in a directory where is the absolute path
name of the directory assigned to the environment variable.
Options
recognizes the following options:
Include source files beginning with a
in the makefile.
Suppress `` makefile message.
Turn off scanning of source code for
files. Old dependency information is left
untouched in the makefile.
Environment variables override macro definitions within
makefiles.
Specify an alternative
makefile file name. The default file name is
Prompt the user for the name of the program or library
and the directory where it is to be installed.
If a carriage-return is typed in response to each
of these queries, assumes that the default pro‐
gram name is or the default library name is and
the destination directory is the current direc‐
tory.
Force the makefile to be a library makefile.
Specify an alternative makefile template path name.
The path name can be relative or absolute.
Specify an alternative
language-specific makefile template. The default
language is C and the corresponding program and
library makefile templates are and respectively.
looks for these templates in or
DIAGNOSTICS
Exit status 0 is normal. Exit status 1 indicates an error.
WARNINGS
The name of the makefile is included as a macro definition within the
makefile and must be changed if the makefile is renamed.
Since executable files are dependent on libraries, standard library
abbreviations must be expanded to full path names within the macro def‐
inition in the makefile.
Generated dependency information appears after a line in the makefile
beginning with This line must not be removed, nor must any other infor‐
mation be inserted in the makefile below this line.
The name of a program or library must not conflict with any predefined
target names in a makefile. It is especially important to avoid the
the name to prevent from recursively executing itself an infinite num‐
ber of times.
AUTHOR
was developed by the University of California, Berkeley.
FILES
Standard program makefile template
Standard library makefile template
User-defined program makefile template
User-defined library makefile template
SEE ALSOar(1), ctags(1), ld(1), make(1).
"Automatic Generation of Make Dependencies", Walden, K., vol. 14, no.
6, pp. 575-585, June 1984.
mkmf(1)