#                                                                    -*-perl-*-

$description = "This script tests to make sure that Remke looks for
parent default makefiles in the correct order (GNUmakefile,makefile,Makefile)";

mkdir "work/options/testing";
chdir "work/options/testing";

# Create a makefile called "GNUmakefile"
my $makefile = "GNUmakefile";
my $log_filename_orig = $log_filename;
$log_filename = "../../../$log_filename";

open(MAKEFILE,"> $makefile");
print MAKEFILE "FIRST: ; \@echo It chose GNUmakefile\n";
close(MAKEFILE);

run_make_with_options("","-c",&get_logfile(1));

chdir "../../..";
$log_filename = $log_filename_orig;
compare_output("It chose GNUmakefile\n",&get_logfile(1));

chdir "work/options/testing";
$log_filename = "../../../$log_filename";
run_make_with_options("","--search-parent",&get_logfile(2));

chdir "../../..";
$log_filename = $log_filename_orig;
compare_output("It chose GNUmakefile\n",&get_logfile(2));

# FIXME: add a test without the option -c to see that this fails.
chdir "work/options/testing";

# $log_filename = "../../../$log_filename";
# run_make_with_options("","",&get_logfile(3));

unlink($makefile);
chdir "..";
rmdir "testing";
chdir "../..";

1;
