# Makefile for the GNU Pascal Test Suite
#
# Copyright (C) 1996-2003 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 -W -Wall -Wundef -Wpointer-arith -Wno-unused
PFLAGS=$(BASIC_PFLAGS) $(TEST_PATHS) $(EXTRA_PFLAGS) $(EXTRA_TEST_PFLAGS)
TEST_RUN_FLAGS=

all: pascal.check

.PHONY: all pascal.check pascal.check-nomsg pascal.check-long pascal.check-long-nolog msg \
        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 | head -1; $(PC) --print-search-dirs | grep install | head -1; hostname || echo "unknown host"; date "+%Y-%m-%d %H:%M:%S"; } | \
	sed -e 's,^,Testing ,;N;s,\n.*gcc-lib[/\], (,;s,[/\].*,),;N;s,\n, (,;s,$$,),;N;s/\n/, /'
	echo "$(PC) $(BASIC_PFLAGS) $(EXTRA_PFLAGS) $(EXTRA_TEST_PFLAGS)"

pascal.check: msg pascal.check-nomsg

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

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

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

msg:
	@echo
	@echo "Running the GPC Test Suite. This may take a while ..."
	@echo

mostlyclean:
	-rm -f *.dat *.o *.s *.i *.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 todo/a.out todo/*.exe todo/*.o todo/*.s todo/*.i todo/*.gpi todo/*.gpd todo/core

clean: mostlyclean

distclean: clean

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

maintainer-clean: extraclean
