# sourced by the various icm_bootstrap shell scripts

subdirs()
{
    [ "`find ./  -mindepth 1 -maxdepth 1 -type d -name ORG`" != "" ] && return

    for subdir in `find ./  -mindepth 1 -maxdepth 1 -type d | sort` ; do
        try cd $subdir
        add=0
        srclist=`find -mindepth 1 -maxdepth 1 -type f -name '*.cc' \
                                  -exec basename '{}' ';' | sort`
        if [ "$srclist" != "" ]
        then
            ih=${subdir}.ih

#            if [ ! -e ${ih}.gch ] ; then
#                try ${CXX} ${CXXFLAGS} -x c++-header $ih
#            fi
            for src in `find -mindepth 1 -maxdepth 1 -type f -name '*.cc' \
                                    -exec basename '{}' ';' | sort` ; do
                obj=../${dir}${src%%.*}.o
                if [ $src -nt ${obj} ] ; then 
                    try ${CXX}  ${CXXFLAGS} -o${obj} -c $src
                fi
                add=1
            done
        fi
        let dir=${dir}+${add}
        try cd ..
    done
}
