#-----------------------------------------------------------------------------#
# Copyright (C) 1997-2000 The University of Melbourne.
# This file may only be copied under the terms of the GNU Library General
# Public License - see the file COPYING.LIB in the Mercury distribution.
#-----------------------------------------------------------------------------#

MAIN_TARGET = all

# We need to use a grade with trailing
GRADEFLAGS += --use-trail

MCFLAGS = --infer-all

MGNUCFLAGS=-g -I..
RM_C=:
MLFLAGS=-g

# Link in the trailed_update library from ..
MCFLAGS += -I.. $(EXTRA_MCFLAGS)
MLFLAGS += -R`pwd`/.. -L.. $(EXTRA_MLFLAGS)
MLLIBS = -ltrailed_update $(EXTRA_MLLIBS)
VPATH = ..:$(MMAKE_VPATH)
C2INITARGS = ../trailed_update.init

# We need the following to use shared libraries on Linux
#MGNUCFLAGS += -DPIC_REG
#MLFLAGS += --shared

MLFLAGS += --static

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

PROGS	=	interpreter vqueens

DEPENDS =	$(PROGS:%=%.depend)
CS	=	$(PROGS:%=%.c)
RESS	=	$(PROGS:%=%.res)

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

$(PROGS): ../libtrailed_update.a

%.out: %
	./$< > $@ 2>&1;

%.res: %.exp %.out
	diff -c $*.exp $*.out > $@

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

interpreter.out: interpreter interpreter.inp
	./interpreter interpreter.m < interpreter.inp > interpreter.out

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

.PHONY: depend
depend: $(DEPENDS)

.PHONY: all
all: $(PROGS)

.PHONY: check
# XXX the test of `interpreter' is disabled,
# since it fails in grade asm_fast.tr.
# (It fails due to a bug in value numbering which causes
# parts of the Mercury library to be miscompiled.)
check: vqueens.res
# check: $(RESS)

.PHONY: cs
cs: $(CS)

.PHONY: clean_local
clean_local:
	rm -f *.out *.res

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

# The Mmake.params file can be used to override definitions in this file
-include ../../Mmake.params

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