This file is indexed.

/usr/share/doc/makepp/makepp_scanning.html is in makepp 2.0.98.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
<?xml version='1.0'?><!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'><head><link rel='stylesheet' href='makepp.css' type='text/css'/><title>Makepp Scanning — How makepp finds include files and other hidden dependencies</title><link rel='next' href='makepp_signatures.html'/><link rel='prev' href='makepp_sandboxes.html'/><meta http-equiv='Content-Type' content='text/html; charset=utf-8'/><link rel='shortcut icon' type='image/png' href='url.png'/><link rel='top' href='http://makepp.sourceforge.net/'/><link rel='index' href='makepp_index.html'/><link rel='contents' href='index.html'/><link rel='help' href='http://sourceforge.net/projects/makepp/support'/><script src='makepp.js' type='text/javascript'></script><meta name='keywords' content='makepp, make++, Make, build tool, repository, cache, Perl, Make alternative, Make replacement, Make enhancement, Make improvement, Make substitute, dmake, gmake, GNU Make, nmake, pmake, easymake, imake, jmake, maketool, mmake, omake, ppmake, PVM gmake, shake, SMake, ant, maven, cook, jam, Cons, SCons, cc -M, gcc -MM, g++ -MM, makedepend, makedep, mkdep, CCache, Compilercache, cachecc1, Make::Cache, automake'/></head><body><div id='_head'><form action='http://www.google.com/search'><p><input type='hidden' name='as_sitesearch' value='makepp.sourceforge.net/2.1'/><input type='text' name='as_q'/><input type='submit' value='Go'/></p></form><a title='Makepp Homepage' href='http://makepp.sourceforge.net/'><img src='makepp.png' alt='Makepp'/></a><div><a href='http://makepp.sourceforge.net/'><img title='Makepp Homepage' id='_home' src='tabs.png' alt='Home'/></a><a href='makepp_faq.html'><img title='Frequently Asked Questions' id='_faq' src='tabs.png' alt='FAQ'/></a><a href='http://makepp.sourceforge.net/gallery/'><img title='Gallery' id='_gallery' src='tabs.png' alt='Gallery'/></a><a href='http://sourceforge.net/projects/makepp/files/2.1/snapshots/'><img title='Download' id='_download' src='tabs.png' alt='Download'/></a><a href='https://sourceforge.net/projects/makepp/'><img title='Makepp on SourceForge' id='_sourceforge' src='tabs.png' alt='SourceForge'/></a><a href='http://search.cpan.org/dist/makepp/'><img title='Makepp on CPAN' id='_cpan' src='tabs.png' alt='CPAN'/></a></div></div><ul><li id='_close'><script type='text/javascript'>r()</script><span title='Flip side' onclick='lr(this)'></span><span title='Collapse' onclick='roll(this)'></span><span title='Expand' onclick='roll(this,1)'>¤</span><span title='Close' onclick='nonav(this)'>×</span></li><li class='fold' onclick='fold(this)'>Overview<ul><li><a href='index.html'>Introduction</a></li><li><a href='makepp_tutorial.html'>Tutorial</a></li><li><a href='makepp_tutorial_compilation.html'>Compilation Tutorial</a></li><li><a href='makepp_release_notes.html'>Release Notes</a></li><li><a href='makepp_compatibility.html'>Compatibility</a></li><li><a href='makepp_incompatibilities.html'>Incompatibilities</a></li><li><a href='makepp_speedup.html'>Speedup</a></li><li><a href='perl_performance.html'>Perl Performance</a></li></ul></li><li class='fold' onclick='fold(this)'>Q&amp;A<ul><li><a href='makepp_cookbook.html'>Cookbook</a></li><li><a href='makepp_faq.html'>FAQ</a></li></ul></li><li id='_act' class='unfold' onclick='fold(this)'><b>Features</b><ul><li><a href='makepp_build_algorithm.html'>Build Algorithm</a></li><li><a href='makepp_build_cache.html'>Build Cache</a></li><li><a href='makepp_build_check.html'>Build Check Methods</a></li><li><a href='makepp_builtin.html'>Builtin Rules</a></li><li><a href='makepp_builtins.html'>Builtin Commands</a></li><li><a href='makepp_extending.html'>Extending</a></li><li><a href='makepp_functions.html'>Functions</a></li><li><a href='makepp_repositories.html'>Repositories</a></li><li><a href='makepp_rules.html'>Rules</a></li><li><a href='makepp_sandboxes.html'>Sandboxes</a></li><li><b>Scanning</b></li><li><a href='makepp_signatures.html'>Signatures</a></li><li><a href='makepp_statements.html'>Statements</a></li><li><a href='makepp_variables.html'>Variables</a></li></ul></li><li class='fold' onclick='fold(this)'>Commands<ul><li><a href='makepp_command.html'>makepp,&nbsp; mpp</a></li><li><a href='makeppbuiltin.html'>makeppbuiltin,&nbsp; mppb</a></li><li><a href='makeppclean.html'>makeppclean,&nbsp; mppc</a></li><li><a href='makeppgraph.html'>makeppgraph,&nbsp; mppg</a></li><li><a href='makeppinfo.html'>makeppinfo,&nbsp; mppi</a></li><li><a href='makepplog.html'>makepplog,&nbsp; mppl</a></li><li><a href='makeppreplay.html'>makeppreplay,&nbsp; mppr</a></li></ul></li><li><a href='makepp_index.html'>Index</a></li></ul><div id='_main'><h1>Makepp Scanning</h1><p><b>How makepp finds include files and other hidden dependencies</b></p><ul><li><a href="#scanners__parsers_">SCANNERS (PARSERS)</a><ul><li><a href="#c_c___compilation__c_compilation__gcc_compilation_">C/C++ compilation (c-compilation, gcc-compilation)</a></li><li><a href="#embedded_sql_c_c___compilation__esql_compilation_">Embedded SQL C/C++ compilation (esql-compilation)</a></li><li><a href="#swig__swig_">Swig (swig)</a></li><li><a href="#vera_and_verilog__vcs_compilation_">Vera and Verilog (vcs_compilation)</a></li><li><a href="#ignorable_wrappers__skip_word__shell_">Ignorable wrappers (skip-word, shell)</a><ul><li><a href="#libtool">Libtool</a></li></ul></li><li><a href="#suppressing_the_scan__none_">Suppressing the scan (none)</a></li></ul></li><li><a href="#related_options">RELATED OPTIONS</a><ul><li><a href="#quickscan_and_smartscan">Quickscan and smartscan</a></li></ul></li><li><a href="#custom_scanners">CUSTOM SCANNERS</a><ul><li><a href="#caching_scanner_info">Caching scanner info</a></li><li><a href="#ad_hoc_scanner">Ad Hoc Scanner</a></li></ul></li></ul><p>Makepp can determine additional dependencies or targets for certain commands that it knows something about. This is especially important for C/C++ compilation, where it is too error-prone to list manually all of the include files that a given source file depends on. By looking at the compilation command and the source files themselves, makepp is able to determine accurately which object files need to be rebuilt when some include file changes.</p><p>Example: Given a rule</p><pre><em>foo.o</em>:                      <span class='comment'># Usually %.o: %.c, just for illustration</span>
    time -p /bin/libtool -bar /usr/bin/cc -c -I somewhere foo.c</pre><p>makepp knows that <tt>time</tt> and <tt>libtool</tt> must be skipped and that <tt>cc</tt> is the actual command to be parsed here. It understands that <i class="file">foo.c</i> is the input file and thus a dependency of this rule. Moreover it will scan that file looking for include statements, also in directory <i class="file">somewhere</i>, because it understood the command options.</p><p>Actually there are three steps to what is historically known as scanning:</p><ol><li><p>The rule action is split into lines (continuation lines count as one). Each line (except builtins and Perl blocks) is <b>lexically analyzed</b> as one or more Shell commands. Redirections are recognized as inputs or outputs to this rule. The first word of each command is looked up (with its directory part but, if not found, again without it) to find a parser for it. These become optional dependencies, they are built if possible, but ignored if not found, as makepp can't know which part of a complex command is actually run.</p><p>Commands in backquotes are analyzed but not executed. (Often execution is important, but this would be a major interference by makepp.) It is better style to avoid them. Instead have makepp run the command at most once by assigning it in this special way:</p><pre><i>XYZFLAGS</i> ;= $(<i><b>shell</b></i> pkg-config --cflags xyz)</pre><p>Currently there is only one lexer class, which understands Bourne Shell. To better handle C Shell or <tt>command.com</tt>, subclasses might be created. However, much syntax is similar enough to not warrant this. Get in touch if you want to contribute either.</p></li><li><p>For known commands the corresponding <b>command parser</b> (also referred to just as parser) analyzes the important options and arguments. The available ones are <a href="#scanners__parsers_">described below</a>.</p><p>Even if no specialized parser was found, the generic one makes the command executable an input of this rule. You can change that with the <a href="makepp_command.html#no_path_exe_dep">--no-path-executable-dependencies command option</a>.</p></li><li><p>If the parser recognized any input files, they get sent to the <b>scanner</b> chosen by the parser. It finds further inputs by looking for <a href="makeppgraph.html#include"><tt>#include</tt></a> or comparable statements.</p><p>This is the most expensive step. All the results get cached to avoid repeating it unnecessarily.</p></li></ol><p>If makepp thinks it's compiling a C/C++ source but can't find a parser, it will give a warning message to let you know. This usually means that you buried your compiler command too deeply in the action for makepp to find it. For example, I have seen rules like this:</p><pre><em>%.o</em>: %.c
    <b>@</b>echo Compiling $&lt; now; obscure_wrapper gcc -c $&lt; $(<i>CFLAGS</i>) -o <em>$@</em></pre><p>The first words of the actions here are <tt>echo</tt> and <tt>obscure_wrapper</tt>, for which there are no parsers, so makepp will not scan for include files in this case. You can ignore the prefixed command by:</p><pre><b>register-parser</b> <em>obscure_wrapper</em> skip-word</pre><p>The following sections document the built in parsers and scanners. In the name you can use <a href="makepp_rules.html#_"><tt><b>-</b></tt></a> interchangeably with <tt>_</tt>.</p><p></p><hr/><h1 id="scanners__parsers_">SCANNERS (PARSERS)</h1><p>The various scanners must be chosen by a command parser, which is given in parentheses:</p><p></p><h2 id="c_c___compilation__c_compilation__gcc_compilation_">C/C++ compilation (c-compilation, gcc-compilation)</h2><p>The C/C++ scanner, handles both languages indifferently. In fact it looks only at preprocessor statements, so it can be used for quite a few languages. The parser that activates it has a special variant for gcc's many options, which gets chosen if the command name includes the string <tt>gcc</tt> or g++. If compilers for other languages with C preprocessor use the same options as the C compiler (at least <a href="makepp_builtins.html#i"><tt><b>-</b>I</tt></a>) then this parser works fine.</p><p>It looks at the command for <tt><b>-</b>Idir</tt> options specifying the include path or <tt><b>-</b>Ldir</tt> options specifying the link path. It then scans any source files for <a href="makeppgraph.html#include"><tt>#include</tt></a> directives, and also looks at the command line to see if there are any source files or libraries mentioned which are not listed as dependencies. It recognizes these by their extension.</p><p>This scanner gives a warning message if files included with <tt>#include &quot;file.h&quot;</tt> are not found, or not buildable by makepp, in the include path, or in the directory containing the file which is <tt>#includ</tt>ing, or in <i class="file">/usr/include</i>. No warning is given if a file included with <tt>#include &lt;file.h&gt;</tt> is not found. Makepp assumes it is in some system include directory that the compiler knows about, and that files in system include directories won't change.</p><p>In addition, files in <i class="file">/usr/include</i>, <i class="file">/usr/local/include</i>, <i class="file">/usr/X11R6/include</i>, and any other directory which is not writable are not scanned to see what they include. Makepp assumes that these files won't change. (If you're running as root, the writability test is performed with the UID and GID of the directory you ran makepp from. This is so compiling a program as an ordinary user and then doing <tt>makepp&nbsp;install</tt> as root won't cause extra directories to be scanned.)</p><p>This is a fairly simple-minded scanner. It will get confused if you do things like this:</p><pre>#ifdef INCLUDE_THIS
