#!/bin/bash

source devel.bash

for d in packages ; do
    echo "Running $d/CASCADE-MAKE.sh"

    (cd $d ; ./CASCADE-MAKE.sh $*)

    if [ $? != 0 ] ; then
        echo "Error encountered running $d/CASCADE-MAKE.sh"
        exit 1
    fi
done

# makedist: just put the files and folder we want in the distribution tarball
# Note that any directories specified for files in the whitelist will also go in
# maintaining directory structure. So "linux/bin/pdf*" will end up in the final
# extracted xpdf-tools folder, not just pdf*.
if [ $makedist = "1" ] ; then
    # temporary folders to ensure folder structure of untarred distribution tarball is correct
    mkdir -p bin
    cp $GSDLOS/bin/pdf* bin/.
    # As per xpdftools' README, licencing files (README, COPYING, COPYING3) and
    # xpdf-tools' manpages need to be redistributed with xpdf-tools binaries
    cp -r $GSDLOS/man .
    toplevel_make_dist $GSDLOS bin man README COPYING*
    # remove the temporary bin and man folders
    rm -rf bin man
fi
