Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


MakeDepend

Tool

SYNTAX

MakeDepend sourceFile… [explicitDependency…] [name=[value]]
[-append filename] [-d name[=value]] [-i dirname] [-ia dirname]
[-ic dirname] [-ignore[dir] dirname] [-ip dirname] [-ir dirname]
[-mf | -nomf] [-objdir dirname] [-objext extension] [-p]
[-quote on | off] [-skip[dir] dirname] [-skipfile filename[,filename]…]
[-w]

DESCRIPTION

From a list of source files, MakeDepend generates makefile dependencies for the "include" files. The generated dependencies can be appended to a specified makefile or written to standard output. If macros are defined on the command line, MakeDepend will attempt to convert directory pathnames into macros when emitting the generated dependencies. Example 2 shows how macros are used in generated dependencies. Example 3 shows how to define macros using Make variables when MakeDepend is used within a makefile. MakeDepend predefines the following macros by getting their definitions from the MPW Shell: AIncludes, CIncludes, PInterfaces and RIncludes.

For each source file, MakeDepend uses the filename suffix to establish its programming language. The recognized filename extensions are defined in the 'xMap' (128) resource within the MakeDepend tool. You can edit this resource if you wish to change the recognized filename extensions. The format of the 'xMap' resource is shown below.

/* filename extensions -> languages */
type 'xMap'
{
  byte = $$CountOf(ExtensionArray);
  array ExtensionArray
  {
    byte AsmExtension = 1, 
         CExtension = 2, 
         CPlusExtension = 3, 
         PascalExtension = 4, 
         RezExtension = 5;
    cstring;
  };
};

The 'xMap' resource currently defines the following source file extensions:

Language

Extensions

Assembly
C
C++
Pascal
Rez

.a
.c
.cp
.p
.r

.asm
 
.cpp
.pas
.rez

.s
 
.cc
 
 

 
 
.cxx
 
 

INPUT

One or more source files.

OUTPUT

MakeDepend writes the generated dependencies to standard output. The dependencies can be appended to a specified makefile by using the -append option.

STATUS

MakeDepend can return the following status codes:

0

no errors

1

fatal error

PARAMETERS

sourceFile

Specifies the names of the source files used to generate the dependencies. This list should include all of the source files needed to build the target, but none of the files derived from them. Specifically, no included files should be listed, and none of the object files produced by the assemblers, compilers, or Rez should be listed.

explicitDependency

These are dependencies that will not be automatically generated by MakeDepend as a result of parsing the source files. MakeDepend understands the various types of "include" statements used by Asm, C/C++, Pascal, and Rez; thus files included by other source files should not be given as explicit dependencies. An example of an explicit dependency is:

:LibFiles:CommonLib.o ƒ :SrcFiles:CommonRoutines.c

OPTIONS

name=[value]

Defines a macro for use in the generated dependencies. If the value is not specified, the macro is set to NULL. There must be no space on either side of the equal sign. If the value is to contain whitespace, the entire argument should be quoted.

-append filename

Appends the generated dependencies to the specified makefile. The default is to write the generated dependencies to standard output. If MakeDepend has previously appended dependencies to the specified makefile, the previous dependencies will be deleted before the new dependencies are appended. In order to find the previous dependencies, MakeDepend searches the makefile for the following line.

#*** Dependencies: Cut here ***

If this line is found, everything after it is deleted. MakeDepend requires that its generated dependencies be at the end of the makefile.

-d name[=value]

Defines a macro for use in the generated dependencies. If the value is not specified, the macro is set to NULL. There must be no space on either side of the equal sign. If the value is to contain whitespace, the entire argument should be quoted.

-i dirname

Adds the directory dirname to the list of directories to be searched for Asm, C/C++, Pascal, and Rez "include" files. Multiple -i options can be specified. This option is equivalent to specifying -ia dirname -ic dirname -ip dirname -ir dirname.

-ia dirname

Adds the directory dirname to the list of directories to be searched for Assembler INCLUDE and LOAD files. Multiple -ia options can be specified. The default is to search the source file's directory and {AIncludes}.

-ic dirname

Adds the directory dirname to the list of directories to be searched for C/C++ #include files. Multiple -ic options can be specified. The default is to search the source file's directory and {CIncludes} for "user" includes and to only search {CIncludes} for "system" includes.

-ignore[dir] dirname

Included files found in the directory dirname will be parsed but will not be listed in the generated dependencies. Multiple -ignoredir options can be specified. This option is generally used to ignore the system includes (e.g. -ignore {CIncludes}).

-ip dirname

Adds the directory dirname to the list of directories to be searched for Pascal USES, {$U…} and {$I…} files. Multiple -ip options can be specified. The default is to search the source file's directory and {PInterfaces}.

-ir dirname

