#-----------------------------------------------------------------------------#
# vim: ts=8 sw=8 noexpandtab ft=make
#-----------------------------------------------------------------------------#

TESTS_DIR = ..
THIS_DIR = feedback
MAYBE_J1 =

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

PROGS = \
	mandelbrot \
	mmc

AUTOPAR_REPORTS = $(PROGS)

REPORTS = $(patsubst %,autopar_%,$(AUTOPAR_REPORTS))

TESTS = $(patsubst %,%-nodepend,$(sort $(REPORTS)))
include ../Mmake.common

# Before 2012 Jan 9, we used to always test the versions of
# mdprof_create_feedback and mdprof_report_feedback in the current workspace.
# Then, in commit 66176a407eb71790e8608bc0ee25b15cf67f6ddf, Paul added code
# here to test the installed versions in PATH instead if the current workspace
# did not have these executables. His log message says:
#
#   The feedback tests on goliath were failing. The problem is that
#   the test suite is run without first building the workspace, and
#   the mdprof_create_feedback and tools are not available.
#
# This is why we try to use the feedback tools in this workspace if available;
# and otherwise, we use the tools in $PATH.

FB_CREATE_WS = ../../deep_profiler/mdprof_create_feedback
FB_REPORT_WS = ../../deep_profiler/mdprof_report_feedback

FB_CREATE_SYS = mdprof_create_feedback
FB_REPORT_SYS = mdprof_report_feedback

FB_CREATE = `if test -e $(FB_CREATE_WS); then \
                echo $(FB_CREATE_WS); \
            else \
                echo $(FB_CREATE_SYS); \
            fi`
FB_REPORT = `if test -e $(FB_REPORT_WS); then \
                echo $(FB_REPORT_WS); \
            else \
                echo $(FB_REPORT_SYS); \
            fi`

%.runtest: %.res ;

%.out: %.feedback
	$(FB_REPORT) $< > $@

autopar_%.feedback: %_dir/Deep.data %_dir/Deep.procrep
	$(FB_CREATE) -v 0 --implicit-parallelism $< $@

%.realclean:
	rm -rf $(@:.realclean=.feedback) \
		$(@:.realclean=.out) \
		$(@:.realclean=.res) \
		$(@:.realclean=.res1) \
		$(@:.realclean=.log)
