# Makefile for the GNU Pascal Compiler Test Suite.
#
# Copyright (C) 1996-2002 Free Software Foundation, Inc.
#
# Authors: J.J. van der Heijden <j.j.vanderheijden@student.utwente.nl>
#          Peter Gerwinski <peter@gerwinski.de>
#          Frank Heckenbach <frank@pascal.gnu.de>
#
# This file is part of GNU Pascal.
#
# GNU Pascal is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# GNU Pascal 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 GNU Pascal; see the file COPYING. If not, write to the
# Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

srcdir = .
SHELL = /bin/sh
MASK = *.pas
PC = gpc
TEST_PATHS =
BASIC_PFLAGS = -g -O3 -Wall
PFLAGS = $(BASIC_PFLAGS) $(TEST_PATHS) $(EXTRA_PFLAGS)

all: pascal.check

.PHONY: all pascal.check-long pascal.check msg pascal.check-nomsg \
        mostlyclean clean distclean extraclean maintainer-clean

# to be removed when using GP
PFLAGS1 = --autobuild

VARS=PC="$(PC)" PFLAGS="$(PFLAGS1) $(PFLAGS)" SRCDIR="$(srcdir)" TEST_MAKE_FLAG=test-make-flag

print-version:
	{ $(PC) --version; $(PC) --print-search-dirs | grep install; hostname || echo "unknown host"; } | \
	sed -e 's,^,Testing GPC ,;N;s,\n.*gcc-lib[/\], (,;s,[/\].*,),;N;s,\n, (,;s,$$,),'
	echo "$(PC) $(BASIC_PFLAGS) $(EXTRA_PFLAGS)"

pascal.check-long: clean print-version
	$(VARS) "$(srcdir)/test_run" "$(MASK)"

pascal.check: msg pascal.check-nomsg

pascal.check-nomsg: clean print-version
	$(VARS) "$(srcdir)/test_run" "$(MASK)" | "$(srcdir)/test_sum"

msg:
	@echo
	@echo "Running the GPC Test Suite. This may take a while ..."
	@echo
	@echo "NOTE, if you've used the Test Suite before:"
	@echo "To get the long output format, run \`make pascal.check-long' now."
	@echo

mostlyclean:
	-rm -f *.dat *.o *.s *.gpm *.gpi *.gpd *.gpc core a.out stderr.out *.exe testmake.tmp dummy.c dummy.pas dummy.out diff_cr*.tmp fixcr fixcr.exe
	-rm -f knownbugs/a.out knownbugs/*.exe knownbugs/*.o knownbugs/*.s knownbugs/*.gpm knownbugs/*.gpi knownbugs/*.gpd knownbugs/core
	-rm -f internal/a.out internal/*.exe internal/*.o internal/*.s internal/*.gpm internal/*.gpi internal/*.gpd internal/core

clean: mostlyclean

distclean: clean

extraclean: distclean
	-rm -f *.BAK *.bak *.orig gpc.out make.out b.out dtlist.*

maintainer-clean: extraclean
