This file is indexed.

/usr/share/doc/makepp/makepp_variables.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
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?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 Variables — How to use variables in makepp</title><link rel='next' href='makepp_command.html'/><link rel='prev' href='makepp_statements.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><a href='makepp_scanning.html'>Scanning</a></li><li><a href='makepp_signatures.html'>Signatures</a></li><li><a href='makepp_statements.html'>Statements</a></li><li><b>Variables</b></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 Variables</h1><p><b>How to use variables in makepp</b></p><ul><li><a href="#variable_assignment">Variable Assignment</a><ul><li><a href="#simple_assignment_operators">Simple assignment operators</a></li><li><a href="#multiline_variables">Multiline variables</a></li><li><a href="#exporting_variables_to_subprocesses">Exporting variables to subprocesses</a></li><li><a href="#sharing_variables_across_makefiles">Sharing variables across makefiles</a></li><li><a href="#target_specific_assignments">Target-specific assignments</a></li></ul></li><li><a href="#variable_substitution">Variable Substitution</a><ul><li><a href="#rc_style_substitution">rc-style substitution</a></li><li><a href="#substitution_references">Substitution References</a></li><li><a href="#whitespace_in_variables">Whitespace in variables</a></li></ul></li><li><a href="#automatic_variables">Automatic Variables</a></li><li><a href="#option_variables">Option Variables</a></li><li><a href="#predefined_variables">Predefined Variables</a></li><li><a href="#variables_and_perl">Variables and Perl</a></li></ul><p><b>?:</b>&nbsp;<a href="#stem"><em>$*</em></a>, <a href="#sorted_dependencies">$+</a>, <a href="#__">$&sol;</a>, <a href="#dependency">$&lt;</a>, <a href="#changed_dependencies">$?</a>, <a href="#output"><em>$@</em></a>, <a href="#dependencies">$^</a>, <a href="#_">=</a>, <a href="#__">!=</a>, <a href="#_26_">&amp;=</a>, <a href="#__">+=</a>, <a href="#__">:=</a>, <a href="#__">;=</a>, <a href="#_">?=</a>,&nbsp; <b>A:</b>&nbsp;<a href="#ar">AR</a>, <a href="#arflags">ARFLAGS</a>, <a href="#as">AS</a>,&nbsp; <b>C:</b>&nbsp;<a href="#cc">CC</a>, <a href="#cflags">CFLAGS</a>, <a href="#changed_dependencies">changed_dependencies</a>, <a href="#changed_dependencies">changed_inputs</a>, <a href="#curdir">CURDIR</a>, <a href="#cxx">CXX</a>, <a href="#cxxflags">CXXFLAGS</a>,&nbsp; <b>D:</b>&nbsp;<a href="#dependencies">dependencies</a>, <a href="#dependency">dependency</a>,&nbsp; <b>F:</b>&nbsp;<a href="#f77">F77</a>, <a href="#fc">FC</a>, <a href="#foreach">foreach</a>,&nbsp; <b>I:</b>&nbsp;<a href="#dependency">input</a>, <a href="#dependencies">inputs</a>,&nbsp; <b>L:</b>&nbsp;<a href="#ld">LD</a>, <a href="#lex">LEX</a>, <a href="#libtool">LIBTOOL</a>,&nbsp; <b>M:</b>&nbsp;<a href="#make">MAKE</a>, <a href="#makecmdgoals">MAKECMDGOALS</a>, <a href="#makeflags">MAKEFLAGS</a>, <a href="#makeinfo">MAKEINFO</a>, <a href="#makepp_debug">MAKEPP_DEBUG</a>, <a href="#makeppflags">MAKEPPFLAGS</a>, <a href="#_makeppflags">_MAKEPPFLAGS</a>, <a href="#makepp_ln_cp">MAKEPP_LN_CP</a>, <a href="#makepp_percent_subdirs">makepp_percent_subdirs</a>, <a href="#makepp_require_phony">makepp_require_phony</a>, <a href="#makepp_signature_c_flat">makepp_signature_C_flat</a>, <a href="#makepp_simple_concatenation">makepp_simple_concatenation</a>, <a href="#makepp_version">MAKEPP_VERSION</a>,&nbsp; <b>O:</b>&nbsp;<a href="#output">output</a>, <a href="#outputs">outputs</a>,&nbsp; <b>P:</b>&nbsp;<a href="makepp_rules.html#perl">PERL</a>, <a href="#pwd">PWD</a>,&nbsp; <b>R:</b>&nbsp;<a href="#rm">RM</a>, <a href="#root">ROOT</a>,&nbsp; <b>S:</b>&nbsp;<a href="#shell">SHELL</a>, <a href="#sorted_dependencies">sorted_dependencies</a>, <a href="#sorted_dependencies">sorted_inputs</a>, <a href="#stem">stem</a>,&nbsp; <b>T:</b>&nbsp;<a href="#output">target</a>, <a href="#outputs">targets</a>,&nbsp; <b>V:</b>&nbsp;<a href="#vpath">VPATH</a>,&nbsp; <b>Y:</b>&nbsp;<a href="#yacc">YACC</a></p><p>Makefiles typically use variables in many places. One important reason for using variables is to ensure that information is contained in only one place in the makefile, so that if it changes, there is no danger of the two copies of the information getting out of sync.</p><p>Variable names are case sensitive. In theory, variable names can be made of many characters, but makepp will probably not be able to grok it if you do anything other than alphanumeric characters, <tt>_</tt>, and <a href="makepp_rules.html#_"><tt><b>-</b></tt></a>.</p><p>Each makefile has its own set of variables, and setting a variable in one makefile will have no effect on its value in any other makefile. If you want to have variables set in many makefiles, the best way to do it is to have each of them include a common definitions file (see the <a href="makepp_statements.html#include_makefile">include statement</a>) or use <tt><b>global</b></tt> variables.</p><p></p><h2 id="variable_assignment">Variable Assignment</h2><p>A variable can assume a value in several different ways:</p><ul><li><p>A variable may be set inside a makefile. There are a number of different ways to do this; see below.</p></li><li><p>A variable's value may be specified on the command line, like this:</p><pre><b>makepp</b> CFLAGS=-O2 my_program</pre><p>If more than one makefile is loaded, the CFLAGS variable is propagated to all of the makefiles. Variables set on the command line automatically override any setting of the variable in any of the makefiles.</p><p>If ever needed, the makefile must in turn explicitly override command line settings. The intention is not to ignore what the user requests, but rather a way to modify it. The <tt><b>override</b></tt> modifier may precede any assignment statement. But in the case of keyword statements, the order is important, which is why the override variant is always shown below. The <tt><b>override</b></tt> modifier applies only to any assignments where it is present, and does not influence later assignments to the variable.</p></li><li><p>If a variable is set in the environment, it can be referenced as a makepp variable. Ordinarily assignments to variables inside a makefile override settings from the environment, but you can change this by using the <a href="makepp_command.html#e"><tt><b>-</b>e</tt></a> or <a href="makepp_command.html#environment_overrides"><tt><b>--</b>environment-overrides</tt></a> command line option.</p></li></ul><p>Variables are assigned with one of several assignment expressions, like this</p><pre><i>X</i> = 1
<i>MODULES</i> := a b c d
<i>CC</i> ?= gcc
<i>CFLAGS</i> += -Wall
<b>define</b> <i>VAR</i>
  var line 1
  var line 2
