#-----------------------------------------------------------------------------#

main_target:	check

# include ../../Mmake.common
# This file is copied from the Mercury tests repository
include ./Mmake.common

#-----------------------------------------------------------------------------#

MORPHINE = ../scripts/morphine  --no-banner

#-----------------------------------------------------------------------------#

DEBUGGER_PROGS=	\
	queens	\
	test_vars \

MCFLAGS = --trace deep
MLFLAGS = --trace

# We need to use shared libraries for collect to work.
# The following is necessary for shared libraries to work on Linux.
MGNUCFLAGS-queens =--pic-reg
MGNUCFLAGS-queens_init =--pic-reg
MLFLAGS-queens = --shared 

# Base grades `jump' and `fast' cannot be used with
# stack layouts (which are required for tracing).

ifneq "$(findstring asm_,$(GRADE))" ""
    PROGS=$(DEBUGGER_PROGS)
else
    ifneq "$(findstring jump,$(GRADE))" ""
	PROGS=
    else
	ifneq "$(findstring fast,$(GRADE))" ""
	    PROGS=
	else
	    PROGS=$(DEBUGGER_PROGS)
	endif
    endif
endif

#-----------------------------------------------------------------------------#

queens.out.orig: queens queens.in 
	$(MORPHINE) < queens.in > queens.out.orig 2>&1

# Filter out things that might change depending if we use Eclipse3.5.2 
# or Eclipse4.*, unix or inet socket, etc.
queens.out: queens.out.orig
	cat queens.out.orig | \
		grep -v 'host = ' | \
		grep -v 'compiled traceable' | \
		grep -v 'loading' | \
		grep -v 'translating ' | \
		grep -v 'is loaded' | \
		grep -v 'is translated' | \
		grep -v 'making scenario' | \
		grep -v 'WARNING' | \
		grep -v 'Compiling collect.m' | \
		grep -v 'mmc --grade' | \
		grep -v 'mmc --no-warn-det-decls-too-lax --grade' | \
		grep -v 'ml --grade' | \
		grep -v 'bin/generate_pred_cov' | \
		grep -v 'bin/generate_call_site_cov' \
			> queens.out 2>&1

test_vars.out.orig: test_vars test_vars.in
	$(MORPHINE) < test_vars.in > test_vars.out.orig 2>&1

test_vars.out: test_vars.out.orig
	cat test_vars.out.orig | \
		grep -v 'host = ' | \
		grep -v 'compiled traceable' | \
		grep -v 'loading' | \
		grep -v 'WARNING' | \
		grep -v 'is loaded' | \
		grep -v 'making scenario' \
			> test_vars.out 2>&1

#-----------------------------------------------------------------------------#

DEPS=		$(PROGS:%=$(deps_subdir)%.dep)
DEPENDS=	$(PROGS:%=%.depend)
OUTS=		$(PROGS:%=%.out)
RESS=		$(PROGS:%=%.res)

dep_local:	$(DEPS)
depend_local:	$(DEPENDS)
check_local:	$(OUTS) $(RESS)
all_local:	$(PROGS)

#-----------------------------------------------------------------------------#

