#######################################################################
# Makefile for guile test-suite (with SCM API)
#######################################################################

EXTRA_TEST_CASES += guilescm_ext_test.externaltest

include ../guile/Makefile

# Overridden variables here
INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guilescm
VARIANT      =
# Refer to the guile directory for the run scripts
SCRIPTPREFIX = ../guile/
GUILE_RUNTIME=

# Custom tests - tests with additional commandline options
# none!

# Runs the testcase. A testcase is only run if
# a file is found which has _runme.scm appended after the testcase name.
run_testcase = \
	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
	fi

setup = \
	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then	  \
	  echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
	else								  \
	  echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ;		  \
	fi

%.externaltest:
	$(local_setup)
	+$(swig_and_compile_external)
	$(local_run_testcase)
	
# Same as setup and run_testcase, but without the SCRIPTPREFIX (so the runme comes from the guilescm directory)
local_setup = \
	if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then	  \
	  echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
	else								  \
	  echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ;		  \
	fi

local_run_testcase = \
	if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX); \
	fi
