## This file contains Automake rules for the TADS 3 compiler.

## Include rules for the TADS 3 test suite if we're building the debug
## version.
##
if T3_DEBUG_BUILD
include $(srcdir)/Testsuite.am
endif

bin_PROGRAMS += t3make

AM_CPPFLAGS += -I$(srcdir)/src -I$(srcdir)/tads3 -I$(srcdir)/tads3/test

## TADS 3 compiler sources.
##
T3CSOURCES = \
    src/ost3comp.cc \
    tads3/os_stdio.cpp \
    tads3/rcmain.cpp \
    tads3/std_dbg.cpp \
    tads3/tcgenfil.cpp \
    tads3/tcmakecl.cpp \
    tads3/tcmake.cpp \
    tads3/tcprsfil.cpp \
    tads3/tcprsimg.cpp \
    tads3/tcprsprg.cpp \
    tads3/tct3img.cpp \
    tads3/tct3prg.cpp \
    tads3/vmbifc.cpp \
    tads3/vmbifreg.cpp \
    tads3/vmhttpdum.cpp \
    tads3/vmimgrb.cpp \
    tads3/vmpreini.cpp \
    tads3/vmwrtimg.cpp

t3make_SOURCES = $(COMMONSOURCES) $(T3HEADERS) $(T3RCSOURCES) $(T3CSOURCES)

## Install compiler data files.
##
t3libdir = $(T3_LIB_DIR)
t3incdir = $(T3_INC_DIR)
t3extdir = $(T3_EXT_DIR)
t3exttcommanddir = $(T3_EXT_TCOMMAND_DIR)
t3exttcommanddocdir = $(T3_EXT_TCOMMAND_DOC_DIR)
t3adv3dir = $(T3_ADV3_DIR)
t3adv3enusdir = $(T3_ADV3_EN_US_DIR)
t3webuiresdir = $(T3_WEBUIRES_DIR)
t3docdir = $(T3_DOC_DIR)

t3lib_DATA = $(T3_LIB_FILES)
t3inc_DATA = $(T3_INC_FILES)
t3ext_DATA = $(T3_EXT_FILES)
t3exttcommand_DATA = $(T3_EXT_TCOMMAND_FILES)
t3exttcommanddoc_DATA = $(T3_EXT_TCOMMAND_DOC_FILES)
t3adv3_DATA = $(T3_ADV3_FILES)
t3adv3enus_DATA = $(T3_ADV3_EN_US_FILES)
t3webuires_DATA = $(T3_WEBUIRES_FILES)
t3doc_DATA = $(T3_DOC_FILES)

## Target to build the TADS 3 sample game.  We'll always rebuild it, no
## matter if it already exists or not.
##
## Note: These are make rules, so use tabs to indent the commands, not spaces!
##
sample: t3make
	test -z "@abs_builddir@/samples/obj" || $(mkinstalldirs) "@abs_builddir@/samples/obj"
	rm -f "@abs_builddir@/samples/sample.t3m"
	cp "$(srcdir)/tads3/samples/sample.t3m" "@abs_builddir@/samples/sample.t3m"
	cd "@abs_builddir@/samples" && "@abs_builddir@/t3make" -f sample.t3m -a -FL "@abs_srcdir@/tads3/lib" \
		-FI "@abs_srcdir@/tads3/include" -I "@abs_srcdir@/tads3/samples" -Fs "@abs_srcdir@/tads3/samples" \
		-Fy "@abs_builddir@/samples/obj" -Fo "@abs_builddir@/samples/obj"

sample-clean:
	rm -f "@abs_builddir@/samples/sample.t3m" "@abs_builddir@/samples/sample.t3" "@abs_builddir@/samples/gameinfo.txt"
	rm -rf "@abs_builddir@/samples/obj"
