A-A-P home page | A-A-P Recipe Executive |
Prev | Tutorial | Next

## Chapter 4. Distributing a Program

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.

## Downloading

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:

    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

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.

Line 3 specifies where this recipe can be obtained. After obtaining this recipe once, it can be updated with a simple command:

% `aap refresh`
Aap: Updating recipe "main.aap"
Aap: Attempting download of "ftp://ftp.mysite.org/pub/theprog/main.aap"
Aap: Downloaded "ftp://ftp.mysite.org/pub/theprog/main.aap" to "/home/mool/.aap/cache/98092140.aap"
Aap: Copied file from cache: "main.aap"
%

The messages from Aap are a bit verbose. This is just in case the downloading is very slow, you will have some idea of what is going on.

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.

Line 9 specifies where the files can be fetched from. This is done by giving the source and header files the `fetch` attribute. The `:attr` command does not cause the files to be fetched yet. When a file is used somewhere and it has a `fetch` attribute, then it is fetched. Thus files that are not used will not be fetched.

A user of your program stores this recipe as `main.aap` and runs `aap` without arguments. What will happen is:

1. Dependencies will be created by the `:program` command to build "theprog" from `main.c` and `version.c`.

2. The target "theprog" depends on `main.c` and `version.c`. Since these files do not exist and they do have a `fetch` attribute, they are fetched.

3. The `main.c` file is inspected for dependencies. It includes the `common.h` file, which is automatically added to the list of dependencies. Since `common.h` does not exist and has a `fetch` attribute, it is fetched as well.

4. Now that all the files are present they are compiled and linked into "theprog".

## Uploading

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:

        URL = scp://user@ftp.mysite.org//pub/theprog/%file%
        :attr {publish = $URL} $Source $Header main.aap

Now you can use `aap publish` to upload your source files as well.

Prev | Up | Next
Chapter 3. Publishing a Web Site | Contents | Chapter 5. Building Variants