Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > M

mkmf(1)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

mkmf — make a makefile

SYNOPSIS

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

DESCRIPTION

The mkmf command creates a makefile that informs the make command how to construct and maintain programs and libraries (see make(1)). After gathering up all 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

.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

The mkmf command 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:

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.

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.

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 editor (see ex(1) and ctags(1)), for C, Pascal, and Fortran source code files.

update

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) 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.

COMPILESYSTYPE

Location of /usr/include. If the COMPILESYSTYPE macro or environment variable is defined, mkmf searches for included files in /$COMPILESYSTYPE/usr/include instead of /usr/include.

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.

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 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.

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 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 /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 /usr/include dependencies.

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 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, F = Fortran and Ratfor syntax, P = Pascal syntax). The following list shows the default configuration for mkmf:

.c:sC

C

.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, C++, Fortran, and Pascal source code are of the form:

C/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 $ can be omitted if the include statement starts in column 7. In either case the trailing $ can be omitted.

Pascal:

$include ' filename '$ $INCLUDE ' 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/ccs/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

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. Old dependency information is left untouched in the makefile.

-e

Environment variables override macro definitions within makefiles.

-f makefile

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

-i

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, 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.

-l

Force 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/ccs/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 to prevent make from recursively executing itself an infinite number of times.

AUTHOR

mkmf was developed by the University of California, Berkeley.

FILES

/usr/ccs/lib/mf/C.p

Standard program makefile template

/usr/ccs/lib/mf/C.l

Standard 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).

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

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.