<b>enddef</b>
<b>export</b> <i>PATH</i> := $(<i><b>PWD</b></i>):$(<i>PATH</i>)
<b>global</b> <i>MYPROJECT.INFO</i> = info to be seen in all makefiles</pre><p>Leading and trailing whitespace around values is always stripped off.</p><p>The different assignment operators have somewhat different meanings.</p><p></p><h3 id="simple_assignment_operators">Simple assignment operators</h3><dl><dt id="_"><b>=</b></dt><dd><pre><i>VARIABLE</i> = text string
<b>override</b> <i>VARIABLE</i> = text string</pre><p>This is the usual assignment statement that all implementations of make support. The expression on the right hand side is not evaluated until the value of <tt>$(<i>VARIABLE</i>)</tt> is actually used somewhere. Thus, if you do the following:</p><pre><i>X</i> = 1
<i>Y</i> = $(<i>X</i>)
<i>X</i> = 2</pre><p>Then <tt>$(<i>Y</i>)</tt> later in the makefile will evaluate to &quot;2&quot;.</p><p>In general, you usually want to use <a href="#__"><tt>:=</tt></a> (see below) instead of <a href="#_"><tt>=</tt></a> because it provides more predictable variable evaluation. However, there are times when you need to defer the variable evaluation. Also, if you're writing a makefile that must be backwards-compatible with some version of make other than GNU make, then you have no choice: you may only use <a href="#_"><tt>=</tt></a>.</p></dd><dt id="__"><b>:=</b></dt><dd><pre><i>VARIABLE</i> := expr
<b>override</b> <i>VARIABLE</i> := expr</pre><p>This is the same as <tt><i>VARIABLE</i> = expr</tt> except that the right hand side is evaluated once and for all at the time of the assignment. Thus if</p><pre><i>X</i> := 1
<i>Y</i> := $(<i>X</i>)
<i>X</i> := 2</pre><p>then <tt>$(<i>Y</i>)</tt> later in the makefile will evaluate to &quot;1&quot; since that's what <tt>$(<i>X</i>)</tt> was when <tt>$(<i>Y</i>)</tt> was defined.</p></dd><dt id="__1"><b>;=</b></dt><dd><pre><i>VARIABLE</i> ;= expr
<b>override</b> <i>VARIABLE</i> ;= expr</pre><p>This is the same as <tt><i>VARIABLE</i> := expr</tt> except that the right hand side is evaluated only at the time of the first use and then remembered. This is useful for expensive commands, which always return the same value, but which you don't want to perform when building unrelated targets:</p><pre><i>VAR1</i> ;= $(<i><b>perl</b></i> expensive calculations)
<i>VAR2</i> ;= $(<i><b>shell</b></i> external command)</pre><p>Note that old makefiles will usually use <a href="#__"><tt>:=</tt></a> here, to at least do this only once. But with this operator you can even additionally not do it, if you currently don't need the value. For values which are identical in several directories, you can optimize this further with <tt><b>global</b></tt>, discussed below.</p><p>However this is not intended as a clever way to force order of evaluation. If a variable defined like this includes the value of another variable, and that other one has a target specific value, and the first expansion is for that target, then the target specific value will stick for all other contexts as well. This is a bug and will hopefully be fixed in the future.</p></dd><dt id="__2"><b>+=</b></dt><dd><pre><i>VARIABLE</i> += expr
<b>override</b> <i>VARIABLE</i> += expr</pre><p>Appends the string to the previous contents of the variable, separated by a space. If the variable was previously assigned with <a href="#__"><tt>:=</tt></a>, then the right hand side is evaluated before appending.</p></dd><dt id="__3"><b>&amp;=</b></dt><dd><pre><i>VARIABLE</i> &amp;= expr
<b>override</b> <i>VARIABLE</i> &amp;= expr</pre><p>Prepends the string to the previous contents of the variable, separated by a space. If the variable was previously assigned with <a href="#__"><tt>:=</tt></a>, then the right hand side is evaluated before appending.</p><p>For example one way of guaranteeing that <a href="#cflags"><tt>CFLAGS</tt></a>, whatever else the user may put in, always starts with <tt><b>-</b>Wall</tt> are these two lines:</p><pre><i>CFLAGS</i> = -O2                <span class='comment'># Possibly overridden on the command line</span>
<b>override</b> <i>CFLAGS</i> &amp;= -Wall    <span class='comment'># Unconditionally prepended</span></pre><p>In old makefiles you typically had to do something like this, which had the side effect of forcing the type to <a href="#__"><tt>:=</tt></a> to prevent endless recursion:</p><pre><i>VARIABLE</i> := expr $(<i>VARIABLE</i>)</pre></dd><dt id="_1"><b>?=</b></dt><dd><pre><i>VARIABLE</i> ?= expr
<b>override</b> <i>VARIABLE</i> ?= expr   <span class='comment'># Useless, but legal</span></pre><p>Sets the value of the variable, but only if the variable is not specified earlier in the makefile, on the command line, or in the environment. The above assignment is exactly equivalent to</p><pre><b>ifndef</b> <i>VARIABLE</i>
<i>VARIABLE</i> = expr
<b>endif</b></pre></dd><dt id="__4"><b>!=</b></dt><dd><pre><i>VARIABLE</i> != shell command
<b>override</b> <i>VARIABLE</i> != shell command</pre><p>Runs the shell command and sets the variable to contain the command's standard output. This is exactly equivalent to</p><pre><i>VARIABLE</i> := $(<i><b>shell</b></i> command)</pre></dd></dl><p></p><h3 id="multiline_variables">Multiline variables</h3><p>The <a href="makepp_statements.html#define"><tt><b>define</b></tt></a> statement is the multiline equivalent of the simple statements above. The operator after the variable is optional. If missing, it is equivalent to <tt><b>define</b> <i>VARIABLE</i> =</tt>. The <a href="#__"><tt>&amp;=</tt></a> and <a href="#__"><tt>+=</tt></a> operators are slightly different here, in that they glue this to the old value with a newline, rather than a space. There must not be anything except a comment after the statement, i.e. the value starts on the next line.</p><pre><b>define</b> <i>VARIABLE</i> :=
first line of variable's value
second line of variable's value
third line of variable's value
<b>endef</b></pre> <pre><b>override define</b> <i>VARIABLE</i>
...
<b>enddef</b></pre><p>Keywords before <a href="makepp_statements.html#define"><tt><b>define</b></tt></a> can be combinations of either one of <tt><b>export</b></tt> or <tt><b>global</b></tt> and <tt><b>override</b></tt>.</p><p>If you need a variable's value to contain newlines, you must use the <a href="makepp_statements.html#define"><tt><b>define</b></tt></a> statement as shown (or you can assign the value directly in Perl). (<tt><b>endef</b></tt> was chosen for compatibility with GNU make. You may also use <tt><b>enddef</b></tt>.) This is primarily useful for &quot;canned command sequences&quot;, e.g., something like this:</p><pre><b>define</b> <i>COMPILE_C_PROGRAM</i>
    <b>@&amp;echo</b> "Compiling $(<i><b>input</b></i>)"
    <b>@</b>$(<i>CC</i>) $(<i>CFLAGS</i>) $(<i>CPPFLAGS</i>) $(<i>INCLUDES</i>) -c $(<i><b>input</b></i>) -o <em>$(<i><b>output</b></i>)</em>
