MAKEDEPEND(1)
๐ MAKEDEPEND(1) ๐
okay so bestie, listen up โ this is makedepend, and it's literally the icon of makefile dependency generation. no cap, it's giving main character energy in the build system. โจ
๐ NAME ๐
makedepend โ create dependencies in makefiles. periodt. ๐
โจ SYNOPSIS โจ
makedepend [ -Dname=def ] [ -Dname ] [ -Iincludedir ] [ -Yincludedir ]
[ -a ] [ -fmakefile ] [ -include file ] [ -oobjsuffix ]
[ -pobjprefix ] [ -sstring ] [ -wwidth ] [ -v ] [ -m ]
[ -- otheroptions -- ] sourcefile ...
๐ธ DESCRIPTION ๐ธ
so the way makedepend works is it reads each sourcefile one by one and parses it like a C-preprocessor. it processes all the #include, #define, #undef, #ifdef, #ifndef, #endif, #if, #elif and #else directives so it can correctly tell which #include directives would actually be used in a compilation. and that's not all โ any #include directives can reference files that have other #include directives, and parsing will occur in those files too. it goes deep, bestie. ๐ฆ
every file that a sourcefile includes, directly or indirectly, is what makedepend calls a dependency. these dependencies are then written to a makefile in such a way that make(1) will know which object files must be recompiled when a dependency has changed. slay. ๐
by default, makedepend places its output in the file named makefile if it exists, otherwise Makefile. an alternate makefile may be specified with the -f option. it first searches the makefile for the line
# DO NOT DELETE THIS LINE -- make depend depends on it.
or one provided with the -s option, as a delimiter for the dependency output. if it finds it, it will delete everything following this to the end of the makefile and put the output after this line. if it doesn't find it, the program will append the string to the end of the makefile and place the output following that. for each sourcefile appearing on the command line, makedepend puts lines in the makefile of the form
sourcefile.o: dfile ...
where sourcefile.o is the name from the command line with its suffix replaced with .o, and dfile is a dependency discovered in a #include directive while parsing sourcefile or one of the files it included. it's literally building the dependency graph for you. ๐
๐ฅ EXAMPLE ๐ฅ
normally, makedepend will be used in a makefile target so that typing make depend will bring the dependencies up to date for the makefile. for example:
SRCS = file1.c file2.c ...
CFLAGS = -O -DHACK -I../foobar -xyz
depend:
makedepend -- $(CFLAGS) -- $(SRCS)
iykyk. ๐ซถ
๐ OPTIONS ๐
the program will ignore any option that it does not understand so that you may use the same arguments that you would for cc(1). iconic behavior, honestly. ๐ญ
-Dname=defor-Dnameโ Define. This places a definition fornameinmakedepend's symbol table. Without=defthe symbol becomes defined as1. easy peasy. โจ-Iincludedirโ Include directory. This option tellsmakedependto prependincludedirto its list of directories to search when it encounters a#includedirective. By default,makedependonly searches the standard include directories (usually/usr/includeand possibly a compiler-dependent directory). gotta find those headers, bestie. ๐-Yincludedirโ Replace all of the standard include directories with the single specified include directory; you can omit theincludedirto simply prevent searching the standard include directories. it's giving "I make the rules now." ๐-aโ Append the dependencies to the end of the file instead of replacing them. lowkey useful when you don't want to lose what's already there. ๐ธ-fmakefileโ Filename. This allows you to specify an alternate makefile in whichmakedependcan place its output. Specifying-as the file name (i.e.,-f-) sends the output to standard output instead of modifying an existing file. piping it out, no cap. ๐ฆ-include fileโ Processfileas input, and include all the resulting output before processing the regular input file. This has the same affect as if the specified file is an include statement that appears before the very first line of the regular input file. it's like a little pre-game, you know? ๐ฅ-oobjsuffixโ Object file suffix. Some systems may have object files whose suffix is something other than.o. This option allows you to specify another suffix, such as.bwith-o.bor:objwith-o:objand so forth. customize your vibe. โญ-pobjprefixโ Object file prefix. The prefix is prepended to the name of the object file. This is usually used to designate a different directory for the object file. The default is the empty string. it's the little label before the name, bestie. ๐-sstringโ Starting string delimiter. This option permits you to specify a different string formakedependto look for in the makefile. change up the marker, why not. ๐-wwidthโ Line width. Normally,makedependwill ensure that every output line that it writes will be no wider than 78 characters for the sake of readability. This option enables you to change this width. keep it cute and readable. ๐-vโ Verbose operation. This option causesmakedependto emit the list of files included by each input file. it's giving "tell me everything." ๐-mโ Warn about multiple inclusion. This option causesmakedependto produce a warning if any input file includes another file more than once. In previous versions ofmakedependthis was the default behavior; the default has been changed to better match the behavior of the C compiler, which does not consider multiple inclusion to be an error. This option is provided for backward compatibility, and to aid in debugging problems related to multiple inclusion. so if you're old-school or debugging, this one's for you. ๐ง-- options --โ Ifmakedependencounters a double hyphen (--) in the argument list, then any unrecognized argument following it will be silently ignored; a second double hyphen terminates this special treatment. In this way,makedependcan be made to safely ignore esoteric compiler arguments that might normally be found in aCFLAGSmake macro (see the EXAMPLE section above). All options thatmakedependrecognizes and appear between the pair of double hyphens are processed normally. it's like a little bubble of "don't worry about it." ๐
๐ ALGORITHM ๐
the approach used in this program enables it to run an order of magnitude faster than any other "dependency generator" I have ever seen. central to this performance are two assumptions: that all files compiled by a single makefile will be compiled with roughly the same -I and -D options; and that most files in a single directory will include largely the same files. smart, right? ๐ง โจ
given these assumptions, makedepend expects to be called once for each makefile, with all source files that are maintained by the makefile appearing on the command line. it parses each source and include file exactly once, maintaining an internal symbol table for each. thus, the first file on the command line will take an amount of time proportional to the amount of time that a normal C preprocessor takes. but on subsequent files, if it encounters an include file that it has already parsed, it does not parse it again. efficiency icon. ๐
for example, imagine you are compiling two files, file1.c and file2.c, they each include the header file header.h, and the file header.h in turn includes the files def1.h and def2.h. when you run the command
makedepend file1.c file2.c
makedepend will parse file1.c and consequently, header.h and then def1.h and def2.h. it then decides that the dependencies for this file are
file1.o: header.h def1.h def2.h
but when the program parses file2.c and discovers that it, too, includes header.h, it does not parse the file, but simply adds header.h, def1.h and def2.h to the list of dependencies for file2.o. it remembered! no repeats, just vibes. ๐ฆ
๐ SEE ALSO ๐
๐ BUGS ๐
makedepend parses, but does not currently evaluate, the SVR4 #predicate(token-list) preprocessor expression; such expressions are simply assumed to be true. This may cause the wrong #include directives to be evaluated. so like, it's not perfect, bestie. don't come for me. ๐ญ
imagine you are parsing two files, say 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 makedepend arrives at a list of dependencies for a file, it is cast in concrete. like, it's done, it's set, no take-backs. ๐
๐ซถ AUTHOR ๐ซถ
Todd Brunhoff, Tektronix, Inc. and MIT Project Athena
okay that's the whole thing! shoutout to the 4th Berkeley Distribution,makedepend 1.0.9, and yeah โ this is the manual page, and you're now amakedependexpert. go make those makefiles, bestie. ๐โจ
๐ฆ where this page comes from
- alpine 3.22: makedepend-doc 1.0.9-r0 ยท MIT-open-group
- alpine 3.23: makedepend-doc 1.0.9-r0 ยท MIT-open-group
- alpine 3.24: makedepend-doc 1.0.9-r0 ยท MIT-open-group
- arch rolling: imake 1.0.11-1 ยท MIT-open-group AND HPND
- nixos 26.05: makedepend 1.0.9
- opensuse-leap 16.0: makedepend 1.0.9-160000.3.2 ยท MIT
- opensuse-leap 16.0: makedepend 1.0.9-160000.3.2 ยท MIT
- opensuse-leap 16.0: makedepend 1.0.9-160000.3.2 ยท MIT
- opensuse-leap 16.0: makedepend 1.0.9-160000.3.2 ยท MIT
- Copyright (c) 1993, 1994, 1998 The Open Group
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms