#!/bin/sh
#
#   Boom builder for iMatix Foreign 1.2b0
#   Generated by iMatix Boom from product.pwl
#   
#   Copyright (c) 1996-2009 iMatix Corporation
#   All rights reserved.
#   
#   This file is licensed under the BSD license as follows:
#   
#   Redistribution and use in source and binary forms, with or without
#   modification, are permitted provided that the following conditions
#   are met:
#   
#   * Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#   * 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.
#   * Neither the name of iMatix Corporation nor the names of its
#     contributors may be used to endorse or promote products derived
#     from this software without specific prior written permission.
#   
#   THIS SOFTWARE IS PROVIDED BY IMATIX CORPORATION "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 IMATIX CORPORATION 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.
#
#   Force environment variables to point to install location
#   Start by using final IBASE, then handle local -install path
#
boom_model_list () {
    set |
        awk 'BEGIN                      { FS="[=_]" }
             /^BOOM_MODEL_[A-Z0-9]*=1$/ { print $3  }'
}
boom_model_expand () {
    for MODEL in `boom_model_list`; do
        eval unset BOOM_MODEL_$MODEL
    done
    OLD_IFS=$IFS
    IFS=,
    for MODEL in $BOOM_MODEL; do
        MODEL=`echo $MODEL | tr \[a-z\] \[A-Z\]`
        eval BOOM_MODEL_$MODEL=1
        eval export BOOM_MODEL_$MODEL
    done
    IFS=$OLD_IFS
}
croak() {
    if [ -n "$*" ]; then
        echo "boom E: [foreign]: $* - stop" 1>&2
    else
        echo "boom E: [foreign]: stop" 1>&2
    fi
    exit 1
}
carp() {
    echo "boom I: [foreign]: $*" 1>&2
}
trap 'croak "Interrupted"' INT
trap 'croak "Terminated"' TERM
trap 'croak "Quit"' QUIT
self=$0
MY_VERSION="1.2b0"
#
#   Set default values for BOOM_MODEL
#
#   Default is release,mt on all platforms.
#
if [ -z "$BOOM_MODEL" ]; then
    BOOM_MODEL=release,mt
fi
boom_model_expand
if [ "$BOOM_MODEL_RELEASE" != "1" ]; then
    if [ "$BOOM_MODEL_DEBUG" != "1" ]; then
        BOOM_MODEL_RELEASE=1
        BOOM_MODEL="$BOOM_MODEL,release"
    fi
fi
if [ "$BOOM_MODEL_ST" != "1" ]; then
    if [ "$BOOM_MODEL_MT" != "1" ]; then
            BOOM_MODEL="$BOOM_MODEL,mt"
    fi
fi
if [ -z "$IBASE" ]; then
    carp "The IBASE variable is not set.  Please set it to the location where iMatix Foreign should be installed."
    exit 1
fi
if [ "$1" = "-v" ]; then
    BOOM_TRACE=1
    export BOOM_TRACE
    shift
fi
if [ "$1" != "-install" ]; then
    #   Normal use, use IBASE
    PATH=.:$IBASE/bin:$PATH; export PATH
    PERLLIB=.:$IBASE/bin:$PERLLIB; export PERLLIB
    INCDIR_ALT=$IBASE/include; export INCDIR_ALT
    _LOCAL_BASE=
    _INSTALL_ROOT=$IBASE
else
    #   Building product, we use -install directory first, then IBASE
    CURDIR=`pwd`
    cd $2
    _LOCAL_BASE=`pwd`
    cd $CURDIR
    PATH=.:$_LOCAL_BASE/bin:$IBASE/bin:$PATH; export PATH
    PERLLIB=.:$_LOCAL_BASE/bin:$IBASE/bin:$PERLLIB; export PERLLIB
    INCDIR_ALT=$_LOCAL_BASE/include:$IBASE/include; export INCDIR_ALT
    shift
    shift
    _INSTALL_ROOT=$_LOCAL_BASE
fi

# ----------------------------   ALLGEN PROJECTS   ----------------------------

a_allgen_projects() {
:
    PUSHDIR=`pwd`
    cd c
    if [ -f boomake ]; then
        sh boomake allgen || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd apr
    if [ -f boomake ]; then
        sh boomake allgen || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd pcre
    if [ -f boomake ]; then
        sh boomake allgen || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd zlib
    if [ -f boomake ]; then
        sh boomake allgen || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd tests
    if [ -f boomake ]; then
        sh boomake allgen || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
}

# --------------------   BUILD PRODUCT INSTALL PACKAGES   ---------------------

a_build_product_install_packages() {
:
    carp "Building Foreign Install..."
    rm -rf _install
    PUSHDIR=`pwd`
    cd c
    if [ -f boomake ]; then
        sh boomake -install ../_install install || croak
    else
        carp "Project has not been built - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd apr
    if [ -f boomake ]; then
        sh boomake -install ../_install install || croak
    else
        carp "Project has not been built - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd pcre
    if [ -f boomake ]; then
        sh boomake -install ../_install install || croak
    else
        carp "Project has not been built - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd zlib
    if [ -f boomake ]; then
        sh boomake -install ../_install install || croak
    else
        carp "Project has not been built - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd tests
    if [ -f boomake ]; then
        sh boomake -install ../_install install || croak
    else
        carp "Project has not been built - boomake is missing"
    fi
    cd $PUSHDIR
    mv _install foreign-$MY_VERSION
    [ "$BOOM_TRACE" ] && echo "pkg_tgz foreign-$MY_VERSION"
    pkg_tgz foreign-$MY_VERSION || croak "\"pkg_tgz foreign-$MY_VERSION\" failed"
    rm -rf foreign-$MY_VERSION
}

# ---------------------   BUILD PRODUCT SOURCE PACKAGES   ---------------------

a_build_product_source_packages() {
:
    rm -f _package.lst
    if [ -f "project.pdl" ]; then
        echo project.pdl>>_package.lst
    fi
    if [ -f "readme.txt" ]; then
        echo readme.txt>>_package.lst
    fi
    if [ -f "release.txt" ]; then
        echo release.txt>>_package.lst
    fi
    if [ -f "stamp_generate" ]; then
        echo stamp_generate>>_package.lst
    fi
    if [ -f "configure" ]; then
        echo configure>>_package.lst
    fi
    if [ -f "Makefile.unix" ]; then
        echo Makefile.unix>>_package.lst
    fi
    if [ -f "boomake" ]; then
        echo boomake>>_package.lst
    fi
    if [ -f "configure.bat" ]; then
        echo configure.bat>>_package.lst
    fi
    if [ -f "Makefile.win32" ]; then
        echo Makefile.win32>>_package.lst
    fi
    if [ -f "boomake.bat" ]; then
        echo boomake.bat>>_package.lst
    fi
    if [ -f "boomakew.bat" ]; then
        echo boomakew.bat>>_package.lst
    fi
    PUSHDIR=`pwd`
    cd c
    cd $PUSHDIR
    if [ -f "c/c" ]; then
        echo c/c>>_package.lst
    fi
    if [ -f "c/c.bat" ]; then
        echo c/c.bat>>_package.lst
    fi
    if [ -f "c/c.cmd" ]; then
        echo c/c.cmd>>_package.lst
    fi
    if [ -f "c/gcccat" ]; then
        echo c/gcccat>>_package.lst
    fi
    if [ -f "c/gcccat.bat" ]; then
        echo c/gcccat.bat>>_package.lst
    fi
    if [ -f "c/boomvs.bat" ]; then
        echo c/boomvs.bat>>_package.lst
    fi
    if [ -f "c/convert71.js" ]; then
        echo c/convert71.js>>_package.lst
    fi
    if [ -f "c/convert80.js" ]; then
        echo c/convert80.js>>_package.lst
    fi
    if [ -f "c/prelude.pdl" ]; then
        echo c/prelude.pdl>>_package.lst
    fi
    if [ -f "c/license.gpl" ]; then
        echo c/license.gpl>>_package.lst
    fi
    if [ -f "c/project.pdl" ]; then
        echo c/project.pdl>>_package.lst
    fi
    if [ -f "c/readme.txt" ]; then
        echo c/readme.txt>>_package.lst
    fi
    if [ -f "c/stamp_generate" ]; then
        echo c/stamp_generate>>_package.lst
    fi
    if [ -f "c/configure" ]; then
        echo c/configure>>_package.lst
    fi
    if [ -f "c/Makefile.unix" ]; then
        echo c/Makefile.unix>>_package.lst
    fi
    if [ -f "c/boomake" ]; then
        echo c/boomake>>_package.lst
    fi
    if [ -f "c/configure.bat" ]; then
        echo c/configure.bat>>_package.lst
    fi
    if [ -f "c/Makefile.win32" ]; then
        echo c/Makefile.win32>>_package.lst
    fi
    if [ -f "c/boomake.bat" ]; then
        echo c/boomake.bat>>_package.lst
    fi
    if [ -f "c/boomakew.bat" ]; then
        echo c/boomakew.bat>>_package.lst
    fi
    if [ -f "c/liblocal.vcproj" ]; then
        echo c/liblocal.vcproj>>_package.lst
    fi
    PUSHDIR=`pwd`
    cd apr

    (cd apr;      test -f Makefile && make -s distclean >/dev/null)
    (cd apr-util; test -f Makefile && make -s distclean >/dev/null)

    (cd ..; perl apr/apr_package_lst.pl apr/apr apr/apr-util >>_package.lst)
   
    cd $PUSHDIR
    if [ -f "apr/project.pdl" ]; then
        echo apr/project.pdl>>_package.lst
    fi
    if [ -f "apr/apr_package_lst.pl" ]; then
        echo apr/apr_package_lst.pl>>_package.lst
    fi
    if [ -f "apr/base_apr.h" ]; then
        echo apr/base_apr.h>>_package.lst
    fi
    if [ "`echo apr/apr*.h`" != "apr/apr*.h" ]; then
        for file in `echo apr/apr*.h`; do
            echo $file>>_package.lst
        done
    fi
    if [ "`echo apr/apu*.h`" != "apr/apu*.h" ]; then
        for file in `echo apr/apu*.h`; do
            echo $file>>_package.lst
        done
    fi
    if [ -f "apr/stamp_generate" ]; then
        echo apr/stamp_generate>>_package.lst
    fi
    if [ -f "apr/configure" ]; then
        echo apr/configure>>_package.lst
    fi
    if [ -f "apr/Makefile.unix" ]; then
        echo apr/Makefile.unix>>_package.lst
    fi
    if [ -f "apr/boomake" ]; then
        echo apr/boomake>>_package.lst
    fi
    if [ -f "apr/configure.bat" ]; then
        echo apr/configure.bat>>_package.lst
    fi
    if [ -f "apr/Makefile.win32" ]; then
        echo apr/Makefile.win32>>_package.lst
    fi
    if [ -f "apr/boomake.bat" ]; then
        echo apr/boomake.bat>>_package.lst
    fi
    if [ -f "apr/boomakew.bat" ]; then
        echo apr/boomakew.bat>>_package.lst
    fi
    if [ -f "apr/liblocal.vcproj" ]; then
        echo apr/liblocal.vcproj>>_package.lst
    fi
    PUSHDIR=`pwd`
    cd pcre
    cd $PUSHDIR
    if [ -f "pcre/pcre_chartables.c" ]; then
        echo pcre/pcre_chartables.c>>_package.lst
    fi
    if [ -f "pcre/pcre_compile.c" ]; then
        echo pcre/pcre_compile.c>>_package.lst
    fi
    if [ -f "pcre/pcre_config.c" ]; then
        echo pcre/pcre_config.c>>_package.lst
    fi
    if [ -f "pcre/pcre_dfa_exec.c" ]; then
        echo pcre/pcre_dfa_exec.c>>_package.lst
    fi
    if [ -f "pcre/pcre_exec.c" ]; then
        echo pcre/pcre_exec.c>>_package.lst
    fi
    if [ -f "pcre/pcre_fullinfo.c" ]; then
        echo pcre/pcre_fullinfo.c>>_package.lst
    fi
    if [ -f "pcre/pcre_get.c" ]; then
        echo pcre/pcre_get.c>>_package.lst
    fi
    if [ -f "pcre/pcre_globals.c" ]; then
        echo pcre/pcre_globals.c>>_package.lst
    fi
    if [ -f "pcre/pcre_info.c" ]; then
        echo pcre/pcre_info.c>>_package.lst
    fi
    if [ -f "pcre/pcre_maketables.c" ]; then
        echo pcre/pcre_maketables.c>>_package.lst
    fi
    if [ -f "pcre/pcre_ord2utf8.c" ]; then
        echo pcre/pcre_ord2utf8.c>>_package.lst
    fi
    if [ -f "pcre/pcre_refcount.c" ]; then
        echo pcre/pcre_refcount.c>>_package.lst
    fi
    if [ -f "pcre/pcre_study.c" ]; then
        echo pcre/pcre_study.c>>_package.lst
    fi
    if [ -f "pcre/pcre_tables.c" ]; then
        echo pcre/pcre_tables.c>>_package.lst
    fi
    if [ -f "pcre/pcre_try_flipped.c" ]; then
        echo pcre/pcre_try_flipped.c>>_package.lst
    fi
    if [ -f "pcre/pcre_ucp_searchfuncs.c" ]; then
        echo pcre/pcre_ucp_searchfuncs.c>>_package.lst
    fi
    if [ -f "pcre/pcre_valid_utf8.c" ]; then
        echo pcre/pcre_valid_utf8.c>>_package.lst
    fi
    if [ -f "pcre/pcre_version.c" ]; then
        echo pcre/pcre_version.c>>_package.lst
    fi
    if [ -f "pcre/pcre_xclass.c" ]; then
        echo pcre/pcre_xclass.c>>_package.lst
    fi
    if [ -f "pcre/pcre.h" ]; then
        echo pcre/pcre.h>>_package.lst
    fi
    if [ -f "pcre/pcre_internal.h" ]; then
        echo pcre/pcre_internal.h>>_package.lst
    fi
    if [ -f "pcre/pcre_scanner.h" ]; then
        echo pcre/pcre_scanner.h>>_package.lst
    fi
    if [ -f "pcre/pcre_printint.src" ]; then
        echo pcre/pcre_printint.src>>_package.lst
    fi
    if [ -f "pcre/ucpinternal.h" ]; then
        echo pcre/ucpinternal.h>>_package.lst
    fi
    if [ -f "pcre/ucp.h" ]; then
        echo pcre/ucp.h>>_package.lst
    fi
    if [ -f "pcre/ucptable.c" ]; then
        echo pcre/ucptable.c>>_package.lst
    fi
    if [ -f "pcre/config.h" ]; then
        echo pcre/config.h>>_package.lst
    fi
    if [ -f "pcre/dftables.c" ]; then
        echo pcre/dftables.c>>_package.lst
    fi
    if [ -f "pcre/pcregrep.c" ]; then
        echo pcre/pcregrep.c>>_package.lst
    fi
    if [ -f "pcre/pcredemo.c" ]; then
        echo pcre/pcredemo.c>>_package.lst
    fi
    if [ -f "pcre/pcretest.c" ]; then
        echo pcre/pcretest.c>>_package.lst
    fi
    if [ -f "pcre/AUTHORS" ]; then
        echo pcre/AUTHORS>>_package.lst
    fi
    if [ -f "pcre/ChangeLog" ]; then
        echo pcre/ChangeLog>>_package.lst
    fi
    if [ -f "pcre/COPYING" ]; then
        echo pcre/COPYING>>_package.lst
    fi
    if [ -f "pcre/INSTALL" ]; then
        echo pcre/INSTALL>>_package.lst
    fi
    if [ -f "pcre/LICENCE" ]; then
        echo pcre/LICENCE>>_package.lst
    fi
    if [ -f "pcre/NEWS" ]; then
        echo pcre/NEWS>>_package.lst
    fi
    if [ -f "pcre/NON-UNIX-USE" ]; then
        echo pcre/NON-UNIX-USE>>_package.lst
    fi
    if [ -f "pcre/README" ]; then
        echo pcre/README>>_package.lst
    fi
    if [ -f "pcre/prelude.pdl" ]; then
        echo pcre/prelude.pdl>>_package.lst
    fi
    if [ -f "pcre/license.gpl" ]; then
        echo pcre/license.gpl>>_package.lst
    fi
    if [ -f "pcre/project.pdl" ]; then
        echo pcre/project.pdl>>_package.lst
    fi
    if [ -f "pcre/readme.txt" ]; then
        echo pcre/readme.txt>>_package.lst
    fi
    if [ -f "pcre/stamp_generate" ]; then
        echo pcre/stamp_generate>>_package.lst
    fi
    if [ -f "pcre/configure" ]; then
        echo pcre/configure>>_package.lst
    fi
    if [ -f "pcre/Makefile.unix" ]; then
        echo pcre/Makefile.unix>>_package.lst
    fi
    if [ -f "pcre/boomake" ]; then
        echo pcre/boomake>>_package.lst
    fi
    if [ -f "pcre/configure.bat" ]; then
        echo pcre/configure.bat>>_package.lst
    fi
    if [ -f "pcre/Makefile.win32" ]; then
        echo pcre/Makefile.win32>>_package.lst
    fi
    if [ -f "pcre/boomake.bat" ]; then
        echo pcre/boomake.bat>>_package.lst
    fi
    if [ -f "pcre/boomakew.bat" ]; then
        echo pcre/boomakew.bat>>_package.lst
    fi
    if [ -f "pcre/libpcre.vcproj" ]; then
        echo pcre/libpcre.vcproj>>_package.lst
    fi
    PUSHDIR=`pwd`
    cd zlib
    cd $PUSHDIR
    if [ -f "zlib/ChangeLog" ]; then
        echo zlib/ChangeLog>>_package.lst
    fi
    if [ -f "zlib/FAQ" ]; then
        echo zlib/FAQ>>_package.lst
    fi
    if [ -f "zlib/README" ]; then
        echo zlib/README>>_package.lst
    fi
    if [ -f "zlib/algorithm.txt" ]; then
        echo zlib/algorithm.txt>>_package.lst
    fi
    if [ -f "zlib/zlib.3" ]; then
        echo zlib/zlib.3>>_package.lst
    fi
    if [ -f "zlib/adler32.c" ]; then
        echo zlib/adler32.c>>_package.lst
    fi
    if [ -f "zlib/compress.c" ]; then
        echo zlib/compress.c>>_package.lst
    fi
    if [ -f "zlib/gzio.c" ]; then
        echo zlib/gzio.c>>_package.lst
    fi
    if [ -f "zlib/uncompr.c" ]; then
        echo zlib/uncompr.c>>_package.lst
    fi
    if [ -f "zlib/crc32.c" ]; then
        echo zlib/crc32.c>>_package.lst
    fi
    if [ -f "zlib/deflate.c" ]; then
        echo zlib/deflate.c>>_package.lst
    fi
    if [ -f "zlib/trees.c" ]; then
        echo zlib/trees.c>>_package.lst
    fi
    if [ -f "zlib/zutil.c" ]; then
        echo zlib/zutil.c>>_package.lst
    fi
    if [ -f "zlib/inflate.c" ]; then
        echo zlib/inflate.c>>_package.lst
    fi
    if [ -f "zlib/infback.c" ]; then
        echo zlib/infback.c>>_package.lst
    fi
    if [ -f "zlib/inftrees.c" ]; then
        echo zlib/inftrees.c>>_package.lst
    fi
    if [ -f "zlib/inffast.c" ]; then
        echo zlib/inffast.c>>_package.lst
    fi
    if [ -f "zlib/inffixed.h" ]; then
        echo zlib/inffixed.h>>_package.lst
    fi
    if [ -f "zlib/zconf.h" ]; then
        echo zlib/zconf.h>>_package.lst
    fi
    if [ -f "zlib/zlib.h" ]; then
        echo zlib/zlib.h>>_package.lst
    fi
    if [ -f "zlib/prelude.pdl" ]; then
        echo zlib/prelude.pdl>>_package.lst
    fi
    if [ -f "zlib/license.gpl" ]; then
        echo zlib/license.gpl>>_package.lst
    fi
    if [ -f "zlib/project.pdl" ]; then
        echo zlib/project.pdl>>_package.lst
    fi
    if [ -f "zlib/readme.txt" ]; then
        echo zlib/readme.txt>>_package.lst
    fi
    if [ -f "zlib/crc32.h" ]; then
        echo zlib/crc32.h>>_package.lst
    fi
    if [ -f "zlib/deflate.h" ]; then
        echo zlib/deflate.h>>_package.lst
    fi
    if [ -f "zlib/trees.h" ]; then
        echo zlib/trees.h>>_package.lst
    fi
    if [ -f "zlib/zutil.h" ]; then
        echo zlib/zutil.h>>_package.lst
    fi
    if [ -f "zlib/inflate.h" ]; then
        echo zlib/inflate.h>>_package.lst
    fi
    if [ -f "zlib/inftrees.h" ]; then
        echo zlib/inftrees.h>>_package.lst
    fi
    if [ -f "zlib/inffast.h" ]; then
        echo zlib/inffast.h>>_package.lst
    fi
    if [ -f "zlib/stamp_generate" ]; then
        echo zlib/stamp_generate>>_package.lst
    fi
    if [ -f "zlib/configure" ]; then
        echo zlib/configure>>_package.lst
    fi
    if [ -f "zlib/Makefile.unix" ]; then
        echo zlib/Makefile.unix>>_package.lst
    fi
    if [ -f "zlib/boomake" ]; then
        echo zlib/boomake>>_package.lst
    fi
    if [ -f "zlib/configure.bat" ]; then
        echo zlib/configure.bat>>_package.lst
    fi
    if [ -f "zlib/Makefile.win32" ]; then
        echo zlib/Makefile.win32>>_package.lst
    fi
    if [ -f "zlib/boomake.bat" ]; then
        echo zlib/boomake.bat>>_package.lst
    fi
    if [ -f "zlib/boomakew.bat" ]; then
        echo zlib/boomakew.bat>>_package.lst
    fi
    if [ -f "zlib/libzip.vcproj" ]; then
        echo zlib/libzip.vcproj>>_package.lst
    fi
    if [ -f "zlib/contrib/minizip/ChangeLogUnzip" ]; then
        echo zlib/contrib/minizip/ChangeLogUnzip>>_package.lst
    fi
    if [ -f "zlib/contrib/minizip/crypt.h" ]; then
        echo zlib/contrib/minizip/crypt.h>>_package.lst
    fi
    if [ -f "zlib/contrib/minizip/ioapi.c" ]; then
        echo zlib/contrib/minizip/ioapi.c>>_package.lst
    fi
    if [ -f "zlib/contrib/minizip/unzip.c" ]; then
        echo zlib/contrib/minizip/unzip.c>>_package.lst
    fi
    if [ -f "zlib/contrib/minizip/zip.c" ]; then
        echo zlib/contrib/minizip/zip.c>>_package.lst
    fi
    if [ -f "zlib/contrib/minizip/ioapi.h" ]; then
        echo zlib/contrib/minizip/ioapi.h>>_package.lst
    fi
    if [ -f "zlib/contrib/minizip/unzip.h" ]; then
        echo zlib/contrib/minizip/unzip.h>>_package.lst
    fi
    if [ -f "zlib/contrib/minizip/zip.h" ]; then
        echo zlib/contrib/minizip/zip.h>>_package.lst
    fi
    if [ -f "zlib/contrib/minizip/zconf.h" ]; then
        echo zlib/contrib/minizip/zconf.h>>_package.lst
    fi
    if [ -f "zlib/contrib/minizip/zlib.h" ]; then
        echo zlib/contrib/minizip/zlib.h>>_package.lst
    fi
    PUSHDIR=`pwd`
    cd tests
    cd $PUSHDIR
    if [ -f "tests/pthread_rwlock_test.c" ]; then
        echo tests/pthread_rwlock_test.c>>_package.lst
    fi
    if [ -f "tests/prelude.pdl" ]; then
        echo tests/prelude.pdl>>_package.lst
    fi
    if [ -f "tests/license.gpl" ]; then
        echo tests/license.gpl>>_package.lst
    fi
    if [ -f "tests/project.pdl" ]; then
        echo tests/project.pdl>>_package.lst
    fi
    if [ -f "tests/readme.txt" ]; then
        echo tests/readme.txt>>_package.lst
    fi
    if [ -f "tests/stamp_generate" ]; then
        echo tests/stamp_generate>>_package.lst
    fi
    if [ -f "tests/configure" ]; then
        echo tests/configure>>_package.lst
    fi
    if [ -f "tests/Makefile.unix" ]; then
        echo tests/Makefile.unix>>_package.lst
    fi
    if [ -f "tests/boomake" ]; then
        echo tests/boomake>>_package.lst
    fi
    if [ -f "tests/configure.bat" ]; then
        echo tests/configure.bat>>_package.lst
    fi
    if [ -f "tests/Makefile.win32" ]; then
        echo tests/Makefile.win32>>_package.lst
    fi
    if [ -f "tests/boomake.bat" ]; then
        echo tests/boomake.bat>>_package.lst
    fi
    if [ -f "tests/boomakew.bat" ]; then
        echo tests/boomakew.bat>>_package.lst
    fi
    if [ -f "tests/liblocal.vcproj" ]; then
        echo tests/liblocal.vcproj>>_package.lst
    fi
    echo "Source package successfully generated">c/stamp_source
    echo "c/stamp_source" >>_package.lst
    echo "Source package successfully generated">apr/stamp_source
    echo "apr/stamp_source" >>_package.lst
    echo "Source package successfully generated">pcre/stamp_source
    echo "pcre/stamp_source" >>_package.lst
    echo "Source package successfully generated">zlib/stamp_source
    echo "zlib/stamp_source" >>_package.lst
    echo "Source package successfully generated">tests/stamp_source
    echo "tests/stamp_source" >>_package.lst
    echo "Source package successfully generated">stamp_source
    echo "stamp_source">>_package.lst
    carp "Building foreign-$MY_VERSION-src.tar.gz..."
    zip  -rq _package.zip -@<_package.lst
    unzip -q _package.zip -d foreign-$MY_VERSION
    rm -f foreign-$MY_VERSION-src.tar.gz
    tar -cf  foreign-$MY_VERSION-src.tar foreign-$MY_VERSION
    gzip foreign-$MY_VERSION-src.tar
    rm -f foreign-$MY_VERSION-src.zip
    carp "Building foreign-$MY_VERSION-src.zip..."
    zip -lrmq foreign-$MY_VERSION-src.zip foreign-$MY_VERSION
    rm _package.zip
    rm _package.lst
    rm stamp_source
    rm -f c/stamp_source
    rm -f apr/stamp_source
    rm -f pcre/stamp_source
    rm -f zlib/stamp_source
    rm -f tests/stamp_source
}

# ----------------------------   BUILD PROJECTS   -----------------------------

a_build_projects() {
:
    rm -rf _install
    mkdir _install
    mkdir _install/lib
    mkdir _install/include
    mkdir _install/bin
    PUSHDIR=`pwd`
    cd c
    if [ -f boomake ]; then
        sh boomake -install ../_install build install || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd apr
    if [ -f boomake ]; then
        sh boomake -install ../_install build install || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd pcre
    if [ -f boomake ]; then
        sh boomake -install ../_install build install || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd zlib
    if [ -f boomake ]; then
        sh boomake -install ../_install build install || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd tests
    if [ -f boomake ]; then
        sh boomake -install ../_install build install || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
}

# ------------------------   CHECK OPERATING CONTEXT   ------------------------

a_check_operating_context() {
:
    if [ -f ./stamp_stripped ]; then
        event=stripped
    elif [ -f ./stamp_source ]; then
        event=source
    else
        event=repository
    fi
}

# ----------------------------   CLEAN PROJECTS   -----------------------------

a_clean_projects() {
:
    rm -rf _install
    PUSHDIR=`pwd`
    cd c
    if [ -f boomake ]; then
        sh boomake clean || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd apr
    if [ -f boomake ]; then
        sh boomake clean || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd pcre
    if [ -f boomake ]; then
        sh boomake clean || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd zlib
    if [ -f boomake ]; then
        sh boomake clean || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd tests
    if [ -f boomake ]; then
        sh boomake clean || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    rm -f foreign_*.zip
    rm -f foreign_*.tar.gz
}

# ---------------------------   COMPILE PROJECTS   ----------------------------

a_compile_projects() {
:
    PUSHDIR=`pwd`
    cd c
    if [ -f boomake ]; then
        sh boomake compile || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd apr
    if [ -f boomake ]; then
        sh boomake compile || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd pcre
    if [ -f boomake ]; then
        sh boomake compile || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd zlib
    if [ -f boomake ]; then
        sh boomake compile || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd tests
    if [ -f boomake ]; then
        sh boomake compile || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
}

# ---------------------------   INSTALL PROJECTS   ----------------------------

a_install_projects() {
:
    PUSHDIR=`pwd`
    cd c
    if [ -f boomake ]; then
        sh boomake install || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd apr
    if [ -f boomake ]; then
        sh boomake install || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd pcre
    if [ -f boomake ]; then
        sh boomake install || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd zlib
    if [ -f boomake ]; then
        sh boomake install || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd tests
    if [ -f boomake ]; then
        sh boomake install || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    if [ -f ./installer ]; then
    [ "$BOOM_TRACE" ] && echo "sh ./installer"
    sh ./installer || croak "\"sh ./installer\" failed"
    fi
}

# ----------------------------   REGEN PROJECTS   -----------------------------

a_regen_projects() {
:
    PUSHDIR=`pwd`
    cd c
    if [ -f boomake ]; then
        sh boomake regen || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd apr
    if [ -f boomake ]; then
        sh boomake regen || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd pcre
    if [ -f boomake ]; then
        sh boomake regen || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd zlib
    if [ -f boomake ]; then
        sh boomake regen || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd tests
    if [ -f boomake ]; then
        sh boomake regen || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
}

# ------------------------   REPORT HELP INFORMATION   ------------------------

a_report_help_information() {
:
    echo "The commands you can currently use on this project are:"
    echo ""
    eval "actions_$state"
}

# ------------------------   REPORT PROJECT VERSION   -------------------------

a_report_project_version() {
:
    echo "foreign-1.2b0"
}

# -----------------------------   TEST PROJECTS   -----------------------------

a_test_projects() {
:
    PUSHDIR=`pwd`
    cd c
    if [ -f boomake ]; then
        sh boomake test || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd apr
    if [ -f boomake ]; then
        sh boomake test || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd pcre
    if [ -f boomake ]; then
        sh boomake test || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd zlib
    if [ -f boomake ]; then
        sh boomake test || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    PUSHDIR=`pwd`
    cd tests
    if [ -f boomake ]; then
        sh boomake test || croak
    else
        croak "Project has not been configured - boomake is missing"
    fi
    cd $PUSHDIR
    if [ -f ./selftest ]; then
    [ "$BOOM_TRACE" ] && echo "sh ./selftest"
    sh ./selftest || croak "\"sh ./selftest\" failed"
    fi
}

# ----------------------   USE SOURCE CONTROL REVISION   ----------------------

a_use_source_control_revision() {
:
    if [ -d .svn ]; then
        SVN_REVISION="`svn info | awk '/^Revision:/ { print $2 }'`"
    else
        SVN_REVISION="svn"
    fi
    MY_VERSION=${MY_VERSION}-${SVN_REVISION}
}

actions_initial() {
    return
}

actions_initial_check() {
    return
}

actions_repository() {
echo "build:"
    echo "  For each project in the product, regenerate code and build binary"
    echo "    files ready for installation.  The projects are built in their"
    echo "    individual directories and installed into the temporary install tree."
echo "compile:"
    echo "  For each project in the product, build binary files ready for installation,"
    echo "    but don't run the code generation phase .  The projects are built in their"
    echo "    individual directories and installed into the temporary install tree."
echo "clean:"
    echo "  Deletes generated project files.  This action removes generated source"
    echo "    and binary files."
echo "regen:"
    echo "  For each project in the product, regenerate any source files that"
    echo "    are produced via GSL, Libero or another code generation tool."
    echo "    Generates only those files that are required to build under"
    echo "    the current model."
echo "allgen:"
    echo "  For each project in the product, regenerate any source files that"
    echo "    are produced via GSL, Libero or another code generation tool."
    echo "    Generates all files."
echo "distrib:"
    echo "  Build all projects and create full distribution packages.  If you do"
    echo "    not want to rebuild the projects, you can use the 'distsrc' and 'distbin'"
    echo "    actions as shortcuts."
echo "distsrc:"
    echo "  Build source distribution packages based on product version number."
echo "distrev:"
    echo "  Build source distribution packages based on source control revision"
    echo "    number."
actions_default
    return
}

