# vi: set ts=8:
#
# Copyright (C) 2003-2007  Simon Baldwin and Mark J. Tilford
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
# USA
#

VERSION = 1.3.7

#
# End of compiler and Glk library set.  The rest of the Makefile is SCARE
# generic, or specific to building the SCARE distribution.
#

# Miscellaneous tools, overridable by the command line.
ZIP	= zip
RM	= rm
CP	= cp
LN	= ln
TAR	= tar

# Default make target is the basic ANSI interpreter.
all:	scare

# Pass-through build targets.
clean distclean scare glkscare scare-$(VERSION).so sx:
	cd source; $(MAKE) $@

# Build SCARE's self-test and run it.
check: sx
	source/sx \
	test/sccore test/scdebug test/scevents test/sclogic		\
	test/scmaths test/scnpcs test/scprintf test/screstrs		\
	test/scstring test/sctasks test/scvars				\
	test/hamper test/humbug test/darkwoods test/akron test/wrecked

# Cleanup.
maintainer-clean: clean
	$(RM) -f scare-$(VERSION).zip scare-$(VERSION)_linux.tgz

clobber: maintainer-clean

# Build the SCARE distributions.
linux-dist:
	$(MAKE) maintainer-clean
	cd source; $(MAKE) 'CEXTRA=-DLINUX_GRAPHICS'			\
	  scare glkscare scare-$(VERSION).so
	cd source; $(CP) scare glkscare scare-$(VERSION).so ..
	$(TAR) zcvf scare-$(VERSION)_linux.tgz				\
	  scare glkscare scare-$(VERSION).so				\
	  README CHANGES COPYING RUNNING
	$(RM) -f scare glkscare scare-$(VERSION).so

source-dist:
	$(MAKE) clean
	$(LN) -s . scare-$(VERSION)
	$(ZIP) -9 scare-$(VERSION).zip					\
	  scare-$(VERSION)/BUILDING scare-$(VERSION)/CHANGES		\
	  scare-$(VERSION)/COPYING scare-$(VERSION)/DEBUGGER		\
	  scare-$(VERSION)/Makefile scare-$(VERSION)/PORTING		\
	  scare-$(VERSION)/README scare-$(VERSION)/RUNNING		\
	  scare-$(VERSION)/TESTING					\
	  scare-$(VERSION)/source/* scare-$(VERSION)/test/*
	$(RM) -f scare-$(VERSION)

dist: linux-dist source-dist

