#!/bin/sh
#
# This file should only be run automatically by make, not directly by
# the user.
#
# This script any number of arguments or none.  For each subdirectory
# listed in the environment variable SUB_PACKAGES, it cd's to that
# subdirectory and runs gmake there.  It passes to gmake all the
# arguments received by the script.  Also, if the VERSION environment
# variable is set, it uses the value of that variable to calculate the
# version of the subpackage, and sets VERSION to that subpackage
# version number for gmake.


if test "${SUB_PACKAGES}""" = ""; then
    exit 1
fi

export PACKAGE_NAME
export VERDATAFILE
export OTHERSRCS
export SUB_PACKAGES
export INFOS
export INFOSRCS
export YSRCS
export DSRCS
export HEADERS
export CSRCS
export SRCS
export MANPAGES
export GIFSRCS
export TMP_YSRCS
export TMP_DSRCS
export TMP_HEADERS
export TMP_CSRCS
export TMP_SRCS
export TMP_INFOSRCS
export TMP_MANPAGES
export TMP_OTHERSRCS
export TARGET
export LIBS
export EXPORTS
export EXTRA_PURE
export EXTRA_YFLAGS
export EXTRA_CFLAGS
export EXTRA_CXXFLAGS
export TCLSRCS
export SUPER_PACKAGES_PATH
export STATIC_LIBNAME
export SHARED_LIBNAME
export LIBNAME_SET_A
export LIBNAME_SET_B
export LIBNAME_SET

PACKAGE_NAME=
VERDATAFILE=
OTHERSRCS=
INFOS=
INFOSRCS=
YSRCS=
DSRCS=
HEADERS=
CSRCS=
SRCS=
MANPAGES=
GIFSRCS=
TMP_YSRCS=
TMP_DSRCS=
TMP_HEADERS=
TMP_CSRCS=
TMP_SRCS=
TMP_INFOSRCS=
TMP_MANPAGES=
TMP_OTHERSRCS=
TARGET=
LIBS=
EXPORTS=
EXTRA_PURE=
EXTRA_YFLAGS=
EXTRA_CFLAGS=
EXTRA_CXXFLAGS=
TCLSRCS=
STATIC_LIBNAME=
SHARED_LIBNAME=
LIBNAME_SET_A=
LIBNAME_SET_B=
LIBNAME_SET=

SUPER_PACKAGES_PATH=${PACKAGE_FULL_NAME}

for subpackage in ${SUB_PACKAGES}; do
    if test ${VERSION}"" = ""; then
        version_arg=""
    else
        version_arg="VERSION="`ver_sub_ver ${subpackage} ${VERSION}`;
    fi
    if test ! -d ${subpackage}; then
        mkdir ${subpackage}
        if test ${?} != 0; then
            exit 1
        fi
    fi
    if test '(' ! -d ${subpackage}/RCS ')' -a '(' -d RCS ')'; then
        ln -s ../RCS/${subpackage} ${subpackage}/RCS
        if test ${?} != 0; then
            exit 1
        fi
    fi
    ( \
        cd ${subpackage}; \
        if test ${?} != 0; then \
            exit 1; \
        fi; \
        \
        if test ! -f Makefile; then \
            co Makefile; \
            if test ${?} != 0; then \
                exit 1; \
            fi \
        fi; \
        \
        if test ${SILENT_RECURSIVE_MAKE}"" = "" ; then \
            echo suif-recursive-make: ${GNU_MAKE} $* ${version_arg}; \
        fi; \
        (SUB_PACKAGES= ; ${GNU_MAKE} $* ${version_arg}); \
        if test ${?} != 0; then \
            exit 1; \
        fi; \
        \
        exit 0;
    )
    if test ${?} != 0; then
        exit 1
    fi
done

exit 0
