#!/usr/bin/perl
# This little script takes a chunk of a makefile and joins  the  lines
# of each entry. Lines starting with a TAB are joined to the preceding
# line.  If the preceding line ended with a '\', the join is  done  by
# removing the "\n\\\t" sequence and replacing it with a space. If the
# preceding line didn't end with a '\', the join is done by  replacing
# the "\n\t" with "; ".
#
# See also sh/mfe.

@text = <STDIN>;	# Slurp up the input.
for ($l = 1; $l < @text; $l++) {
	if ($text[$l] =~ s/^\t\s*//) {
		if ($text[$l-1] =~ s/\s*\\\s*$/ /) {
			$text[$l-1] .= $text[$l];
		} else {
			$text[$l-1] =~ s/\n$/; $text[$l]/;
		}
		splice(@text,$l,1);
		-- $l;
	}
}
print @text;
