User Commands MAKEDEPEND(1) NNAAMMEE makedepend - create dependencies in makefiles SSYYNNOOPPSSIISS mmaakkeeddeeppeenndd [ --DDnnaammee==ddeeff ] [ --DDnnaammee ] [ --IIiinncclluuddeeddiirr ] [ --YYiinncclluuddeeddiirr ] [ --aa ] [ --ffmmaakkeeffiillee ] [ --oooobbjjssuuffffiixx ] [ --ppoobb-- jjpprreeffiixx ] [ --ssssttrriinngg ] [ --wwwwiiddtthh ] [ --vv ] [ --mm ] [ -- ootthh-- eerrooppttiioonnss -- ] sourcefile ... DDEESSCCRRIIPPTTIIOONN MMaakkeeddeeppeenndd reads each _s_o_u_r_c_e_f_i_l_e in sequence and parses it like a C-preprocessor, processing all _#_i_n_c_l_u_d_e_, _#_d_e_f_i_n_e_, _#_u_n_d_e_f_, _#_i_f_d_e_f_, _#_i_f_n_d_e_f_, _#_e_n_d_i_f_, _#_i_f and _#_e_l_s_e directives so that it can correctly tell which _#_i_n_c_l_u_d_e_, directives would be used in a compilation. Any _#_i_n_c_l_u_d_e_, directives can ref- erence files having other _#_i_n_c_l_u_d_e directives, and parsing will occur in these files as well. Every file that a _s_o_u_r_c_e_f_i_l_e includes, directly or indi- rectly, is what mmaakkeeddeeppeenndd calls a "dependency". These dependencies are then written to a _m_a_k_e_f_i_l_e in such a way that mmaakkee((11)) will know which object files must be recompiled when a dependency has changed. By default, mmaakkeeddeeppeenndd places its output in the file named _m_a_k_e_f_i_l_e if it exists, otherwise _M_a_k_e_f_i_l_e_. An alternate makefile may be specified with the --ff option. It first searches the makefile for the line # DO NOT DELETE THIS LINE -- make depend depends on it. or one provided with the --ss option, as a delimiter for the dependency output. If it finds it, it will delete every- thing 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 _s_o_u_r_c_e_f_i_l_e appearing on the command line, mmaakkeeddeeppeenndd 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 _#_i_n_c_l_u_d_e directive while parsing _s_o_u_r_c_e_f_i_l_e or one of the files it included. EEXXAAMMPPLLEE Normally, mmaakkeeddeeppeenndd 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 ... X Version 11 Last change: Release 6 1 User Commands MAKEDEPEND(1) CFLAGS = -O -DHACK -I../foobar -xyz depend: makedepend -- $(CFLAGS) -- $(SRCS) OOPPTTIIOONNSS MMaakkeeddeeppeenndd will ignore any option that it does not under- stand so that you may use the same arguments that you would for cccc((11)).. --DDnnaammee==ddeeff oorr --DDnnaammee Define. This places a definition for _n_a_m_e in mmaakkeeddee-- ppeenndd''ss symbol table. Without _=_d_e_f the symbol becomes defined as "1". --IIiinncclluuddeeddiirr Include directory. This option tells mmaakkeeddeeppeenndd to prepend _i_n_c_l_u_d_e_d_i_r to its list of directories to search when it encounters a _#_i_n_c_l_u_d_e directive. By default, mmaakkeeddeeppeenndd only searches the standard include directo- ries (usually /usr/include and possibly a compiler- dependent directory). --YYiinncclluuddeeddiirr Replace all of the standard include directories with the single specified include directory; you can omit the _i_n_c_l_u_d_e_d_i_r to simply prevent searching the standard include directories. --aa Append the dependencies to the end of the file instead of replacing them. --ffmmaakkeeffiillee Filename. This allows you to specify an alternate makefile in which mmaakkeeddeeppeenndd can place its output. --oooobbjjssuuffffiixx 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 ".b" with _-_o_._b or ":obj" with _-_o_:_o_b_j and so forth. --ppoobbjjpprreeffiixx Object file prefix. The prefix is prepended to the name of the object file. This is usually used to desig- nate a different directory for the object file. The default is the empty string. --ssssttrriinngg Starting string delimiter. This option permits you to specify a different string for mmaakkeeddeeppeenndd to look for in the makefile. X Version 11 Last change: Release 6 2 User Commands MAKEDEPEND(1) --wwwwiiddtthh Line width. Normally, mmaakkeeddeeppeenndd will 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. --vv Verbose operation. This option causes mmaakkeeddeeppeenndd to emit the list of files included by each input file on standard output. --mm Warn about multiple inclusion. This option causes mmaakkeeddeeppeenndd to produce a warning if any input file includes another file more than once. In previous ver- sions of mmaakkeeddeeppeenndd this 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 prob- lems related to multiple inclusion. ---- ooppttiioonnss ---- If mmaakkeeddeeppeenndd encounters 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, mmaakkeeddeeppeenndd can be made to safely ignore esoteric com- piler arguments that might normally be found in a CFLAGS mmaakkee macro (see the EEXXAAMMPPLLEE section above). All options that mmaakkeeddeeppeenndd recognizes and appear between the pair of double hyphens are processed normally. AALLGGOORRIITTHHMM 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 assump- tions: 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. Given these assumptions, mmaakkeeddeeppeenndd expects to be called once for each makefile, with all source files that are main- tained by the makefile appearing on the command line. It parses each source and include file exactly once, maintain- ing 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 encounter's an include file that it has already parsed, it does not parse it again. For example, imagine you are compiling two files, _f_i_l_e_1_._c and _f_i_l_e_2_._c_, they each include the header file _h_e_a_d_e_r_._h_, and X Version 11 Last change: Release 6 3 User Commands MAKEDEPEND(1) the file _h_e_a_d_e_r_._h in turn includes the files _d_e_f_1_._h and _d_e_f_2_._h_. When you run the command makedepend file1.c file2.c mmaakkeeddeeppeenndd will parse _f_i_l_e_1_._c and consequently, _h_e_a_d_e_r_._h and then _d_e_f_1_._h and _d_e_f_2_._h_. It then decides that the dependen- cies for this file are file1.o: header.h def1.h def2.h But when the program parses _f_i_l_e_2_._c and discovers that it, too, includes _h_e_a_d_e_r_._h_, it does not parse the file, but sim- ply adds _h_e_a_d_e_r_._h_, _d_e_f_1_._h and _d_e_f_2_._h to the list of depen- dencies for _f_i_l_e_2_._o_. SSEEEE AALLSSOO cc(1), make(1) BBUUGGSS mmaakkeeddeeppeenndd parses, but does not currently evaluate, the SVR4 #predicate(token-list) preprocessor expression; such expres- sions are simply assumed to be true. This may cause the wrong _#_i_n_c_l_u_d_e directives to be evaluated. Imagine you are parsing two files, say _f_i_l_e_1_._c and _f_i_l_e_2_._c_, each includes the file _d_e_f_._h_. The list of files that _d_e_f_._h includes might truly be different when _d_e_f_._h is included by _f_i_l_e_1_._c than when it is included by _f_i_l_e_2_._c_. But once mmaakkeeddeeppeenndd arrives at a list of dependencies for a file, it is cast in concrete. AAUUTTHHOORR Todd Brunhoff, Tektronix, Inc. and MIT Project Athena X Version 11 Last change: Release 6 4