actions_source() {
echo "build:"
    echo "  For each project in the product, build binary files ready for"
    echo "    installation.  The projects are built in their individual directories"
    echo "    and installed into the temporary install tree."
echo "clean:"
    echo "  Deletes generated project files.  This action removes generated binary"
    echo "    files."
echo "regen:"
    echo "  For each project in the product, regenerate any source files that"
    echo "    are produced via GSL, Libero or another code generation tool."
    echo "    Generates only those files that are required to build under"
    echo "    the current model."
echo "allgen:"
    echo "  For each project in the product, regenerate any source files that"
    echo "    are produced via GSL, Libero or another code generation tool."
    echo "    Generates all files."
actions_default
    return
}

actions_stripped() {
echo "build:"
    echo "  For each project in the product, build binary files ready for"
    echo "    installation.  The projects are built in their individual directories"
    echo "    and installed into the temporary install tree."
echo "clean:"
    echo "  Deletes generated project files.  This action removes generated binary"
    echo "    files."
actions_default
    return
}

actions_default() {
echo "install:"
    echo "  Install each project into its target directory.  The projects must"
    echo "    have been built (and installed into the temporary install tree, which"
    echo "    is what the build action does)."
echo "distbin:"
    echo "  Build binary distribution packages.  The actual packages built depend on"
    echo "    the project packagers used, but typically you will get a ZIP or TGZ file"
    echo "    containing all the projects' deliverables.  Note that this action works"
    echo "    entirely from the temporary install tree, which the 'build' action makes."
echo "test:"
    echo "  Runs each project's test process."
echo "help:"
    echo "  Shows a list of the commands allowed on the project."
echo "version:"
    echo "  Show product version."
    return
}

