<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Frank Seitz - Developer Logbuch - make</title>
    <link>http://fseitz.de/blog/</link>
    <description>Notizen aus der Welt der Web-, Datenbank- und Unix-Programmierung</description>
    <dc:language>de</dc:language>
    <generator>Serendipity 1.5.1 - http://www.s9y.org/</generator>
    <pubDate>Wed, 31 Mar 2010 08:15:54 GMT</pubDate>

    <image>
        <url>http://fseitz.de/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Frank Seitz - Developer Logbuch - make - Notizen aus der Welt der Web-, Datenbank- und Unix-Programmierung</title>
        <link>http://fseitz.de/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>GNU Makefile zum Konvertieren von Dateien</title>
    <link>http://fseitz.de/blog/index.php?/archives/31-GNU-Makefile-zum-Konvertieren-von-Dateien.html</link>
            <category>make</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/31-GNU-Makefile-zum-Konvertieren-von-Dateien.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=31</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=31</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
  Mitunter soll eine Menge von Dateien, die man erstellt und bearbeitet,
  systematisch in etwas anderes, z.B. ein anderes Format, konvertiert
  werden. Die Konvertierung lässt sich mit dem Utilty &lt;tt class=&quot;sdoc-seg-c&quot;&gt;make&lt;/tt&gt;
  organisieren, so dass überflüssige Konvertierungen vermieden werden.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Wie sieht ein GNU Makefile für diese Aufgabe aus?
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Das folgende (fiktive) Beispiel geht davon aus, dass wir .in-Dateien
  in .out-Dateien konvertieren wollen. Die Konvertierung übernimmt das
  (fiktive) Programm in2out.
&lt;/p&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;sdoc-code-table&quot;&gt;
&lt;tr class=&quot;sdoc-code-tr-odd&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt; 1&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;OUTFILES = $(patsubst %.in,%.out,$(wildcard *.in))&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-even&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt; 2&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-odd&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt; 3&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;%.out: %.in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-even&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt; 4&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;	in2out $&amp;lt; $*.out&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-odd&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt; 5&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-even&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt; 6&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;all: $(OUTFILES)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-odd&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt; 7&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-even&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt; 8&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;clean:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-odd&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt; 9&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;	rm -f *.out&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;dl class=&quot;sdoc-list-dl&quot;&gt;
  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;Zeile 1&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Definition der Liste der Targets, also der Dateien, die zu
      generieren sind. Das sind .out-Dateien. Diese Liste könnten wir per
      Hand pflegen, was aber mühselig wäre. Stattdessen nutzen wir die
      Möglichkeiten von GNU make und generieren die Liste mittels der
      Funktionen &lt;tt class=&quot;sdoc-seg-c&quot;&gt;wildcard&lt;/tt&gt; und &lt;tt class=&quot;sdoc-seg-c&quot;&gt;patsub&lt;/tt&gt; aus den im aktuellen
      Verzeichnis befindlichen .in-Quell-Dateien.
    &lt;/p&gt;
  &lt;/dd&gt;
  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;Zeile 3-4&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Pattern Rule, welche definiert, welche Kommandofolge aus einer
      .in-Quelldatei eine .out-Zieldatei erzeugt. Hier ist es ein einzelnes
      Kommando, der Aufruf von &lt;tt class=&quot;sdoc-seg-c&quot;&gt;in2out [infile] [outfile]&lt;/tt&gt;.
      Die make-Variable &lt;tt class=&quot;sdoc-seg-c&quot;&gt;$&amp;lt;&lt;/tt&gt; enthält den Namen der .in-Quelldatei,
      die Variable &lt;tt class=&quot;sdoc-seg-c&quot;&gt;$*&lt;/tt&gt; den Grundnamen der Quelldatei, aus dem
      durch Anhängen von &quot;.out&quot; der Name der Zieldatei wird.
    &lt;/p&gt;
  &lt;/dd&gt;
  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;Zeile 6&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Regel, die bei Aufruf von
    &lt;/p&gt;
    &lt;div class=&quot;sdoc-code-div&quot;&gt;
      &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ make&lt;/pre&gt;
    &lt;/div&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      oder
    &lt;/p&gt;
    &lt;div class=&quot;sdoc-code-div&quot;&gt;
      &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ make all&lt;/pre&gt;
    &lt;/div&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      zu erfüllen versucht wird. Diese (PHONY-)regel besagt, dass
      als Vorbedingung alle &lt;tt class=&quot;sdoc-seg-c&quot;&gt;$(OUTFILES)&lt;/tt&gt; zu generieren sind.
    &lt;/p&gt;
  &lt;/dd&gt;
  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;Zeile 8-9&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Regel ohne Vorbedingung, die aufräumt, also alle .out-Dateien löscht, z.B.
      um sie insgesamt neu zu generieren. Aufruf:
    &lt;/p&gt;
    &lt;div class=&quot;sdoc-code-div&quot;&gt;
      &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ make clean&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/dd&gt;
&lt;/dl&gt; 
    </content:encoded>

    <pubDate>Tue, 09 Feb 2010 12:09:39 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/31-guid.html</guid>
    
</item>

</channel>
</rss>