<b>endef</b></pre><p>Then you can use this multi-line variable in several rules, like this:</p><pre><em>%.o</em> : %.c
    $(<i>COMPILE_C_PROGRAM</i>)</pre> <pre><em>$(<i>ARCH</i>)/%.o</em> : $(<i>ARCH</i>)/%.c
    $(<i>COMPILE_C_PROGRAM</i>)</pre><p>Note that you can often achieve the same effect by using a semicolon instead of a newline, because the shell interprets that as a command delimeter too. For example,</p><pre><i>COMPILE_C_PROGRAM</i> = @echo "Compiling $(<i><b>input</b></i>)"; \
    $(<i>CC</i>) $(<i>CFLAGS</i>) $(<i>CPPFLAGS</i>) $(<i>INCLUDES</i>) -c $(<i><b>input</b></i>) -o <em>$(<i><b>output</b></i>)</em></pre><p>will have the same effect, except that the semicolon forces Perl to pass it to the shell, instead of executing the command directly and more efficiently. You also have to put each builtin on a line of its own, meaning that you have to switch to the external echo in the semicolon case.</p><p>There is one speciality when expanding within <a href="makepp_statements.html#define"><tt><b>define</b></tt></a>, i.e. <tt><b>define</b> <i>X</i> :=</tt> or on a variable that was already <a href="#__"><tt>:=</tt></a>, <tt><b>define</b> <i>X</i> &amp;=</tt> and <tt><b>define</b> <i>X</i> +=</tt>. In this case the <tt>$(<i><b>shell</b></i> command ...)</tt> or builtin <tt>$(&amp;command ...)</tt> do not get newlines transformed into spaces.</p><p></p><h3 id="exporting_variables_to_subprocesses">Exporting variables to subprocesses</h3><pre><b>export</b> <i>VAR</i> ...
<b>export</b> <i>VAR</i> = value
<b>override export</b> <i>VAR</i> += value</pre><p>The first form marks the given variables for export to subprocesses, with whatever value the variable then has. The second form, which applies only to one variable, additionally assigns a value right away. All the variants of assignment are allowed.</p><p></p><h3 id="sharing_variables_across_makefiles">Sharing variables across makefiles</h3><pre><b>global</b> <i>VAR</i> ...
<b>global</b> <i>VAR</i> = value
<b>override global</b> <i>VAR</i> &amp;= value</pre><p>The first form marks the given variables as global to all makefiles. If any of them already had a value, that value is moved from the makefile local variable to the global one. However if, at the time this statement is seen, any other makefiles already had a value for any of them, then those makefiles will not see the global one.</p><p>The second form, which applies only to one variable, additionally assigns a value right away. All the variants of assignment are allowed. Note that <a href="#__"><tt>:=</tt></a> will expand right away to the values in the local makefile. On the contrary <a href="#_"><tt>=</tt></a> variables will expand to the values at the point of use.</p><p>Global variables can be tricky to deal with, because makepp may load makefiles in any order, as the need arises to build some target for which no rule or makefiles is loaded. For this reason it is recommended to have a <i class="file">RootMakeppfile</i> and to explicitly load all others which modify or use the variable with <tt><b>load-makefile</b></tt>.</p><pre><b>global</b> <i>GLIBLIBS</i> ;= $(<i><b>shell</b></i> pkg-config --libs glib-2.0)</pre><p>Also note that your project may some day be built together with other projects. For this reason it is recommended to always make the project name part of any global variable name.</p><p></p><h3 id="target_specific_assignments">Target-specific assignments</h3><pre><em>target</em>: <i>VARIABLE</i> = string
<em>target</em>: <i>VARIABLE</i> := string
<em>target</em>: <b>override </b><i>VARIABLE</i> += string</pre><p>Sets a target-specific value of the variable. A target-specific value is in effect <i>only</i> in an action which produces the given target. This is primarily used for things like this:</p><pre><i>CFLAGS</i> := -O2
<em>my_prog</em>: file1.o file2.o special_file.o<b class="tall"> </b>
<em>special_file.o</em> : <i>CFLAGS</i> := -g<b class="tall"> </b>
<em>%.o</em>: %.c<b class="tall"> </b>
      $(<i>CC</i>) $(<i>CFLAGS</i>) -c $(<i><b>input</b></i>) -o <em>$(<i><b>output</b></i>)</em></pre><p>What happens here is that all <a href="makeppreplay.html#c"><tt>.c</tt></a> files will be compiled with optimization (<tt><b>-</b>O2</tt>) <i>except</i> <tt>special_file.c</tt>, which is compiled in debug mode (<a href="makeppgraph.html#g"><tt><b>-</b>g</tt></a>). This is a convenient way to specify different compilation options for only a few files.</p><p>Target-specific variable assignments like this apply only to the actions of the rule; they are not in effect when evaluating the targets or the dependencies of a rule. If a rule has more than one target, target-specific variable assignments are taken only from the <i>first</i> target. Also note that makepp's target-specific variables are slightly different from GNU make's in that they only apply to the rule for the one file mentioned, and not to any of its predecessors.</p><p>Wildcard expansion is performed on the target, so you can do something like this:</p><pre><em>test_*.o</em> : <i>CFLAGS</i> += -DTEST</pre><p>For compatibility with GNU make, <tt>%</tt> may be used in place of <a href="makepp_tutorial.html#_"><tt>*</tt></a>.</p><p></p><h2 id="variable_substitution">Variable Substitution</h2><p>Makepp's variable substitution rules are similar to those of other makes, but somewhat more powerful. As in all makes, <tt>$(<i>CC</i>)</tt> or <tt>${<i>CC</i>}</tt> both represent the value of the variable CC. If you need a literal dollar sign, put in a double dollar sign (<tt>$$</tt>), like this:</p><pre><em>target</em>: dep1 dep2 dep3 dep4
    <b>&amp;rm</b> -f <em>$(<i><b>output</b></i>)</em>
    for file in $(<i><b>inputs</b></i>); do cat $$file &gt;&gt; <em>$(<i><b>output</b></i>)</em>; done</pre><p>Additionally makepp has a <tt>$[VARIABLE]</tt> syntax, which does the same thing as the other two, but before makepp groks anything else. This allows using it for complete rules and/or conditionals:</p><pre><b>define</b> <i>bracket_rule</i> =
