From d33dd2ef943698beb7c6d6bf3a74578f11512148 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 16 Apr 2005 20:23:52 +0000 Subject: [PATCH] Added Autodist. --- Makefile.ad | 165 + Makefile.defines.in | 57 + Makefile.defines_int.in | 58 + apps/Makefile.ad | 23 + apps/autodist/AUTHORS | 3 + apps/autodist/COPYING | 25 + apps/autodist/INSTALL | 236 + apps/autodist/Makefile.am | 49 + apps/autodist/README | 49 + apps/autodist/autodist.conf | 49 + apps/autodist/autodist.in | 1600 +++++++ apps/autodist/configure.ad | 52 + apps/autodist/default | 10 + apps/autodist/doc/Makefile.am | 19 + apps/autodist/doc/autodist.texi | 1603 +++++++ apps/autodist/doc/fdl.texi | 452 ++ apps/autodist/doc/mdate-sh | 133 + apps/autodist/doc/texinfo.tex | 6740 ++++++++++++++++++++++++++++ apps/autodist/makedist.in | 35 + apps/autodist/tests/Makefile.am | 27 + apps/autodist/tests/autodist1.test | 67 + apps/autodist/tests/autodist2.test | 86 + config.guess | 1449 ++++++ config.sub | 1552 +++++++ configure.ad | 1289 ++++++ distdir/BSD | 25 + distdir/BSD-header | 8 + distdir/GPL | 340 ++ distdir/GPL-header | 8 + distdir/autodist | 18 + distdir/autodist.conf | 49 + distdir/default | 16 + distdir/post-dist | 14 + includes/.cvsignore | 2 + install-sh | 251 ++ missing | 336 ++ 36 files changed, 16895 insertions(+) create mode 100644 Makefile.ad create mode 100644 Makefile.defines.in create mode 100644 Makefile.defines_int.in create mode 100644 apps/Makefile.ad create mode 100644 apps/autodist/AUTHORS create mode 100644 apps/autodist/COPYING create mode 100644 apps/autodist/INSTALL create mode 100644 apps/autodist/Makefile.am create mode 100644 apps/autodist/README create mode 100644 apps/autodist/autodist.conf create mode 100755 apps/autodist/autodist.in create mode 100644 apps/autodist/configure.ad create mode 100644 apps/autodist/default create mode 100644 apps/autodist/doc/Makefile.am create mode 100644 apps/autodist/doc/autodist.texi create mode 100644 apps/autodist/doc/fdl.texi create mode 100755 apps/autodist/doc/mdate-sh create mode 100644 apps/autodist/doc/texinfo.tex create mode 100755 apps/autodist/makedist.in create mode 100644 apps/autodist/tests/Makefile.am create mode 100755 apps/autodist/tests/autodist1.test create mode 100755 apps/autodist/tests/autodist2.test create mode 100755 config.guess create mode 100755 config.sub create mode 100644 configure.ad create mode 100644 distdir/BSD create mode 100644 distdir/BSD-header create mode 100644 distdir/GPL create mode 100644 distdir/GPL-header create mode 100644 distdir/autodist create mode 100644 distdir/autodist.conf create mode 100644 distdir/default create mode 100644 distdir/post-dist create mode 100644 includes/.cvsignore create mode 100755 install-sh create mode 100755 missing diff --git a/Makefile.ad b/Makefile.ad new file mode 100644 index 0000000..1ffcbca --- /dev/null +++ b/Makefile.ad @@ -0,0 +1,165 @@ +# +# Makefile.ad +# +# Author: Pekka Riikonen +# +# Copyright (C) 2000 - 2005 Pekka Riikonen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign + +SUBDIRS = \ +#ifdef SILC_DIST_APPS + apps \ +#endif SILC_DIST_APPS +#ifdef SILC_DIST_LIB + lib \ +#endif SILC_DIST_LIB +#ifdef SILC_DIST_CLIENT + irssi \ +#endif SILC_DIST_CLIENT +#ifdef SILC_DIST_SERVER + silcd \ +#endif SILC_DIST_SERVER +#ifdef SILC_DIST_TOOLKIT + silc \ + win32 \ +#endif SILC_DIST_TOOLKIT +#ifdef SILC_DIST_INCLUDES + includes \ +#endif SILC_DIST_INCLUDES +#ifdef SILC_DIST_DOC + doc +#endif SILC_DIST_DOC + +EXTRA_DIST = \ + silcdefs.h.in \ +#ifdef SILC_DIST_SILC +#ifdef SILC_DIST_TOOLKIT + README.CVS README.WIN32 README.MACOSX silcer tutorial \ +#endif SILC_DIST_TOOLKIT + libtoolfix \ + CHANGES CREDITS +#endif SILC_DIST_SILC + +#ifdef SILC_DIST_SILC +# +# Installing of SILC into the system +# + +install-dirs: + -mkdir -p $(etcdir) + -mkdir -p $(modulesdir) + -mkdir -p $(docdir) + +doc-install: + -$(INSTALL_DATA) $(srcdir)/doc/CodingStyle $(docdir)/ + -$(INSTALL_DATA) $(srcdir)/doc/FAQ $(docdir)/ + -$(INSTALL_DATA) $(srcdir)/doc/*.txt $(docdir)/ + -$(INSTALL_DATA) $(srcdir)/COPYING $(docdir)/ + -$(INSTALL_DATA) $(srcdir)/CHANGES $(docdir)/ + -$(INSTALL_DATA) $(srcdir)/CREDITS $(docdir)/ + -$(INSTALL_DATA) $(srcdir)/README* $(docdir)/ + -$(INSTALL_DATA) $(srcdir)/INSTALL $(docdir)/ + -$(INSTALL_DATA) $(srcdir)/TODO $(docdir)/ + +#ifdef SILC_DIST_SIM +sim-install: + -$(INSTALL_DATA) $(srcdir)/lib/silcsim/*.so $(modulesdir)/ +#endif SILC_DIST_SIM + +#ifdef SILC_DIST_CLIENT +install-dirs-client: install-dirs + -mkdir -p $(helpdir) + -mkdir -p $(mandir)/man1 + +doc-install-client: doc-install + $(INSTALL_DATA) $(srcdir)/irssi/silc.conf $(docdir)/example_silc.conf + -@if test -f $(srcdir)/doc/silc.1 ; then \ + $(INSTALL_DATA) $(srcdir)/doc/silc.1 $(mandir)/man1; \ + fi + +etc-install-client: + -@if test '!' -d $(srcdir)/irssi ; then \ + if test '!' -f $(etcdir)/silc.conf ; then \ + $(INSTALL_DATA) $(srcdir)/irssi/silc.conf \ + $(etcdir)/silc.conf; \ + fi; \ + fi +#endif SILC_DIST_CLIENT + +#ifdef SILC_DIST_SERVER +install-dirs-server: install-dirs + -mkdir -p $(logsdir) + -mkdir -p $(mandir)/man5 + -mkdir -p $(mandir)/man8 + +doc-install-server: doc-install + -$(INSTALL_DATA) $(srcdir)/doc/example_silcd.conf $(docdir)/ + -@if test -f $(srcdir)/doc/silcd.8 ; then \ + $(INSTALL_DATA) $(srcdir)/doc/silcd.8 $(mandir)/man8; \ + fi + -@if test -f $(srcdir)/doc/silcd.conf.5 ; then \ + $(INSTALL_DATA) $(srcdir)/doc/silcd.conf.5 $(mandir)/man5; \ + fi + +etc-install-server: + -@if test '!' -f $(etcdir)/silcd.conf ; then \ + $(INSTALL_DATA) $(srcdir)/doc/example_silcd.conf \ + $(etcdir)/silcd.conf; \ + $(INSTALL_DATA) $(srcdir)/doc/silcalgs.conf \ + $(etcdir)/silcalgs.conf; \ + chmod go= $(etcdir)/silcd.conf; \ + fi + +examples-install: + -mkdir -p $(docdir)/examples/ + -$(INSTALL_DATA) $(srcdir)/doc/examples/README $(docdir)/examples/ + -$(INSTALL_DATA) $(srcdir)/doc/examples/silc* $(docdir)/examples/ + +generate-server-key: + -@if test '!' -f $(etcdir)/silcd.pub ; then \ + $(sbindir)/silcd -C $(etcdir); \ + fi +#endif SILC_DIST_SERVER + +#ifdef SILC_DIST_TOOLKIT +toolkit-install: + -mkdir -p $(docdir)/toolkit/ + -$(INSTALL_DATA) $(srcdir)/doc/toolkit/* $(docdir)/toolkit + -$(INSTALL_DATA) $(srcdir)/lib/doc/*.gif $(docdir)/toolkit + -cp -R $(srcdir)/tutorial $(prefix) +#endif SILC_DIST_TOOLKIT + +install-data-hook: \ +#ifdef SILC_DIST_CLIENT + install-dirs-client \ + doc-install-client \ + etc-install-client \ +#endif SILC_DIST_CLIENT +#ifdef SILC_DIST_SERVER + install-dirs-server \ + doc-install-server \ + etc-install-server \ + examples-install \ + generate-server-key \ +#endif SILC_DIST_SERVER +#ifdef SILC_DIST_TOOLKIT + toolkit-install \ +#endif SILC_DIST_TOOLKIT +#ifdef SILC_DIST_SIM + sim-install +#endif SILC_DIST_SIM + +include $(top_srcdir)/Makefile.defines.in + +#endif SILC_DIST_SILC diff --git a/Makefile.defines.in b/Makefile.defines.in new file mode 100644 index 0000000..926a303 --- /dev/null +++ b/Makefile.defines.in @@ -0,0 +1,57 @@ +# +# Makefile.defines.pre +# +# Author: Pekka Riikonen +# +# Copyright (C) 2001 Pekka Riikonen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +# +# This file is intended to include all common compilation defines for the +# SILC source tree. All Makefile.ams in the SILC source tree are expected +# to include this file (Makefile.defines.in). Also this file may be included +# in any external project that is included in the SILC source tree. +# +# Add following to your Makefile.am: +# +# include $(top_srcdir)/Makefile.defines.in +# +# All packages in the SILC source tree that include the Makefile.defines.in +# must also include the following two lines in their configure.in file. +# +# INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int" +# AC_SUBST(INCLUDE_DEFINES_INT) +# +# (See the Makefile.defines_int.pre for all different definitions but DO NOT +# directly include that file!) +# + +@INCLUDE_DEFINES_INT@ + +# +# INCLUDE defines +# +INCLUDES = $(ADD_INCLUDES) $(SILC_CFLAGS) -DHAVE_SILCDEFS_H \ + -I$(srcdir) -I$(top_srcdir) \ + -I$(silc_top_srcdir) $(SILC_LIB_INCLUDES) \ + -I$(silc_top_srcdir)/includes \ + -I$(silc_top_srcdir)/doc + +# +#includes-install: Makefile +# for i in $(include_HEADERS); do s=$(srcdir)/$$i; +#d=$(silc_top_srcdir)/includes/$$i; \ +# ln $$s $$d 2>/dev/null || (rm -f $$d; cp -p $$s $$d;); \ +# done; +# +#all-local: includes-install diff --git a/Makefile.defines_int.in b/Makefile.defines_int.in new file mode 100644 index 0000000..3f82947 --- /dev/null +++ b/Makefile.defines_int.in @@ -0,0 +1,58 @@ +# +# Makefile.defines_int.pre +# +# Author: Pekka Riikonen +# +# Copyright (C) 2000 - 2001 Pekka Riikonen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +# +# Internal file for definitions. This is read by Makefile.defines. DO NOT +# include this file directly to your Makefile.ams. +# + +# +# Generic definitions +# +silc_top_srcdir=@SILC_TOP_SRCDIR@ +silc_install_prefix=@prefix@ + +# +# Common libraries that are linked against the created executable +# +SILC_COMMON_LIBS= @LIBS@ -L$(silc_top_srcdir)/lib -lsilc + +# +# Common compilation flags +# +SILC_CFLAGS=@CFLAGS@ + +# +# SILC Library includes +# +SILC_LIB_INCLUDES=@SILC_LIB_INCLUDES@ + +# +# Installation defines +# +silc_etcdir=@ETCDIR@ +silc_modulesdir=@MODULESDIR@ +silc_helpdir=@HELPDIR@ +silc_docdir=@DOCDIR@ +silc_logsdir=@LOGSDIR@ +etcdir = $(DESTDIR)$(silc_etcdir) +modulesdir = $(DESTDIR)$(silc_modulesdir) +helpdir = $(DESTDIR)$(silc_helpdir) +docdir = $(DESTDIR)$(silc_docdir) +logsdir = $(DESTDIR)$(silc_logsdir) +mandir = $(DESTDIR)@mandir@ diff --git a/apps/Makefile.ad b/apps/Makefile.ad new file mode 100644 index 0000000..0a01a55 --- /dev/null +++ b/apps/Makefile.ad @@ -0,0 +1,23 @@ +# +# Makefile.ad +# +# Author: Pekka Riikonen +# +# Copyright (C) 2005 Pekka Riikonen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign + +SUBDIRS = \ +#ifdef SILC_DIST_AUTODIST + autodist +#endif SILC_DIST_AUTODIST diff --git a/apps/autodist/AUTHORS b/apps/autodist/AUTHORS new file mode 100644 index 0000000..99141c0 --- /dev/null +++ b/apps/autodist/AUTHORS @@ -0,0 +1,3 @@ +Authors of SILC Autodist. + +Pekka Riikonen diff --git a/apps/autodist/COPYING b/apps/autodist/COPYING new file mode 100644 index 0000000..5329321 --- /dev/null +++ b/apps/autodist/COPYING @@ -0,0 +1,25 @@ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/apps/autodist/INSTALL b/apps/autodist/INSTALL new file mode 100644 index 0000000..56b077d --- /dev/null +++ b/apps/autodist/INSTALL @@ -0,0 +1,236 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free +Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + +By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PREFIX', the package will +use PREFIX as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). Here is a another example: + + /bin/bash ./configure CONFIG_SHELL=/bin/bash + +Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent +configuration-related scripts to be executed by `/bin/bash'. + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/apps/autodist/Makefile.am b/apps/autodist/Makefile.am new file mode 100644 index 0000000..c9d8c9a --- /dev/null +++ b/apps/autodist/Makefile.am @@ -0,0 +1,49 @@ +# +# Makefile.am +# +# Author: Pekka Riikonen +# +# Copyright (C) 2005 Pekka Riikonen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign + +SUBDIRS = . doc tests + +AUTODIST_SOURCE = autodist.in makedist.in +bin_SCRIPTS = autodist makedist + +autodistdir = @AUTODISTDIR@ +autodist_DATA = autodist.conf default COPYING + +CLEANFILES = $(bin_SCRIPTS) + +APIVERSION = @APIVERSION@ +# Install versioned links. +install-exec-hook: + @for i in $(bin_SCRIPTS); do \ + f="`echo $$i | sed '$(transform)'`"; \ + fv="$$f-$(APIVERSION)"; \ + rm -f $(DESTDIR)$(bindir)/$$fv; \ + chmod +x $(DESTDIR)$(bindir)/$$f; \ + chmod a-w $(DESTDIR)$(bindir)/$$f; \ + ln $(DESTDIR)$(bindir)/$$f $(DESTDIR)$(bindir)/$$fv; \ + done + +uninstall-hook: + @for i in $(bin_SCRIPTS); do \ + f="`echo $$i|sed '$(transform)'`"; \ + fv="$$f-$(APIVERSION)"; \ + rm -f $(DESTDIR)$(bindir)/$$fv; \ + done + +EXTRA_DIST = $(AUTODIST_SOURCE) default autodist.conf diff --git a/apps/autodist/README b/apps/autodist/README new file mode 100644 index 0000000..e954599 --- /dev/null +++ b/apps/autodist/README @@ -0,0 +1,49 @@ +Autodist + +The Autodist is a source distribution management system that allows +powerful mechanisms to define what is included in and excluded from a +distribution, and what license the distribution is released under. It is +also used to create the actual distribution source packages. Autodist +allows distribution management in file, directory and file content level. +Different distributions may include different portions of files, for +example, excluding certain features from certain distributions. It is +always guaranteed that anything not defined for the distribution, is +removed automatically (files, file content, directories), thus ensuring +that nothing is accidentally included in the distribution. + +Autodist is closely related to the Autoconf and Automake tools, and +complements the features Autoconf and Automake provides. It is especially +targeted into circumstances where multiple distributions are created from +one source tree. The Autoconf and Automake environment is mainly designed +for one application per one source tree situations. Autodist provides +mechanisms to create all kinds of distributions that can be created from +one source tree. To be able to use Autodist, the Autoconf and Automake +must be installed into the system. + +The motivation behind Autodist stems from need to be able to create +multiple distributions from one large source tree in a precise and +controllable manner. The Autoconf and Automake provides mere basic +control what is included in and excluded from distributions and how the +distributions are created. They also do not provide mechanism to define +different licensing conditions for different distributions, or changing +the license automatically for different user or customer purposes. Many +large software projects, companies and corporations have commonly been +using Autoconf and Automake tools, but have had the need to create their +own ad-hoc mechanisms to control distribution creation. The Autodist +attempts to provide a tool that any size software project or company can +effectively use to manage their distributions. + +Autodist is not a binary packaging system. It is specificly used to +create source distributions. A binary packaging system, however can be +hooked to the distribution creation process, if needed. + +Read the INSTALL file on how to install the Autodist. Refer info pages +for Autodist documentation by giving 'info autodist'. Mail suggestions +and/or patches to autodist@silcnet.org, and bugs to +autodist-bugs@silcnet.org. Please, always include the Autodist version +number to your email. Give 'autodist --version' to get version. + +Autodist was originally written for the SILC Project (Secure Internet Live +Conferencing), which needed controlled mechanism to create several +distinct distributions from one source tree. + diff --git a/apps/autodist/autodist.conf b/apps/autodist/autodist.conf new file mode 100644 index 0000000..4748b0e --- /dev/null +++ b/apps/autodist/autodist.conf @@ -0,0 +1,49 @@ +# Autodist configuration file + +# By default distdef prefix is '_DIST_'. To add your own prefix set the +# prefix here. NOTE: Remember to change all 'define' directives in +# distributions to use the new prefix if you change it. Example: +# +# DISTPREFIX="SILC" +# +# Will set the distdef prefix as 'SILC_DIST_'. +# +DISTPREFIX="" + +# The distdef header will be created by the Autodist. It need to be included +# in the source code in order for the preprocessor to respect distdef +# conditionals in source code. Example: +# +# DISTDEFS="include/distdefs.h" +# +DISTDEFS="distdefs.h" + +# Location of the aclocal tool. If this is omitted the Autodist will not +# run aclocal. User need to run it manually then. +# +ACLOCAL="aclocal" + +# Location of the autoheader tool. If this is omitted the Autodist will not +# run autoheader. User need to run it manually then. +# +AUTOHEADER="autoheader" + +# Location of the autoconf tool. If this is omitted the Autodist will not +# run autoconf. User need to run it manually then. +# +AUTOCONF="autoconf" + +# Location of the automake tool. If this is omitted the Autodist will not +# run automake. User need to run it manually then. +# +AUTOMAKE="automake -a" + +# Location of the libtoolize tool. This option should be omitted if your +# source tree does not use libtool. +# +LIBTOOLIZE="libtoolize --automake --copy" + +# Location of the make program. This must be specified in order to be +# able to create distributions. +# +MAKE="make" diff --git a/apps/autodist/autodist.in b/apps/autodist/autodist.in new file mode 100755 index 0000000..27e6c22 --- /dev/null +++ b/apps/autodist/autodist.in @@ -0,0 +1,1600 @@ +#!/bin/sh +# +# Author: Pekka Riikonen +# +# Copyright (C) 2005 Pekka Riikonen +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +############################################################################### +# Global variables + +# Packaging and compressing +ad_gzip=true +ad_bzip2=false +ad_compress=false +ad_zip=false + +# Distribution subdirectory +distdir="distdir" +am_distdir= + +# This current distribution +distribution=default +distfile=$distribution +dist_version=0.0 +package= +bug_report= + +# All inherited distributions in this distribution +inherits= + +# All distribution defines for this distribution +distdefs= + +# All distribution undefines for this distribution +undistdefs= + +# All distribution options +options= +opt_template=false +opt_no_dist=false +opt_no_inherit=false + +# All includes +includes= + +# All excludes +excludes= + +# All noprocesses +noprocess= + +# All pre, post pre-dist and post-dist hooks +pre_hooks= +post_hooks= +pre_dist_hooks= +post_dist_hooks= + +# Distribution license and license header +license= +licenseh= + +# Whether to output ad_debug information +debug=false + +# Autodist version +ver=@VERSION@ + +############################################################################### +# Configuration file +if test -f "$distdir/autodist.conf"; then + . $distdir/autodist.conf +fi + +DP=$DISTPREFIX + + +############################################################################### +# Functions + +# +# Print out debug information if debugging is enabled. To enable debugging +# set the global variable "debug" to true value. +# +# Arguments: ad_debug +# +ad_debug() +{ + if test x$debug = xtrue; then + set -f + echo autodist: $1 + set +f + fi +} + +# +# Prints out error message and exits the script. +# +# Arguments: ad_fatal +# +ad_fatal() +{ + set -f + echo autodist: error: $1 + set +f + exit 1 +} + +# +# Prints out warning message +# +# Arguments: ad_warning +# +ad_warning() +{ + set -f + echo autodist: warning: $1 + set +f +} + +# +# Initializes the Autodist environment, creates default distribution +# directory, and default distribution. +# +# Arguments: ad_initialize +# +ad_initialize() +{ + ad_debug ">ad_initialize" + + # Create default distdir + if test '!' -f $distdir; then + mkdir -p $distdir + fi + + # Create Autodist configuration file + if test -f @AUTODISTDIR@/autodist.conf; then + cp -p @AUTODISTDIR@/autodist.conf $distdir + fi + + # Create default distribution + if test -f @AUTODISTDIR@/default; then + cp -p @AUTODISTDIR@/default $distdir + fi + + ad_debug "ad_create_distdefs_h" + + fname=$DISTDEFS + rm -f $fname + echo "/*" > $fname + echo " Automatically generated by Autodist $ver. Do not edit." >> $fname + echo >> $fname + echo " Generated: `date` by `whoami`" >> $fname + echo " Distribution: $distribution" >> $fname + echo " License: $license" >> $fname + echo "*/" >> $fname + echo >> $fname + echo "#ifndef _"$DP"_DISTDEFS_H" >> $fname + echo "#define _"$DP"_DISTDEFS_H" >> $fname + echo >> $fname + + for i in $distdefs + do + echo "#define $i 1" >>$fname + done + + echo >> $fname + echo "#endif /* _"$DP"_DISTDEFS_H */" >> $fname + + ad_debug "ad_make_configure" + local run_autoconf=false + + rm -f configure + + if test "$ACLOCAL"; then + ad_debug "Running aclocal" + $ACLOCAL 1>/dev/null 2>/dev/null + if test $? != 0; then + ad_fatal "aclocal failed" + fi + fi + + if test "$AUTOCONF"; then + ad_debug "Running autoconf" + $AUTOCONF + if test $? != 0; then + ad_fatal "autoconf failed" + fi + run_autoconf=true + fi + + if test "$AUTOHEADER"; then + ad_debug "Running autoheader" + $AUTOHEADER + if test $? != 0; then + ad_fatal "autoheader failed" + fi + fi + + if test "$LIBTOOLIZE"; then + ad_debug "Running libtoolize" + $LIBTOOLIZE + if test $? != 0; then + ad_fatal "libtoolize failed" + fi + fi + + if test x$run_autoconf = xtrue; then + if test '!' -f configure; then + ad_fatal "creating configure script failed" + fi + fi + + ad_debug " +# +ad_make_configure_ac() +{ + ad_debug ">ad_make_configure_ac: $1" + + if test '!' -f $1; then + ad_fatal "The configure file '$1' does not exist" + fi + + local check="`cat $1 | sed 's/^[ ]*//' | grep -v "^#" | grep -e "AD_INIT"`" + if test -z $check; then + rm -f configure.ad.cfs + rm -f $fname $fname.tmp + ad_fatal "The 'AD_INIT' macro has not been set in configure.ac" + fi + + rm -f configure.ac configure.ad.cfs + + cfs=`find . -name configure\*\.ad` + for i in $cfs + do + if test "x$i" = "x$1"; then + continue + fi + ad_debug "including $i" + cat $i >> configure.ad.cfs + done + + if test -f configure.ad.cfs; then + local check="`cat $1 | sed 's/^[ ]*//' | grep -v "^#" | grep -e "AD_INCLUDE_CONFIGURE"`" + if test -z $check; then + rm -f configure.ad.cfs + ad_warning "configure.ad fragments found but 'AD_INCLUDE_CONFIGURE' is not set" + fi + fi + + # Header for configure.ac + fname="configure.tmp.ac" + echo "# Automatically generated by Autodist $ver. Do not edit." > $fname + echo "# To make changes edit the $i file in the source tree." >> $fname + echo >> $fname + echo "# Source: $i" >> $fname + echo "# Generated: `date` by `whoami`" >> $fname + echo "# Distribution: $distribution" >> $fname + echo "# License: $license" >> $fname + echo >> $fname + + ad_debug "creating configure.ac" + if test -f configure.ad.cfs; then + sed '/AD_INCLUDE_CONFIGURE/ r configure.ad.cfs' $1 > $fname.tmp + sed -e "/AD_INCLUDE_CONFIGURE/s///" $fname.tmp >> $fname + rm -f configure.ad.cfs $fname.tmp + else + cat $1 >> $fname.tmp + fi + + # Process AD_INIT + sed -e "/AD_INIT/s//AC_INIT([$distribution], [$dist_version], [$bug_report], [$package])/" $fname > $fname.tmp + + # Process for distribution + rm -f $fname + ad_process_file $fname.tmp $fname + + # Remove any trailing backslashes + if test -f "$fname"; then + cat $fname | sed -e :a -e '/\\$/N; s/\\\n//; ta' > configure.ac + else + cp -p $fname.tmp configure.ac + fi + rm -f $fname $fname.tmp + + ad_debug "ad_make_makefile_ins" + + if test "$AUTOMAKE"; then + ad_debug "Running automake" + $AUTOMAKE + if test $? != 0; then + ad_fatal "automake failed" + fi + fi + + ad_debug "ad_make_makefile_ams" + + files=`find . -name Makefile\.ad` + for ff in $files + do + fname=`echo $ff | sed s/\.ad//` + + # Header for the Makefile.am + echo "# Automatically generated by Autodist $ver from Makefile.ad. Do not edit." > $fname.am + echo "# To make changes edit the $ff file in the source tree." >> $fname.am + echo >> $fname.am + echo "# Source: $ff" >> $fname.am + echo "# Generated: `date` by `whoami`" >> $fname.am + echo "# Distribution: $distribution" >> $fname.am + echo "# License: $license" >> $fname.am + echo >> $fname.am + + # Run the distribution processing for this Makefile.ad + ad_debug "Processing $ff to be $fname.am" + ad_process_file $ff $fname.tmp + + # Remove any trailing backslashes + if test -f "$fname.tmp"; then + cat $fname.tmp | sed -e :a -e '/\\$/N; s/\\\n//; ta' >> $fname.am + else + cat $ff >> $fname.am + fi + + rm -f $fname.tmp + done + + ad_debug "ad_process_ads" + + files=`find . -name \*\.ad \! -name configure\*\.ad \! -name Makefile\.ad` + for i in $files + do + fname=`echo $i | sed s/\.ad//` + + # Header + echo "# Automatically generated by Autodist $ver. Do not edit." > $fname + echo "# To make changes edit the $i file in the source tree." >> $fname + echo >> $fname + echo "# Source: $i" >> $fname + echo "# Generated: `date` by `whoami`" >> $fname + echo "# Distribution: $distribution" >> $fname + echo "# License: $license" >> $fname + echo >> $fname + + # Run the distribution processing for this file + ad_debug "Processing $i to be $fname" + ad_process_file $i $fname + done + + ad_debug " [] +# +# If only source path, which may be file, directory or regular expression, +# is specified the path will be same in distribution. If the destination +# path is specified that will be the new name and/or new location of the +# source path. This, in effect, is a cp utility with ability to create +# directories if they do not exist. +# +# Arguments: ad_dist_includes +# +ad_dist_includes() +{ + ad_debug ">ad_dist_includes: $1 $2" + + # By default do not expand pathnames + set -f + + # Add : separator at the end + local incs="`echo "$1" | sed 's/$/ : /'`" + + src= + dst= + for i in $incs + do + if test "$i" = ":" && test -z "$src"; then + continue + fi + if test -z "$src"; then + src=$i + continue + fi + if test -z "$dst" && test "$i" != ":"; then + dst=$i + else + dst=$src + fi + + ad_debug "Including $src into $dst" + + if test -f "$src"; then + # Add file + + if test "$src" = "$dst"; then + # Add to same location + d=`echo $src | sed 's,/[^/]*$,,'` + if test "$d" != "$src" && test "$d" != "." && \ + test '!' -d $am_distdir/$d; then + mkdir -p $am_distdir/$d || exit 1 + fi + else + # Add to different location + check=`echo "$dst" | sed 's/?//; s/*//; s/\[//; s/\]//'` + if test "$check" != "$dst"; then + ad_fatal "Invalid destination in 'include $src $dst'" + fi + + d=`echo $dst | sed 's,/[^/]*$,,'` + if test "$d" != "$dst" && test "$d" != "." && \ + test '!' -d $am_distdir/$d; then + mkdir -p $am_distdir/$d || exit 1 + fi + fi + + cp -p $src $am_distdir/$d || exit 1 + + elif test -d "$src"; then + # Add directory + + if test "$src" = "$dst"; then + # Add to same location + d=`echo $src | sed 's,/[^/]*$,,'` + ds=`echo $src | sed 's/\/$//'` + if test "$ds" = "$d"; then + d=`echo $d | sed 's,/[^/]*$,,'` + fi + if test '!' -d $am_distdir/$d && test "$ds" != "$d"; then + mkdir -p $am_distdir/$d || exit 1 + fi + + cp -pR $src $am_distdir/$d || exit 1 + else + # Add to different location + check=`echo "$dst" | sed 's/?//; s/*//; s/\[//; s/\]//'` + if test "$check" != "$dst"; then + ad_fatal "Invalid destination in 'include $src $dst'" + fi + + d=`echo $dst | sed 's,/[^/]*$,,'` + ds=`echo $dst | sed 's/\/$//'` + if test "$ds" = "$d"; then + d=`echo $d | sed 's,/[^/]*$,,'` + fi + if test '!' -d $am_distdir/$d && test "$dst" != "$d"; then + mkdir -p $am_distdir/$d || exit 1 + fi + + cp -pR $src $am_distdir/$dst || exit 1 + fi + + elif test x$2 != xtrue; then + # We assume regular expression in filename + check=`echo "$src" | sed 's/?//; s/*//; s/\[//; s/\]//'` + if test "$check" == "$src"; then + if test '!' -a $src; then + ad_fatal "Including $src: No such file or directory" + fi + src= + dst= + continue + fi + + # Recursively call this function with expanded pathnames. The + # reason why we don't let sh by default expand patnames is that + # the include's destination is optional. If sh expands by default + # we don't know the destination. For this reason, we handle the + # expansion here ourselves. + + # If src and dst are same, then expand the pathname as we'll copy + # matches to their own locations. + if test "$src" = "$dst"; then + # Expand pathnames, and format to our include format + set +f + srcs=`echo $src | sed -e 's/ / : /g' -e 's/^/ : /'` || exit 1 + set -f + else + # Destination is new, and it has to be a directory. + check=`echo "$dst" | sed 's/?//; s/*//; s/\[//; s/\]//'` + if test "$check" != "$dst"; then + ad_fatal "Invalid destination in 'include $src $dst'" + fi + + # Make sure dst has / at the end, as this must be a directory + dst=`echo $dst | sed 's/\/$//; s/$/\//'` + + # Escape dst for sed + dste=`echo $dst | sed 's/\\//\\\\\//g'` || exit 1 + + # Expand pathnames, and format to our include format + set +f + srcs=`echo $src | sed -e "s/ / $dste : /g" \ + -e 's/^/ : /' -e "s/$/ $dste/"` || exit 1 + set -f + fi + + # Include recursively + ad_dist_includes "$srcs" true + + elif test '!' -a $src; then + ad_fatal "Including $src: No such file or directory" + fi + + src= + dst= + done + + set +f + + ad_debug " +# +# The path may be file, directory or regular expression. +# +# Arguments: ad_dist_includes +# +ad_dist_excludes() +{ + ad_debug ">ad_dist_excludes: $1" + + for i in $1 + do + ad_debug "Excluding $i" + rm -rf $am_distdir/$i + done + + ad_debug " +# +ad_process_tree() +{ + ad_debug ">ad_process_tree: $1" + + # We take all files, other than *.ad, including source files, in case + # they use the non-C-compiler-friendly format of distdefs, which is + # possible. + + files=`find $am_distdir \! -name \*\.ad` + files=`echo $files | sed 's/$am_distdir//'` + + # Take away noprocess list + if test -f autodist.noprocess; then + files=`echo $files | sh autodist.noprocess` || exit 1 + fi + + for ff in $files + do + ad_process_file $ff $ff.tmp + if test -f $ff.tmp; then + rm -f $ff || exit 1 + mv -f $ff.tmp $ff || exit 1 + fi + done + + ad_debug " +# +ad_process_source_tree() +{ + ad_debug ">ad_process_source_tree: $1" + + # We take only C/C++ files since they use the C compiler friendly + # version of distdefs. Other files are not assumed to use them. + files=`find $am_distdir \! -name \*\.ad \( \ + -name \*\.[cC] -o \ + -name \*\.[cC][cCpP] -o \ + -name \*\.[cC][xX][xX] -o \ + -name \*\.[cC][pP][pP] -o \ + -name \*\.[cC]++ -o \ + -name \*\.m -o \ + -name \*\.[hH] -o \ + -name \*\.hh \)` + + # Take away noprocess list + if test -f autodist.noprocess; then + files=`echo $files | sh autodist.noprocess` || exit 1 + fi + + for ff in $files + do + ad_process_source_file $ff $ff.tmp + if test -f $ff.tmp; then + rm -f $ff || exit 1 + mv -f $ff.tmp $ff || exit 1 + fi + done + + ad_debug "ad_makedist_makesane:" + + # DO NOT change these order unless you know what you are doing. + if test -f $am_distdir/configure.ac; then + touch $am_distdir/configure.ac + fi + + if test -f $am_distdir/aclocal.m4; then + touch $am_distdir/aclocal.m4 + fi + + if test '!' -f Makefile; then + ad_fatal "Makefile: No such file or directory" + fi + + configh=`grep "^CONFIG_HEADER" Makefile | cut -d= -f2 | sed 's/^[ \t]//'` + touch $am_distdir/$configh.in 1>/dev/null 2>/dev/null + + files=`find $am_distdir -name Makefile\.in` + for i in $files + do + touch $i + done + + if test -f $am_distdir/configure; then + touch $am_distdir/configure + fi + + if test -f $am_distdir/config.status; then + touch $am_distdir/config.status + fi + + ad_debug "ad_makedist" + + if test '!' -f autodist.dist; then + ad_fatal "Autodist has not been run yet to prepare source tree" + fi + + if test -z $MAKE; then + ad_fatal "The MAKE variable is not set in autodist.conf" + fi + + # Get distdir from Makefile + if test '!' -f Makefile; then + ad_fatal "The source tree is not configured, run ./configure first" + fi + + # Parse the requested distribution + distribution=`cat autodist.dist | grep "dist:" | cut -d: -f2` + dist_version=`cat autodist.dist | grep "ver:" | cut -d: -f2` + ad_parse_distribution $distribution false + ad_process_distdefs + am_distdir="$package-$dist_version" + + if test x$opt_no_dist = xtrue; then + ad_fatal "The '$distribution' distribution cannot be packaged" + fi + + # Create distribution directory + ad_debug "Creating distribution directory $am_distdir" + $MAKE distdir || exit 1 + chmod -R a+r $am_distdir + + if test '!' -d $am_distdir; then + ad_fatal "Distribution directory $am_distdir not created" + fi + + # Run pre-dist-hooks + ad_run_dist_hooks "$pre_dist_hooks" + + # Run excludes + ad_dist_excludes "$excludes" + + # Run includes + ad_dist_includes "$includes" + + # Include specific license file if specified + if test "$license" != ""; then + cp -p $license $am_distdir/COPYING || exit 1 + fi + + # Process noprocesses + ad_process_noprocess + + # Process source files + ad_debug "Process distribution source tree" + ad_process_source_tree $am_distdir + + # Process non-source files + ad_debug "Process distribution tree" + ad_process_tree $am_distdir + + # Run post-dist-hooks + ad_run_dist_hooks "$post_dist_hooks" + + # Make distribution sane + ad_makedist_makesane + + # Package + ad_debug "Packaging distribution" + tar chof $am_distdir.tar $am_distdir || exit 1 + + # Compress + ad_debug "Compressing distribution package" + if test x$ad_gzip = xtrue; then + gzip -9 -c $am_distdir.tar > $am_distdir.tar.gz || exit 1 + fi + if test x$ad_bzip2 = xtrue; then + bzip2 -9 -c $am_distdir.tar > $am_distdir.tar.bz2 || exit 1 + fi + if test x$ad_compress = xtrue; then + compress -c $am_distdir.tar > $am_distdir.tar.Z || exit 1 + fi + if test x$ad_zip = xtrue; then + rm -f $am_distdir.zip + zip -rq $am_distdir.zip $am_distdir || exit 1 + fi + rm -f $am_distdir.tar + + # Cleanup + rm -rf $am_distdir + rm -f autodist.noprocess + + ad_debug " +# +# Following options are supported: +# +# template +# no-dist +# no-inherit +# +# Arguments: ad_handle_options +# +ad_handle_options() +{ + ad_debug ">ad_handle_options: $1" + + for i in $1 + do + if test "$i" = "template"; then + opt_template=true + continue + elif test "$i" = "no-dist"; then + opt_no_dist=true + continue + elif test "$i" = "no-inherit"; then + opt_no_inherit=true + continue + fi + done + + ad_debug "ad_clear_options" + opt_template=false + opt_no_dist=false + opt_no_inherit=false + ad_debug " +# +ad_parse_distribution() +{ + ad_debug ">ad_parse_distribution: $1 $2" + + if test '!' -f $distdir/$1; then + ad_fatal "Distribution '$1' is not declared" + fi + + # Get inherited + local inhs=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "inherit " | cut -d' ' -f2 | sort | uniq` + + # Get distdefs + local defs=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "define " | cut -d' ' -f2 | sort | uniq` + + if test "$inhs" = "" && test "$defs" = ""; then + ad_fatal "Distribution '$1' does not define anything" + fi + + # Get undefined distdefs + local undefs=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "undef " | cut -d' ' -f2 | sort | uniq` + + # Get includes + local incs=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "include " | sed 's/include / : /'` + + # Get excludes + local excs=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "exclude " | cut -d' ' -f2- | sort | uniq` + + # Get noprocesses + local nops=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "noprocess " | cut -d' ' -f2- | sort | uniq` + + # Get options + local opts=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "option " | cut -d' ' -f2- | sort | uniq` + + # Check options + ad_handle_options "$opts" + if test x$2 = xtrue && test x$opt_no_inherit = xtrue; then + ad_fatal "Distribution '$1' cannot be inherited" + fi + if test x$2 = xfalse && test x$opt_template = xtrue; then + ad_fatal "Template distribution '$1' cannot be prepared or packaged" + fi + + ad_debug "inherits=$inhs" + ad_debug "distdefs=$defs" + ad_debug "includes=$incs" + ad_debug "excludes=$excs" + ad_debug "noprocess=$nops" + ad_debug "undistdefs=$undefs" + ad_debug "options=$opts" + + # Expand distdefs from inherited distributions + for i in $inhs + do + if test x$1 = x$i; then + ad_fatal "Infinite recursion detected. Fix the '$distdir/$1' \ + distribution to not have 'inherit $i' declared." + fi + + if test '!' -f $distdir/$i; then + ad_fatal "Distribution '$i' is not declared (inherited from '$1')" + fi + + ad_parse_distribution $i true + ad_clear_options + done + + # Get license + license=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "license " | cut -d' ' -f2` + licenseh=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "license-header " | sed 's/license-header / : /'` + + ad_debug "license=$license" + ad_debug "licenseh=$licenseh" + + if test x$2 = xfalse; then + # Get distribution name + local dname=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "name " | cut -d' ' -f2-` + + if test "$dname"; then + distribution=$dname + fi + + # Get distribution package name (optional) + local dpname=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "package " | cut -d' ' -f2` + + if test "$dpname"; then + package=$dpname + else + package=$distribution + fi + + # Get Bug-report email address (optional) + local bugr=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "bug-report " | cut -d' ' -f2-` + + if test "$bugr"; then + bug_report=$bugr + fi + + ad_debug "distribution=$distribution" + ad_debug "package=$package" + ad_debug "bug-report=$bug_report" + + # Get hooks (optional) + local prh=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "pre-hook " | cut -d' ' -f2-` + local poh=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "post-hook " | cut -d' ' -f2-` + local prdh=`cat $distdir/$1 | sed 's/^[ ]*//' | grep -v "^#" \ + | grep "pre-dist-hook " | sed 's/^[ ]*//' | cut -d' ' -f2-` + local podh=`cat $distdir/$1 | grep -v "^#" \ + | grep "post-dist-hook " | sed 's/^[ ]*//' | cut -d' ' -f2-` + + pre_hooks="$pre_hooks $prh" + post_hooks="$post_hooks $poh" + pre_dist_hooks="$pre_dist_hooks $prdh" + post_dist_hooks="$post_dist_hooks $podh" + options="$options $opts" + + ad_handle_options "$options" + ad_debug "options=$options" + fi + + # Return to caller + inherits="$inherits $inhs" + distdefs="$distdefs $defs" + includes="$includes $incs" + excludes="$excludes $excs" + noprocess="$noprocess $nops" + undistdefs="$undistdefs $undefs" + + ad_debug "ad_process_distdefs" + + # Remove all undefined distribution defines + for i in $undistdefs + do + ad_debug "undefining $i distdef" + distdefs=`echo $distdefs | sed s/$i//` + done + + rm -f autodist.tmp.defs autodist.pre.hooks autodist.post.hooks + rm -f autodist.pre.dist.hooks autodist.post.dist.hooks + + # Remove duplicate distdefs + for i in $distdefs + do + echo $i >>autodist.tmp.defs + done + distdefs=`cat autodist.tmp.defs | sort | uniq` + distdefs=`echo $distdefs` + rm -f autodist.tmp.defs + + ad_debug "distdefs=$distdefs" + + ad_debug " +# +ad_process_license_header() +{ + ad_debug ">ad_process_license_header" + + # Add : separator at the end + lics=`echo "$licenseh" | sed 's/$/ : /'` + + src= + dst= + for i in $lics + do + if test "$i" = ":" && test -z "$src"; then + continue + fi + if test -z "$src"; then + src=$i + continue + fi + if test -z "$dst" && test "$i" != ":"; then + dst=$i + else + ad_fatal "Missing argument in 'license-header $src'" + fi + + ad_debug "Replacing $src license with $dst license" + + if test '!' -f $src; then + ad_fatal "License header $src: No such file or directory" + fi + + if test '!' -f $dst; then + ad_fatal "License header $dst: No such file or directory" + fi + + # Awk script to replace the license header + fl=`sed q $src | sed 's/\\//\\\\\//g' > autodist.lsrc` || exit 1 + ll=`sed -n '$p' $src | sed 's/\\//\\\\\//g' > autodist.ldst` || exit 1 + echo "/`cat autodist.lsrc`/,/`cat autodist.ldst`/ { FILE1=\"$src\"; FILE2=\"$dst\"; getline F1 < FILE1; getline F2 < FILE2; if (F1) sub(F1, F2); else { F1=\"\$\"; sub(F1, F2); } }" >> $1 + rm -f autodist.lsrc autodist.ldst + + src= + dst= + done + + ad_debug "ad_process_noprocess" + local np=false + + local n="sed " + + for i in $noprocess + do + # Escape + ie=`echo $i | sed 's/\\//\\\\\//g'` || exit 1 + + n="$n -e 's/$am_distdir\\/$ie//'" + np=true + done + + rm -f autodist.noprocess + if test x$np = xtrue; then + echo $n > autodist.noprocess || exit 1 + fi + + ad_debug " +# +ad_process_file() +{ + local found=false + + # Process only regular files + if test '!' -f $1; then + return + fi + + ad_debug ">ad_process_file: $1 $2" + + local f="autodist.tmp.script" + rm -f $f + + # If license header is provided, replace the license header in the file. + ad_process_license_header $f + + ad_debug "Getting #ifdef's and #ifndef's" + + # Get defined distribution defines + local defs=`awk "/^#ifdef "$DP"_DIST_|^#else "$DP"_DIST_/ { print; }" \ + $1 |cut -d'*' -f2 |cut -d' ' -f2 | sort | uniq` + + # Get explicitly not-defined distribution defines + local ndefs=`awk "/^#ifndef "$DP"_DIST_|^#else !"$DP"_DIST_/ { print; }" \ + $1 |cut -d'*' -f2 |cut -d' ' -f2 | cut -d'!' -f2 | sort | uniq` + + ad_debug "defs=$defs" + ad_debug "ndefs=$ndefs" + + # Create the script to include and exclude stuff in the file according + # to the distribution defines + + # ifdefs + ad_debug "processing ifdefs" + for d in $defs + do + found=false + for i in $distdefs + do + if test x$d = x$i; then + found=true + break + fi + done + + # If distribution define was not found exclude those lines from the file. + # This also handles the #ifdef's #else (ie. #ifndef) branch. + if test x$found = xfalse; then + ad_debug "ifdef $d will be excluded (it is NOT defined)" + echo "/^#ifdef $d/,/^#else !$d|^#endif $d/ { next; }" >> $f + else + echo "/^#else !$d/,/^#endif $d/ { next; }" >> $f + fi + done + + # ifndefs + ad_debug "processing ifndefs" + for d in $ndefs + do + found=false + for i in $distdefs + do + if test x$d = x$i; then + found=true + break + fi + done + + # If distribution define was found exclude those lines from the file. + # This also handles the #ifndef's #else (ie. #ifdef) branch. + if test x$found = xtrue; then + ad_debug "ifndef $d will be excluded (it IS defined)" + echo "/^#ifndef $d/,/^#else $d|^#endif $d/ { next; }" >> $f + else + echo "/^#else $d/,/^#endif $d/ { next; }" >> $f + fi + done + + # Now process the file with the script + if test -f $f; then + + # Those distdef lines that remain in the file are removed to make + # the appearance prettier + echo "/^#ifdef "$DP"_DIST_|^#endif "$DP"_DIST_|^#else "$DP"_DIST_|^#else !"$DP"_DIST_|^#ifndef "$DP"_DIST_/ { next; }" >> $f + echo "{ print; }" >> $f + + # Execute the script + cp -p $1 $2 || exit 1 + awk -f $f $1 > $2 || exit 1 + fi + + rm -f $f + + ad_debug " +# +ad_process_source_file() +{ + local found=false + + # Process only regular files + if test '!' -f $1; then + return + fi + + ad_debug ">ad_process_source_file: $1 $2" + + local f="autodist.tmp.script" + rm -f $f + + # If license header is provided, replace the license header in the file. + ad_process_license_header $f + + ad_debug "Getting #ifdef's and #ifndef's" + + # Get defined distribution defines + local defs=`awk '/^#ifdef SILC_DIST_|^#else \/\* SILC_DIST_/ { print; }' \ + $1 |cut -d'*' -f2 |cut -d' ' -f2 | sort | uniq` + + # Get explicitly not-defined distribution defines + local ndefs=`awk '/^#ifndef SILC_DIST_|^#else \/\* \!SILC_DIST_/ { print; }' \ + $1 |cut -d'*' -f2 |cut -d' ' -f2 | cut -d'!' -f2 | sort | uniq` + + ad_debug "defs=$defs ndefs=$ndefs" + + # Create the script to include and exclude stuff in the file according + # to the distribution defines + + # ifdefs + ad_debug "processing ifdefs" + for d in $defs + do + found=false + for i in $distdefs + do + if test x$d = x$i; then + found=true + break + fi + done + + # If distribution define was not found exclude those lines from the file. + # This also handles the #ifdef's #else (ie. #ifndef) branch. + if test x$found = xfalse; then + ad_debug "ifdef $d will be excluded (it is NOT defined)" + echo "/^#ifdef $d/,/^#else \/\* \!$d|^#endif \/\* $d/ { next; }" >> $f + else + echo "/^#else \/\* \!$d/,/^#endif \/\* $d/ { next; }" >> $f + fi + done + + # ifndefs + ad_debug "processing ifndefs" + for d in $ndefs + do + found=false + for i in $distdefs + do + if test x$d = x$i; then + found=true + break + fi + done + + # If distribution define was found exclude those lines from the file. + # This also handles the #ifndef's #else (ie. #ifdef) branch. + if test x$found = xtrue; then + ad_debug "ifndef $d will be excluded (it IS defined)" + echo "/^#ifndef $d/,/^#else \/\* $d|^#endif \/\* $d/ { next; }" >> $f + else + echo "/^#else \/\* $d/,/^#endif \/\* $d/ { next; }" >> $f + fi + done + + # Now process the file with the script + if test -f $f; then + + # Those distdef lines that remain in the file are removed to make + # the appearance prettier + echo "/^#ifdef SILC_DIST_|^#endif \/\* SILC_DIST_|^#else \/\* SILC_DIST_|^#else \/\* \!SILC_DIST_|^#ifndef SILC_DIST_/ { next; }" >> $f + echo "{ print; }" >> $f + + # Execute the script + cp -p $1 $2 || exit 1 + awk -f $f $1 > $2 || exit 1 + fi + + rm -f $f + + ad_debug " +# +ad_run_hooks() +{ + ad_debug ">ad_run_hooks: $1" + + for i in $1 + do + if test '!' -f $i; then + ad_fatal "Hook script $i does not exist" + fi + sh $i $distribution $dist_version $package || exit 1 + done + + ad_debug " +# +ad_run_dist_hooks() +{ + ad_debug ">ad_run_dist_hooks: $1" + + for i in $1 + do + if test '!' -f $i; then + ad_fatal "Dist hook script $i does not exist" + fi + sh $i $distribution $dist_version $package $am_distdir || exit 1 + done + + ad_debug "&2; exit 1; } + distdir="${1}"; + shift;; + + --list) + exit 0;; + + -s | --distdefs) + shift; + if test $# -eq 0; then + ad_parse_distribution $distribution false + echo "Distribution: ${distribution}" 1>&2; + else + ad_parse_distribution $1 false + echo "Distribution: ${1}" 1>&2; + fi + ad_process_distdefs + echo "Distdefs:" 1>&2; + echo "${distdefs}"; + exit 0;; + + -i | --init) + ad_initialize; + exit 0;; + + -m | --makedist) + ad_makedist + exit 0;; + + --gzip) + ad_gzip=true + shift;; + + --bzip2) + ad_bzip2=true + shift;; + + --compress) + ad_compress=true + shift;; + + --zip) + ad_zip=true + shift;; + + -v | --verbose) + debug=true + shift;; + + -h | --help | --h*) + echo "${usage}" 1>&2; + echo 1>&2; + echo "${help}" 1>&2; + echo 1>&2; + exit 0;; + + -V | --version) + echo "@PACKAGE@ (@PACKAGE_NAME@) $ver" 1>&2; + echo "Written by Pekka Riikonen" 1>&2; + echo 1>&2; + echo "Copyright (C) 2004 - 2005 SILC Project" 1>&2; + echo "\ +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " 1>&2; + exit 0;; + + --) + shift; + break;; + + -*) + echo "${usage}" 1>&2; + exit 1;; + + *) + break;; + + esac +done + +# +# Parse the requested distribution +# +if test $# != 0; then + distribution="${1}"; + distfile=$distribution + shift +fi +ad_parse_distribution $distribution false +ad_process_distdefs + +if test $# != 0; then + dist_version="${1}"; +fi + +ad_debug "Preparing source tree for configuration and compilation..." +ad_debug "Preparing $distribution distribution version $dist_version" + +# +# Create the distribution defines header file +# +if test "$DISTDEFS"; then + ad_create_distdefs_h +else + ad_fatal "DISTDEFS not defined in $distdir/autodist.conf" +fi + +# +# Run pre-hooks +# +ad_run_hooks "$pre_hooks" + +# +# Generate the Makefile.am files from Makefile.ad files +# +ad_make_makefile_ams + +# +# Generate the configure.ac from configure.ad file(s) +# +ad_make_configure_ac ./configure.ad + +# +# Generate configure script +# +ad_make_configure + +# +# Generate Makefile.in files +# +ad_make_makefile_ins + +# +# Process all files with .ad suffix for distribution processing +# +ad_process_ads + +# +# Create autodist.dist +# +ad_debug "Creating autodist.dist" +echo "dist:$distfile" > autodist.dist +echo "ver:$dist_version" >> autodist.dist +echo "$package-$dist_version" >> autodist.dist + +# +# Run post-hooks +# +ad_run_hooks "$post_hooks" + +ad_debug "Done, now run ./configure and make." +exit 0 diff --git a/apps/autodist/configure.ad b/apps/autodist/configure.ad new file mode 100644 index 0000000..806ac54 --- /dev/null +++ b/apps/autodist/configure.ad @@ -0,0 +1,52 @@ +#ifdef SILC_DIST_AUTODIST +# +# apps/autodist/configure.ad +# +# Author: Pekka Riikonen +# +# Copyright (C) 2005 Pekka Riikonen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +# The APIVERSION is appended to the filename, to give versioned name. +# The base version (X.Y) is taken. +APIVERSION=`echo "$VERSION" | sed -e 's/^\([[0-9]]*\.[[0-9]]*[[a-z]]*\).*$/\1/'` +AC_SUBST(APIVERSION) + +old_exec_prefix=$exec_prefix +old_prefix=$prefix +exec_prefix=$silc_prefix +prefix=$silc_prefix + +# Path to the autodist in installed environment +s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir` +AUTODIST=$s_bindir/autodist +AC_SUBST(AUTODIST) + +# Path to the Autodist data +s_datadir=`eval echo $datadir`;s_bindir=`eval echo $s_datadir` +AUTODISTDIR=$s_datadir/autodist +AC_SUBST(AUTODISTDIR) + +exec_prefix=$old_exec_prefix +prefix=$old_prefix + +# +# Makefile outputs +# +AC_CONFIG_FILES( +apps/autodist/Makefile +apps/autodist/autodist +apps/autodist/makedist +apps/autodist/doc/Makefile +apps/autodist/tests/Makefile +) +#endif SILC_DIST_AUTODIST diff --git a/apps/autodist/default b/apps/autodist/default new file mode 100644 index 0000000..84cea7c --- /dev/null +++ b/apps/autodist/default @@ -0,0 +1,10 @@ +# Default distribution +# +# NOTE: By default, this distribution cannot be packaged. Take away the +# 'no-dist option if you whish to use this as a normal distribution. +# +# If you add new distributions into distdir/ you may want to inherit them +# here. +# +option no-dist +define _DIST_DEFAULT diff --git a/apps/autodist/doc/Makefile.am b/apps/autodist/doc/Makefile.am new file mode 100644 index 0000000..2ffb4b0 --- /dev/null +++ b/apps/autodist/doc/Makefile.am @@ -0,0 +1,19 @@ +# +# Makefile.am +# +# Author: Pekka Riikonen +# +# Copyright (C) 2005 Pekka Riikonen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +info_TEXINFOS = autodist.texi +autodist_TEXINFOS = fdl.texi diff --git a/apps/autodist/doc/autodist.texi b/apps/autodist/doc/autodist.texi new file mode 100644 index 0000000..870cc91 --- /dev/null +++ b/apps/autodist/doc/autodist.texi @@ -0,0 +1,1603 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header +@setfilename autodist.info +@settitle autodist +@setchapternewpage off +@c %**end of header + +@include version.texi + +@copying + +This manual is for SILC Autodist (version @value{VERSION}, +@value{UPDATED}), a program which is used to manage and create source +distributions. + +Copyright @copyright{} 2004 - 2005 Pekka Riikonen, SILC Project + +@quotation +Permission is granted to copy, distribute and/or modify this document +under the terms of the @acronym{GNU} Free Documentation License, +Version 1.2 or any later version published by the Free Software +Foundation; with no Invariant Sections, with the Front-Cover texts +being ``A @acronym{GNU} Manual,'' and with the Back-Cover Texts as in +(a) below. A copy of the license is included in the section entitled +``@acronym{GNU} Free Documentation License.'' + +(a) The FSF's Back-Cover Text is: ``You have freedom to copy and +modify this @acronym{GNU} Manual, like @acronym{GNU} software. Copies +published by the Free Software Foundation raise funds for +@acronym{GNU} development.'' +@end quotation +@end copying + +@dircategory Software development +@direntry +* autodist: (autodist). Managing and creating source distributions. +@end direntry + +@dircategory Individual utilities +@direntry +* makedist: (autodist)Invoking makedist. Creating distribution +@end direntry + +@titlepage +@title SILC Autodist +@subtitle For version @value{VERSION}, @value{UPDATED} +@author Pekka Riikonen +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage + +@ifnottex +@node Top +@comment node-name, next, previous, up +@top SILC Autodist + +@insertcopying + +@menu +* Introduction:: Purpose of Autodist +* Integrating Autodist:: Integrating Autodist into your project +* Invoking Autodist:: Running Autodist +* Examples:: Examples using Autodist + +@detailmenu + --- The Detailed Node Listing --- + +Introduction + +* Motivation:: Reasons for using Autodist + +Integrating Autodist + +* Creating distdir:: Creating distributions directory +* autodist.conf:: Configuring Autodist +* Creating new distribution:: Adding new distribution +* Distribution file format:: Detailed document for distfile format +* configure.ad files:: configure script for creating configure.ac +* Makefile.ad files:: Makefile.ad for creating Makefile.am +* Other .ad files:: Other files with .ad suffix +* Distdefines:: Using distdefs in files + +Invoking Autodist + +* Preparing source tree:: Preparing source tree with Autodist +* Creating distribution:: Creating distribution with Autodist + +Examples + +* Single distribution tree:: Single distribution example +* Multiple distribution tree:: Multiple distributions example + +@end detailmenu +@end menu + +@end ifnottex + + +@node Introduction +@chapter Introduction + +The Autodist is a source distribution management system that allows +powerful mechanisms to define what is included in and excluded from a +distribution, and what license the distribution is released under. It is +also used to create the actual distribution source packages. Autodist +allows distribution management in file, directory and file content level. +Different distributions may include different portions of files, for +example, excluding certain features from certain distributions. It is +always guaranteed that anything not defined for the distribution, is +removed automatically (files, file content, directories), thus ensuring +that nothing is accidentally included in the distribution. + +The Autodist creates 'Makefile.am' files from 'Makefile.ad' files and +'configure.ac' file from one or more 'configure.ad' files. Any other file +ending with '.ad' suffix will also be processed. The processed file will +have the '.ad' suffix removed (@pxref{Preparing source tree, , , , }). +Autodist also creates and packages the distribution using common GNU +distribution creation process, specificly `make dist'. Autodist, however, +controls this process and during packaging phase the Autodist processes +all files in the distribution (other than '*.ad' files, which has already +been processed earlier by Autodist). The resulted package is a processed +source distribution package, processed according to the rules specified +in the distribution file(s) (@pxref{Creating distribution, , , , }). + +Any file in the source tree may use distdefs (distribution defines (@pxref{Distdefines, , , , })) which are defined in the distributions. When distribution +is packaged only the files, directories and file content that is either +outside of any distdef, or inside the defined distdefs will be included +in the distribution. Any other file, directory or content in the file +will be removed. It is guaranteed, if a file, a directory or a piece of +file content is not inside a defined distdef it will not be delivered to +the distribution. + +Any file, 'Makefile.am', 'configure.ac', or source file processed with +Autodist is always compliant with the tools needed to process them. All +files can also be processed with the corresponding tools even before +processing them with Autodist. This makes it possible, for example, to +compile sources before they have been processed, and undefined lines +are removed. The distdefs are respected in source files by the +preprocessor. + +Autodist is not a binary packaging system. It is specificly used to +create source distributions. A binary packaging system, however can be +hooked to the distribution creation process, if needed. + +@menu +* Motivation:: Reasons for using Autodist +@end menu + + +@node Motivation +@section Reasons for using Autodist + +Autodist is closely related to the Autoconf and Automake tools, and +complements the features Autoconf and Automake provides. It is especially +targeted into circumstances where multiple distributions are created from +one source tree. The Autoconf and Automake environment is mainly designed +for one distribution (one application) per one source tree situations. +Autodist provides mechanisms to create all kinds of distributions that can +be created from one source tree. To be able to use Autodist, the Autoconf +and Automake must be installed into the system (@pxref{Integrating Autodist, , , , }). +Autoconf version must be at least 2.52g. + +Small software projects usually do very well with Autoconf and Automake +and their distribution management features. Often these projects do not +need Autodist, though they can benefit from it. However, if your software +project is large, you need to create multiple distributions from one source +tree, you have complex licensing terms for different distributions, you +have different target users or customers that may require different +feature set or licenses in different distributions, you have need to +continue concurrent development in the main source tree and still be able +to create stable distributions, and/or you have need to control file +content in different distributions (to avoid distributing code or features +that aren't supposed to be distributed, or to avoid leaking information +to your competitors on what new features you are working on), then Autodist +is a tool you may find usefull. + +The motivation behind Autodist stems from need to be able to create +multiple distributions from one large source tree in a precise and +controllable manner, and guarantee that anything that is not part of the +distribution is removed from the distribution. The Autoconf and Automake +provides mere basic control what is included in and excluded from +distributions and how the distributions are created. They also do not +provide mechanism to define different licensing conditions for different +distributions, or changing the license automatically for different user +or customer purposes. Many large software projects, companies and +corporations have commonly been using Autoconf and Automake tools, but +have had the need to create their own ad-hoc mechanisms to control +distribution creation. The Autodist attempts to provide a tool that any +size software project can effectively use to manage their distributions. + +Without a tool like Autodist, large software projects usually has to be +split into separate source trees, which may not always be possible because +they may share large portions of common code (which may further make +concurrent development of the applications hard), or multiple Autoconf and +Automake environments (multiple configure scripts) needs to be created +in one source tree. In this case the source tree usually gets very +complicated and controlling what is compiled and what is included in +distributions becomes harder, especially when different parts code is shared +between applications and libraries. + + +@node Integrating Autodist +@chapter Integrating Autodist + +Integrating Autodist into existing software project can be a very simple +task or a fairly complicated task. It depends on the size and complexity +of the software project. Generally speaking, integrating Autodist into +software project is fairly straightforward process: + +1. The distributions directory and 'default' distribution are created + +2. The 'configure.ad' is created + +3. If needed, 'Makefile.ad' file(s) are created + +After this the Autodist can already be used to prepare the source tree +for configuration and compilation (@pxref{Preparing source tree, , , , }). +Adding a new distribution would then allow the actual distribution +packaging also. + +If the software project has had own ad-hoc distribution system already in +place, it may take some work to move from that system into the Autodist. +If there are multiple applications and distributions created from the +source tree, the distributions and distribution defines for them need to +be created. While this may be unthankful job, it only needs to be done +once. + +Integrating Autodist into a new software project is a very simple task as +renaming 'configure.ac' and possibly 'Makefile.am' files are not required, +as they may not exist yet. + + +@menu +* Creating distdir:: Creating distributions directory +* autodist.conf:: Configuring Autodist +* Creating new distribution:: Adding new distribution +* Distribution file format:: Detailed document for distfile format +* configure.ad files:: configure script for creating configure.ac +* Makefile.ad files:: Makefile.ad for creating Makefile.am +* Other .ad files:: Other files with .ad suffix +* Distdefines:: Using distdefs in files +@end menu + + +@node Creating distdir +@section Creating distributions directory + +The distributions directory is 'distdir', which is expected to be +located in the root of the source tree. This directory will hold all +the distribution files, and the Autodist configuration file 'autodist.conf' (@pxref{autodist.conf, , , , }). +If this directory does not exist it can be created with the Autodist. + +@example + autodist -i +@end example + +This will create the 'distdir' and copy the default 'autodist.conf' +configuration file and the 'default' distribution into the directory. +The 'default' distribution will be used by default by the Autodist +unless other distribution is specified. + +After this the Autodist has effectively been integrated into the +software project. However, usually after this, one would create new +distributions, the 'configure.ad' and possibly 'Makefile.ad' file(s). +Without 'configure.ad' file a distribution package cannot be created. +However, even without 'configure.ad' file the source tree can be +prepared for configuration and compilation (@pxref{Preparing source tree, , , , }). + +@menu +* autodist.conf:: Configuring Autodist +@end menu + + +@node autodist.conf +@section Configuring Autodist + +After the Autodist has been integrated into the software by creating +the 'distdir', the 'autodist.conf' configuration file was added to the +'distdir' also. Usually software projects will want to modify some of +the 'autodist.conf' options, mainly specifying the distdef prefix. + +The 'autodist.conf' is a text file. The following options are available +in 'autodist.conf': + + +@example +DISTPREFIX="" +@end example + +By default the distdef prefix is '_DIST_'. To add own software package +specific prefix the 'DISTPREFIX' can be defined. + +Example: +@example +DISTPREFIX="SILC" +@end example + +Will set the distdef prefix as 'SILC_DIST_'. + + +@example +DISTDEFS="distdefs.h" +@end example + +The 'DISTDEFS' option specifies the file name of the distdef header file +which Autodist will create. The software project should '#include' the +header file in order for the preprocessor to respect the distdef +conditionals (@pxref{Distdefines, , , , }). By default the file name +is 'distdefs.h' and is created at the root of source tree. Other location +may be specified if needed. + +Example: +@example +DISTDEFS="include/distdefs.h" +@end example + + +@example +ACLOCAL="aclocal" +@end example + +The 'ACLOCAL' specifies the location of the 'aclocal' tool. If Autodist +should not run 'aclocal' this option may be removed or set to empty value. +User need to then run it manually. + + +@example +AUTOHEADER="autoheader" +@end example + +The 'AUTOHEADER' specifies the location of the 'autoheader' tool. If +Autodist should not run 'autoheader' this option may be removed or set +to empty value. User need to then run it manually. + +@example +AUTOCONF="autoconf" +@end example + +The 'AUTOCONF' specifies the location of the 'autoconf' tool. If +Autodist should not run 'autoconf' this option may be removed or set +to empty value. User need to then run it manually. + + +@example +AUTOMAKE="automake -a -c" +@end example + +The 'AUTOMAKE' specifies the location of the 'automake' tool. If +Autodist should not run 'automake' this option may be removed or set +to empty value. User need to then run it manually. By default, the +'-a' and '-c' options are given to 'automake' to add any missing required +files. + + +@example +LIBTOOLIZE="libtoolize --automake -c" +@end example + +The 'LIBTOOLIZE' specifies the location of the 'libtoolize' tool. +This option should be removed or ste to empty value if 'libtool' is not +used in the source tree. + + +@example +MAKE=make +@end example + +The 'MAKE' specifies the location of the 'make' program. This option must +be set to valid value in order to create distributions. + + +@menu +* Creating new distribution:: Adding new distribution +@end menu + + +@node Creating new distribution +@section Creating new distribution + +After the Autodist has been integrated into the software project by +creating the 'distdir' and 'default' distribution, the source tree +can be prepared for configuration and compilation (@pxref{Preparing source tree, , , , }). However, the 'default' distribution should be used only as +a development distribution. Usually it is used to prepare the raw source +tree (such as a tree just checkout +from CVS) for configuration and compilation. By default, the 'default' +distribution cannot be packaged. However, if the software project is +small (one distribution), it may be convenient to edit the 'default' +distribution to be as the distribution that is packaged from the source +tree. In software project where multiple distributions are created using +the 'default' only as a development distribution is recommended. The +real distributions should be defined as separate distributions. + +Creating a new distribution is a simple process. Each distribution +is placed in the 'distdir' and the file name of the distribution file is +used to reference to it. By default, the distribution name is the +file name of the distribution file. The actual distribution file is +a simple text file with various directives that define the distribution. + +If the 'default' distribution is used as a development distribution it +might be desired to inherit some or all of the created distributions in +it, so that development becomes possible with the 'default' distribution. +Adding 'inherit' directive into the 'distdir/default' will inherit the +specified distribution. + + +@menu +* Distribution file format:: Detailed document for distfile format +@end menu + + +@node Distribution file format +@section Distribution file format in detail + +The distribution file, or distfile from now on, defines your distribution, +distribution defines, options, included and excluded files and +directories, license, and additional processing. Each distribution is +defined in a separate file and the distributions are referenced by +their file name. + +The distfile is a text file that contains various directives that define +the actual distribution. Lines starting with '#' are considered comments +and are ignored. + + +@section Directive: name + +The 'name' directive defines the name of the distribution. It is optional +directive, and if omitted the distribution name will be the name of the +distfile. + +Example: +@example +name FOO Application +@end example + +Will set your distribution name as 'Foo Application'. + + +@section Directive: package + +The 'package' directive defines the name of the distribution package. It is +optional directive, and if omitted the distribution package name will +be the name of the distribution, if defined, or if omitted, then the name +of the distfile. If this directive is omitted then normal GNU convention +is used to decide the package name, derived from the distribution name. + +Example: +@example +package foo-client +@end example + +Will create distribution packages named, for example, as +'foo-client-1.0.tar.gz'. + + +@section Directive: bug-report + +The 'bug-report' directive can be used to define the email address where +the bug-reports for the distribution should be sent. The directive is +optional. The 'bug-report' email address will be set for the Autoconf +which will deliver it via AC_INIT macro. + + +@section Directive: license + +The 'license' directive can be used to define the license file for the +distribution. This directive is optional. The license file will be +copied into the distribution in the name 'COPYING'. If the 'COPYING' +file already exist it will be replaced. + +Example: +@example +license license/GPL +@end example + +Will include the file 'license/GPL' into the distribution in the file +name 'COPYING'. + + +@section Directive: license-header + +The 'license-header' can be used to re-license your files into a new +license. This directive is optional. There may be zero or more +'license-header' directives in distribution. The 'license-header' +directive will compare the license header that usually appear at the +start of a file to the . If it matches it will +be replaced with the . The license header in the file +will be replaced and the file will have effectively been re-licensed. + +Example: +@example +license-header license/BSD-header license/GPL-header +@end example + +Will replace all appearances of the license header in 'license/BSD-header' +file to the license header in 'license/GPL-header' in any file in the +distribution. Note that, the header change will be performed when +the distribution is packaged (@pxref{Creating distribution, , , , }). + +With 'license-header' directive you may initially set your files in the +source tree into what ever license you prefer. However, if you need to +re-license parts of the source tree in certain distributions the +'license-header' will achieve this automatically. For example, suppose +one wants to create two different versions of a library distribution, with +different feature sets, in two different licenses. + +There are several limitations in the current implementation of Autodist +with the 'license-header' directive: + +First limitation is that the header files must have equal amount of lines. +If the new header file has fewer lines that the current header file, all +of the lines from the current header will not be replaced. If the new header +has fewer lines, empty lines must be added to it. If the new header file +has more lines than the current header file, the extra lines will not appear +in the replaced header. Basic rule is to always make sure the header file +has equal amount of lines in them. + +Second limitation is in indentation of the header files. It is suggested, +though not mandatory, that the header files have the same indentation as +is commonly used in the source tree; if the license header text in a file +starts at the second character instead of at the start of the line, then +the header file should start the license text at the second character also. +If same indentation is not used the appearance of the replaced header +may not be perfect. While this is a cosmetic issue, one still to remember. + +Example current header: +@example +--- Start example + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +--- end example +@end example + +Example new header: +@example +--- Start example + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the conditions listed in the + COPYING file are met. + + + +--- end example +@end example + +In this example, if the text in the current header file is found in any +file in the distribution it will be replaced with the new header file. +Notice that, both header files has same amount of lines (8 lines). + +Note that, the current header must match exactly the header used in +files. Otherwise the replacement will not be complete. + + +@section Directive: inherit + +The Autodist provides inheritance of distributions. The 'inherit' +directive is used to define the distribution which will be inherited +into the distribution. The specifies the name of the +inherited distribution. If the distribution cannot be inherited Autodist +will give an error. + +The 'inherit' will inherit the following information from the distribution: +distdefs, undefines, includes, excludes and noprocess. Other information +will not be inherited. If the inherited distribution inherits other +distributions, they will also be inherited automatically. User should be +careful when inheriting distributions as it may be possible to create an +infinite recursion. The Autodist would allow for this and not detect this +error. Zero or more 'inherit' directives may be set for distribution. + +Example: +@example +inherit common +inherit client +inherit toolkit +@end example + +Will inherit distributions 'common', 'client' and 'toolkit' into this +distribution. All distdefs, undefines, includes, excludes and noprocesses +from these distributions are now also part this distribution. + + +@section Directive: define + +The 'define' directive is used to define the distdef symbols for the +distribution. This directive is optional, however, all distributions +should define at least one distdef so that the distribution may be +controlled with the distdef conditionals in files in the source tree (@pxref{Distdefines, , , , }). By default, the distdef prefix is '_DIST_'. Many +software projects will want to set their own prefix for the distdefs +for consistency. The prefix may be defined in the 'autodist.conf' file +(@pxref{autodist.conf, , , , }). + +Example: +@example +define _DIST_FOO +define _DIST_FEATURE_X +define _DIST_LIBRARY_Y +@end example + +Will define the following distdefs for the distribution: '_DIST_FOO', +'_DIST_FEATURE_X' and '_DIST_LIBRARY_Y'. These distdefs may then be +used in the source tree and source code to control what is included in +or excluded from this distribution. + + +@section Directive: undef + +The 'undef' directive may be used to explicitly undefine a distdef. +When inheriting distributions it may be desired to be able undefine +certain distdefs. This directive is optional. + +Example: +@example +undef _DIST_FEATURE_Y +@end example + +Will undefine '_DIST_FEATURE_Y' distdef. This distdef will not be part +of this distribution anymore, even if it is defined in some inherited +distribution. + + +@section Directive: option