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