SYSTEM=	$(shell uname)

ifeq ($(SYSTEM),ULTRIX)
DOSEMU=	softpc
endif

ifeq ($(SYSTEM),Linux)
DOSEMU=	dosemu
endif

ifeq ($(SYSTEM),FreeBSD)
DOSEMU=	pcemu
endif

SUBDIRS+= lib/dos/$(DOSEMU)/src

all::
	@test ! -d bin && mkdir bin || true
	@test ! -d lib/dos/reloc/bin && mkdir -p lib/dos/reloc/bin || true


all:: bin/dos

all clean::
	@set -e; for i in $(SUBDIRS) ; do \
                ( cd $$i; $(MAKE) $@ ) ; \
        done

all install::
	@echo ""
	@echo "put any DOS binaries you want to run into lib/dos/reloc/bin"
	@echo "put everything in bin into your PATH"

#


bin/dos: Makefile
	echo '#!/bin/sh' > $@
	echo "exec `pwd`/lib/dos/$(DOSEMU)/dos "'"$$@"' >> $@
	chmod 755 bin/dos

clean::
	rm -r bin
	