MAKEDEPEND(1) AIX MAKEDEPEND(1) NAME makedepend - create dependencies in makefiles SYNOPSIS mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd [ ----DDDDnnnnaaaammmmeeee====ddddeeeeffff ] [ ----DDDDnnnnaaaammmmeeee ] [ ----IIIIiiiinnnncccclllluuuuddddeeeeddddiiiirrrr ] [ ----aaaa ] [ ----ffffmmmmaaaakkkkeeeeffffiiiilllleeee ] [ ----oooooooobbbbjjjjssssuuuuffffffffiiiixxxx ] [ ----ppppoooobbbbjjjjpppprrrreeeeffffiiiixxxx ] [ ----ssssssssttttrrrriiiinnnngggg ] [ ----wwwwwwwwiiiiddddtttthhhh ] [ - - ooootttthhhheeeerrrrooooppppttttiiiioooonnnnssss - - ] sourcefile ... DESCRIPTION MMMMaaaakkkkeeeeddddeeeeppppeeeennnndddd 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 reference files having other #_i_n_c_l_u_d_e directives, and pars- ing will occur in these files as well. Every file that a _s_o_u_r_c_e_f_i_l_e includes, directly or indirectly, is what mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd calls a "dependency". These dependencies are then written to a _m_a_k_e_f_i_l_e in such a way that mmmmaaaakkkkeeee((((1111)))) will know which object files must be recompiled when a dependency has changed. By default, mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd 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 -_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 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, mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd 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. EXAMPLE Normally, mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd 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: Rev. Release 5 Page 1 MAKEDEPEND(1) AIX MAKEDEPEND(1) makedepend -- $(CFLAGS) -- $(SRCS) OPTIONS MMMMaaaakkkkeeeeddddeeeeppppeeeennnndddd will ignore any option that it does not under- stand so that you may use the same arguments that you would for cccccccc((((1111)))).... ----DDDDnnnnaaaammmmeeee====ddddeeeeffff oooorrrr ----DDDDnnnnaaaammmmeeee Define. This places a definition for _n_a_m_e in mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd''''ssss symbol table. Without =_d_e_f the symbol becomes defined as "1". ----IIIIiiiinnnncccclllluuuuddddeeeeddddiiiirrrr Include directory. This option tells mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd 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, mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd only searches /usr/include. ----aaaa Append the dependencies to the end of the file instead of replacing them. ----ffffmmmmaaaakkkkeeeeffffiiiilllleeee Filename. This allows you to specify an alternate makefile in which mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd can place its output. ----oooooooobbbbjjjjssssuuuuffffffffiiiixxxx 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. ----ppppoooobbbbjjjjpppprrrreeeeffffiiiixxxx 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. ----ssssssssttttrrrriiiinnnngggg Starting string delimiter. This option permits you to specify a different string for mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd to look for in the makefile. ----wwwwwwwwiiiiddddtttthhhh Line width. Normally, mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd 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. ---- ---- ooooppppttttiiiioooonnnnssss ---- ---- If mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd 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, Rev. Release 5 Page 2 MAKEDEPEND(1) AIX MAKEDEPEND(1) mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd can be made to safely ignore esoteric com- piler arguments that might normally be found in a CFLAGS mmmmaaaakkkkeeee macro (see the EEEEXXXXAAAAMMMMPPPPLLLLEEEE section above). All options that mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd recognizes and appear between the pair of double hyphens are processed normally. 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 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, mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd 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 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 mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd 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. SEE ALSO cc(1), make(1) BUGS If you do not have the source for cpp, the Berkeley C preprocessor, then mmmmaaaakkkkeeeeddddeeeeppppeeeennnndddd will be compiled in such a way that all #_i_f directives will evaluate to "false" regardless of their actual value. This may cause the wrong #_i_n_c_l_u_d_e directives to be evaluated. MMMMaaaakkkkeeeeddddeeeeppppeeeennnndddd should simply have its own parser written for #_i_f expressions. Rev. Release 5 Page 3 MAKEDEPEND(1) AIX MAKEDEPEND(1) 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 mmmmaaaakkkk---- eeeeddddeeeeppppeeeennnndddd arrives at a list of dependencies for a file, it is cast in concrete. AUTHOR Todd Brunhoff, Tektronix, Inc. and MIT Project Athena Rev. Release 5 Page 4