Previous: Single distribution tree, Up: Examples
Lets suppose you have a source tree from which you create multiple distributions, say three. If you really have a such source tree you must have by now noticed the difficulty of maintaining such a source tree and problems with controlling the distributions. Maybe you have sufficed with Autoconf and Automake, or perhaps you have created your own scripts that carry out the kludges. No more, for Autodist is here.
First, you integrate Autodist into your tree by creating the distributions directory 'distdir':
autodist -i
Then, you create the 'configure.ad' file from your existing 'configure.ac' or 'configure.in' file. If you don't have configure script written yet, please refer to the Autoconf manual. In the 'configure.ad' you add as first macro in the file:
AD_INIT
You then continue with creating the distribution files for your three distributions. Let's name them 'foozbar', 'libfoozbar' and 'nomad'. We will also create a common template that all distributions inherit.
# Foozbar distribution name Foozbar package foozbar bug-report foozbar-bugs@foo.z.bar inherit common define _DIST_FOOZBAR
# libfoozbar distribution name libfoozbar bug-report libfoozbar-bugs@foo.z.bar inherit common define _DIST_LIBFOOZBAR
# Nomad distribution name Nomad package nomad-the-server bug-report nomad-bugs@foo.z.bar inherit common include doc/nomad define _DIST_NOMAD define _DIST_NOMAD_LIB undef _DIST_CRYPTO pre-dist-hook nomad-pre-dist-hook
# Common template option template define _DIST_DOC define _DIST_LIB define _DIST_MATH define _DIST_CRYPTO define _DIST_UNIX define _DIST_MACOSX define _DIST_WIN32
You put the distribution files in the 'distdir' directory. In addition you will be doing development in the source tree using the 'default' distribution, you will add the new distributions to the 'distdir/default':
inherit foozbar inherit libfoozbar inherit nomad
To prepare the source tree for configuration and compilation you would simply give:
autodist
This will prepare your source tree for configuration and compilation. Since the 'default' distribution inherits all distributions your development source tree will have all of them included. If you do not want to do this then don't inherit them in the 'default', but run the autodist specifically for the distributions, for example:
autodist foozbar
Since all the distributions inherit the 'common' distribution they get all the distdefs that the 'common' defines. In this example various distdefs have been defined. You would use them in your code and in your makefiles to control various things. For example, let's say the 'common' distdefs control what directories distributions have. An example 'Makefile.ad' file:
SUBDIRS = \ #ifdef _DIST_LIB lib \ #endif _DIST_LIB #ifdef _DIST_DOC doc \ #endif _DIST_DOC
Perhaps the 'Makefile.ad' in 'lib' subdirectory could define something like this:
SUBDIRS = \ util \ #ifdef _DIST_MATH mathlib \ #endif _DIST_MATH #ifdef _DIST_CRYPTO cryptolib \ #endif _DIST_CRYPTO #ifdef _DIST_NOMAD_LIB nomadlib \ #endif _DIST_NOMAD_LIB #ifdef _DIST_LIBFOOZBAR foozbarlib \ #endif _DIST_LIBFOOZBAR
Since the 'nomad' distribution undefined the '_DIST_CRYPTO' distdef it would not have the 'cryptolib' in its distribution. Clearly Nomad don't need it. In addition of using the distdefs just in the makefiles you may want to use them in the source code as well:
...some code... #ifdef _DIST_MATH /* Initialize math library */ math_init(); #endif /* _DIST_MATH */ ...some code...
After an intensive development period you're ready to create new releases. Let's say you're going to release all distributions:
First you release Foozbar 0.5.1:
autodist foozbar 0.5.1 makedist --bzip2
The end result is two files: 'foozbar-0.5.1.tar.gz' and 'foozbar-0.5.1.tar.bz2'.
Then you continue with libfoozbar and Nomad:
autodist libfoozbar 1.0.5 makedist
Nomad has also an RPM .spec file that you have written and a pre-dist-hook that will replace the RPM release version with sed tool with the one you give as extra parameter to autodist:
autodist nomad 2.0 0.fc7 makedist
The end results are: 'libfoozbar-1.0.5.tar.gz' and 'nomad-2.0.tar.gz', and the RPM will have a release version '0.fc7' when you compile the RPM. Any extra parameter that you pass to autodist will be delivered to your hook scripts.