<b>  ifdef</b> SOME_VAR
    <em>bracket</em>:
        <b>&amp;echo</b> this is a rule -o <em>$(<i><b>output</b></i>)</em>
  endif
<b>enddef</b></pre> <pre>$[bracket_rule]</pre><p></p><h3 id="rc_style_substitution">rc-style substitution</h3><p>By default, makepp uses rc-style substitution (so called because it was pioneered by the rc shell). This is best illustrated by an example:</p><pre><i>MODULES</i> = a b c d
<em>mylib.a</em> : module_dir/$(<i>MODULES</i>).o $(<i>OTHER_OBJECTS</i>)<b class="tall"> </b>
    $(<i>CXX</i>) $(<i><b>dependencies</b></i>) -o <em>$(<i><b>target</b></i>)</em></pre><p>The prefix <tt>module_dir/</tt> is prepended to each word in MODULES, and the suffix <tt>.o</tt> is appended to each word.</p><p>You can also use rc-style substitution without even putting the list of words into a variable; the syntax is <tt>$(&nbsp;word1&nbsp;word2)</tt>. Note the space between the parenthesis and the first word. So the above example could have been written as:</p><pre><em>mylib.a</em> : module_dir/$( a b c d).o $(<i>OTHER_OBJECTS</i>)
    $(<i>CXX</i>) $(<i><b>dependencies</b></i>) -o <em>$(<i><b>target</b></i>)</em></pre><p>A variable will give rc-style substitution only when there is more than one word in it. With one word it is like traditional make. Alas, when the variable is empty, there is a conflict. Traditional makes simply expand it to the empty string. But when you think of it as a list, you'd want <tt><b>-</b>I$(<i>DIRLIST</i>)</tt> to disapear, not to give a lonely <a href="makepp_builtins.html#i"><tt><b>-</b>I</tt></a>. The solution is to wrap it into a list that starts with a space: <tt><b>-</b>I$( $(<i>DIRLIST</i>))</tt> gives you exactly as many options, as there are words in the list.</p><p>If you put several variables in the same word which expand to arrays of words, rc-style substitution actually takes the cartesian product, so you can do something like this if you want:</p><pre><i>DIRS</i> = s1 s2
<i>MODULES</i> = a b c
<i>SUFFIXES</i> = .o .c
<i>FILES</i> := $(<i>DIRS</i>)/$(<i>MODULES</i>)$(<i>SUFFIXES</i>)</pre><p>and FILES will contain the string</p><pre>s1/a.o s1/a.c s1/b.o s1/b.c s1/c.o s1/c.c s2/a.o s2/a.c s2/b.o s2/b.c s2/c.o s2/c.c</pre><p>Besides white space, rc-style substitution stops at any quote, any round, curly or square parentheses, and any of <tt>, : ; = # @</tt>. Note that this may be surprising, and again need an explicit list. Say you want to look for headers by wildcard in all directories starting with an upper-case letter:</p><pre><i>BAD</i> := [A-Z]*/**/*.$( hpp h)        <span class='comment'># [A-Z]*/**/*.hpp */**/*.h</span>
<i>GOOD</i> := $( [A-Z]*/**/*.)$( hpp h)   <span class='comment'># [A-Z]*/**/*.hpp [A-Z]*/**/*.h</span></pre><p>If rc-style substitution gets in the way, or if you need to have leading or trailing whitespace in your make variables, then you can turn off rc-style substitution by setting the variable <tt><i>makepp_simple_concatenation</i>=1</tt>. You can turn it off globally on the command line or as an environment variable. Or on a per-makefile basis by setting the variable in your makefile. You should do this near the top of the makefile, or else you may run into funny situations where rc-style substitution is used for some evaluations and not others. (All expressions evaluated before the assignment will use rc-style substitutions, and all expressions evaluated after will not. Since the time of evaluation of expressions in makefiles is complicated and not always obvious from the order of statements in the makefile, it's best to set <a href="#makepp_simple_concatenation"><tt>makepp_simple_concatenation</tt></a> as early as possible.) You can even set it just for one target:</p><pre><em>target</em>: <i>makepp_simple_concatenation</i> = 1
<em>target</em>:
    <b>&amp;echo</b> before_first$(<i>LIST</i>)after_last -o <em>$(<i><b>output</b></i>)</em></pre><p>Because <tt>$[VARIABLE]</tt> is evaluated earlier than <tt>$(<i>VARIABLE</i>)</tt>, combining the two in rc-substitution will not give the result you may expect, unless you wrap it in an explicit list:</p><pre><i>A</i> = a b
