$description = "The following test creates a makefile to test GNU make's
reinvocation feature--if the makefile or one it includes can be rebuilt
it is, and make is reinvoked.";

$details = "We create a rule to rebuild the makefile from a temp file, then
touch the temp file to make it newer than the makefile.";

# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
# THE NAME OF THE MAKEFILE.  THIS INSURES CONSISTENCY AND KEEPS TRACK OF
# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
# EXAMPLE: $makefile2 = &get_tmpfile;

$makefile2 = &get_tmpfile;

open(MAKEFILE,"> $makefile");
print MAKEFILE "
all:
	\@echo 'running rules.'

$makefile $makefile2: $makefile.orig
	\@echo 'rebuilding \$\@.'
	\@touch \$\@

include $makefile2

";
close(MAKEFILE);

&touch("$makefile2");

sleep(1);

&touch("$makefile.orig");

&run_make_with_options($makefile,
                       "",
                       &get_logfile,
                       0);

# Create the answer to what should be produced by this Makefile

$answer = "rebuilding $makefile2.\nrebuilding $makefile.\nrunning rules.\n";

&compare_output($answer,&get_logfile(1))
  && unlink "$makefile.orig";

# This tells the test driver that the perl test script executed properly.
1;