Adds the directory dirname to the list of directories to be searched for Rez #include, Include, Read, $$Resource and $$Read files. Multiple -ir options can be specified. The default is to search the source file's directory and {RIncludes}.

-mf | -nomf

Enables or suppresses the use of Process Manager temporary memory.

Note that the MakeDepend command's use of Process Manager temporary memory excludes other applications from using it, even the Finder. If temporary memory is unavailable, this option has no effect.

WARNING
If MakeDepend aborts abnormally, that is, there is a crash or a nonmaskable interrupt (NMI), much of the Process Manager temporary memory might be left permanently allocated, thus potentially crippling launches and Finder copy operations. The only way to recover from this situation is to restart the computer. •

-objdir dirname

Specifies the directory that will contain the object files. The default is the current directory.

-objext extension

Specifies the filename extension to use for the object files. The default is ".o". Multiple -objext options can be specified. For example, the following options could be specified in order to generate dependencies for both 68k and PowerPC object files.

-objext .o -objext .x

-p

Writes progress information to diagnostic output.

-quote on | off

Controls the quoting of filenames in the generated dependencies. The default is to quote the filenames.

-skip[dir] dirname

Included files found in the directory dirname will not be parsed or listed in the generated dependencies. Multiple -skipdir options can be specified. This option is generally used to ignore the system includes (e.g. -skipdir {CIncludes}).

-skipfile filename[,filename]…

The specified files will not be parsed or listed in the generated dependencies. Multiple -skipfile options can be specified.

-w

Suppresses warning messages.

EXAMPLE 1

A simple example of using MakeDepend is

MakeDepend -append Makefile ≈.c

This generates dependencies for the C source files in the current directory and appends the dependencies to the makefile named Makefile, also in the current directory.

EXAMPLE 2

The following is a more elaborate example, with macros, special include directories, and source files from different directories. Note that the trailing "∂" on each line indicates to the MPW Shell that the command continues to the next line. The indentation is for readability only, and means nothing to either MakeDepend or the MPW Shell.

MakeDepend -append Makefile     ∂ 
# Specify the directory that will contain the object files. ∂
    -objdir :Objects:           ∂
# Specify additional directories to search for "include" files. ∂
    -i :Src:Errors:             ∂
    -i :Src:Main:               ∂
    -i :Src:Utilities:          ∂
# Skip files included from {CIncludes} and {AIncludes}. ∂
    -skip {CIncludes}           ∂
    -skip {AIncludes}           ∂
# Define macros for use in the generated dependencies. ∂
    ObjDir=:Objects:            ∂
    Errors=:Src:Errors:         ∂
    Main=:Src:Main:             ∂
    Utilities=:Src:Utilities:   ∂
# Specify the source files.     ∂
    :Src:Errors:≈.c             ∂
    :Src:Main:≈.c               ∂
    :Src:Main:≈.r               ∂
    :Src:Utilities:≈.c          ∂
    :Src:Utilities:≈.a

The following is a small sample of the output from the MakeDepend command shown above. This sample shows how the macros are used in the generated dependencies.

"{ObjDir}"main.c.o ƒ ∂
   "{Main}"main.c ∂
   "{Main}"main.h ∂
   "{Utilities}"DataBuffer.h ∂
   "{Errors}"ErrorMsgs.h ∂
   "{Utilities}"HashTable.h

EXAMPLE 3

The following is an example of how to use MakeDepend from within a makefile named Makefile. In this example, the MakeDepend command line options are specified using previously defined Make variables.

# Define variables for the directories.
ObjDir      =    :Objects:
Errors      =    :Src:Errors:
Main        =    :Src:Main:
Utilities   =    :Src:Utilities:

<< the normal makefile contents goes here >>

# Build this target to (re)generate the dependencies.
Dependencies  ƒ  $OutOfDate
    MakeDepend            ∂
    -append Makefile      ∂
    -objdir {ObjDir}      ∂
    -i {Errors}           ∂
    -i {Main}             ∂
    -i {Utilities}        ∂
    -skip {CIncludes}     ∂
    -skip {AIncludes}     ∂
    ObjDir={ObjDir}       ∂
    Errors={Errors}       ∂
    Main={Main}           ∂
    Utilities={Utilities} ∂
    {Errors}≈.c           ∂
    {Main}≈.c             ∂
    {Main}≈.r             ∂
    {Utilities}≈.c        ∂
    {Utilities}≈.a

To (re)generate the dependencies, set the current directory to the folder containing Makefile and execute the following two commands.

Make Dependencies > MakeOut
MakeOut

The first command executes Make using the target Dependencies and redirects the output (i.e. the MakeDepend command) to the file named MakeOut in the current directory. When MakeOut is executed, MakeDepend will generate the dependencies and append them to Makefile.

 
 


Last Updated July 2000