<i>N</i> = 1 2
<i>BAD</i> := $(<i>A</i>)$[N]
<i>GOOD</i> := $(<i>A</i>)$( $[N])</pre><p>The last lines get read as</p><pre><i>BAD</i> := $(<i>A</i>)1 2      <span class='comment'># a1 b1 2</span>
<i>GOOD</i> := $(<i>A</i>)$( 1 2) <span class='comment'># a1 a2 b1 b2</span></pre><p></p><h3 id="substitution_references">Substitution References</h3><p>A substitution reference has the form <tt>$(<i>VAR</i>:A=B)</tt>, where A is a pattern to match and B is a pattern to replace it with. Substitution references are an abbreviation for the <tt>patsubst</tt> function. For example:</p><pre><i>source_files</i> = a.c b.c c.c d.c
<i>object_files</i> = $(<i>source_files</i>:%.c=%.o)</pre><p>will set <tt>$(<i>object_files</i>)</tt> to <tt>a.o&nbsp;b.o&nbsp;c.o&nbsp;d.o</tt>. The <tt>%</tt> is a special character matches any arbitrary string. If both A and B start with <tt>%</tt>, a common case when replacing suffixes, they can be omitted:</p><pre><i>object_files</i> = $(<i>source_files</i>:.c=.o)
<i>object_files</i> = $(<i>source_files</i>:c=o) <span class='comment'># same, because . is not special</span></pre><p></p><h3 id="whitespace_in_variables">Whitespace in variables</h3><p>If you need to control the whitespace in a variable, you must (currently) disable rc-style substitution (by setting <tt><i>makepp_simple_concatenation</i>=1</tt>) and then use a syntax like this:</p><pre><i>null</i> =
<i>T</i> = -o $(<i>null</i>)</pre><p>or, with an empty evaluation:</p><pre><i>T</i> = -o $()</pre><p>When you do this, the variable <tt>T</tt> contains <tt><b>-</b>o</tt> followed by a space.</p><p>This kind of a technique to handle whitespace is not recommended. If you need variables in your makefile to contain spaces, you should think seriously about what you're doing. If you need to handle spaces, it is usually much better to put Perl code into your makefile to take care of it (using the <a href="makepp_statements.html#perl_begin"><tt><b>perl_begin</b></tt></a> or <a href="makepp_statements.html#sub"><tt><b>sub</b></tt></a> statements), or to handle it in shell statements in the actions of rules.</p><p>These cases typically come up when people attempt to use the same rules for different architectures which do not use typical Unix command syntax. E.g., sometimes one sees things like this in makefiles:</p><pre><b>ifeq</b> ($(<i>ARCH</i>),weirdarch)
<i>O</i> := /OUTPUT=
<b>else</b>
<i>null</i> :=
<i>O</i> := -o $(<i>null</i>)
<b>endif</b>
<em>%.o</em> : %.c<b class="tall"> </b>
    $(<i>COMPILER</i>) $(<i><b>input</b></i>) $(<i>O</i>)<em>$(<i><b>output</b></i>)</em></pre><p>You can do this with makepp if you really want to, but you will probably find that your makefiles are substantially more readable if you have less complicated variable substitution, e.g.,</p><pre><b>ifeq</b> ($(<i>ARCH</i>),weirdarch)
  <em>%.o</em> : %.c
    $(<i>WEIRD_COMPILER</i>) $(<i><b>input</b></i>) /OUTPUT=<em>$(<i><b>output</b></i>)</em>
<b>else</b>
  <em>%.o</em> : %.c
    $(<i>CC</i>) -c $(<i><b>input</b></i>) -o <em>$(<i><b>output</b></i>)</em>
<b>endif</b></pre><p>Whitespace is never allowed in variable names, only in their values. This is different from some make implementations.</p><p></p><h2 id="automatic_variables">Automatic Variables</h2><p>Automatic variables are variables that assume different values depending on which rule they are evaluated in. Makepp supports most of the automatic variables that other versions of make use. In addition, it has less cryptic, longer names for most of them that you can use instead. (For legacy makefiles that happen to redefine these names, the definition in the makefile overrides the default meaning. For example, if you say <tt>target&nbsp;=&nbsp;abc</tt> in your makefile, then <tt><em>$(<i><b>target</b></i>)</em></tt> will always expand to <tt>abc</tt>, and will no longer be equivalent to <a href="#__"><tt><em>$@</em></tt></a>.)</p><p>The following is a complete list of all the automatic variables that makepp supports:</p><dl><dt id="output"><b>output</b></dt><dt id="target"><b>target</b></dt><dt id="__5"><b>$@</b></dt><dd><p>The target of the current rule. Actually, since makepp supports multiple targets for any rule, this is the <b>first</b> target. For example, in the following rule</p><pre><em>y.tab.c y.tab.h</em> : <b>parser</b>.y
    $(<i>YACC</i>) -o <em>$(<i><b>output</b></i>)</em> $(<i>YFLAGS</i>) $(<i><b>input</b></i>)</pre><p><a href="makepp_tutorial.html#__output_"><tt><em>$(<i><b>output</b></i>)</em></tt></a> will contain the value <i class="file">y.tab.c</i>. Since these magic variables are in fact functions, you can also pass an index as argument. This counts from 1 or backwards from -1. So <tt><em>$(<i><b>output</b></i></em> 2)</tt> or <tt><em>$(<i><b>output</b></i></em> -1)</tt> will contain the value <i class="file">y.tab.h</i>.</p><p>While all three forms of this variable have the same value, there is a difference in interpretation for multitarget rules. If you use the old-style cryptic name <a href="#__"><tt><em>$@</em></tt></a>, makepp will interpret that as an old-style rule set, rather than a modern rule that produces all those targets in one go:</p><pre><em>a b</em>:                        <span class='comment'># really: one rule each for a and b</span>
    touch <em>$@</em>
