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

THIS_DIR = recompilation

TESTS_SHOULD_SUCCEED = \
	add_constructor_nr \
	add_constructor_r \
	add_instance_r \
	add_instance_2_r \
	add_type_nr \
	change_class_r \
	change_func_r \
	change_instance_r \
	change_mode_r \
	change_type_nr \
	combined_type_mode_nr \
	field_r \
	func_overloading_nr \
	func_overloading_r \
	lambda_mode_r \
	no_version_numbers_r \
	pragma_type_spec_r \
	pred_ctor_ambiguity_r \
	pred_overloading_r \
	typeclass_method_pragma_r \
	type_spec_rename_var_r \
	type_spec_unname_var_r \
	unchanged_pred_nr \
	unchanged_with_type_nr

# Parallel mmake with nested sub-modules is broken.
# The commands to create `.c' files from the `.m' file containing the
# nested sub-module are run twice, resulting in incorrect output in
# the `.err' file.
NO_PARALLEL_MAKE_TESTS = \
	nested_module_r \
	nested_module_2_r

TESTS_SHOULD_FAIL = \
	add_type_re \
	remove_type_re \
	type_qual_re \
	with_type_re

PROGS= $(TESTS_SHOULD_SUCCEED) $(NO_PARALLEL_MAKE_TESTS) \
	$(TESTS_SHOULD_FAIL)

TESTS= $(sort $(PROGS:%=%-nodepend))
SUBDIRS =
TESTS_DIR = ..
include $(TESTS_DIR)/Mmake.common

# Module-specific options should go in Mercury.options so they
# can be found by `mmc --make'.
include Mercury.options

$(TESTS_SHOULD_SUCCEED:%=%.runtest): %.runtest:
	+@if ./two_module_test false $* $*_2; then \
		:; \
	else \
		cat $*.res; \
		exit 1; \
	fi

$(NO_PARALLEL_MAKE_TESTS:%=%.runtest): %.runtest:
	+@if mmakeopts=-j1 ./two_module_test false $* $*_2; then \
		:; \
	else \
		cat $*.res; \
		exit 1; \
	fi

$(TESTS_SHOULD_FAIL:%=%.runtest): %.runtest:
	+@if ./two_module_test true $* $*_2; then \
		rm $*.failing_make_output; \
	else \
		cat $*.res; \
		exit 1; \
	fi

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

clean_local:

realclean_local:
	for module in $(PROGS) x; do \
		rm -f $$module.m $${module}_2.m ;\
	done

should_run_recompilation_tests:
	@echo $(RUN_RECOMPILATION_TESTS)

# Smart recompilation doesn't yet work with --intermodule-optimization.
# The `override' is needed because otherwise make ignores the assignment if
# EXTRA_MCFLAGS is set on the command line, as it is for the nightly tests.
override EXTRA_MCFLAGS += --no-intermodule-optimization --smart-recompilation \
			--find-all-recompilation-reasons

$(dates_subdir)nested_module_2_r_2.date: \
				$(int0s_subdir)nested_module_2_r_2.int0

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