makedepend(1X) makedepend(1X)NAME makedepend - creates dependencies in makefiles SYNOPSIS makedepend [-Dname=def] [-Dname] [-Iincludedir] [-fmakefile] [-oobjsuffix] [-sstring] [-wwidth] [--options--] file... DESCRIPTION makedepend reads each file in sequence and parses it like a C-preprocessor, processing all #include, #define, #undef, #ifdef, #ifndef, #endif, #if, and #else directives so that it can correctly tell which #include directives would be used in a compilation. Any #include directives can refer- ence files having other #include directives, and parsing oc- curs in these files as well. Every file that file includes, directly or indirectly, is what makedepend calls a dependency. These dependencies are then written to a make(1) description file in such a way that make knows which object files must be recompiled when a dependency has changed. By default, makedepend places its output in a file named makefile if it exists; otherwise makedepend places its out- put in a file named Makefile. You can specify an alternate makefile by using the -f option. The makedepend command first searches for a string that is a delimiter for the dependency output. It searchs the makefile for the string # DO NOT DELETE THIS LINE -- make depend depends on it. or searches for a string specified by the -s option. If the string is found, makedepend deletes everything following the string and places its output after the string. If the string is not found, makedepend appends the string to the end of the makefile and places its output after the string. For each file appearing on the command line, makedepend puts lines in the makefile of the form file.o: dfile ... where file.o is file from the command line with its suffix replaced with .o, and dfile is a dependency discovered in a #include directive while parsing file or one of the files it includes. Options The makedepend command accepts the same options as cc(1) and ignores any options that it does not understand. November, 1990 1
makedepend(1X) makedepend(1X)-fmakefile Specifies an alternate makefile in which makedepend can place its output. -Iincludedir Specifies a directory to search for include files. This option tells makedepend to prepend includedir to its list of directories to search when it en- counters a #include directive. By default, mak- edepend only searches /usr/include. -Dname-Dname=defSpecifies a definition for name in the makedependsymbol table. If you omit =def, the symbol is de-fined as 1.-oobjsuffixSpecifies an alternate object-file suffix. Somesystems may have object files whose suffix is some-thing other than .o.-sstringSpecifies a string delimiter for makedepend to lookfor in the makefile.-wwidth Specifies a line width. For the sake of readabili-ty,makedepend ensures that every output line that itwrites is no wider than 78 characters. This optionallows you to change the default width.- - options - -Specifies a series of options for makedepend tosilently ignore. The second double hyphen ter-minates the series. In this way, makedepend can bemade to safely ignore esoteric compiler argumentsthat might normally be found in a CFLAGS make macro.See ``Examples'' later in this manual page. Allmakedepend options that occur between a pair of dou-ble hyphens are processed normally.AlgorithmThe performance of makedepend relies on two assumptions:first, all files compiled by a single makefile are compiledwith roughly the same -I and -D options; and second, mostfiles in a single directory generally include the samefiles.Given these assumptions, makedepend expects to be calledonce for each makefile, with all source files that are main-tained by the makefile appearing on the command line. It2 November, 1990
makedepend(1X) makedepend(1X)parses each source and include file exactly once, maintain- ing an internal symbol table for each. Thus, the first file on the command line takes an amount of time proportional to the amount of time that a normal C preprocessor takes. If on subsequent files an include file that has already been parsed is encountered, makedepend does not parse the include file again. For example, imagine you are compiling two files, file1.c and file2.c. Both files include the header file header.h, and header.h includes the files def1.h and def2.h. When you run the command makedepend file1.c file2.c makedepend parses file1.c and consequently, header.h and then def1.h and def2.h. The result is the following depen- dency: file1.o: header.h def1.h def2.h When makedepend parses file2.c, it discovers that file2.c also includes header.h. There is no need to parse header.h, so makedepend simply adds header.h, def1.h, and def2.h to the list of dependencies for file2.o. EXAMPLES Normally, makedepend is used in a makefile target so that the command make depend updates the dependencies in a makefile. For example, SRCS = file1.c file2.c ... CFLAGS = -O -DHACK -I../foobar -xyz depend: makedepend -- $(CFLAGS) -- $(SRCS) LIMITATIONS The makedepend command is compiled in such a way that all #if directives evaluate to TRUE regardless of their actual value. This action may cause the wrong #include directives to be evaluated. The makedepend command should simply have its own parser written for #if directives. Imagine you are parsing two files, file1.c and file2.c. Each includes the file def.h. The list of files that def.h includes might truly be different when def.h is included by file1.c than when it is included by file2.c. But once mak- edepend arrives at a list of dependencies for a file, the November, 1990 3
makedepend(1X) makedepend(1X)list cannot be changed. NOTES Author: Todd Brunhoff, Tektronix, Inc. and MIT Project Athe- na SEE ALSO cc(1), make(1) in A/UX Command Reference 4 November, 1990