<em>c d</em>:                        <span class='comment'># error: mpp complains that this didn't build d</span><b class="tall"> </b>
    touch <em>$(<i><b>output</b></i>)</em></pre></dd><dt id="outputs"><b>outputs</b></dt><dt id="targets"><b>targets</b></dt><dd><p>All targets of the current rule. Same as <tt><em>$(<i><b>target</b></i>)</em></tt> unless there is more than one target. In the above example, <a href="makepp_tutorial.html#__outputs_"><tt><em>$(<i><b>outputs</b></i>)</em></tt></a> will be y.tab.c y.tab.h. You can pass an index list, so <tt><em>$(<i><b>outputs</b></i></em> 2 1)</tt> will be y.tab.h y.tab.c.</p></dd><dt id="dependency"><b>dependency</b></dt><dt id="input"><b>input</b></dt><dt id="__6"><b>$&lt;</b></dt><dd><p>The first explicit dependency of the rule. For example, in this rule</p><pre><em>%.o</em> : %.c
    $(<i>CC</i>) $(<i>CFLAGS</i>) -c $(<i><b>input</b></i>) -o <em>$(<i><b>output</b></i>)</em></pre><p><a href="makepp_tutorial.html#__input_"><tt>$(<i><b>input</b></i>)</tt></a> will be the name of the <i class="file">.c</i> file, regardless of what <i class="file">.h</i> files makepp discovers. If you specify more than one dependency, you can get them by passing an index: <tt>$(<i><b>input</b></i> $(<i>INDEX</i>))</tt> is the INDEXth dependency.</p></dd><dt id="dependencies"><b>dependencies</b></dt><dt id="inputs"><b>inputs</b></dt><dt id="__7"><b>$^</b></dt><dd><p>All the explicit dependencies of the target, not including <i class="file">.h</i> files discovered by <a href="makepp_scanning.html">the makepp_scanning manpage</a> for includes.</p><p>For example, in the rule</p><pre><em>myprog.o</em> : *.o
    $(<i>CC</i>) $(<i>CFLAGS</i>) $(<i><b>inputs</b></i>) -o <em>$(<i><b>output</b></i>)</em></pre><p><a href="makepp_tutorial.html#__inputs_"><tt>$(<i><b>inputs</b></i>)</tt></a> will be all the .o files in the directory. You can pick only the ones you want by passing an index list. If you explicitly specify different kinds of files, you can pick them as in <tt>$(<i><b>inputs</b></i> 2 3 4)</tt> (but with a wildcard this is not too promising).</p></dd><dt id="sorted_dependencies"><b>sorted_dependencies</b></dt><dt id="sorted_inputs"><b>sorted_inputs</b></dt><dt id="__8"><b>$+</b></dt><dd><p>All the dependencies of the target, in sorted order, with duplicates removed. Equivalent to <tt>$(<i><b>sort</b></i>&nbsp;$(<i><b>inputs</b></i>))</tt>.</p></dd><dt id="changed_dependencies"><b>changed_dependencies</b></dt><dt id="changed_inputs"><b>changed_inputs</b></dt><dt id="_2"><b>$?</b></dt><dd><p>The dependencies of the target that have changed. This includes only explicit dependencies (i.e., ones you list in the makefile), not implicitly discovered dependencies from scanning (such as .h files).</p><p>This is commonly used in commands like this:</p><pre><em>libmine.a</em> : $(<i>MODULES</i>) : <b>build_check</b> <em>ignore_action</em>
    $(<i>AR</i>) ru <em>$@</em> $?</pre><p>i.e., <i class="file">ar</i> is told to replace only those modules that have changed. (Note the <a href="makepp_build_check.html#ignore_action"><tt>ignore_action</tt></a> build check rule. If you don't specify this, makepp will force the action to be executed whenever it changes. If no dependencies have changed, the action string will be <tt>ar&nbsp;ru libmine.a</tt> which is probably different from what it was last time you ran it, so without <a href="makepp_build_check.html#ignore_action"><tt>ignore_action</tt></a> makepp will execute it. In this case, it's harmless, but with other commands, it could be a problem. See <a href="makepp_build_check.html">the makepp_build_check manpage</a> for details on <a href="makepp_build_check.html#ignore_action"><tt>ignore_action</tt></a>.)</p><p>Building archives like this is not a good idea because it will make your builds less reliable. The problem with this is that if you build the archive, then remove one of the modules from the list of MODULES, the modules will still be in the archive and makepp</p></dd><dt id="stem"><b>stem</b></dt><dt id="__9"><b>$*</b></dt><dd><p>The stem in a pattern rule (i.e., whatever the '%' matched). Alternatively, if this is not a pattern rule, returns the file name without the extension (i.e., it's equivalent to <tt>$(<i><b>basename</b></i>&nbsp;$(<i><b>input</b></i>))</tt>.</p><p>This is mostly for backward compatibility. For example, in old versions of make the only way to tell it how to compile any <i class="file">.c</i> file into the corresponding <i class="file">.o</i> file was like this:</p><pre><em>.c.o</em>:
    $(<i>CC</i>) $(<i>CFLAGS</i>) -c <em>$*</em>.c -o <em>$*</em>.o</pre><p>This is a lousy way to write the rule. It's much clearer to use GNU-make style pattern rules, like this:</p><pre><em>%.o</em> : %.c
    $(<i>CC</i>) $(<i>CFLAGS</i>) -c $(<i><b>input</b></i>) -o <em>$(<i><b>output</b></i>)</em></pre></dd><dt id="foreach"><b>foreach</b></dt><dd><p>The current filename from the <a href="#foreach"><tt>foreach</tt></a> clause. <a href="#foreach"><tt>foreach</tt></a> clauses are rarely used, but they are the most general-purpose kind of pattern rule that makepp supports. For example,</p><pre><span class='comment'>#</span>
<span class='comment'># Build .c files with some sort of a special preprocessor:</span>
<span class='comment'>#</span>
<em>%.c</em> : %.k
    $(<i>preprocessor</i>) $(<i><b>input</b></i>) &gt; <em>$(<i><b>output</b></i>)</em>
<span class='comment'>#</span><b class="tall"> </b>
<span class='comment'># Compile .c files into .o files:</span>
<span class='comment'>#</span>
<em>%.o</em> : %.c
    $(<i>CC</i>) $(<i>CFLAGS</i>) -c $(<i><b>input</b></i>) -o <em>$(<i><b>output</b></i>)</em>
<span class='comment'>#</span><b class="tall"> </b>
<span class='comment'># Special alternate compilation flags for .c files which are derived</span>
<span class='comment'># from .k files:</span>
<span class='comment'>#</span>
<em>$(<i><b>foreach</b></i></em>:%.k=%.o) : $(<i><b>foreach</b></i>:%.k=%.c) : <b>foreach</b> *.k
    $(<i>CC</i>) $(<i>SPECIAL_K_FLAGS</i>) -c $(<i><b>input</b></i>) -o <em>$(<i><b>output</b></i>)</em></pre><p>See the documentation on <a href="makepp_rules.html#foreach_rules">the foreach clause in rules</a> for more details and examples.</p></dd><dt id="__10"><b>$/</b></dt><dd><p>This is essentially a constant, either <tt>/</tt>, or on native Windows <tt>\</tt>. You need it, if you want to start a program portably, e.g. one you built in the current directory:</p><pre><em>myoutput</em>:
    .$/myprog &gt;<em>$(<i><b>output</b></i>)</em></pre><p>For filenames passed as arguments it is not so necessary as Windows can handle Unix syntax there.</p></dd></dl><p></p><h2 id="option_variables">Option Variables</h2><p>You can set these in all the ways explained <a href="#variable_assignment">above</a> (except if stated otherwise) to modify the bahaviour of makepp. By default they are all undefined.</p><dl><dt id="makepp_debug"><b>MAKEPP_DEBUG</b></dt><dd><p>If you export this with a true value before calling makepp, you get more debugging info. This is the <tt>RULE_SOURCE</tt> of files built while this is in effect under <a href="makeppinfo.html">makeppinfo, mppi</a> and details about variable expansion and rule matching under <a href="makepplog.html">makepplog, mppl</a>. This will also show you if makepp runs out of memory or hangs, because it is endlessly expanding the same variables:</p><pre><i>A</i> = $A                      <span class='comment'># deferred evaluation, need :=</span>
<i>B</i> = $C
<i>C</i> = $B</pre></dd><dt id="makepp_ln_cp"><b>MAKEPP_LN_CP</b></dt><dd><p>See the note under <a href="makepp_builtins.html#ln_option_sourcefile_destfile">&amp;ln</a>.</p></dd><dt id="makepp_percent_subdirs"><b>makepp_percent_subdirs</b></dt><dd><p>Set this to some true value (like <tt>1</tt>) to have <tt>%</tt> in targets or dependencies match across more than one directory.</p></dd><dt id="makepp_require_phony"><b>makepp_require_phony</b></dt><dd><p>Set this to some true value (like <tt>1</tt>) to prevent implicit phonyness (i.e. if a rule succeeds without producing its target). This variable should be true by default, to prevent broken dependency chains, but that would break backward compatibility with sloppy makefiles.</p></dd><dt id="makepp_signature_c_flat"><b>makepp_signature_C_flat</b></dt><dd><p>This is an option to <a href="makepp_signatures.html#c">signature C</a>. Set this to some true value (like <tt>1</tt>) to treat your sources as flattened, i.e. all newlines (except around preprocessor statements) are treated like whitespace and <tt>#line</tt> directives are ignored.</p></dd><dt id="makepp_simple_concatenation"><b>makepp_simple_concatenation</b></dt><dd><p>Set this to some true value (like <tt>1</tt>) to prevent <a href="makepp_tutorial.html#rc_style_substitution">rc-style substitution</a>.</p></dd><dt id="perl"><b>PERL</b></dt><dd><p>You can set this to the exact perl you are using to run the scripts in the makepp suite, and export it. This can help to run sub-scripts with the same perl. This is mostly useful for the test suite, the <a href="makepp_faq.html#how_to_choose_perl_version">installation</a> and for <a href="#make">recursive builds</a>.</p></dd><dt id="vpath"><b>VPATH</b></dt><dd><p>Setting this variable to some value implicitly calls <tt><b>vpath</b> % value</tt>.</p></dd></dl><p></p><h2 id="predefined_variables">Predefined Variables</h2><p>Makepp predefines a few variables, which you can override:</p><dl><dt id="ar"><b>AR</b></dt><dd><p><i>Default:</i> <tt>ar</tt>.</p></dd><dt id="arflags"><b>ARFLAGS</b></dt><dd><p><i>Default:</i> <tt>rv</tt>.</p></dd><dt id="as"><b>AS</b></dt><dd><p><i>Default:</i> <tt>as</tt>.</p></dd><dt id="cc"><b>CC</b></dt><dd><p><i>Default:</i> The first found among <tt>gcc</tt>, <tt>egcc</tt>, <tt>pgcc</tt>, <tt>c89</tt> or <tt>cc</tt>, or on Windows additionally <tt>cl</tt> or <tt>bcc32</tt>.</p></dd><dt id="cflags"><b>CFLAGS</b></dt><dd><p><i>Default:</i> If <tt>$(<i>CC</i>)</tt> is a GNU compiler <tt><b>-</b>g -Wall</tt>, if it is one of the two Windows compilers nothing, else <a href="makeppgraph.html#g"><tt><b>-</b>g</tt></a>.</p></dd><dt id="curdir"><b>CURDIR</b></dt><dd><p>The directory in which the current Makefile resides.</p></dd><dt id="cxx"><b>CXX</b></dt><dd><p><i>Default:</i> The first found among <a href="makeppgraph.html#g"><tt>g++</tt></a>, <a href="makeppreplay.html#c"><tt>c++</tt></a>, <tt>pg++</tt>, <tt>cxx</tt>, <a href="makepp_signatures.html#c"><tt>C</tt></a><a href="makepp_signatures.html#c"><tt>C</tt></a> or <tt>aCC</tt>, or on Windows additionally <tt>cl</tt> or <tt>bcc32</tt>.</p></dd><dt id="cxxflags"><b>CXXFLAGS</b></dt><dd><p><i>Default:</i> If <tt>$(<i>CXX</i>)</tt> is a GNU compiler <tt><b>-</b>g -Wall</tt>, if it is one of the two Windows compilers nothing, else <a href="makeppgraph.html#g"><tt><b>-</b>g</tt></a>.</p></dd><dt id="f77"><b>F77</b></dt><dd><p><i>Default:</i> The first found among <tt>f77</tt>, <tt>g77</tt> or <tt>fort77</tt>.</p></dd><dt id="fc"><b>FC</b></dt><dd><p><i>Default:</i> <tt>$(<i>F77</i>)</tt>.</p></dd><dt id="ld"><b>LD</b></dt><dd><p><i>Default:</i> <tt>ld</tt>.</p></dd><dt id="lex"><b>LEX</b></dt><dd><p><i>Default:</i> The first found among <tt>lex</tt> or <tt>flex</tt>.</p></dd><dt id="libtool"><b>LIBTOOL</b></dt><dd><p><i>Default:</i> <tt>libtool</tt>.</p></dd><dt id="make"><b>MAKE</b></dt><dd><p>This variable has two different values, depending on the presence or not of <a href="makepp_command.html#traditional_recursive_make"><tt><b>--</b>traditional-recursive-make</tt></a>. Makepp recognizes when this variable is used and turns off some features, even before the recursion actually takes place. This can be undesirable while you are gradually eliminating it, so first convert the calls to a makepp specific <tt>$((<i>MAKE</i>))</tt>, which will not turn off features. You should not set it because that breaks our smart recursion work around.</p></dd><dt id="makecmdgoals"><b>MAKECMDGOALS</b></dt><dd><p>This variable is set but not used by makepp. You can query it to do something only if a certain target was requested.</p><p><i>Default:</i> Whatever explicit targets the user (or a recursive invocation) provided. Empty when implicitly building default target.</p><pre><b>ifneq</b> $(<i><b>filter</b></i> special-target, $(<i>MAKECMDGOALS</i>))
    <span class='comment'># special-target is one of the current explicit targets</span>
<b>else ifeq</b> $(<i>MAKECMDGOALS</i>)
    <span class='comment'># no explicit targets</span>
<b>endif</b></pre></dd><dt id="makeflags"><b>MAKEFLAGS (exported)</b></dt><dd><p>The standard options with which makepp was called. Those that have a single letter form are combined at the beginning without a leading <a href="makepp_rules.html#_"><tt><b>-</b></tt></a> (heaven knows why gmake chose to drop the <a href="makepp_rules.html#_"><tt><b>-</b></tt></a>).</p></dd><dt id="makeinfo"><b>MAKEINFO</b></dt><dd><p><i>Default:</i> <tt>makeinfo</tt>.</p></dd><dt id="makeppflags"><b>MAKEPPFLAGS (exported)</b></dt><dd><p>This is set to the same value as MAKEFLAGS, but only if this variable is present in makepp's environment.</p></dd><dt id="_makeppflags"><b>_MAKEPPFLAGS (exported)</b></dt><dd><p>The makepp specific options needed for POSIX/gmake compatibility, with which makepp was called. These are in a separate variable so a legacy makefile can't break compatibility by unsetting MAKEFLAGS. This is only set with <a href="makepp_command.html#traditional_recursive_make"><tt><b>--</b>traditional-recursive-make</tt></a>.</p></dd><dt id="makepp_version"><b>MAKEPP_VERSION</b></dt><dd><p>The version of makepp you are running with. If it is a beta version, it will have a hyphen followed by YYMMDD plus some more internal data. You can use this for <tt><b>ifdef</b></tt> to hide makepp specific constructs from other makes.</p><p><i>Default:</i> The same value displayed by <tt>makepp --version</tt></p></dd><dt id="pwd"><b>PWD</b></dt><dd><p>An alias for <a href="#curdir">CURDIR</a>.</p></dd><dt id="rm"><b>RM</b></dt><dd><p><i>Default:</i> <tt>rm -f</tt>. This is meant for legacy Makefiles. For new ones preferably use the builtin <a href="makepp_builtins.html#rm_option_filename">&amp;rm</a> command directly. If you want to write a phony clean rule, look at the <tt>makeppclean -r</tt> command instead.</p></dd><dt id="root"><b>ROOT</b></dt><dd><p>The relative path to the root of your build system, i.e. the directory further up in which you have a <tt>RootMakeppfile(.mk)</tt>. If you don't have one, this variable is empty.</p></dd><dt id="shell"><b>SHELL</b></dt><dd><p>This variable is only respected if you <tt><b>export</b></tt> it. In that case it is the Shell which is used to execute not-builtin actions with some special character in it (plain ones being exec`ed directly). On Windows Strawberry or ActiveState Perl, if you have a Unix-like Shell, you must instead set your SHELL variable to a value ending in <tt>sh</tt> or <tt>sh.exe</tt> <b>before</b> calling makepp.</p><p><i>Default:</i> The first found among <tt>/usr/xpg4/bin/sh</tt> (e.g. Solaris) or <tt>/sbin/xpg4/sh</tt> (e.g. Reliant Unix) or <tt>/bin/sh</tt>.</p></dd><dt id="yacc"><b>YACC</b></dt><dd><p><i>Default:</i> The first found among <tt>bison -y</tt> or <tt>yacc</tt>.</p></dd></dl><p></p><h2 id="variables_and_perl">Variables and Perl</h2><p>Variable values are stored as ordinary Perl scalars, so you can access them directly from Perl code if you need to do any complicated manipulations with them; see <a href="makepp_extending.html">the makepp_extending manpage</a> for details.</p><p>Accessing global variables from Perl is achieved by prefixing them with the <tt>Mpp::global</tt> package. In fact any variable, not yet present in the current makefile, and which you assign to in this package will from then on be global, as though you had just issued the <tt><b>global</b></tt> statement for it.</p><p>This direct access is however error-prone! The user may have overridden these variables on the command line or through the environment. Some other makefile loaded before this one may have made the variable global or target specific. In these cases you would not find the value of the variable, or when assigning it, might take away its property (equivalent to an <tt><b>override</b></tt> modifier, except for target specifics.)</p><p>With direct access you also bypass the expansion of these variables, if they are of type <a href="#_"><tt>=</tt></a> or <a href="#__"><tt>;=</tt></a>. Special variables like <tt>$(<i>CC</i>)</tt> start out as functions, until they are assigned to. So in many cases you won't see their value.</p><p>For these reasons it is better to let makepp determine the correct value. You can use the <a href="makepp_rules.html#makeperl"><tt><b>makeperl</b></tt></a> variant, in which the variable has been evaluated before the Perl code gets interpreted:</p><pre><b>makeperl </b>{ $$current_value = '$(<i>MAKEFILE_VAR</i>)' }</pre><p>If you need a variable in makefile perl blocks this is achieved via the Perl variable <tt>$makefile</tt> as follows:</p><pre><b>perl </b>{ $current_value = $makefile-&gt;expand_variable( 'MAKE_VAR' ) }</pre><p>Functions always get the makefile object passed in as the second argument <tt>$_[1]</tt>:</p><pre><b>sub</b> <i>f_f</i> { $current_value = $_[1]-&gt;expand_variable( 'MAKE_VAR' ) }</pre><p>Commands are supposed to be called within a rule action, where the makefile object is accessible via <tt>$Mpp::Subs::rule-&gt;{MAKEFILE}</tt>:</p><pre><b>sub</b> <i>c_cmd</i> { $current_value = $Mpp::Subs::rule-&gt;{MAKEFILE}-&gt;expand_variable( 'MAKE_VAR' ) }</pre><p></p><hr/> <address><a href="mailto:holt-makepp@gholt.net">Gary Holt</a><br/>Last modified: 2013-08-19</address></div><div id='_clear'/></body></html>