#
# Choose-OS Makefile
#
# Copyright (c) Tuomo Valkonen 1996-1998.
#
############################################################################

#
# Valid EXTRA_DEFINES are:
#
#	-DBUG_HARDWARE
#		Define this if there is noise in the background image.
#		
#	-DSUPPORT_EMERGENCY
#		Define this if you're gonna use the emergency bootsector
#		feature.
#
#	-DSUPPORT_BZIMAGE
#		Compile with this to have support for bzImages.
#
#	-DSUPPORT_INITRD
#		Compile with this to support initial ramdisk
#
#	-DSUPPORT_REWRITE
#		Compile with support for bootsector modification
#
#	-DCHECK_CYLINDER
#		Check for cylinder number being in range when loading.
#
#	-DNO_BEEP
#		Don't beep when rewriting MBR/1st mapfile sector
#
#	-DSUPPORT_DOSMENUKEY
#		Support the 'dosmenukey=' -option.
#
#	THE FOLLOWING FEATURES ARE UNTESTED OR AND YOU'RE EXPERIMENTING WITH
#	THEM AT YOUR OWN RISK !!!
#
#	-DSUPPORT_DRIVESWAP
#		Compile with support for hda/hdb swapping
#
#	-DSUPPORT_DOS4BOOT
#		Compile with support for telling dos4+ to boot of hdb
#
#	-DVERIFY_DOS4
#		Verify it really is dos4
#
############################################################################

EXTRA_DEFINES=-DBUG_HARDWARE -DSUPPORT_BZIMAGE -DSUPPORT_INITRD -DSUPPORT_DOSMENUKEY
#-DSUPPORT_REWRITE

#
# No user serviceable parts inside. Please consult your nearest retailer.
#
############################################################################

.EXPORT_ALL_VARIABLES:

TOPDIR=         $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
DEST_DIR=	$(TOPDIR)/../bin

INC_DIR=	$(TOPDIR)/include

COMMON_FLAGS=	$(EXTRA_DEFINES) -I$(TOPDIR)/.include

AS86=		as86 -0 -a
LD86=		ld86 -0 -s
CPP=		gcc -E $(COMMON_FLAGS)
MAKE_DEPEND=	$(CPP) -M
CC=		gcc -funsigned-char -s $(COMMON_FLAGS)
DEPEND=		.depend

SUBDIRS=	loader installer utils

DIRSEPARATOR=	$(TOPDIR)/utils/dirseparator

SEPARATOR=	$(TOPDIR)/utils/separator

#
# Rules
#
############################################################################

all:	
	@echo -e "\nCompiling Choose-OS\n"
	@rm -f errors.log
	@set -e; for i in $(SUBDIRS); do $(DIRSEPARATOR);$(MAKE) -C $$i 2>&1|tee -a errors.log;done
	@rm -f errors.log
	
	@echo -e "\nCompilation complete.\n"

clean:
	@echo -e "\nCleaning up\n"
	@set -e; for i in $(SUBDIRS); do $(DIRSEPARATOR);$(MAKE) clean -C $$i ;done
	@echo -e "\nComplete.\n"

depend:
	@echo -e "\nCreating dependencies\n"
	@set -e; for i in $(SUBDIRS); do $(DIRSEPARATOR);$(MAKE) depend -C $$i ;done
	@echo -e "\nComplete.\n"
	