#include "this.h"
#endif</pre><p>because it doesn't know about preprocessor conditionals. This is usually harmless; it might cause additional extra files to be labeled as dependencies (occasionally causing unnecessary rebuilds), or else it might cause makepp to warn that the include file was not found. You can either ignore the warning messages, or put an empty file <tt>this.h</tt> out there to shut makepp up.</p><p>If your compiler has a funny name, you can say either of</p><pre><b>register-parser</b> <em>obscure_c_compiler</em> c-compilation
<b>register-parser</b> <em>obscure_gcc_alias</em> gcc-compilation</pre><p></p><h2 id="embedded_sql_c_c___compilation__esql_compilation_">Embedded SQL C/C++ compilation (esql-compilation)</h2><p>These commands, which come with the various databases, preprocess special sections in otherwise C/C++-like sources, and produce C/C++ headers and sources. This finds EXEC SQL INCLUDE &quot;filename&quot; or $INCLUDE &quot;filename&quot; directives.</p><p>These preprocessors are recognized: Altibase APRE*C/C++ (<i class="file">apre</i>), CASEMaker DBMaker (<i class="file">dmppcc</i>), Firebird / InterBase (<i class="file">gpre</i>), IBM DB2 (<i class="file">db2 precompile, db2 prep</i>) &amp; Informix ESQL/C (<i class="file">esql</i>), Ingres (<i class="file">esqlc</i>), Mimer (<i class="file">esql</i>), Oracle (<i class="file">proc</i>), PostgreSQL (<i class="file">ecpg</i>) &amp; YARD (<i class="file">yardpc</i>). If your preprocessor is not recognized, you can say</p><pre><b>register-parser</b> <em>obscure_esqlc_preprocessor</em> esql-compilation</pre><p>This will however only handle the style common to Informix and others: Command arguments ending in <tt>.ec</tt> are files to be scanned, <a href="makepp_builtins.html#i"><tt><b>-</b>I</tt></a> defines the include path and EXEC SQL INCLUDE directives without a suffix get <a href="makeppreplay.html#h"><tt>.h</tt></a> appended.</p><p></p><h2 id="swig__swig_">Swig (swig)</h2><p>Swig (Simplified Wrapper and Interface Generator, <a href="http://www.swig.org/)">http://www.swig.org/)</a> is a program that converts a C/C++ header file into the wrapper functions needed to make your code callable from a variety of other languages, such as Perl, Python, Tcl, C#, Ruby, OCaml, and probably some others that I don't know about.</p><p>Makepp understands and parses the swig command line, looking for <a href="makepp_builtins.html#i"><tt><b>-</b>I</tt></a> and <a href="makeppclean.html#l"><tt><b>-</b>l</tt></a> options. It also knows how to scan swig's interface definition files (<i class="file">.i</i> files) looking for <tt>%include</tt>, <tt>%import</tt>, and also <a href="makeppgraph.html#include"><tt>#include</tt></a> if <tt><b>-</b>includeall</tt> is in effect.</p><p>If your swig has a funny name, you can say</p><pre><b>register-parser</b> <em>obscure_swig_alias</em> swig</pre><p></p><h2 id="vera_and_verilog__vcs_compilation_">Vera and Verilog (vcs_compilation)</h2><p>If you design hardware, this will come in handy.</p><p></p><h2 id="ignorable_wrappers__skip_word__shell_">Ignorable wrappers (skip-word, shell)</h2><p>Makepp recognizes the following command words and many more and skips over them appropriately in in its search for the correct scanner: <tt>condor_compile</tt>, <tt>distcc</tt>, <a href="makepp_rules.html#ignore_error"><tt>ignore_error</tt></a>, <tt>libtool</tt>, <a href="makepp_rules.html#noecho"><tt>noecho</tt></a> <tt>purify</tt>.</p><p>There is a variant of this which finds the nested commands in <tt>sh -c 'command1; command2'</tt>.</p><p>If you have more such commands, you can say</p><pre><b>register-parser</b> <em>command</em> skip-word</pre><p></p><h3 id="libtool">Libtool</h3><p>Libtool is a very clever compilation system that greatly simplifies making shared libraries by hiding all the system-dependent details away in a shell script. The only difficulty is that the library binary files are not actually stored in the same directory as the output file--libtool actually creates a subdirectory, <tt>.libs</tt>, which contains the real files. This is ordinarily not a problem, but makepp has to know where the real binaries are if it is to link them in from a repository. At the moment, libtool libraries (<tt>.la</tt> files) are not linked in from repositories; they are always rebuilt if needed. Also, makepp at the moment is not able to use the dependency information that is stored inside the <tt>.la</tt> file itself. This will hopefully change soon.</p><p></p><h2 id="suppressing_the_scan__none_">Suppressing the scan (none)</h2><p>Sometimes you may not want a rule or a certain command to be parsed. You can turn off parsing and thereby scanning with</p><pre><b>register-parser</b> <em>cc</em> none</pre><p></p><hr/><h1 id="related_options">RELATED OPTIONS</h1><p></p><h2 id="quickscan_and_smartscan">Quickscan and smartscan</h2><p>The <tt>:<b>quickscan</b></tt> and <tt>:<b>smartscan</b></tt> rule options, if applicable, affect the way that files are scanned.</p><p>In <tt>:<b>quickscan</b></tt> mode (the default), all include directives are assumed active. This allows for very efficient scanning.</p><p>In <tt>:<b>smartscan</b></tt> mode, an attempt is made to interpret macros and expressions so that inactive include directives are ignored. For example, the executable produced by compiling the following C program ought <i>not</i> to depend on <i class="file">foo.h</i>:</p><pre>#if 0
#include "foo.h"
#endif
int main() { return 0; }</pre><p></p><hr/><h1 id="custom_scanners">CUSTOM SCANNERS</h1><p>You can specify your own parser either in a <a href="makepp_rules.html#parser_parser">rule option</a> like <tt>:<b>parser</b> <em>foo</em></tt>, or by using the <a href="makepp_statements.html#register_command_parser_command_word_parser"><tt><b>register_parser</b></tt> or <tt><b>register_command_parser</b></tt></a> statements.</p><p>Either way, as described under <a href="makepp_statements.html#register_command_parser_command_word_parser"><tt><b>register_parser</b></tt></a>, there you must directly or indirectly (via a class) specify a function that creates a parser object. This object will usually create a scanner object for files, and feed it with its findings from the command line options. These two objects will call the parser's <tt>add_*_dependency</tt> methods which forward the information to the somewhat more complicated <tt>Mpp::Lexer::add_*_dependency</tt> utility functions.</p><p>However your parser function can also do this work itself for simple cases. There are a couple of special return values if this function doesn't return a parser object:</p><dl><dt id="undef"><b><tt>undef</tt></b></dt><dd><p>The scan info is not cacheable and must be recalculated next time the rule's target needs to be built.</p></dd><dt id="p_none_p_skip_word_or_p_shell"><b><tt>p_none, p_skip_word</tt> or <tt>p_shell</tt></b></dt><dd><p>These are in fact numeric constants, which tell the lexer to do the work of these pseudo-parsers.</p></dd><dt id="any_reference_e_g_1"><b>any reference, e.g. <tt>\1</tt></b></dt><dd><p>This is equivalent to returning a parser object of the <tt>Mpp::CommandParser</tt> base class, which will only additionally make the command executable itself a dependency.</p></dd></dl><p>In most cases, objects of type <tt>Mpp::CommandParser</tt> should instantiate at least one object of type <tt>Mpp::Scanner</tt>. The <tt>Mpp::Scanner</tt> base class takes care of the distinction between quickscan and smartscan. Note that the behavior of <tt>Mpp::Scanner</tt> can be markedly affected by this distinction, but that should be transparent to the derived class if it is well-formed. New derived <tt>Mpp::Scanner</tt> classes ought to be tested in both modes.</p><p>If you write your own <tt>Mpp::Scanner</tt> class, you should also base your rescanning decision on the build info <tt>RESCAN</tt>. This gets set by <tt>makeppreplay</tt> after signing files without scanning. So despite the signatures being consistent, a rescan is still necessary. If your <tt>Mpp::Scanner</tt> uses the inherited <tt>scan_file1</tt> method, you're probably fine.</p><p>For more details, refer to the respective class documentation. For examples, see <tt>Mpp::CommandParser::Gcc</tt> and <tt>Mpp::CommandParser::Vcs</tt>. Look at the <tt>p_</tt> functions in <i class="file">Mpp/Subs.pm</i> which get aliased into their respective classes as <tt>factory</tt> when loaded.</p><p></p><h2 id="caching_scanner_info">Caching scanner info</h2><p>If the all of the scanner's important side effects are effected through calls to methods of the <tt>Mpp::CommandParser</tt> base class, then those side effects can be cached in the build info file, so that they can be played back by a subsequent invocation of makepp without doing all of the costly scanning work. This can save quite a bit of time, especially in smartscan mode.</p><p>If the scanner has other important side effects, then it should call the <tt>Rule</tt> object's mark_scaninfo_uncacheable method. Otherwise, the scanner info retrieved from the build info may be inaccurate, causing the build result possibly to be incorrect. This method is called automatically when a value from the %parsers hash does not return an object of type <tt>Mpp::CommandParser</tt>, or when the parser is specified with a rule option and the <a href="makepplog.html#p"><tt>p_*</tt></a> routine does not return an object of type <tt>Mpp::CommandParser</tt>.</p><p>Cached scan info is invalidated using criteria similar to those used for determining when the target is out of date. Similarly, it can be retrieved from a repository using criteria similar to those used for determining when a target can be linked in from a repository.</p><p>You can force makepp to ignore the cached scanner info with the <a href="makepp_command.html#force_rescan"><tt><b>--</b>force-rescan</tt></a> option. This is useful when a broken scanner may have caused incorrect scanner info to be cached.</p><p></p><h2 id="ad_hoc_scanner">Ad Hoc Scanner</h2><p>Often you will have just one or few files which contain dependency information. You don't want to write this into a makefile redundantly (since redundancy later often leads to inconsistencies when one update gets forgotten). But you also don't want to write a Mpp::Scanner? As a workaround you can generate an include file on the fly. For example Qt has <i class="file">.qrc</i> files which can look like:</p><pre>&lt;RCC&gt;
  &lt;qresource prefix="..."&gt;
    &lt;file&gt;abc&lt;/file&gt;
    &lt;file&gt;xyz&lt;/file&gt;
    ...</pre><p>If you adhere to the above layout, you can transform the relevant lines into a makepp include file, which gets automatically created by being included.</p><pre><em>%.qrc.makepp</em>: %.qrc
    <b>&amp;grep</b> 's!&lt;RCC&gt;\n!<em>$(<i><b>stem</b></i>)</em>.cc:! || s! *&lt;file&gt;! ! &amp;&amp; s!&lt;/file&gt;\n!!' $(<i><b>input</b></i>) -o <em>$(<i><b>output</b></i>)</em>
<b>include</b> $(<i><b>wildcard</b></i> *.qrc)   <span class='comment'># .makepp is appended automatically</span><b class="tall"> </b></pre><p>Several variants of this are given in the <a href="makepp_cookbook.html#how_do_i_convert_a_file_into_dependencies">Cookbook</a>. The drawback is that you begin building while reading the makefile. So the <a href="makepp_command.html#loop">--loop</a> command option will not be so useful on the first iteration.</p><hr/><address>Last modified: 2013-04-22</address></div><div id='_clear'/></body></html>