# Main Makefile for Shag/OS


SUBDIRS = fconfig/ util/ bin/ lib/ sys/ drv/ objtest/ ubin/

COMMANDS += setup bootdisk

all:
	@if [ ! -f config.var ] ; then \
		echo ""; \
		echo "Don't run 'make' in this directory"; \
		echo " - Create a build directory (ex: mkdir ../build)"; \
		echo " - Switch to that directory (ex: cd ../build)"; \
		echo " - Run 'config' from there  (ex: ../"`basename \`pwd\``"/config)"; \
		echo "Or read the file 'INSTALL' for more details"; \
		echo ""; \
	else \
		echo ""; \
		echo "More specific targets are needed"; \
		echo "Choose one of the following:"; \
		echo "	make setup	: general purpose setup"; \
		echo "	make bootdisk	: create a bootable floppy disk"; \
		echo "or read the INSTALL document for more information"; \
		echo ""; \
	fi;


setup setup.done:
	@set -e; if [ $@ = setup.done ] ; then \
		echo "Setup has not been done first.  'make setup' implied..."; \
	fi; \
	if ! $(MAKE) \
			bin/config bin/all \
			lib/setup \
			util/all \
	   		sys/boot/ sys/mkern/ \
			; then \
		echo "output can be found in 'setup.log'"; \
		exit 1; \
	else \
		echo "setup complete. (output in 'setup.log')"; \
		touch setup.done; \
	fi 2>&1 | tee setup.log; \
	if [ ! -f setup.done ] ; then \
		exit 1; \
	fi 

bootdisk: setup.done
	@set -e; if ! $(MAKE) sys/boot/bootdisk ; then \
		echo "output can be found in 'bootdisk.log'"; \
		exit 1; \
	else \
		echo "bootdisk complete. (output in 'bootdisk.log')"; \
	fi 2>&1 | tee bootdisk.log