#   State machine starts here
#
firsttime=true
while [ "$1" -o "$firsttime" ]; do
  firsttime=
  state=initial
  event=ok
  debug=
  export state event debug
  while [ -n "$state" ]; do
    if [ "$inherit_state" ]; then
        check_state=$inherit_state
        inherit_state=
    else
        check_state=$state
    fi
    case "$check_state" in
    initial)
        if [ -n "$debug" ]; then
            echo "State: initial"
        fi
        case "$event" in
        "")
            if [ -n "$debug" ]; then
                echo "Get event from user"
            fi
            if [ "$1" ]; then
                event=$1
                shift
            else
                event=empty
            fi
            continue
        ;;
        ok)
            if [ -n "$debug" ]; then
                echo "Event: ok"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: check operating context"
            fi
            if [ -z "$exception" ]; then
                a_check_operating_context
            fi
            state=initial_check
            if [ -n "$exception" ]; then
                continue
            fi
        ;;
        *)
            echo "Unknown command - use one of:"
            echo ""
            eval "actions_$state"
            exit 1
        ;;
        esac
    ;;
    initial_check)
        if [ -n "$debug" ]; then
            echo "State: initial check"
        fi
        case "$event" in
        "")
            if [ -n "$debug" ]; then
                echo "Get event from user"
            fi
            if [ "$1" ]; then
                event=$1
                shift
            else
                event=empty
            fi
            continue
        ;;
        repository)
            if [ -n "$debug" ]; then
                echo "Event: repository"
            fi
            event=
            exception=
            state=repository
            if [ -n "$exception" ]; then
                continue
            fi
        ;;
        source)
            if [ -n "$debug" ]; then
                echo "Event: source"
            fi
            event=
            exception=
            state=source
            if [ -n "$exception" ]; then
                continue
            fi
        ;;
        stripped)
            if [ -n "$debug" ]; then
                echo "Event: stripped"
            fi
            event=
            exception=
            state=stripped
            if [ -n "$exception" ]; then
                continue
            fi
        ;;
        *)
            echo "Unknown command - use one of:"
            echo ""
            eval "actions_$state"
            exit 1
        ;;
        esac
    ;;
    repository)
        if [ -n "$debug" ]; then
            echo "State: repository"
        fi
        case "$event" in
        "")
            if [ -n "$debug" ]; then
                echo "Get event from user"
            fi
            if [ "$1" ]; then
                event=$1
                shift
            else
                event=empty
            fi
            continue
        ;;
        build)
            if [ -n "$debug" ]; then
                echo "Event: build"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: build projects"
            fi
            if [ -z "$exception" ]; then
                a_build_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        compile)
            if [ -n "$debug" ]; then
                echo "Event: compile"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: compile projects"
            fi
            if [ -z "$exception" ]; then
                a_compile_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        clean)
            if [ -n "$debug" ]; then
                echo "Event: clean"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: clean projects"
            fi
            if [ -z "$exception" ]; then
                a_clean_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        regen)
            if [ -n "$debug" ]; then
                echo "Event: regen"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: regen projects"
            fi
            if [ -z "$exception" ]; then
                a_regen_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        allgen)
            if [ -n "$debug" ]; then
                echo "Event: allgen"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: allgen projects"
            fi
            if [ -z "$exception" ]; then
                a_allgen_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        distrib)
            if [ -n "$debug" ]; then
                echo "Event: distrib"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: build projects"
            fi
            if [ -z "$exception" ]; then
                a_build_projects
            fi
            if [ -n "$debug" ]; then
                echo "Action: build product source packages"
            fi
            if [ -z "$exception" ]; then
                a_build_product_source_packages
            fi
            if [ -n "$debug" ]; then
                echo "Action: build product install packages"
            fi
            if [ -z "$exception" ]; then
                a_build_product_install_packages
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        distsrc)
            if [ -n "$debug" ]; then
                echo "Event: distsrc"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: allgen projects"
            fi
            if [ -z "$exception" ]; then
                a_allgen_projects
            fi
            if [ -n "$debug" ]; then
                echo "Action: build product source packages"
            fi
            if [ -z "$exception" ]; then
                a_build_product_source_packages
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        distrev)
            if [ -n "$debug" ]; then
                echo "Event: distrev"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: allgen projects"
            fi
            if [ -z "$exception" ]; then
                a_allgen_projects
            fi
            if [ -n "$debug" ]; then
                echo "Action: use source control revision"
            fi
            if [ -z "$exception" ]; then
                a_use_source_control_revision
            fi
            if [ -n "$debug" ]; then
                echo "Action: build product source packages"
            fi
            if [ -z "$exception" ]; then
                a_build_product_source_packages
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        *)
            inherit_state=default
        ;;
        esac
    ;;
    source)
        if [ -n "$debug" ]; then
            echo "State: source"
        fi
        case "$event" in
        "")
            if [ -n "$debug" ]; then
                echo "Get event from user"
            fi
            if [ "$1" ]; then
                event=$1
                shift
            else
                event=empty
            fi
            continue
        ;;
        build)
            if [ -n "$debug" ]; then
                echo "Event: build"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: build projects"
            fi
            if [ -z "$exception" ]; then
                a_build_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        clean)
            if [ -n "$debug" ]; then
                echo "Event: clean"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: clean projects"
            fi
            if [ -z "$exception" ]; then
                a_clean_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        regen)
            if [ -n "$debug" ]; then
                echo "Event: regen"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: regen projects"
            fi
            if [ -z "$exception" ]; then
                a_regen_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        allgen)
            if [ -n "$debug" ]; then
                echo "Event: allgen"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: allgen projects"
            fi
            if [ -z "$exception" ]; then
                a_allgen_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        *)
            inherit_state=default
        ;;
        esac
    ;;
    stripped)
        if [ -n "$debug" ]; then
            echo "State: stripped"
        fi
        case "$event" in
        "")
            if [ -n "$debug" ]; then
                echo "Get event from user"
            fi
            if [ "$1" ]; then
                event=$1
                shift
            else
                event=empty
            fi
            continue
        ;;
        build)
            if [ -n "$debug" ]; then
                echo "Event: build"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: build projects"
            fi
            if [ -z "$exception" ]; then
                a_build_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        clean)
            if [ -n "$debug" ]; then
                echo "Event: clean"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: clean projects"
            fi
            if [ -z "$exception" ]; then
                a_clean_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        *)
            inherit_state=default
        ;;
        esac
    ;;
    default)
        if [ -n "$debug" ]; then
            echo "State: default"
        fi
        case "$event" in
        "")
            if [ -n "$debug" ]; then
                echo "Get event from user"
            fi
            if [ "$1" ]; then
                event=$1
                shift
            else
                event=empty
            fi
            continue
        ;;
        install)
            if [ -n "$debug" ]; then
                echo "Event: install"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: install projects"
            fi
            if [ -z "$exception" ]; then
                a_install_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        distbin)
            if [ -n "$debug" ]; then
                echo "Event: distbin"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: build product install packages"
            fi
            if [ -z "$exception" ]; then
                a_build_product_install_packages
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        test)
            if [ -n "$debug" ]; then
                echo "Event: test"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: test projects"
            fi
            if [ -z "$exception" ]; then
                a_test_projects
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        help)
            if [ -n "$debug" ]; then
                echo "Event: help"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: report help information"
            fi
            if [ -z "$exception" ]; then
                a_report_help_information
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        version)
            if [ -n "$debug" ]; then
                echo "Event: version"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: report project version"
            fi
            if [ -z "$exception" ]; then
                a_report_project_version
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        empty)
            if [ -n "$debug" ]; then
                echo "Event: empty"
            fi
            event=
            exception=
            if [ -n "$debug" ]; then
                echo "Action: report help information"
            fi
            if [ -z "$exception" ]; then
                a_report_help_information
            fi
            if [ -n "$1" -a -z "$exception" ]; then
                continue 2
            fi
            state=
        ;;
        *)
            echo "Unknown command - use one of:"
            echo ""
            eval "actions_$state"
            exit 1
        ;;
        esac
    ;;
    esac
  done
done
