# Makefile for the ELKS command set.
#
###############################################################################
#
# Include standard rules.

BASEDIR = .

include $(BASEDIR)/Makefile-rules

###############################################################################
#
# Subdirectories for clean / build / install

# All subdirectories to build & clean

IA16DIRS =       \
	lib         \
	advent      \
	ash         \
	bc          \
	debug       \
	disk_utils  \
	fsck_dos    \
	ekermit	    \
	elvis	    \
	file_utils  \
	gui         \
	minix1      \
	minix2      \
	minix3      \
	misc_utils  \
	oss         \
	picoisa     \
	romprg      \
	sash        \
	screen      \
	cron        \
	sh_utils    \
	sys_utils   \
	tui         \
	test        \
	# EOL

# This GCC-only ELKS port intentionally builds without floating point support
# for 4 MHz-class systems.  BASIC depends on strtod and libm float routines,
# so do not build it unless a float-capable libc is restored.

ifeq ($(wildcard $(BASEDIR)/test/Makefile),)
IA16DIRS := $(filter-out test, $(IA16DIRS))
endif

ifeq ($(CONFIG_APP_ESD_ELKS), y)
IA16DIRS += ../extapps/esd-elks
endif

ifeq ($(CONFIG_APP_SBVOL), y)
IA16DIRS += ../extapps/sbvol
endif

ifeq ($(CONFIG_APP_PC1640_NVR), y)
IA16DIRS += ../extapps/amstrad-1640-bios-config
endif

###############################################################################
#
# Compile all IA16 apps

ALL = ia16

all: $(ALL)

ia16:
	@if [ ! -e $(TOPDIR)/include/autoconf.h ]; \
	then echo -e "\n*** ERROR: You must configure ELKS first ***\n" >&2; exit 1; fi
	for DIR in $(IA16DIRS); do $(MAKE) -C $$DIR all || exit 1; done

clean:
	for DIR in $(IA16DIRS); do $(MAKE) -C $$DIR clean || exit 1; done

install:
	$(MAKE) -f Make.install "CONFIG=$(TOPDIR)/.config"

###############################################################################
