.EXPORT_ALL_VARIABLES:

# Delete SUBDIRS, configure scripts tend to use this name.
SUBDIRS =
#---------------
# REALSUBDIRS are directories that can directly be created via "${MAKE}".
REALSUBDIRS =
REALSUBDIRS- =
REALSUBDIRS-y =
#---------------
# CONFIGDIRS are directories that are configured via ./configure, etc.
CONFIGDIRS =
CONFIGDIRS- =
CONFIGDIRS-y =
#---------------
# NEWCONFIGDIRS use a gnu ${MAKE} file "RUN" for "all:", "clean:", "install:".
NEWCONFIGDIRS =
NEWCONFIGDIRS- =
NEWCONFIGDIRS-y =
#-----------------------------------------------------------------------------
REALSUBDIRS-$(CONFIG_REAL_BASH) += bash
CONFIGDIRS-$(CONFIG_REAL_BASH_205B) += bash-2.05b
CONFIGDIRS-$(CONFIG_REAL_BC) += bc-1.06
REALSUBDIRS-$(CONFIG_REAL_BRIDGE_UTILS) += bridge-utils
REALSUBDIRS-$(CONFIG_REAL_BUSYBOX) += busybox
REALSUBDIRS-$(CONFIG_REAL_CATCHUP) += catchup
REALSUBDIRS-$(CONFIG_REAL_DATE) += date
REALSUBDIRS-$(CONFIG_REAL_DD) += dd
REALSUBDIRS-$(CONFIG_REAL_DHCPCD) += dhcpcd
CONFIGDIRS-$(CONFIG_REAL_FILEUTILS) += fileutils-4.1

# NOTE: freeswan requires new busybox for shell.
REALSUBDIRS-$(CONFIG_REAL_FREESWAN) += freeswan

REALSUBDIRS-$(CONFIG_REAL_GNUFTPD) += gnuftpd
REALSUBDIRS-$(CONFIG_REAL_IPROUTE2) += iproute2
REALSUBDIRS-$(CONFIG_REAL_IPTABLES) += iptables
REALSUBDIRS-$(CONFIG_REAL_L2TPD) += l2tpd-0.67
REALSUBDIRS-$(CONFIG_REAL_MAWK) += mawk/mawk-1.3.3
REALSUBDIRS-$(CONFIG_REAL_MTD) += mtd/util

REALSUBDIRS-$(CONFIG_REAL_VLAN) += vlan

CONFIGDIRS-$(CONFIG_REAL_NET_SNMP) += net-snmp-5.0.1

ifeq ($(NTP), 1)
REALSUBDIRS-$(CONFIG_REAL_NTPCLIENT) += ntpclient
endif

NEWCONFIGDIRS-$(CONFIG_REAL_PING) += ping
REALSUBDIRS-${CONFIG_REAL_PPTP_CLIENT} += pptp-client
NEWCONFIGDIRS-${CONFIG_REAL_PPTPD} += pptpd
CONFIGDIRS-$(CONFIG_REAL_RP_PPPOE) += rp-pppoe-3.5
CONFIGDIRS-$(CONFIG_REAL_SH_UTILS) += sh-utils-2.0
REALSUBDIRS-$(CONFIG_REAL_SHUTILS) += shutils
CONFIGDIRS-$(CONFIG_REAL_STRACE) += strace-4.4
REALSUBDIRS-$(CONFIG_REAL_SYSTEM) += system
REALSUBDIRS-$(CONFIG_REAL_TEST_POST) += test-post
CONFIGDIRS-$(CONFIG_REAL_TEXTUTILS) += textutils-2.0
REALSUBDIRS-$(CONFIG_REAL_UDHCP) += udhcp
REALSUBDIRS-$(CONFIG_REAL_WIRELESS) += wireless_tools.25
CONFIGDIRS-$(CONFIG_REAL_ZEBRA) += zebra
REALSUBDIRS-$(CONFIG_REAL_ZIC) += zic
#-----------------
# Order dependancy for zlib, openssl, and openssh.
CONFIGDIRS-$(CONFIG_REAL_ZLIB) += zlib-1.1.4
CONFIGDIRS-$(CONFIG_REAL_OPENSSL) += openssl-0.9.6e
CONFIGDIRS-$(CONFIG_REAL_OPENSSH) += openssh-3.5p1
#-----------------------------------------------------------------------------
NEWCONFIGDIRS-${CONFIG_REAL_UTIL_LINUX} += util-linux-2.11z
#-----------------------------------------------------------------------------
# ---  Following were started, but not finished.
#-- REALSUBDIRS += procps
# popts does not pass several tests.  "bash ./testis.sh"
#-- REALSUBDIRS += popt-1.6.4
#-----------------------------------------------------------------------------

REALSUBDIRS += $(REALSUBDIRS-y)
CONFIGDIRS += $(CONFIGDIRS-y)
NEWCONFIGDIRS += $(NEWCONFIGDIRS-y)

all:	${REALSUBDIRS} ${CONFIGDIRS} ${NEWCONFIGDIRS}
#---------------
${REALSUBDIRS}::
	${MAKE} ${MFLAGS} -C $@ || exit 1
#---------------
${CONFIGDIRS}::
	(cd $@ && ./RUN && ${MAKE}) || exit 1
#---------------
${NEWCONFIGDIRS}::
	${MAKE} ${MFLAGS} -C $@ -f RUN all || exit 1
#---------------
install:
	for i in $${REALSUBDIRS} ; do ${MAKE} ${MFLAGS} -C $$i install || exit 1; done
	for i in $${CONFIGDIRS} ; do (cd $$i; ${MAKE} -f RUN.INSTALL install) || exit 1; done
	for i in $${NEWCONFIGDIRS} ; do ${MAKE} ${MFLAGS} -C $$i -f RUN install || exit 1; done
#---------------
clean:
	for i in ${REALSUBDIRS} ; do ${MAKE} ${MFLAGS} -C $$i clean || true; done
	for i in ${REALSUBDIRS-} ; do ${MAKE} ${MFLAGS} -C $$i clean || true; done
	for i in ${CONFIGDIRS} ; do (cd $$i; ./RUN.CLEAN) || true; done
	for i in ${CONFIGDIRS-} ; do (cd $$i; ./RUN.CLEAN) || true; done
	for i in ${NEWCONFIGDIRS} ; do ${MAKE} ${MFLAGS} -C $$i -f RUN clean || true; done
	for i in ${NEWCONFIGDIRS-} ; do ${MAKE} ${MFLAGS} -C $$i -f RUN clean || true; done
#-----------------------------------------------------------------------------
# End of file Makefile
