<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 4. Distributing a Program</title><meta name="generator" content="DocBook XSL Stylesheets V1.71.1"><link rel="start" href="index.html" title="A-A-P Recipe Executive"><link rel="up" href="tutorial.html" title="Part I. Tutorial"><link rel="prev" href="tutor-website.html" title="Chapter 3. Publishing a Web Site"><link rel="next" href="tutor-variant.html" title="Chapter 5. Building Variants"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table width="100%" id="navtable"><tbody><tr><td align="left" class="left" width="33%"><b><a href="http://www.a-a-p.org">A-A-P home page</a></b></td><td align="center" class="center" width="34%"><b><a href="index.html">A-A-P Recipe Executive</a></b></td><td align="right" class="right" width="33%"></td></tr><tr><td align="left" class="left"><a accesskey="p" href="tutor-website.html">Prev</a></td><td align="center" class="center">Tutorial</td><td align="right" class="right"><a accesskey="n" href="tutor-variant.html">Next</a></td></tr></tbody></table><hr><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="tutor-distribute"></a>Chapter 4. Distributing a Program</h2></div></div></div><p> Open source software needs to be distributed. This chapter gives a simple example of how you can upload your files and make it easy for others to download and install your program. </p><h2><a name="id2627110"></a>Downloading</h2><p> To make it easy for others to obtain the latest version of your program, you give them a recipe. That is all they need. In the recipe you describe how to download the files and compile the program. Here is an example: </p><pre class="programlisting"> 1 Origin = ftp://ftp.mysite.org/pub/theprog 2 3 :recipe {fetch = $Origin/main.aap} 4 5 Source = main.c 6 version.c 7 Header = common.h 8 9 :attr {fetch = $Origin/%file%} $Source $Header 10 11 :program theprog : $Source </pre><p> The first line specifies the location where all the files can be found. It is good idea to specify this only once. If you would use the text all over the recipe it is more difficult to read and it would be more work when the URL changes. </p><p> Line 3 specifies where this recipe can be obtained. After obtaining this recipe once, it can be updated with a simple command: </p><div class="literallayout"><p> % <strong class="userinput"><code>aap refresh</code></strong><br> Aap: Updating recipe "main.aap"<br> Aap: Attempting download of "ftp://ftp.mysite.org/pub/theprog/main.aap"<br> Aap: Downloaded "ftp://ftp.mysite.org/pub/theprog/main.aap" to "/home/mool/.aap/cache/98092140.aap"<br> Aap: Copied file from cache: "main.aap"<br> %<br> </p></div><p> The messages from <span class="application">Aap</span> are a bit verbose. This is just in case the downloading is very slow, you will have some idea of what is going on. </p><p> Lines 5 to 7 define the source files. This is not different from the examples that were used to compile a program, except that we explicitly mention the header file used. </p><p> Line 9 specifies where the files can be fetched from. This is done by giving the source and header files the <code class="literal">fetch</code> attribute. The <code class="computeroutput">:attr</code> command does not cause the files to be fetched yet. When a file is used somewhere and it has a <code class="literal">fetch</code> attribute, then it is fetched. Thus files that are not used will not be fetched. </p><p> A user of your program stores this recipe as <code class="filename">main.aap</code> and runs <strong class="userinput"><code>aap</code></strong> without arguments. What will happen is: </p><div class="orderedlist"><ol type="1"><li><p> Dependencies will be created by the <code class="literal">:program</code> command to build "theprog" from <code class="filename">main.c</code> and <code class="filename">version.c</code>. </p></li><li><p> The target "theprog" depends on <code class="filename">main.c</code> and <code class="filename">version.c</code>. Since these files do not exist and they do have a <code class="literal">fetch</code> attribute, they are fetched. </p></li><li><p> The <code class="filename">main.c</code> file is inspected for dependencies. It includes the <code class="filename">common.h</code> file, which is automatically added to the list of dependencies. Since <code class="filename">common.h</code> does not exist and has a <code class="literal">fetch</code> attribute, it is fetched as well. </p></li><li><p> Now that all the files are present they are compiled and linked into "theprog". </p></li></ol></div><p> </p><h2><a name="id2627351"></a>Uploading</h2><p> You need to upload the files mentioned in the recipe above. This needs to be repeated each time one of the files changes. This is essentially the same as publishing a web site. You will need to upload both the source files and the recipe itself. The {publish} attribute can be used for this. You can add the following two lines to the recipe above in order to upload all the files: </p><pre class="programlisting"> URL = scp://user@ftp.mysite.org//pub/theprog/%file% :attr {publish = $URL} $Source $Header main.aap </pre><p> Now you can use <strong class="userinput"><code>aap publish</code></strong> to upload your source files as well. </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="tutor-website.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="tutorial.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="tutor-variant.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 3. Publishing a Web Site </td><td width="20%" align="center"><a accesskey="h" href="index.html"> Contents</a></td><td width="40%" align="right" valign="top"> Chapter 5. Building Variants</td></tr></table></div></body></html>