Merged silc_1_0_branch to trunk.
[silc.git] / apps / autodist / doc / autodist.texi
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename autodist.info
4 @settitle autodist
5 @setchapternewpage off
6 @c %**end of header
7
8 @include version.texi
9
10 @copying
11
12 This manual is for SILC Autodist (version @value{VERSION},
13 @value{UPDATED}), a program which is used to manage and create source
14 distributions.
15
16 Copyright @copyright{} 2004 - 2005 Pekka Riikonen, SILC Project
17
18 @quotation
19 Permission is granted to copy, distribute and/or modify this document
20 under the terms of the @acronym{GNU} Free Documentation License,
21 Version 1.2 or any later version published by the Free Software
22 Foundation; with no Invariant Sections, with the Front-Cover texts
23 being ``A @acronym{GNU} Manual,'' and with the Back-Cover Texts as in
24 (a) below.  A copy of the license is included in the section entitled
25 ``@acronym{GNU} Free Documentation License.''
26
27 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and
28 modify this @acronym{GNU} Manual, like @acronym{GNU} software.  Copies
29 published by the Free Software Foundation raise funds for
30 @acronym{GNU} development.''
31 @end quotation
32 @end copying
33
34 @dircategory Software development
35 @direntry
36 * autodist: (autodist).         Managing and creating source distributions.
37 @end direntry
38
39 @dircategory Individual utilities
40 @direntry
41 * makedist: (autodist)Invoking makedist.          Creating distribution
42 @end direntry
43
44 @titlepage
45 @title SILC Autodist
46 @subtitle For version @value{VERSION}, @value{UPDATED}
47 @author Pekka Riikonen
48 @page
49 @vskip 0pt plus 1filll
50 @insertcopying
51 @end titlepage
52
53 @ifnottex
54 @node Top
55 @comment  node-name,  next,  previous,  up
56 @top SILC Autodist
57
58 @insertcopying
59
60 @menu
61 * Introduction::                Purpose of Autodist
62 * Integrating Autodist::        Integrating Autodist into your project
63 * Invoking Autodist::           Running Autodist
64 * Examples::                    Examples using Autodist
65
66 @detailmenu
67  --- The Detailed Node Listing ---
68
69 Introduction
70
71 * Motivation::                  Reasons for using Autodist
72
73 Integrating Autodist
74
75 * Creating distdir::            Creating distributions directory
76 * autodist.conf::               Configuring Autodist
77 * Creating new distribution::   Adding new distribution
78 * Distribution file format::    Detailed document for distfile format
79 * configure.ad files::          configure script for creating configure.ac
80 * Makefile.ad files::           Makefile.ad for creating Makefile.am
81 * Other .ad files::             Other files with .ad suffix
82 * Distdefines::                 Using distdefs in files
83
84 Invoking Autodist
85
86 * Preparing source tree::       Preparing source tree with Autodist
87 * Creating distribution::       Creating distribution with Autodist
88
89 Examples
90
91 * Single distribution tree::    Single distribution example
92 * Multiple distribution tree::  Multiple distributions example
93
94 @end detailmenu
95 @end menu
96
97 @end ifnottex
98
99
100 @node Introduction
101 @chapter Introduction
102
103 The Autodist is a source distribution management system that allows
104 powerful mechanisms to define what is included in and excluded from a
105 distribution, and what license the distribution is released under.  It is
106 also used to create the actual distribution source packages.  Autodist
107 allows distribution management in file, directory and file content level.
108 Different distributions may include different portions of files, for
109 example, excluding certain features from certain distributions.  It is
110 always guaranteed that anything not defined for the distribution, is
111 removed automatically (files, file content, directories), thus ensuring
112 that nothing is accidentally included in the distribution.
113
114 The Autodist creates 'Makefile.am' files from 'Makefile.ad' files and
115 'configure.ac' file from one or more 'configure.ad' files.  Any other file
116 ending with '.ad' suffix will also be processed.  The processed file will
117 have the '.ad' suffix removed (@pxref{Preparing source tree, , , , }).
118 Autodist also creates and packages the distribution using common GNU
119 distribution creation process, specificly `make dist'.  Autodist, however,
120 controls this process and during packaging phase the Autodist processes
121 all files in the distribution (other than '*.ad' files, which has already
122 been processed earlier by Autodist).  The resulted package is a processed
123 source distribution package, processed according to the rules specified
124 in the distribution file(s) (@pxref{Creating distribution, , , , }).
125
126 Any file in the source tree may use distdefs (distribution defines (@pxref{Distdefines, , , , })) which are defined in the distributions.  When distribution
127 is packaged only the files, directories and file content that is either
128 outside of any distdef, or inside the defined distdefs will be included
129 in the distribution.  Any other file, directory or content in the file
130 will be removed.  It is guaranteed, if a file, a directory or a piece of
131 file content is not inside a defined distdef it will not be delivered to
132 the distribution.
133
134 Any file, 'Makefile.am', 'configure.ac', or source file processed with
135 Autodist is always compliant with the tools needed to process them.  All
136 files can also be processed with the corresponding tools even before
137 processing them with Autodist.  This makes it possible, for example, to
138 compile sources before they have been processed, and undefined lines
139 are removed.  The distdefs are respected in source files by the
140 preprocessor.
141
142 Autodist is not a binary packaging system.  It is specificly used to
143 create source distributions.  A binary packaging system, however can be
144 hooked to the distribution creation process, if needed.
145
146 @menu
147 * Motivation::                  Reasons for using Autodist
148 @end menu
149
150
151 @node Motivation
152 @section Reasons for using Autodist
153
154 Autodist is closely related to the Autoconf and Automake tools, and
155 complements the features Autoconf and Automake provides.  It is especially
156 targeted into circumstances where multiple distributions are created from
157 one source tree.  The Autoconf and Automake environment is mainly designed
158 for one distribution (one application) per one source tree situations.
159 Autodist provides mechanisms to create all kinds of distributions that can
160 be created from one source tree.  To be able to use Autodist, the Autoconf
161 and Automake must be installed into the system (@pxref{Integrating Autodist, , , , }).
162 Autoconf version must be at least 2.52g.
163
164 Small software projects usually do very well with Autoconf and Automake
165 and their distribution management features.  Often these projects do not
166 need Autodist, though they can benefit from it.  However, if your software
167 project is large, you need to create multiple distributions from one source
168 tree, you have complex licensing terms for different distributions, you
169 have different target users or customers that may require different
170 feature set or licenses in different distributions, you have need to
171 continue concurrent development in the main source tree and still be able
172 to create stable distributions, and/or you have need to control file
173 content in different distributions (to avoid distributing code or features
174 that aren't supposed to be distributed, or to avoid leaking information
175 to your competitors on what new features you are working on), then Autodist
176 is a tool you may find usefull.
177
178 The motivation behind Autodist stems from need to be able to create
179 multiple distributions from one large source tree in a precise and
180 controllable manner, and guarantee that anything that is not part of the
181 distribution is removed from the distribution.  The Autoconf and Automake
182 provides mere basic control what is included in and excluded from
183 distributions and how the distributions are created.  They also do not
184 provide mechanism to define different licensing conditions for different
185 distributions, or changing the license automatically for different user
186 or customer purposes.  Many large software projects, companies and
187 corporations have commonly been using Autoconf and Automake tools, but
188 have had the need to create their own ad-hoc mechanisms to control
189 distribution creation.  The Autodist attempts to provide a tool that any
190 size software project can effectively use to manage their distributions.
191
192 Without a tool like Autodist, large software projects usually has to be
193 split into separate source trees, which may not always be possible because
194 they may share large portions of common code (which may further make
195 concurrent development of the applications hard), or multiple Autoconf and
196 Automake environments (multiple configure scripts) needs to be created
197 in one source tree.  In this case the source tree usually gets very
198 complicated and controlling what is compiled and what is included in
199 distributions becomes harder, especially when different parts code is shared
200 between applications and libraries.
201
202
203 @node Integrating Autodist
204 @chapter Integrating Autodist
205
206 Integrating Autodist into existing software project can be a very simple
207 task or a fairly complicated task.  It depends on the size and complexity
208 of the software project.  Generally speaking, integrating Autodist into
209 software project is fairly straightforward process:
210
211 1. The distributions directory and 'default' distribution are created
212
213 2. The 'configure.ad' is created
214
215 3. If needed, 'Makefile.ad' file(s) are created
216
217 After this the Autodist can already be used to prepare the source tree
218 for configuration and compilation (@pxref{Preparing source tree, , , , }).
219 Adding a new distribution would then allow the actual distribution
220 packaging also.
221
222 If the software project has had own ad-hoc distribution system already in
223 place, it may take some work to move from that system into the Autodist.
224 If there are multiple applications and distributions created from the
225 source tree, the distributions and distribution defines for them need to
226 be created.  While this may be unthankful job, it only needs to be done
227 once.
228
229 Integrating Autodist into a new software project is a very simple task as
230 renaming 'configure.ac' and possibly 'Makefile.am' files are not required,
231 as they may not exist yet.
232
233
234 @menu
235 * Creating distdir::            Creating distributions directory
236 * autodist.conf::               Configuring Autodist
237 * Creating new distribution::   Adding new distribution
238 * Distribution file format::    Detailed document for distfile format
239 * configure.ad files::          configure script for creating configure.ac
240 * Makefile.ad files::           Makefile.ad for creating Makefile.am
241 * Other .ad files::             Other files with .ad suffix
242 * Distdefines::                 Using distdefs in files
243 @end menu
244
245
246 @node Creating distdir
247 @section Creating distributions directory
248
249 The distributions directory is 'distdir', which is expected to be
250 located in the root of the source tree.  This directory will hold all
251 the distribution files, and the Autodist configuration file 'autodist.conf' (@pxref{autodist.conf, , , , }).
252 If this directory does not exist it can be created with the Autodist.
253
254 @example
255   autodist -i
256 @end example
257
258 This will create the 'distdir' and copy the default 'autodist.conf'
259 configuration file and the 'default' distribution into the directory.
260 The 'default' distribution will be used by default by the Autodist
261 unless other distribution is specified.
262
263 After this the Autodist has effectively been integrated into the
264 software project.  However, usually after this, one would create new
265 distributions, the 'configure.ad' and possibly 'Makefile.ad' file(s).
266 Without 'configure.ad' file a distribution package cannot be created.
267 However, even without 'configure.ad' file the source tree can be
268 prepared for configuration and compilation (@pxref{Preparing source tree, , , , }).
269
270 @menu
271 * autodist.conf::               Configuring Autodist
272 @end menu
273
274
275 @node autodist.conf
276 @section Configuring Autodist
277
278 After the Autodist has been integrated into the software by creating
279 the 'distdir', the 'autodist.conf' configuration file was added to the
280 'distdir' also.  Usually software projects will want to modify some of
281 the 'autodist.conf' options, mainly specifying the distdef prefix.
282
283 The 'autodist.conf' is a text file.  The following options are available
284 in 'autodist.conf':
285
286
287 @example
288 DISTPREFIX=""
289 @end example
290
291 By default the distdef prefix is '_DIST_'.  To add own software package
292 specific prefix the 'DISTPREFIX' can be defined.
293
294 Example:
295 @example
296 DISTPREFIX="SILC"
297 @end example
298
299 Will set the distdef prefix as 'SILC_DIST_'.
300
301
302 @example
303 DISTDEFS="distdefs.h"
304 @end example
305
306 The 'DISTDEFS' option specifies the file name of the distdef header file
307 which Autodist will create.  The software project should '#include' the
308 header file in order for the preprocessor to respect the distdef
309 conditionals (@pxref{Distdefines, , , , }).  By default the file name
310 is 'distdefs.h' and is created at the root of source tree.  Other location
311 may be specified if needed.
312
313 Example:
314 @example
315 DISTDEFS="include/distdefs.h"
316 @end example
317
318
319 @example
320 ACLOCAL="aclocal"
321 @end example
322
323 The 'ACLOCAL' specifies the location of the 'aclocal' tool.  If Autodist
324 should not run 'aclocal' this option may be removed or set to empty value.
325 User need to then run it manually.
326
327
328 @example
329 AUTOHEADER="autoheader"
330 @end example
331
332 The 'AUTOHEADER' specifies the location of the 'autoheader' tool.  If
333 Autodist should not run 'autoheader' this option may be removed or set
334 to empty value.  User need to then run it manually.
335
336 @example
337 AUTOCONF="autoconf"
338 @end example
339
340 The 'AUTOCONF' specifies the location of the 'autoconf' tool.  If
341 Autodist should not run 'autoconf' this option may be removed or set
342 to empty value.  User need to then run it manually.
343
344
345 @example
346 AUTOMAKE="automake -a -c"
347 @end example
348
349 The 'AUTOMAKE' specifies the location of the 'automake' tool.  If
350 Autodist should not run 'automake' this option may be removed or set
351 to empty value.  User need to then run it manually.  By default, the
352 '-a'  and '-c' options are given to 'automake' to add any missing required 
353 files.
354
355
356 @example
357 LIBTOOLIZE="libtoolize --automake -c"
358 @end example
359
360 The 'LIBTOOLIZE' specifies the location of the 'libtoolize' tool.
361 This option should be removed or ste to empty value if 'libtool' is not
362 used in the source tree.
363
364
365 @example
366 MAKE=make
367 @end example
368
369 The 'MAKE' specifies the location of the 'make' program.  This option must
370 be set to valid value in order to create distributions.
371
372
373 @menu
374 * Creating new distribution::   Adding new distribution
375 @end menu
376
377
378 @node Creating new distribution
379 @section Creating new distribution
380
381 After the Autodist has been integrated into the software project by
382 creating the 'distdir' and 'default' distribution, the source tree
383 can be prepared for configuration and compilation (@pxref{Preparing source tree, , , , }).  However, the 'default' distribution should be used only as
384 a development distribution.  Usually it is used to prepare the raw source
385 tree (such as a tree just checkout
386 from CVS) for configuration and compilation.  By default, the 'default'
387 distribution cannot be packaged.  However, if the software project is
388 small (one distribution), it may be convenient to edit the 'default'
389 distribution to be as the distribution that is packaged from the source
390 tree.  In software project where multiple distributions are created using
391 the 'default' only as a development distribution is recommended.  The
392 real distributions should be defined as separate distributions.
393
394 Creating a new distribution is a simple process.  Each distribution
395 is placed in the 'distdir' and the file name of the distribution file is
396 used to reference to it.  By default, the distribution name is the
397 file name of the distribution file.  The actual distribution file is
398 a simple text file with various directives that define the distribution.
399
400 If the 'default' distribution is used as a development distribution it
401 might be desired to inherit some or all of the created distributions in
402 it, so that development becomes possible with the 'default' distribution.
403 Adding 'inherit' directive into the 'distdir/default' will inherit the
404 specified distribution.
405
406
407 @menu
408 * Distribution file format::    Detailed document for distfile format
409 @end menu
410
411
412 @node Distribution file format
413 @section Distribution file format in detail
414
415 The distribution file, or distfile from now on, defines your distribution,
416 distribution defines, options, included and excluded files and
417 directories, license, and additional processing.  Each distribution is
418 defined in a separate file and the distributions are referenced by
419 their file name.
420
421 The distfile is a text file that contains various directives that define
422 the actual distribution.  Lines starting with '#' are considered comments
423 and are ignored.
424
425
426 @section Directive: name <name>
427
428 The 'name' directive defines the name of the distribution.  It is optional
429 directive, and if omitted the distribution name will be the name of the
430 distfile.
431
432 Example:
433 @example
434 name FOO Application
435 @end example
436
437 Will set your distribution name as 'Foo Application'.
438
439
440 @section Directive: package <package>
441
442 The 'package' directive defines the name of the distribution package.  It is
443 optional directive, and if omitted the distribution package name will
444 be the name of the distribution, if defined, or if omitted, then the name
445 of the distfile.  If this directive is omitted then normal GNU convention
446 is used to decide the package name, derived from the distribution name.
447
448 Example:
449 @example
450 package foo-client
451 @end example
452
453 Will create distribution packages named, for example, as
454 'foo-client-1.0.tar.gz'.
455
456
457 @section Directive: bug-report <email address>
458
459 The 'bug-report' directive can be used to define the email address where
460 the bug-reports for the distribution should be sent.  The directive is
461 optional.  The 'bug-report' email address will be set for the Autoconf
462 which will deliver it via AC_INIT macro.
463
464
465 @section Directive: license <filename>
466
467 The 'license' directive can be used to define the license file for the
468 distribution.  This directive is optional.  The license file will be
469 copied into the distribution in the name 'COPYING'.  If the 'COPYING'
470 file already exist it will be replaced.
471
472 Example:
473 @example
474 license license/GPL
475 @end example
476
477 Will include the file 'license/GPL' into the distribution in the file
478 name 'COPYING'.
479
480
481 @section Directive: license-header <current-license> <new-license>
482
483 The 'license-header' can be used to re-license your files into a new
484 license.  This directive is optional.  There may be zero or more
485 'license-header' directives in distribution.  The 'license-header'
486 directive will compare the license header that usually appear at the
487 start of a file to the <current-license>.  If it matches it will
488 be replaced with the <new-license>.  The license header in the file
489 will be replaced and the file will have effectively been re-licensed.
490
491 Example:
492 @example
493 license-header license/BSD-header license/GPL-header
494 @end example
495
496 Will replace all appearances of the license header in 'license/BSD-header'
497 file to the license header in 'license/GPL-header' in any file in the
498 distribution.  Note that, the header change will be performed when
499 the distribution is packaged (@pxref{Creating distribution, , , , }).
500
501 With 'license-header' directive you may initially set your files in the
502 source tree into what ever license you prefer.  However, if you need to
503 re-license parts of the source tree in certain distributions the
504 'license-header' will achieve this automatically.  For example, suppose
505 one wants to create two different versions of a library distribution, with
506 different feature sets, in two different licenses.
507
508 There are several limitations in the current implementation of Autodist
509 with the 'license-header' directive:
510
511 First limitation is that the header files must have equal amount of lines.
512 If the new header file has fewer lines that the current header file, all
513 of the lines from the current header will not be replaced.  If the new header
514 has fewer lines, empty lines must be added to it.  If the new header file
515 has more lines than the current header file, the extra lines will not appear
516 in the replaced header.  Basic rule is to always make sure the header file
517 has equal amount of lines in them.
518
519 Second limitation is in indentation of the header files.  It is suggested,
520 though not mandatory, that the header files have the same indentation as
521 is commonly used in the source tree; if the license header text in a file
522 starts at the second character instead of at the start of the line, then
523 the header file should start the license text at the second character also.
524 If same indentation is not used the appearance of the replaced header
525 may not be perfect.  While this is a cosmetic issue, one still to remember.
526
527 Example current header:
528 @example
529 --- Start example
530   This program is free software; you can redistribute it and/or modify
531   it under the terms of the GNU General Public License as published by
532   the Free Software Foundation; version 2 of the License.
533
534   This program is distributed in the hope that it will be useful,
535   but WITHOUT ANY WARRANTY; without even the implied warranty of
536   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
537   GNU General Public License for more details.
538 --- end example
539 @end example
540
541 Example new header:
542 @example
543 --- Start example
544   All rights reserved.
545
546   Redistribution and use in source and binary forms, with or without
547   modification, are permitted provided that the conditions listed in the
548   COPYING file are met.
549
550
551
552 --- end example
553 @end example
554
555 In this example, if the text in the current header file is found in any
556 file in the distribution it will be replaced with the new header file.
557 Notice that, both header files has same amount of lines (8 lines).
558
559 Note that, the current header must match exactly the header used in 
560 files.  Otherwise the replacement will not be complete.
561
562
563 @section Directive: inherit <distfile>
564
565 The Autodist provides inheritance of distributions.  The 'inherit'
566 directive is used to define the distribution which will be inherited
567 into the distribution.  The <distfile> specifies the name of the
568 inherited distribution.  If the distribution cannot be inherited Autodist
569 will give an error.
570
571 The 'inherit' will inherit the following information from the distribution:
572 distdefs, undefines, includes, excludes and noprocess.  Other information
573 will not be inherited.  If the inherited distribution inherits other
574 distributions, they will also be inherited automatically.  User should be
575 careful when inheriting distributions as it may be possible to create an
576 infinite recursion.  The Autodist would allow for this and not detect this
577 error.  Zero or more 'inherit' directives may be set for distribution.
578
579 Example:
580 @example
581 inherit common
582 inherit client
583 inherit toolkit
584 @end example
585
586 Will inherit distributions 'common', 'client' and 'toolkit' into this
587 distribution.  All distdefs, undefines, includes, excludes and noprocesses
588 from these distributions are now also part this distribution.
589
590
591 @section Directive: define <symbol>
592
593 The 'define' directive is used to define the distdef symbols for the
594 distribution.  This directive is optional, however, all distributions
595 should define at least one distdef so that the distribution may be
596 controlled with the distdef conditionals in files in the source tree (@pxref{Distdefines, , , , }).  By default, the distdef prefix is '_DIST_'.  Many
597 software projects will want to set their own prefix for the distdefs
598 for consistency.  The prefix may be defined in the 'autodist.conf' file
599 (@pxref{autodist.conf, , , , }).
600
601 Example:
602 @example
603 define _DIST_FOO
604 define _DIST_FEATURE_X
605 define _DIST_LIBRARY_Y
606 @end example
607
608 Will define the following distdefs for the distribution: '_DIST_FOO',
609 '_DIST_FEATURE_X' and '_DIST_LIBRARY_Y'.  These distdefs may then be
610 used in the source tree and source code to control what is included in
611 or excluded from this distribution.
612
613
614 @section Directive: undef <symbol>
615
616 The 'undef' directive may be used to explicitly undefine a distdef.
617 When inheriting distributions it may be desired to be able undefine
618 certain distdefs.  This directive is optional.
619
620 Example:
621 @example
622 undef _DIST_FEATURE_Y
623 @end example
624
625 Will undefine '_DIST_FEATURE_Y' distdef.  This distdef will not be part
626 of this distribution anymore, even if it is defined in some inherited
627 distribution.
628
629
630 @section Directive: option <option> [...]
631
632 The 'option' directive is used to define various options for the
633 distribution.  The options can change the behavior of the distribution.
634 This directive is optional.  One or more options may be defined in one
635 'option' directive.  Zero or more 'option' directives may be set for
636 distribution.  The following options are available.
637
638 @example
639 template
640 @end example
641
642 When set, the distribution is a template distribution.  Templates are
643 special distributions which cannot be prepared or packaged with Autodist.
644 Templates can only be inherited.  Usually, templates are used to define a
645 common template distribution for other distributions.  Templates may set
646 distdefs, undefines, includes and excludes.  A large software project
647 could have several distributions that share a common base.  In this case
648 defining the common base as a template distribution and then inheriting
649 that distribution makes it easier to manage the distfiles.
650
651 @example
652 no-dist
653 @end example
654
655 Distributions with the 'no-dist' option are similar to templates, except
656 that they can be prepared with Autodist, but they cannot be packaged.
657 These are usually used as a common development distribution, such as the
658 'default' distribution created with 'autodist -i'.
659
660 @example
661 no-inherit
662 @end example
663
664 If this option is set to normal distributions or distributions with
665 'no-dist' option, the distribution cannot be inherited.  For template
666 this option has no effect.  If distribution with this option is inherited
667 the Autodist will give an error.
668
669
670 @section Directive: include <source> [<destination>]
671
672 The 'include' directive can be used to include files or directories into
673 the distribution.  Sometimes it may be desired to specify included
674 files and directories in distribution instead of Makefile.am and
675 EXTRA_DIST, especially if there are many distributions that need to
676 include specific files and directories.  While it would be possible
677 to define them in Makefile.ad and use distdef conditionals to define
678 which will be included in which distribution, if there are many different
679 distributions it may pollute the Makefile.ad unnecessarily.
680
681 This directive is optional.  The <source> may be a single file, a  single
682 directory or a regular expression which will match several files and/or
683 directories.  The <destination> is optional.  If it is omitted then
684 the <source> will be copied into the same location in the distribution.
685 If the <destination> is provided the <source> will be copied into the
686 specified location.
687
688 Example:
689 @example
690 include apps/foobar/README README
691 include lib/libfoo
692 include lib/libfoobar lib/foobarlib
693 include doc/foo*
694 include scripts/foobar.sh foo.sh
695 @end example
696
697 Will include the file 'apps/foobar/README' into the top distribution
698 directory in the name 'README', the directory 'lib/libfoo' into same
699 location in distribution, the directory 'lib/libfoobar' into
700 'lib/foobarlib' changing the name of the directory into 'foobarlib',
701 the files and directories that match 'doc/foo*' into the same locations
702 in distribution, and finally the 'scripts/foobar.sh' into the top
703 distribution directory changing the name of the file into 'foo.sh'.
704
705 Note that, the 'include' directives will be processed by the Autodist
706 only when the distribution is packaged (@pxref{Creating distribution, , , , }).  When preparing the source
707 tree for configuration and compilation (@pxref{Preparing source tree, , , , })
708 the 'include' directives are ignored.  This is same behavior as with
709 Makefile.am's EXTRA_DIST.
710
711 If the included file or directory does not exist the Autodist will
712 give an error and stop the distribution creation.  If the destination
713 file exist, it will be replaced with the included file.  If the
714 destination directory already exists, the contents of the source
715 directory will be copied into the directory.  Note that, the directory
716 will not be copied into the directory; if the <destination> is specified,
717 also the name of the <source> file or directory must be specified,
718 otherwise the 'include' will change the name into the one specified.
719
720 Example:
721 @example
722 include lib/libfoo lib
723 @end example
724
725 In this example the 'lib/libfoo' will be included as 'lib'.  If the 'lib'
726 already exists, this effectively copies the contents of the 'lib/libfoo'
727 into 'lib'.  In order to include the directory with same name, the
728 name must be specified.
729
730 Example:
731 @example
732 include lib/libfoo lib/libfoo
733 include lib/foobar new_lib/foobar
734 @end example
735
736 This will include the 'lib/libfoo' into 'lib/libfoo' in distribution,
737 and 'lib/foobar' into 'new_lib/foobar' in distribution.
738
739
740 @section Directive: exclude <filename> [...]
741
742 The 'exclude' directive can be used to exclude files and directories from
743 the distribution.  This directive is optional.  This directive is
744 processed before processing the 'include' directive.  The <filename>
745 can be a single file, a single directory or a regular expression that
746 will match several files and/or directories.
747
748 Example:
749 @example
750 exclude README
751 exclude doc/client*
752 @end example
753
754 This will exclude the file 'README' and anything that match 'doc/client*'.
755
756
757 @section Directive: noprocess <filename> [...]
758
759 The 'noprocess' directive can be used to tell Autodist specificly not to
760 process a file.  The Autodist will not process the file during
761 preparation or during distribution packaging.  This directive is optional.
762 One or more file can be specified in the 'noprocess' directive.  Zero or
763 more 'noprocess' directives can be used in distribution.  The <filename>
764 can be a single file, a single directory or a regular expression that
765 will match several files and/or directories.  If directory is specified
766 then all files inside the directory will not be processed.
767
768 Example:
769 @example
770 noprocess autodist.texi
771 @end example
772
773 Autodist will not process 'autodist.texi' file.
774
775 Note that, 'noprocess' directive cannot be used to disallow processing
776 of any file with '.ad' suffix.
777
778
779 @section Directive: pre-hook <filename> [...]
780
781 The 'pre-hook' directive can be used define additional scripts that
782 will be run before the source tree is prepared.  This directive is
783 optional.  One or more scripts may be defined in one 'pre-hook' directive.
784 Zero or more 'pre-hook' directives may be set for distribution.  The
785 'pre-hook' hook will be run immediately after invoking Autodist to start
786 preparing the source tree for configuration and compilation (@pxref{Preparing source tree, , , , }).
787
788 The scripts will get three (3) command line arguments when Autodist
789 executes the script: distribution name, distribution version and package
790 name of distribution.  The script may use these arguments if it needs them.
791
792
793 @section Directive: post-hook <filename> [...]
794
795 The 'post-hook' directive can be used define additional scripts that
796 will be run after the source tree is prepared.  This directive is
797 optional.  One or more scripts may be defined in one 'post-hook' directive.
798 Zero or more 'post-hook' directives may be set for distribution.  The
799 'post-hook' hook will be run immediately after the Autodist has finished
800 preparing the source three for configuration and compilation (@pxref{Preparing source tree, , , , }).  The Autodist will exit after it has run the
801 'post-hook' scripts.
802
803 The scripts will get three (3) command line arguments when Autodist
804 executes the script: distribution name, distribution version and package
805 name of distribution.  The script may use these arguments if it needs them.
806
807
808 @section Directive: pre-dist-hook <filename> [...]
809
810 The 'pre-dist-hook' directive can be used define additional scripts that
811 will be run when Autodist has started distribution creation.  This directive
812 is optional.  One or more scripts may be defined in one 'pre-dist-hook'
813 directive.  Zero or more 'pre-dist-hook' directives may be set for
814 distribution.  The 'pre-dist-hook' hook will be run immediately after
815 the Autodist has created the distribution directory but has not yet
816 started any distribution processing.
817
818 The scripts will get four (4) command line arguments when Autodist
819 executes the script: distribution name, distribution version, package
820 name of distribution and destination distribution directory name.  The
821 script may use these arguments if it needs them.
822
823
824 @section Directive: post-dist-hook <filename> [...]
825
826 The 'post-dist-hook' directive can be used define additional scripts that
827 will be run when Autodist has finished distribution processing.  This
828 directive is optional.  One or more scripts may be defined in one
829 'post-dist-hook' directive.  Zero or more 'post-dist-hook' directives may
830 be set for distribution.  The 'post-dist-hook' hook will be run immediately
831 after the Autodist has finished processing the destination distribution
832 directory but has not yet created the distribution package.
833
834 The scripts will get four (4) command line arguments when Autodist
835 executes the script: distribution name, distribution version, package
836 name of distribution and destination distribution directory name.  The
837 script may use these arguments if it needs them.
838
839
840 @section Example distfile
841
842 The following is a simple distfile example.  The example assumes that the
843 distdefs prefix is 'SILC'.
844
845 @example
846 # SILC Client distribution
847 name SILC Client
848 package silc-client
849 bug-report silc-client-bugs@@silcnet.org
850 inherit common
851 inherit platform-unix
852 inherit platform-win32
853 define SILC_DIST_CLIENT
854 define SILC_DIST_CLIENTLIB
855 define SILC_DIST_IRSSI
856 undef SILC_DIST_MPI
857 exclude doc/draft*
858 pre-hook scripts/client-pre-run
859 post-dist-hook scripts/client-post-dist-run
860 post-dist-hook scripts/client-post-dist-kludge
861 @end example
862
863 @menu
864 * configure.ad files::          configure script for creating configure.ac
865 @end menu
866
867
868 @node configure.ad files
869 @section configure.ad files
870
871 Autodist creates 'configure.ac' file from the 'configure.ad' file.  The
872 'configure.ad' file is a rather normal 'configure.ac' except that it accepts
873 also Autodist macros.  Autodist also supports configure script fragments,
874 also named as 'configure.ad'.  Any 'configure.ad' file in the source tree
875 can be incorporated into the the top 'configure.ad' file.  Sometimes it may
876 be useful to split a large configure script into smaller fragments.
877 Especially in multi distribution system where certain libraries or features
878 can be excluded from certain distributions it may be useful to handle
879 their configuration from a configure fragment.  If the library is
880 excluded then also its configuration can be excluded.
881
882 If the software project already has a 'configure.ac' or 'configure.in'
883 file, the 'configure.ad' can be created by simply renaming the current
884 file to 'configure.ad'.  In this case the current configure script
885 must be edited to support Autodist.  This is done by replacing the
886 'AC_INIT' to 'AD_INIT'.  After specifying the 'AD_INIT' as the first
887 macro in the 'configure.ad', the Autodist support has been fully
888 integrated into the software project.
889
890 If your software project is going to use configure fragments, then
891 also Autodist macro 'AD_INCLUDE_CONFIGURE' must be used.  Autodist will
892 automatically combine the fragments with the top 'configure.ac' script.
893 To exclude a 'configure.ad' fragment from a distribution use the distdef
894 conditionals inside the 'configure.ad' fragment file.  If the distdef is
895 not defined the fragment will be excluded automatically.
896
897 The following macros are available in current Autodist version.
898
899 @defmac AD_INIT
900
901 The 'AD_INIT' macro is used in place of Autoconf macro 'AC_INIT'.  The
902 'AD_INIT' must be the first macro in the 'configure.ad', just like the
903 'AC_INIT' macro in 'configure.ac'.  The AD_INIT macro is used to deliver
904 the distribution names, distribution version, package name and bug-report
905 email address to the 'configure.ac' file that Autodist will create.
906 The 'AC_INIT' macro must not be used in 'configure.ad' file.
907
908 This macro is mandatory and Autodist will exit with error if it is not
909 specified in 'configure.ad'.  This macro has no arguments.
910 @end defmac
911
912
913 @defmac AD_INCLUDE_CONFIGURE
914
915 This macro is used to tell Autodist that it should include any other
916 'configure.ad' fragment that is found from the source tree into the
917 top 'configure.ad' file.  Note that, the 'configure.ad' fragments will
918 be incorporated at the location where this macro is used in the
919 'configure.ad'.  Usually this macro is placed just before the Autoconf
920 macro 'AC_OUTPUT'.  This macro has no arguments.
921
922 Note that, the 'configure.ad' fragments are not real full featured
923 configure scripts.  They must not use 'AD_INIT', 'AD_INCLUDE_CONFIGURE',
924 'AC_INIT' or any other initialization macros.
925
926 @end defmac
927
928 @menu
929 * Makefile.ad files::           Makefile.ad for creating Makefile.am
930 @end menu
931
932
933 @node Makefile.ad files
934 @section Makefile.ad files
935
936 Autodist creates 'Makefile.am' files from 'Makefile.ad' files.  A software
937 project do not need to use 'Makefile.ad' files if there is no need to
938 use distdef conditionals inside makefiles.  Usually a multi distribution
939 software project, however will need to define certain things to different
940 distributions.  In these cases 'Makefile.ad' file needs to be created.
941
942 Even though it would be possible to use distdef conditionals also inside
943 'Makefile.am' files, Autodist does not process 'Makefile.am' files when
944 preparing the source tree for configuration and compilation (@pxref{Preparing source tree, , , , }).  Thus, the prepared environment would not be
945 identical to the created distribution package (when the 'Makefile.am'
946 will be processed), and configuration and compilation would be inconsistent.
947 Basic rule is, if you need distdefs (@pxref{Distdefines, , , , }) inside
948 makefiles, put them inside 'Makefile.ad' file.
949
950
951 @menu
952 * Other .ad files::             Other files with .ad suffix
953 @end menu
954
955
956 @node Other .ad files
957 @section Other .ad files
958
959 Any file in the source tree can have the '.ad' suffix appended.  Autodist
960 will process any file that has the suffix when the source tree is
961 prepared for configuration and compilation (@pxref{Preparing source tree, , , , }).  If the files have distdef conditionals the Autodist will process them.
962 The files will have the '.ad' suffix removed.
963
964 Basic rule is, if you need to process some file when preparing the
965 source tree for configuration and compilation, add '.ad' suffix to it.
966 Distdefs (@pxref{Distdefines, , , , }) can be used in any file in source
967 tree but without '.ad' suffix Autodist will not process those files during
968 preparation.  They will be processed when creating the distribution package.
969 If you need processed files during configuration or compilation then they
970 need to have '.ad' suffix.
971
972 @menu
973 * Distdefines::                 Using distdefs in files
974 @end menu
975
976
977 @node Distdefines
978 @section Using distribution defines (distdefs)
979
980 Distribution defines, or distdefs from now on, are used to define inside
981 a file what will be included in the distribution.  Distribution may define
982 many different distdefs, for example, based on feature sets, platforms, or
983 for other similar reasons.  If distdef is not defined for the distribution
984 but is used in a file, anything inside the distdef in that file will be
985 removed when the distribution is packaged (@pxref{Creating distribution, , , , }).  This guarantees that only the files, directories and file content
986 (such as source code) that is supposed to be delivered with the distribution
987 are delivered.  Delivering files or code accidentally in the distribution
988 cannot happen.
989
990 All other files, except files ending with '.ad' suffix are processed for
991 distdefs only when the distribution is packaged.  Files ending with '.ad'
992 suffix are processed for distdefs when preparing the source tree for
993 configuration and compilation (@pxref{Preparing source tree, , , , }).
994
995 By default the distdefs are named '_DIST_XXX', where 'XXX' is the name of
996 distdef.  However, many projects will want to define their own prefix
997 for distdefs in the 'autodist.conf' configuration file (@pxref{autodist.conf, , , , }).
998 In the following examples a prefix 'SILC' is used, hence the prefix for 
999 the distdefs are 'SILC_DIST_'.
1000
1001 The basic format for the distdefs are as follows:
1002
1003 @example
1004 #ifdef SILC_DIST_DEFINE
1005 #endif SILC_DIST_DEFINE
1006
1007 #ifndef SILC_DIST_DEFINE
1008 #endif SILC_DIST_DEFINE
1009
1010 #ifdef SILC_DIST_DEFINE
1011 #else !SILC_DIST_DEFINE
1012 #endif SILC_DIST_DEFINE
1013
1014 #ifndef SILC_DIST_DEFINE
1015 #else SILC_DIST_DEFINE
1016 #endif SILC_DIST_DEFINE
1017 @end example
1018
1019 This format should be used only in non-source files, as for example C and
1020 C++ compilers will not like this format inside a file.  In source files
1021 a compiler friendly format, defined below, should be used.
1022
1023 @example
1024 #ifdef SILC_DIST_DEFINE
1025 #endif /* SILC_DIST_DEFINE */
1026
1027 #ifndef SILC_DIST_DEFINE
1028 #endif /* SILC_DIST_DEFINE */
1029
1030 #ifdef SILC_DIST_DEFINE
1031 #else /* !SILC_DIST_DEFINE */
1032 #endif /* SILC_DIST_DEFINE */
1033
1034 #ifndef SILC_DIST_DEFINE
1035 #else /* SILC_DIST_DEFINE */
1036 #endif /* SILC_DIST_DEFINE */
1037 @end example
1038
1039 Note that, only the format defined above is supported.  Other more complex
1040 use of the preprocessor directives such as using '&&' and '||' in the '#ifdef'
1041 or '#ifndef' are not supported, and neither is '#elif'.  Also note, that in
1042 the compiler friendly format the name of the distdef in comments and the
1043 use of '!' character in the '#else' branch of '#ifdef' are mandatory.  Also
1044 note, that the distdef conditionals must be placed at the start of the line,
1045 they must not be indented.
1046
1047 The following example shows the use of non-source format:
1048
1049 @example
1050 SUBDIRS =                        \
1051 #ifdef SILC_DIST_SERVER
1052        server                    \
1053        server-foobar             \
1054 #endif SILC_DIST_SERVER
1055 #ifndef SILC_DIST_CLIENT
1056        tests                     \
1057 #endif SILC_DIST_CLIENT
1058 #ifdef SILC_DIST_TOOLKIT
1059        toolkit                   \
1060        toolkit-docs              \
1061 #else !SILC_DIST_TOOLKIT
1062        doc                       \
1063        lib                       \
1064 #ifdef SILC_DIST_CLIENT
1065        client                    \
1066 #endif SILC_DIST_CLIENT
1067 #endif SILC_DIST_TOOLKIT
1068 @end example
1069
1070 Say, in this example, your distribution has the SILC_DIST_CLIENT and
1071 SILC_DIST_SERVER defined, but not the SILC_DIST_TOOLKIT, the end result
1072 would be:
1073
1074 @example
1075 SUBDIRS =                        \
1076        server                    \
1077        server-foobar             \
1078        doc                       \
1079        lib                       \
1080        client                    \
1081 @end example
1082
1083 The lines defined specificly for the SILC_DIST_TOOLKIT, which in our
1084 example was not defined, were removed.  Also lines that specificly
1085 expected certain distdefs not to be defined ('#ifndef') were removed.
1086 (Note the last remaining '\' in example above would be removed by the
1087 Autodist automatically to avoid errors with Automake.)
1088
1089 The following example shows the use of source code format:
1090
1091 @example
1092   initialize_lib();
1093 #ifdef SILC_DIST_MPI
1094   init_mpi();
1095   mpi = mpi_alloc();
1096 #else /* !SILC_DIST_MPI */
1097   init_gmp();
1098 #endif /* SILC_DIST_MPI */
1099
1100 #ifndef SILC_DIST_FOOBAR
1101   foobar_replacement();
1102 #else /* SILC_DIST_FOOBAR */
1103   real_foobar();
1104 #endif /* SILC_DIST_FOOBAR */
1105 @end example
1106
1107 Say, you have both SILC_DIST_MPI and SILC_DIST_FOOBAR defined, the end result
1108 would be:
1109
1110 @example
1111   initialize_lib();
1112   init_mpi();
1113   mpi = mpi_alloc();
1114
1115   real_foobar();
1116 @end example
1117
1118 Even before processing the source files with Autodist, the preprocessor 
1119 will respect the preprocessor directives if the code use '#include' to 
1120 include the distdef header file created by the Autodist (see 
1121 'autodist.conf' (@pxref{autodist.conf, , , , })).  When the distribution 
1122 is packaged (@pxref{Creating distribution, , , , }) the Autodist will 
1123 process the files, and will remove any line not defined to be included.  
1124 The preprocessor directives will also be removed.
1125
1126 Because the software project includes the header file with '#include' the 
1127 distdef header file needs to be present in the distribution, unless it is 
1128 placed inside some other '#ifdef' conditional.  If the distribution is
1129 prepared but not compiled (it is packaged after preparation without
1130 compilation) then including the distdef header in the source is not 
1131 necessary.  Including it then in the distribution is not necessary either.
1132  
1133 The software project should not use the same name space that distdef
1134 conditionals use for other than distribution usage.  The Autodist will
1135 process any line that uses the formats above and has the specified prefix
1136 (eg. 'SILC_DIST_') in those lines.  Using same prefix for other purposes
1137 will produce unexpected results and invalid distributions.
1138
1139 The following suffixes will be considered as source files by the Autodist:
1140
1141 @example
1142     .c
1143     .C
1144     .cc
1145     .cp
1146     .cpp
1147     .CPP
1148     .cxx
1149     .CXX
1150     .c++
1151     .m
1152     .h
1153     .H
1154     .hh
1155 @end example
1156
1157 Using distdefs in any other file must follow the non-source format.
1158
1159
1160 @node Invoking Autodist
1161 @chapter Invoking Autodist
1162
1163 The Autodist has two basic functions:
1164
1165     1. Preparing source tree for configuration and compilation (@pxref{Preparing source tree, , , , })
1166
1167     2. Creating distribution packages (@pxref{Creating distribution, , , , })
1168
1169 The 'autodist' accepts the following options:
1170
1171 @table @samp
1172
1173 @item -h
1174 @itemx --help
1175 Prints the help for the Autodist and exits.
1176
1177 @item -V
1178 @itemx --version
1179 Prints version number and exits.
1180
1181 @item -v
1182 @itemx --verbose
1183 Verbosely report processing.
1184
1185 @item -d
1186 @itemx --distdir <dir>
1187 Search distributions from <dir> instead of default 'distdir'.
1188
1189 @item -s
1190 @itemx --distdefs [<dist>]
1191 Prints distribution defines of <dist> and exits.
1192
1193 @item -i
1194 @itemx --init
1195 Initializes Autodist environment.  Creates the default distribution
1196 directory 'distdir', 'autodist.conf' configuration file and the
1197 default distribution 'default', then exits.
1198
1199 @item -m
1200 @itemx --makedist
1201 Creates and packages distribution
1202
1203 @itemx --gzip
1204 Create package compressed with gzip (default)
1205
1206 @itemx --bzip2
1207 Create also package compressed with bzip2
1208
1209 @itemx --compress
1210 Create also package compressed with compress
1211
1212 @itemx --zip
1213 Create also package compressed with zip
1214
1215
1216 @end table
1217
1218 @menu
1219 * Preparing source tree::       Preparing source tree with Autodist
1220 * Creating distribution::       Creating distribution with Autodist
1221 @end menu
1222
1223
1224 @node Preparing source tree
1225 @section Preparing source tree for configuration and compilation
1226
1227 Before distribution can be created from the source tree, the source tree
1228 must be prepared for configuration and compilation.  If your project is
1229 not using Autodist, then you would do this by running perhaps 'aclocal',
1230 'autoconf', 'autoheader' and 'automake' tools manually, or you would run an
1231 'autogen.sh' script that prepares your raw source tree.  With Autodist
1232 this process is performed by Autodist, and running these tools manually
1233 or using 'autogen.sh' script is not necessary.
1234
1235 By default the 'autodist.conf' (@pxref{autodist.conf, , , , }) has defined 
1236 the tools that will be run by the Autodist when preparing the source tree.  
1237 These are 'aclocal', 'autoheader', 'autoconf', 'automake' and 
1238 'libtoolize'.  If you do not whish that Autodist runs some or any of these 
1239 tools automatically, do not set them in the 'autodist.conf'.  You would 
1240 then need to run them manually. However, this is not recommended.  If you 
1241 need to run additional preparation scripts you may set your scripts either 
1242 in the 'pre-hook' and/or 'post-hook' where you can run what ever 
1243 additional processing you may need to prepare your source tree.
1244
1245 By default the Autodist creates a 'default' distribution when you
1246 initialize your project by running 'autodist -i'.  The 'default'
1247 distribution should be used when you are developing in your source
1248 tree.  By default, the 'default' distribution cannot be packaged,
1249 however, if your project creates only one distribution you may find
1250 it more convenient to define your distribution inside the 'default'
1251 distribution and allow it to be packaged also.  If your source tree
1252 will create multiple distributions, the 'default' should be used only
1253 as development distribution.  You would use it when you, for example,
1254 checkout your source tree from CVS and prepare it for configuration
1255 and compilation.  To prepare your source tree with the 'default'
1256 distribution run Autodist without any arguments.
1257
1258 @example
1259   autodist
1260 @end example
1261
1262 The Autodist will prepare your source tree.  After that you may run
1263 './configure' and continue to compile with 'make'.
1264
1265 If you do not whish to use the 'default' distribution, or you whish
1266 to do the development in a tree specificly prepared for some specific
1267 distribution, or you are preparing to create a new distribution package,
1268 you will need to run the Autodist with the distribution you whish to
1269 prepare.
1270
1271 @example
1272   autodist example-distribution 1.0.3
1273 @end example
1274
1275 This prepares your source tree for 'example-distribution' of version
1276 '1.0.3'.  After that you may run './configure' and continue to compile
1277 with 'make'.  If the version is omitted the version will be '0.0'.
1278
1279 Note that, running Autodist for preparation merely prepares your source
1280 tree for the distribution, it does not create an actual distribution
1281 package.  When preparing source tree for configuration and compilation
1282 the Autodist will process any file that ends with '.ad' suffix.  It will
1283 process all 'configure.ad' and 'Makefile.ad' files for that distribution.
1284 When you run './configure' your tree will be configured for that
1285 distribution, and when you compile with 'make' it will compile for that
1286 distribution.
1287
1288 However, the source files, or any other file (except files ending with
1289 '.ad' suffix) are not processed by the Autodist.  When compiling
1290 your sources the preprocessor, however, will respect your distdef
1291 conditionals inside your source files if you include the distdef header
1292 file.  This way, even the compiled binaries will be compiled for that
1293 distribution, even though the source files has not yet been processed
1294 by the Autodist.  Rest of the files in the distribution will be processed
1295 when you create the actual distribution package.  It is guaranteed that
1296 the distribution you have prepared will behave in your source tree exactly
1297 the same way as if it was already packaged with Autodist (providing that
1298 you remember to include the distdef header file in your code).
1299
1300 @menu
1301 * Creating distribution::       Creating distribution with Autodist
1302 @end menu
1303
1304
1305 @node Creating distribution
1306 @section Creating distribution package(s)
1307
1308 Before creating a new distribution package, you will need to prepare
1309 the source tree for the distribution you want to create.  After preparing
1310 your source tree you will be ready to create a new distribution.  The
1311 Autodist package provides a simple helper script 'makedist' that may
1312 be used to create the distribution.  However, if you whish, you may
1313 run the Autodist yourself, as the 'makedist' will call Autodist anyway.
1314
1315 To create a new distribution for the distribution you have prepared for
1316 run makedist.
1317
1318 @example
1319   makedist
1320 @end example
1321
1322 This will run the Autodist and create a new distribution package that
1323 is archived with 'tar' and compressed with 'gzip'.  If you whish to
1324 create packages also compressed with 'bzip2', 'compress' and/or 'zip'
1325 you may give one or all of the following options:
1326
1327 @example
1328   makedist --bzip2 --compress --zip
1329 @end example
1330
1331 This example would create, in addition of 'tar.gz' package, also a
1332 'tar.bz2', 'tar.Z' and '.zip' packages.  Current version of Autodist does
1333 not support archiving with 'shar'.
1334
1335 If you whish to run additional processing for your distributions when
1336 they are being packaged you may set 'pre-dist-hook' and/or 'post-dist-hook'
1337 in your distribution file.  Also note that any hooks provided by Automake
1338 in Makefiles will be run in normal manner.
1339
1340 For additional help, you may give:
1341
1342 @example
1343   makedist --help
1344 @end example
1345
1346
1347 @node Examples
1348 @chapter Examples
1349
1350 @menu
1351 * Single distribution tree::    Single distribution example
1352 * Multiple distribution tree::  Multiple distributions example
1353 @end menu
1354
1355 @node Single distribution tree
1356 @section Single distribution tree example, start to finish
1357
1358 Lets suppose you have a simple source tree with one application,
1359 called 'foozbar' you whish to release.  While you would probably suffice
1360 using Autoconf and Automake features you may still use Autodist.
1361
1362 First, you create the default 'distdir' into your software package:
1363
1364 @example
1365   autodist -i
1366 @end example
1367
1368 Then, you create the 'configure.ad' file from your existing 'configure.ac'
1369 or 'configure.in' file.  If you don't have configure script written yet,
1370 please refer to the Autoconf manual.  In the 'autodist.ad' you add as
1371 first macro in the file:
1372
1373 @example
1374   AD_INIT
1375 @end example
1376
1377 Then, you create distribution file for your application:
1378
1379 @example
1380 # Foozbar distribution
1381 name Foozbar
1382 package foozbar
1383 bug-report foozbar-bugs@@foo.z.bar
1384 define _DIST_FOOZBAR
1385 @end example
1386
1387 This distribution file go into 'distdir/foozbar'.
1388
1389 And there you go.  You have succesfully integrated Autodist into your
1390 source tree.  If you need to do development and you whish to use the
1391 'default' distribution for that, you should inherit the new 'foozbar'
1392 distribution in it.  Add the following line in 'distdir/default':
1393
1394 @example
1395   inherit foozbar
1396 @end example
1397
1398 After that, you can prepare the source tree for configuration and
1399 compilation by giving:
1400
1401 @example
1402   autodist
1403 @end example
1404
1405 After this command you can give './configure' and 'make'.
1406
1407 If you want to do development directly in a tree prepared for the
1408 'foozbar' distribution, or you are ready to start creating a new
1409 distribution package, you give:
1410
1411 @example
1412   autodist foozbar 1.0
1413 @end example
1414
1415 After this command you can give './configure' and 'make'.
1416
1417 To create the distribution package, you will give:
1418
1419 @example
1420   makedist
1421 @end example
1422
1423 The end result will be a 'foozbar-1.0.tar.gz' package.
1424
1425
1426 @node Multiple distribution tree
1427 @section Multiple distribution tree example, start to finish
1428
1429 Lets suppose you have a source tree from which you create multiple
1430 distributions, say three.  If you really have a such source tree you
1431 must have by now noticed the difficulty of maintaining such a source tree
1432 and problems with controlling the distributions.  Maybe you have sufficed
1433 with Autoconf and Automake, or perhaps you have created your own scripts
1434 that carry out the kludges.  No more, for Autodist is here.
1435
1436 First, you integrate Autodist into your tree by creating the distributions
1437 directory 'distdir':
1438
1439 @example
1440   autodist -i
1441 @end example
1442
1443 Then, you create the 'configure.ad' file from your existing 'configure.ac'
1444 or 'configure.in' file.  If you don't have configure script written yet,
1445 please refer to the Autoconf manual.  In the 'autodist.ad' you add as
1446 first macro in the file:
1447
1448 @example
1449   AD_INIT
1450 @end example
1451
1452 You then continue with creating the distribution files for your three
1453 distributions.  Let's name them 'foozbar', 'libfoozbar' and 'nomad'.
1454 We will also create a common template that all distributions inherit.
1455
1456 @example
1457 # Foozbar distribution
1458 name Foozbar
1459 package foozbar
1460 bug-report foozbar-bugs@@foo.z.bar
1461 inherit common
1462 define _DIST_FOOZBAR
1463 @end example
1464
1465 @example
1466 # libfoozbar distribution
1467 name libfoozbar
1468 bug-report libfoozbar-bugs@@foo.z.bar
1469 inherit common
1470 define _DIST_LIBFOOZBAR
1471 @end example
1472
1473 @example
1474 # Nomad distribution
1475 name Nomad
1476 package nomad-the-server
1477 bug-report nomad-bugs@@foo.z.bar
1478 inherit common
1479 include doc/nomad
1480 define _DIST_NOMAD
1481 define _DIST_NOMAD_LIB
1482 undef _DIST_CRYPTO
1483 @end example
1484
1485 @example
1486 # Common template
1487 define _DIST_DOC
1488 define _DIST_LIB
1489 define _DIST_MATH
1490 define _DIST_CRYPTO
1491 define _DIST_UNIX
1492 define _DIST_MACOSX
1493 define _DIST_WIN32
1494 @end example
1495
1496 You put the distribution files in the 'distdir' directory.  In addition
1497 you will be doing development in the source tree using the 'default'
1498 distribution, you will add the new distributions to the 'distdir/default':
1499
1500 @example
1501 inherit foozbar
1502 inherit libfoozbar
1503 inherit nomad
1504 @end example
1505
1506 To prepare the source tree for configuration and compilation you would
1507 simply give:
1508
1509 @example
1510 autodist
1511 @end example
1512
1513 This will prepare your source tree for configuration and compilation.  Since
1514 the 'default' distribution inherits all distributions your development
1515 source tree will have all of them included.  If you do not want to do this
1516 then don't inherit them in the 'default', but run the autodist specificly
1517 for the distributions, for example:
1518
1519 @example
1520 autodist foozbar
1521 @end example
1522
1523 Since all the distributions inherit the 'common' distribution they get
1524 all the distdefs that the 'common' defines.  In this example various distdefs
1525 has been defined.  You would use them in your code and in your makefiles
1526 to control various things.  For example, let's say the 'common' distdefs
1527 control what directories distributions have.  An example 'Makefile.ad'
1528 file:
1529
1530 @example
1531 SUBDIRS =                       \
1532 #ifdef _DIST_LIB
1533        lib                      \
1534 #endif _DIST_LIB
1535 #ifdef _DIST_DOC
1536        doc                      \
1537 #endif _DIST_DOC
1538 @end example
1539
1540 Perhaps the 'Makefile.ad' in 'lib' subdirectory could define something
1541 like this:
1542
1543 @example
1544 SUBDIRS =                       \
1545         util                    \
1546 #ifdef _DIST_MATH
1547         mathlib                 \
1548 #endif _DIST_MATH
1549 #ifdef _DIST_CRYPTO
1550         cryptolib               \
1551 #endif _DIST_CRYPTO
1552 #ifdef _DIST_NOMAD_LIB
1553         nomadlib                \
1554 #endif _DIST_NOMAD_LIB
1555 #ifdef _DIST_LIBFOOZBAR
1556         foozbarlib               \
1557 #endif _DIST_LIBFOOZBAR
1558 @end example
1559
1560 Since the 'nomad' distribution undefined the '_DIST_CRYPTO' distdef it
1561 would not have the 'cryptolib' in its distribution.  Clearly Nomad
1562 don't need it.  In addition of using the distdefs just in the makefiles
1563 you may want to use them in the source code as well:
1564
1565 @example
1566      ...some code...
1567
1568 #ifdef _DIST_MATH
1569   /* Initialize math library */
1570   math_init();
1571 #endif /* _DIST_MATH */
1572
1573      ...some code...
1574 @end example
1575
1576 After an intensive development period you're ready to create new releases.
1577 Let's say you're going to release all distributions:
1578
1579 First you release Foozbar 0.5.1:
1580
1581 @example
1582 autodist foozbar 0.5.1
1583 makedist --bzip2
1584 @end example
1585
1586 The end result is two files: 'foozbar-0.5.1.tar.gz' and
1587 'foozbar-0.5.1.tar.bz2'.
1588
1589 Then you continue with libfoozbar and Nomad:
1590
1591 @example
1592 autodist libfoozbar 1.0.5
1593 makedist
1594
1595 autodist nomad 2.0
1596 makedist
1597 @end example
1598
1599 The end results are: 'libfoozbar-1.0.5.tar.gz' and 'nomad-2.0.tar.gz'.
1600
1601 @page
1602 @contents
1603 @bye