###	SPAR <http://www.cpan.org/scripts/>
###	32	644	1161580578	1406914716	makepp_test_script.pl
# Test all variants of existing and created symlinks, to existing and created files.

makepp;
my( %warnings, %errors );
n_files 'n_files1', sub {
  undef $warnings{$1} if
    /warning: (.+?is a symbolic link|I attempted to build.+|.+? is probably also phony)/;
  undef $errors{$1} if
    /error: There is no rule to build inexistent(.+)/;
};
die if 3 != keys %warnings;
die if 2 != keys %errors;

unlink qw(a bl f g h);		# Force rebuild of linkee or make link stale.
wait_timestamp qw(c e);
for my $file (qw(c e)) {	# Edit linkees.
  open my $fh, '>', $file or die "$file--$!";
  close $fh;
}

eval { makepp qw(D=dd -k) }; # [a-e]l2 and dl must not be rebuilt!
%warnings = ();
n_files 'n_files2', sub {
  undef $warnings{$1} if
    /warning:(.*)/;
};
die unless 1 == keys %warnings;

makepp qw(--rm-stale D=dd);
die if grep -f, qw(fl fl2 fc gl gl2 gc hl hl2 hc);

1;
###	32	644	1230569382	1304538479	Makeppfile
default: default1			# Provoke inexistent warnings.

default1: default2

default2: default3			# Provoke no-phony warnings.
	  @&expr 1

default3: ?c
	  @&expr 1

$(foreach) $(foreach)l: :foreach a b # Both created in one rule.
	&echo $(output) -o $(output)
	&ln -fs $(outputs)

%l: %
	&ln -fs $(input) $(output)

%l2: %l
	&ln -fs $(input) $(output)

%c: %l2 :signature md5
	&cp $(input) $(output)

cl:
	&echo $(output) -o $(output) # Should warn about link to c.

D=d
d:
	&echo $D -o $(output)

%l: %
	&ln -fs $(input) $(output)
###	0	644	1230569045	1230571314	c
###	L	S	0	0	cl
c
###	1	644	1230569045	1230569045	e
e
###	1	644	1230569045	1230569045	f
f
###	1	644	1230569045	1230569045	g
g
###	L	S	0	0	gl
g
###	1	644	1230569045	1230569045	h
h
###	D	755	1230569356	1230569356	answers
###	1	644	1230569356	1230569356	answers/n_files1
27 4 0
###	1	644	1230569356	1230569356	answers/n_files2
9 0 3
###	1	644	1230569356	1230569356	answers/n_files
0 4 0