# 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.6

#
# Compiler and Glk library setup.  Configure this section to match the
# system you're using to build SCARE, or override with VARIABLE= on the
# make command line.
#

# GCC compiler and linker flags.
CC	= gcc
DEBUG	=
CEXTRA	=
CFLAGS	= -O2 -D__NO_STRING_INLINES -fPIC -ansi -Wall -W   \
	  -DLINUX_GRAPHICS \
	  -pedantic -Wshadow -Wpointer-arith -Wstrict-prototypes	   \
	  -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls	   \
	  -Wwrite-strings -Wundef -Wbad-function-cast -Waggregate-return   \
	  -Wnested-externs						   \
	  $(DEBUG) $(CEXTRA)
LDLIBS	= -L/usr/local/lib
LDEXTRA	= 
LDFLAGS	= -all_load $(DEBUG) $(LDEXTRA)

# Generic compiler and linker flags.
#CC	= cc
#DEBUG	=
#CEXTRA	=
#CFLAGS	=
#LDLIBS	=
#LDEXTRA=
#LDFLAGS=


# Always use the Bourne shell.
SHELL	= /bin/sh

# Miscellaneous tools, overridable by the command line.
UNZIP	= unzip
RM	= rm
TEST	= test

# SCARE objects and headers.
OBJECTS	= sctafpar.o sctaffil.o scprops.o scvars.o scexpr.o scprintf.o	\
	  scinterf.o scparser.o sclibrar.o scrunner.o scevents.o	\
	  scnpcs.o scobjcts.o sctasks.o screstrs.o scgamest.o scserial.o\
	  scresour.o scmemos.o scutils.o scdebug.o
HEADERS	= scare.h scprotos.h scgamest.h

# SCARE verifier objects and headers.
XOBJECTS= sxmain.o sxutils.o sxglob.o sxtester.o sxscript.o sxfile.o	\
	  sxstubs.o
XHEADERS= sxprotos.h

# Zlib components used by SCARE.
ZLIBVER	= 123
ZLIBSRC	= zlib$(ZLIBVER).zip
ZOBJECTS= crc32.o inffast.o inflate.o inftrees.o zutil.o compress.o	\
	  adler32.o deflate.o trees.o
ZSOURCES= crc32.c inffast.c inflate.c inftrees.c zutil.c compress.c	\
	  adler32.c deflate.c trees.c
ZHEADERS= crc32.h inffast.h inflate.h inftrees.h inffixed.h zutil.h	\
	  zconf.h deflate.h trees.h zlib.h

# Default make target is the basic ANSI interpreter.
all:	scare-dumb scare-curses scare-x11 sx

$(ZOBJECTS): $(ZHEADERS) $(ZSOURCES)

$(ZHEADERS) $(ZSOURCES): $(ZLIBSRC)
	@$(UNZIP) -uqqa $(ZLIBSRC) $@

$(OBJECTS): $(HEADERS)

ansi dumb scare-dumb: $(ZOBJECTS) $(OBJECTS) os_ansi.o
	$(CC) $(LDFLAGS) -o scare-dumb $(OBJECTS) $(ZOBJECTS) os_ansi.o $(LDLIBS)
	ln -s scare-dumb dscare
	mv scare-dumb dscare ..

curses scare-curses: $(ZOBJECTS) $(OBJECTS) os_curses.o
	$(CC) $(LDFLAGS) -o scare-curses $(OBJECTS) $(ZOBJECTS) os_curses.o \
	$(LDLIBS) -lncurses
	ln -s scare-curses scare
	mv scare-curses scare ..

x11 scare-x11:
	# empty for now

# Option to build the SCARE verifier.
$(XOBJECTS): $(XHEADERS)

sx: $(ZOBJECTS) $(OBJECTS) $(XOBJECTS)
	$(CC) $(LDFLAGS) -o sx $(OBJECTS) $(ZOBJECTS) $(XOBJECTS) $(LDLIBS)
	mv sx ..

# Cleanup.
clean:
	$(RM) -f scare-dumb scare-curses scare-x11 dscare scare xscare sx *.o core core.*
	$(RM) -f scare_plugin.c scare-$(VERSION).so
	$(RM) -f $(ZSOURCES)
	$(RM) -f $(ZHEADERS)

distclean: clean

clobber: clean

maintainer-clean: clobber

# Unimplemented targets.
dist check:

