MKMF(1) — HP-UX
NAME
mkmf − make a makefile
SYNOPSIS
mkmf [ −acdil ] [ −f makefile ] [ −F template ] [ −M language ] [ macroname=value ... ]
DESCRIPTION
Mkmf creates a makefile that informs the make(1) command how to construct and maintain programs and libraries. After gathering up all the source code file names in the current working directory and inserting them into the makefile, mkmf 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 suffixes. Mkmf recognizes the following suffixes:
.c C
.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, 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, the −l option must be used.
Make Requests
Given a makefile created by mkmf, make recognizes the following requests:
allCompile and load a program or library.
cleanRemove all object and core files.
clobberRemove all files that can be regenerated.
dependUpdate included file dependencies in a makefile.
echoList the names of the source code files on standard output.
extractExtract all the object files from the library and place them in the same directory as the source code files. The library is not altered.
indexPrint an index of functions on standard output.
installCompile and load the program or library and move it to its destination directory.
printPrint source code files on standard output.
tagsCreate a tags file for the ex(1) editor, for C, Pascal, and Fortran source code files.
updateRecompile only if there are source code files that are newer than the program or library, link and install the program or library.
Several requests may be given simultaneously. For example, to compile and link a program, move the program to its destination directory, and remove any unnecessary object files:
make install clean
Macro Definitions
Mkmf understands the following macro definitions:
CFLAGSC 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.
DESTDirectory where the program or library is to be installed.
EXTHDRSList of included files external to the current directory. Mkmf automatically updates this macro definition in the makefile if dependency information is being generated.
FFLAGSFortran 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.
HDRSList of included files in the current directory. Mkmf automatically updates this macro definition in the makefile.
INSTALLInstallation program name.
LDLink editor name.
LDFLAGSLink editor flags.
LIBRARYLibrary name. This macro also implies the −l option.
LIBSList of libraries needed by the link editor to resolve external references.
MAKEFILEMakefile name.
OBJSList of object files. Mkmf automatically updates this macro definition in the makefile.
PROGRAMProgram name.
SRCSList of source code files. Mkmf automatically updates this macro definition in the makefile.
SUFFIXList 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 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.
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, F = Fortran, and Ratfor syntax, P = Pascal syntax). The following table describes the default configuration for mkmf:
.c:sC C
.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, 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, Fortran, and Pascal source code are of the form:
C:#include "filename"
#include <filename>
where # must be the first character in the line.
Fortran:
$include ’filename’$
$INCLUDE ’filename’$
where $ must be the first character in the line. Alternatively, the $ may be omitted if the include statement starts in column 7. In either case the trailing $ can be omitted.
Pascal:
$include ’filename’$
$search ’filename’$
$INCLUDE ’filename’$
$SEARCH ’filename’$
where $ must be the first character in the line and the trailing $ is optional.
User-Defined Templates
If mkmf cannot find a makefile within the current directory, it normally uses one of the standard makefile templates, ‘C.p’ or ‘C.l’, in /usr/lib/mf unless the user has alternative ‘C.p’ or ‘C.l’ template files in a directory $PROJECT/lib/mf where $PROJECT is the absolute path name of the directory assigned to the PROJECT environment variable.
Options
−aInclude source files beginning with a . in the makefile.
−cSuppress ‘creating makefile from ...’ message.
−dTurn 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.
−iPrompt 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, mkmf assumes that the default program name is a.out or the default library name is lib.a, and the destination directory is the current directory.
−lForce the makefile to be a library makefile.
−F template
Specify an alternative makefile template path name. The path name can be relative or absolute.
−M language
Specify an alternative language-specific makefile template. The default language is C and the corresponding program and library makefile templates are ‘C.p’ and ‘C.l’, respectively. Mkmf looks for these templates in /usr/lib/mf or $PROJECT/lib/mf.
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 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.
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 update. Otherwise, make(1) recursively executes itself an infinite number of times.
FILES
/usr/lib/mf/C.pStandard program makefile template
/usr/lib/mf/C.lStandard library makefile template
$PROJECT/lib/mf/C.p User-defined program makefile template
$PROJECT/lib/mf/C.l User-defined library makefile template
SEE ALSO
ar(1), ctags(1), ld(1), make(1). "Make: A Program for Maintaining Computer Programs", HP-UX Concepts and Tutorials, Feldman, S.I., vol. 2 (Program Development and Maintenance). "Automatic Generation of Make Dependencies", Software−Practice and Experience, Walden, K., vol. 14, no. 6, pp. 575-585, June 1984.
AUTHOR
Mkmf was developed by the University of California, Berkeley.
Hewlett-Packard Company — May 11, 2021