MAKEDEPEND(1) MAKEDEPEND(1) NNAAMMEE makedepend - create dependencies in makefiles SSYYNNOOPPSSIISS mmaakkeeddeeppeenndd [ --DD_n_a_m_e==_d_e_f ] [ --DD_n_a_m_e ] [ --II_i_n_c_l_u_d_e_d_i_r ] [ --YY_i_n_c_l_u_d_e_d_i_r ] [ --aa ] [ --ff_m_a_k_e_f_i_l_e ] [ --oo_o_b_j_s_u_f_f_i_x ] [ --pp_o_b_j_p_r_e_f_i_x ] [ --ss_s_t_r_i_n_g ] [ --ww_w_i_d_t_h ] [ --vv ] [ --mm ] [ -- _o_t_h_e_r_o_p_t_i_o_n_s -- ] _s_o_u_r_c_e_f_i_l_e ... DDEESSCCRRIIPPTTIIOONN The mmaakkeeddeeppeenndd program 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_, _#_e_l_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 reference 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 _d_e_p_e_n_d_e_n_c_y_. 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 recom­ piled 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 _s_o_u_r_c_e_f_i_l_e_._o is the name from the command line with its suffix replaced with ``.o'', and _d_f_i_l_e 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 ... CFLAGS = -O -DHACK -I../foobar -xyz depend: makedepend -- $(CFLAGS) -- $(SRCS) OOPPTTIIOONNSS The program will ignore any option that it does not under­ stand so that you may use the same arguments that you would for cccc((11)).. --DD_n_a_m_e==_d_e_f or --DD_n_a_m_e 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''. --II_i_n_c_l_u_d_e_d_i_r 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 directories (usually /usr/include and possi­ bly a compiler-dependent directory). --YY_i_n_c_l_u_d_e_d_i_r 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 stan­ dard include directories. --aa Append the dependencies to the end of the file instead of replacing them. --ff_m_a_k_e_f_i_l_e Filename. This allows you to specify an alternate makefile in which mmaakkeeddeeppeenndd can place its output. Specifying ``-'' as the file name (i.e., --ff--) sends the output to standard output instead of modifying an existing file. --oo_o_b_j_s_u_f_f_i_x 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. --pp_o_b_j_p_r_e_f_i_x Object file prefix. The prefix is prepended to the name of the object file. This is usually used to des­ ignate a different directory for the object file. The default is the empty string. --ss_s_t_r_i_n_g Starting string delimiter. This option permits you to specify a different string for mmaakkeeddeeppeenndd to look for in the makefile. --ww_w_i_d_t_h 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 versions 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 problems related to multiple inclusion. ---- _o_p_t_i_o_n_s ---- If mmaakkeeddeeppeenndd encounters a double hyphen (--) in the argument list, then any unrecognized argument follow­ ing it will be silently ignored; a second double hyphen terminates this special treatment. In this way, mmaakkeeddeeppeenndd can be made to safely ignore esoteric compiler 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 nor­ mally. AALLGGOORRIITTHHMM The approach used in this program enables it to run an order of magnitude faster than any other ``dependency gen­ erator'' 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. Given these assumptions, mmaakkeeddeeppeenndd 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, main­ taining 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 prepro­ cessor takes. But on subsequent files, if it encounters 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 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 dependencies 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 simply adds _h_e_a_d_e_r_._h_, _d_e_f_1_._h and _d_e_f_2_._h to the list of dependencies 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 expressions 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 Release 6.5 MAKEDEPEND(1)