MKMF(1-BSD) RISC/os Reference Manual MKMF(1-BSD)
NAME
mkmf - makefile editor
SYNOPSIS
mkmf [-acdil] [-f makefile] [-F template] [macroname=value
...]
DESCRIPTION
mkmf creates a makefile that tells the make command how to
construct and maintain programs and libraries. After gath-
ering up all the source code file names in the current work-
ing directory and inserting them into the makefile, mkmf
scans source code files for included files and generates
dependency information which is appended to the makefile.
Source code files are identified by their file name suf-
fixes. mkmf knows about the following suffixes:
.c C
.e Efl
.F Fortran
.f Fortran
.h Include files
.i Pascal include files
.l Lex or Lisp
.o Object files
.p Pascal
.r Ratfor
.s Assembler
.y Yacc
mkmf checks for an existing makefile before creating one. If
no -f option is present, the makefiles `makefile' and
`Makefile' are tried in order.
After the makefile has been created, arbitrary changes can
be made using a regular 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 deals with libraries, the -l option must be
used.
make Requests
Given a makefile created by mkmf, make recognizes the fol-
lowing requests:
all Compile and load a program or library.
clean Remove all unnecessary files.
depend Edit the makefile and regenerate the dependency
Printed 1/15/91 Page 1
MKMF(1-BSD) RISC/os Reference Manual MKMF(1-BSD)
information.
extract Extract all the 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.
install Compile and load the program or library and move
it to its destination directory.
library Compile and load a library.
print Print source code files on standard output.
tags Create a tags file for the ex editor, for C, Pas-
cal, and Fortran source code files.
program Compile and link a program.
update Recompile only if there are source code files that
are newer than the program or library, link and
install the program or library. In the case of an
out-of-date library, all the object files are
extracted from the library before any recompila-
tion takes place.
Several requests may be given simultaneously. For example,
to compile and link a program, move the program to its des-
tination directory, and remove any unnecessary object files:
make program 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 searchs in directories
named in -I compiler options, and then in the
`/usr/include' directory.
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.
FFLAGS Fortran compiler flags. After searching for
included files in the directory currently
Page 2 Printed 1/15/91
MKMF(1-BSD) RISC/os Reference Manual MKMF(1-BSD)
being processed, mkmf searchs in directories
named in -I compiler options, and then in the
`/usr/include' directory.
HDRS List of included files in the current direc-
tory. mkmf automatically updates this macro
definition in the makefile.
LIBRARY Library name. This macro also implies the -l
option.
LIBS List of libraries needed by the link editor
to resolve external references.
MAKEFILE Makefile name.
OBJS List of object files. mkmf automatically
updates this macro definition in the
makefile.
PROGRAM Program name.
SRCS List of source code files. mkmf automati-
cally updates this macro definition in the
makefile.
SUFFIX List of additional file name suffixes for
mkmf to know about.
Both these and any other macro definitions already within
the makefile may be replaced by definitions on the command
line in the form macroname=value. For example, to change
the C compiler flags, the program name, and the destination
directory in the makefile, the user might type the following
line:
mkmf ``CFLAGS=-I../include -O'' PROGRAM=mkmf DEST=/usr/new
Note that macro definitions like CFLAGS with blanks in them
must be enclosed in double quote `"' marks.
File Name Suffixes
mkmf can be instructed to recognize additional file name
suffixes, or ignore ones that it already knows about, by
specifying suffix descriptions in the SUFFIX macro defini-
tion. 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 = exe-
cutable file) and I is an optional character indicating the
include syntax for included files (C = C syntax, F = For-
tran, Efl, and Ratfor syntax, P = Pascal syntax). The fol-
lowing table describes the default configuration for mkmf:
Printed 1/15/91 Page 3
MKMF(1-BSD) RISC/os Reference Manual MKMF(1-BSD)
.c:sC C
.e:sF Efl
.F:sF Fortran
.f:sF Fortran
.h: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
For example, to change the object file suffix to .obj, unde-
fine the Pascal include file suffix, and prevent Fortran
files from being scanned for included files, the SUFFIX
macro definition might look like:
"SUFFIX = .obj:o .i: .f:s"
Include Statement Syntax
The syntax of include statements for C, Fortran, and Pascal
source code are of the form
C: #include "filename"
where # must be the first character in the line.
Fortran:
include 'filename'
INCLUDE 'filename'
where the include statement starts in column 7.
Pascal:
#include "filename"
#INCLUDE "filename"
where # must be the first character in the line.
User-Defined Templates
If mkmf can not find a makefile within the current direc-
tory, it normally uses one of the standard makefile tem-
plates, `p.Makefile' or `l.Makefile', in /usr/new/lib unless
the user has alternative `p.Makefile' or `l.Makefile' tem-
plate files in a directory $PROJECT/lib where $PROJECT is
the absolute pathname of the directory assigned to the PRO-
JECT environment variable.
OPTIONS
-a When searching a directory for source and include
files, also consider files which have names beginning
Page 4 Printed 1/15/91
MKMF(1-BSD) RISC/os Reference Manual MKMF(1-BSD)
with periods. By default, mkmf ignores file names
which have leading "dots," such as those of backup
files created by some editors.
-c Suppress `creating makefile from ...' message.
-d Turn off scanning of source code for `include' files.
Old dependency information is left untouched in the
makefile.
-f makefile
Specify an alternative makefile file name. The default
file name is `Makefile'.
-i Cause mkmf to prompt the user for the name of the pro-
gram or library, and the directory where it is to be
installed. If a carriage return is typed in response to
each of these queries, mkmf will assume that the
default program name is a.out or the default library
name is lib.a, and the destination directory is the
current directory.
-l Force the makefile to be a library makefile.
-F template
Specify an alternative makefile template file name. The
default program makefile template is `p.Makefile' and
the default library makefile template is `l.Makefile'.
mkmf normally looks for template in /usr/new/lib or
$PROJECT/lib. However, template can be specified as an
absolute pathname.
FILES
/usr/new/lib/p.Makefile Standard program makefile tem-
plate.
/usr/new/lib/l.Makefile Standard library makefile tem-
plate.
$PROJECT/lib/p.Makefile User-defined program makefile
template.
$PROJECT/lib/l.Makefile User-defined library makefile
template.
SEE ALSO
ar(1), ctags(1), ex(1), ld(1), ls(1), make(1).
Feldman, S.I., "Make - A Program for Maintaining Computer
Programs"
Walden, K., "Automatic Generation of Make Dependencies",
Software-Practice and Experience, vol. 14, no. 6, pp. 575-
585, June 1984.
Printed 1/15/91 Page 5
MKMF(1-BSD) RISC/os Reference Manual MKMF(1-BSD)
DIAGNOSTICS
Exit status 0 is normal. Exit status 1 indicates an error.
AUTHOR
Peter J. Nicklin
BUGS
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 pathnames
within the LIBS macro definition 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 information be inserted in the
makefile below this line.
Page 6 Printed 1/15/91