diff options
Diffstat (limited to 'en_US.ISO8859-1/books/pmake/shortcuts/chapter.xml')
-rw-r--r-- | en_US.ISO8859-1/books/pmake/shortcuts/chapter.xml | 130 |
1 files changed, 63 insertions, 67 deletions
diff --git a/en_US.ISO8859-1/books/pmake/shortcuts/chapter.xml b/en_US.ISO8859-1/books/pmake/shortcuts/chapter.xml index 9c7a90cac9..6383e90286 100644 --- a/en_US.ISO8859-1/books/pmake/shortcuts/chapter.xml +++ b/en_US.ISO8859-1/books/pmake/shortcuts/chapter.xml @@ -2,8 +2,7 @@ <!-- $FreeBSD$ --> - -<chapter id="shortcuts"> +<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="shortcuts"> <title>Short-cuts and Other Nice Things</title> <para>Based on what I have told you so far, you may have gotten the @@ -18,7 +17,7 @@ what you are using) than I did in <xref linkend="basics"/>, just so you are on your toes. So without further ado…</para> - <section id="rules"> + <section xml:id="rules"> <title>Transformation Rules</title> <para>As you know, a file's name consists of two parts: a base @@ -47,7 +46,7 @@ together. Suffixes are made known to <application>PMake</application> by placing them as sources on a dependency line whose target is the special - target <makevar>.SUFFIXES</makevar>. E.g.:</para> + target <varname>.SUFFIXES</varname>. E.g.:</para> <programlisting>.SUFFIXES : .o .c .c.o : @@ -73,7 +72,7 @@ <orderedlist> <listitem> - <para>The <makevar>.IMPSRC</makevar> variable. + <para>The <varname>.IMPSRC</varname> variable. This variable is set to the <quote>implied source</quote> (the file from which the target is being created; the one with the first @@ -184,12 +183,12 @@ cc a.o b.o</screen> but only the most recent one will be used). You will notice, however, that there is a definite order to the suffixes that are tried. This order is set by the relative positions of - the suffixes on the <makevar>.SUFFIXES</makevar> line + the suffixes on the <varname>.SUFFIXES</varname> line – the earlier a suffix appears, the earlier it is checked as the source of a transformation. Once a suffix has been defined, the only way to change its position in the pecking order is to remove all the suffixes (by having a - <makevar>.SUFFIXES</makevar> dependency line with no sources) + <varname>.SUFFIXES</varname> dependency line with no sources) and redefine them in the order you want. (Previously-defined transformation rules will be automatically redefined as the suffixes they involve are @@ -252,7 +251,7 @@ cc a.o b.o</screen> create the <filename>.c</filename> file from either a <filename>.y</filename> file or a <filename>.l</filename> file. Since <filename>.y</filename> came first on the - <makevar>.SUFFIXES</makevar> line, it checks for + <varname>.SUFFIXES</varname> line, it checks for <filename>jive.y</filename> first, but can not find it, so it looks for <filename>jive.l</filename> and, lo and behold, there it is. At this point, it has defined a transformation path as follows:</para> @@ -290,7 +289,7 @@ cc -o jive.out jive.o</screen> known suffix? <application>PMake</application> simply pretends it actually has a known suffix and searches for transformations accordingly. The suffix it chooses is the - source for the <maketarget>.NULL</maketarget> target mentioned + source for the <buildtarget>.NULL</buildtarget> target mentioned later. In the system makefile, <filename>.out</filename> is chosen as the <quote>null suffix</quote> because most people use <application>PMake</application> to create programs. You @@ -300,7 +299,7 @@ cc -o jive.out jive.o</screen> mode (see <xref linkend="gods"/>).</para> </section> - <section id="including"> + <section xml:id="including"> <title>Including Other Makefiles</title> <para>Just as for programs, it is often useful to extract certain @@ -351,7 +350,7 @@ cc -o jive.out jive.o</screen> <listitem> <para>Directories given by - <makevar>.PATH</makevar> dependency lines (see + <varname>.PATH</varname> dependency lines (see <xref linkend="gods"/>).</para> </listitem> @@ -375,7 +374,7 @@ cc -o jive.out jive.o</screen> <para>will not work.</para> </section> - <section id="savingcmds"> + <section xml:id="savingcmds"> <title>Saving Commands</title> <para>There may come a time when you will want to save certain @@ -416,14 +415,14 @@ lib2.a : $(LIB2OBJS) <para>commands until the end, when they would run one after the other (using the correct value for the - <makevar>.TARGET</makevar> variable, of course).</para> + <varname>.TARGET</varname> variable, of course).</para> <para>Commands saved in this manner are only executed if <application>PMake</application> manages to re-create everything without an error.</para> </section> - <section id="targetattr"> + <section xml:id="targetattr"> <title>Target Attributes</title> <para><application>PMake</application> allows you to give @@ -480,7 +479,7 @@ lib2.a : $(LIB2OBJS) through the loading and dumping unless one of your files has changed. Your makefile might look a little bit like this (remember, this is an educational example, - and do not worry about the <maketarget>COMPILE</maketarget> + and do not worry about the <buildtarget>COMPILE</buildtarget> rule, all will soon become clear, grasshopper): <programlisting>system : init a.fasl b.fasl c.fasl @@ -561,10 +560,10 @@ prog2 : $(PROG2OBJS) .INVISIBLE MAKEINSTALL</programlisting> where <literal>MAKEINSTALL</literal> is some complex <literal>.USE</literal> rule (see - below) that depends on the <makevar>.ALLSRC</makevar> + below) that depends on the <varname>.ALLSRC</varname> variable containing the right things. Without the <literal>.INVISIBLE</literal> - attribute for <maketarget>prog2</maketarget>, + attribute for <buildtarget>prog2</buildtarget>, the <literal>MAKEINSTALL</literal> rule could not be applied. This is not as useful as it should be, and the semantics may change (or the @@ -581,10 +580,10 @@ prog2 : $(PROG2OBJS) .INVISIBLE MAKEINSTALL</programlisting> the target's shell script to be executed only if one or more of the sources was out-of-date. In addition, the target's name, in both its - <makevar>.TARGET</makevar> + <varname>.TARGET</varname> variable and all the local variables of any target that depends on it, is replaced by the value - of its <makevar>.ALLSRC</makevar> variable. As an + of its <varname>.ALLSRC</varname> variable. As an example, suppose you have a program that has four libraries that compile in the same directory along with, and at @@ -607,7 +606,7 @@ libraries : lib1.a lib2.a lib3.a lib4.a .JOIN <filename>lib2.a</filename>, <filename>lib3.a</filename> and <filename>lib4.a</filename>. It will then execute ranlib on any library that was changed and set - program's <makevar>.ALLSRC</makevar> variable to contain + program's <varname>.ALLSRC</varname> variable to contain what's in <literal>$(OBJS)</literal> followed by <quote><filename>lib1.a</filename> <filename>lib2.a</filename> @@ -706,7 +705,7 @@ libraries : lib1.a lib2.a lib3.a lib4.a .JOIN <entry><literal>.USE</literal></entry> <entry><para>By giving a target this attribute, you turn it - into <application></application>PMake's equivalent of + into <application/>PMake's equivalent of a macro. When the target is used as a source for another target, the other target acquires the commands, sources and attributes (except @@ -717,7 +716,7 @@ libraries : lib1.a lib2.a lib3.a lib4.a .JOIN target, the rules are applied sequentially. The typical <literal>.USE</literal> rule (as I call them) will use the sources of the target to which it is applied (as - stored in the <makevar>.ALLSRC</makevar> variable for + stored in the <varname>.ALLSRC</varname> variable for the target) as its <quote>arguments,</quote> if you will. For example, you probably noticed that the commands for creating <filename>lib1.a</filename> and @@ -741,10 +740,10 @@ MAKELIB : .USE easier (they are in the default, system makefile directory...take a look). Note that the <literal>.USE</literal> rule source itself - (<maketarget>MAKELIB</maketarget>) does not appear in + (<buildtarget>MAKELIB</buildtarget>) does not appear in any of the targets's local variables. There is no limit to the number of times I could use the - <maketarget>MAKELIB</maketarget> rule. If there were + <buildtarget>MAKELIB</buildtarget> rule. If there were more libraries, I could continue with <literal>lib3.a : $(LIB3OBJS) MAKELIB</literal> and so on and so forth.</para></entry> @@ -754,7 +753,7 @@ MAKELIB : .USE </informaltable> </section> - <section id="specialtargets"> + <section xml:id="specialtargets"> <title>Special Targets</title> <para>As there were in <application>Make</application>, so there @@ -775,7 +774,7 @@ MAKELIB : .USE <tbody> <row valign="top"> - <entry><maketarget>.BEGIN</maketarget></entry> + <entry><buildtarget>.BEGIN</buildtarget></entry> <entry>Any commands attached to this target are executed before anything else is done. You can use @@ -784,7 +783,7 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.DEFAULT</maketarget></entry> + <entry><buildtarget>.DEFAULT</buildtarget></entry> <entry>This is sort of a <literal>.USE</literal> rule for any target (that was used only as a source) @@ -792,18 +791,18 @@ MAKELIB : .USE out any other way to create. It is only <quote>sort of</quote> a <literal>.USE</literal> rule because only the shell script attached to the - <maketarget>.DEFAULT</maketarget> target is used. - The <makevar>.IMPSRC</makevar> variable of a target - that inherits <maketarget>.DEFAULT</maketarget>'s + <buildtarget>.DEFAULT</buildtarget> target is used. + The <varname>.IMPSRC</varname> variable of a target + that inherits <buildtarget>.DEFAULT</buildtarget>'s commands is set to the target's own name.</entry> </row> <row valign="top"> - <entry><maketarget>.END</maketarget></entry> + <entry><buildtarget>.END</buildtarget></entry> <entry>This serves a function similar to - <maketarget>.BEGIN</maketarget>, in that commands + <buildtarget>.BEGIN</buildtarget>, in that commands attached to it are executed once everything has been re-created (so long as no errors occurred). It also serves the extra function of @@ -815,7 +814,7 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.EXPORT</maketarget></entry> + <entry><buildtarget>.EXPORT</buildtarget></entry> <entry>The sources for this target are passed to the exportation system compiled into @@ -825,7 +824,7 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.IGNORE</maketarget></entry> + <entry><buildtarget>.IGNORE</buildtarget></entry> <entry>This target marks each of its sources with the <literal>.IGNORE</literal> attribute. @@ -836,7 +835,7 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.INCLUDES</maketarget></entry> + <entry><buildtarget>.INCLUDES</buildtarget></entry> <entry><para>The sources for this target are taken to be suffixes that indicate a file that can be included in @@ -844,8 +843,8 @@ MAKELIB : .USE already been declared with <literal>.SUFFIXES</literal> (see below). Any suffix so marked will have the directories on - its search path (see <maketarget>.PATH</maketarget>, - below) placed in the <makevar>.INCLUDES</makevar> + its search path (see <buildtarget>.PATH</buildtarget>, + below) placed in the <varname>.INCLUDES</varname> variable, each preceded by a <option>-I</option> flag. This variable can then be used as an argument for the compiler in the normal fashion. The @@ -858,18 +857,18 @@ MAKELIB : .USE <application>PMake</application> will place <literal>-I/usr/local/X/lib/bitmaps</literal> - in the <makevar>.INCLUDES</makevar> variable and you can + in the <varname>.INCLUDES</varname> variable and you can then say <programlisting>cc $(.INCLUDES) -c xprogram.c</programlisting> - (Note: the <makevar>.INCLUDES</makevar> variable is + (Note: the <varname>.INCLUDES</varname> variable is not actually filled in until the entire makefile has been read.)</para></entry> </row> <row valign="top"> - <entry><maketarget>.INTERRUPT</maketarget></entry> + <entry><buildtarget>.INTERRUPT</buildtarget></entry> <entry>When <application>PMake</application> is interrupted, it will execute the commands in the @@ -877,24 +876,24 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.LIBS</maketarget></entry> + <entry><buildtarget>.LIBS</buildtarget></entry> <entry>This does for libraries what - <maketarget>.INCLUDES</maketarget> does for include + <buildtarget>.INCLUDES</buildtarget> does for include files, except the flag used is <option>-L</option>, as required by those linkers that allow you to tell them where to find libraries. - The variable used is <makevar>.LIBS</makevar>. + The variable used is <varname>.LIBS</varname>. Be forewarned that <application>PMake</application> may not have been compiled to do this if the linker on your system does not accept the <option>-L</option> - flag, though the <makevar>.LIBS</makevar> variable + flag, though the <varname>.LIBS</varname> variable will always be defined once the makefile has been read.</entry> </row> <row valign="top"> - <entry><maketarget>.MAIN</maketarget></entry> + <entry><buildtarget>.MAIN</buildtarget></entry> <entry>If you did not give a target (or targets) to create when you invoked @@ -904,7 +903,7 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.MAKEFLAGS</maketarget></entry> + <entry><buildtarget>.MAKEFLAGS</buildtarget></entry> <entry>This target provides a way for you to always specify flags for <application>PMake</application> @@ -916,7 +915,7 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.NULL</maketarget></entry> + <entry><buildtarget>.NULL</buildtarget></entry> <entry>This allows you to specify what suffix <application>PMake</application> should pretend @@ -927,7 +926,7 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.PATH</maketarget></entry> + <entry><buildtarget>.PATH</buildtarget></entry> <entry>If you give sources for this target, <application>PMake</application> will take them as @@ -935,16 +934,15 @@ MAKELIB : .USE find in the current directory. If you give no sources, it will clear out any directories added to the search path before. Since the effects of this - all get very complex, we will leave it till <xref - linkend="gods"/> to give you a complete + all get very complex, we will leave it till <xref linkend="gods"/> to give you a complete explanation.</entry> </row> <row valign="top"> - <entry><maketarget>.PATH<replaceable>suffix</replaceable></maketarget></entry> + <entry><buildtarget>.PATH<replaceable>suffix</replaceable></buildtarget></entry> <entry>This does a similar thing to - <maketarget>.PATH</maketarget>, but it does it only + <buildtarget>.PATH</buildtarget>, but it does it only for files with the given suffix. The suffix must have been defined already. Look at Search Paths (<xref linkend="searchpaths"/>) for more @@ -952,9 +950,9 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.PRECIOUS</maketarget></entry> + <entry><buildtarget>.PRECIOUS</buildtarget></entry> - <entry>Similar to <maketarget>.IGNORE</maketarget>, + <entry>Similar to <buildtarget>.IGNORE</buildtarget>, this gives the <literal>.PRECIOUS</literal> attribute to each source on the dependency line, unless there are no sources, in which case the <literal>.PRECIOUS</literal> @@ -962,7 +960,7 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.RECURSIVE</maketarget></entry> + <entry><buildtarget>.RECURSIVE</buildtarget></entry> <entry>This target applies the <literal>.MAKE</literal> attribute to all its sources. It does nothing if you @@ -970,23 +968,21 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.SHELL</maketarget></entry> + <entry><buildtarget>.SHELL</buildtarget></entry> <entry><application>PMake</application> is not constrained to only using the Bourne shell to execute the commands you put in the makefile. You can tell it some other shell to use with this - target. Check out <quote><xref linkend="ashell" - endterm="ashelltitle"/></quote> (<xref - linkend="ashell"/>) for more + target. Check out <quote><xref linkend="ashell" endterm="ashelltitle"/></quote> (<xref linkend="ashell"/>) for more information.</entry> </row> <row valign="top"> - <entry><maketarget>.SILENT</maketarget></entry> + <entry><buildtarget>.SILENT</buildtarget></entry> <entry>When you use - <maketarget>.SILENT</maketarget> as a target, it + <buildtarget>.SILENT</buildtarget> as a target, it applies the <literal>.SILENT</literal> attribute to each of its sources. If there are no sources on the dependency line, then it is as if you gave @@ -996,14 +992,14 @@ MAKELIB : .USE </row> <row valign="top"> - <entry><maketarget>.SUFFIXES</maketarget></entry> + <entry><buildtarget>.SUFFIXES</buildtarget></entry> <entry>This is used to give new file suffixes for <application>PMake</application> to handle. Each source is a suffix <application>PMake</application> should recognize. If you give a - <maketarget>.SUFFIXES</maketarget> dependency line + <buildtarget>.SUFFIXES</buildtarget> dependency line with no sources, <application>PMake</application> will forget about all the suffixes it knew (this also nukes the null suffix). For those @@ -1021,7 +1017,7 @@ MAKELIB : .USE <para>applies the attribute to all the targets listed as sources.</para> </section> - <section id="modyvarex"> + <section xml:id="modyvarex"> <title>Modifying Variable Expansion</title> <para>Variables need not always be expanded verbatim. @@ -1131,7 +1127,7 @@ MAKELIB : .USE <programlisting>OBJS = ../lib/a.o b /usr/lib/libm.a TAILS = $(OBJS:T)</programlisting> - <para>the variable <makevar>TAILS</makevar> would expand + <para>the variable <varname>TAILS</varname> would expand to <literal>a.o b libm.a.</literal></para> </listitem> </varlistentry> @@ -1143,7 +1139,7 @@ TAILS = $(OBJS:T)</programlisting> <para>This is similar to <literal>:T</literal>, except that every word is replaced by everything but the tail (the <quote>head</quote>). Using the same definition of - <makevar>OBJS</makevar>, the string + <varname>OBJS</varname>, the string <literal>$(OBJS:H)</literal> would expand to <literal>../lib /usr/lib.</literal> Note that the final slash on the heads is removed and anything without @@ -1184,7 +1180,7 @@ TAILS = $(OBJS:T)</programlisting> words may be replaced.</para> </section> - <section id="moreexercises"> + <section xml:id="moreexercises"> <title>More Exercises</title> <bridgehead>Exercise 3.1</bridgehead> |