#!/bin/bash

if [ "$#" == "0" ] ; then
echo "
    Usage: icm_bootstrap <any argument>

    Parser and scanner files generated by bison and flex must already
    be available (which is true for the standard distribution)

    Before calling this script icm_prepare must have been called.
"                                     
    exit 0
fi

if [ ! -e tmp/INSTALL.sh ] ; then
    echo tmp/INSTALL.sh does not exist. Try running the icm_prepare script
    exit 1
fi

. bootstrap/functions
. tmp/INSTALL.sh


for target in rss icmake icmun icm-pp icm-comp icm-exec
do
    cd $target
    ./icm_bootstrap
    cd ..
done


echo ./scripts to ./tmp
cp scripts/icmbuild.in scripts/icmstart.in tmp/

echo skeleton files to tmp/${SKELDIR}
try cp -r usr/share/icmake/* tmp/${SKELDIR}

echo configuration files to tmp/${CONFDIR}
try cp -r etc/icmake/* tmp/${CONFDIR}

cd doc

echo man-pages to tmp/${MANDIR}/man1 and .../man7
for x in *.1 ; do
    gzip -9cn $x > ../tmp/${MANDIR}/man1/$x.gz || exit 1
done

for x in *.7 ; do
    gzip -9cn $x > ../tmp/${MANDIR}/man7/$x.gz  || exit 1
done

echo documentation to tmp/${DOCDIR} and tmp/${DOCDOCDIR}

for x in icmake.doc icmake.ps README.icmbuild ; do
    gzip -9cn $x > ../tmp/${DOCDOCDIR}/$x.gz  || exit 1
done

cd ..

gzip -9cn changelog > tmp/${DOCDIR}/changelog.gz || exit 1

try cp -r examples tmp/${DOCDOCDIR}

echo ./etc files to tmp/etc/
try cp -r etc  tmp/ 


echo Done.








