+
+close $out;
+
+# Write out doc/licence.but.
+
+$outfile = "doc/licence.but";
+open $out, ">", $outfile or die "$outfile: open: $!\n";
+select $out;
+
+print "\\# Generated by @{[basename __FILE__]} from $infile.\n";
+print "\\# You should edit those files rather than editing this one.\n\n";
+
+print "\\A{licence} PuTTY \\ii{Licence}\n\n";
+
+for my $i (0..$#paras) {
+ my $para = &halibutescape($paras[$i]);
+ if ($i == 0) {
+ $para =~ s!copyright!\\i{copyright}!; # index term in paragraph 1
+ }
+ print "$para\n\n";
+}
+
+close $out;
+
+# And write out doc/copy.but, which defines a macro used in the manual
+# preamble blurb.
+
+$outfile = "doc/copy.but";
+open $out, ">", $outfile or die "$outfile: open: $!\n";
+select $out;
+
+print "\\# Generated by @{[basename __FILE__]} from $infile.\n";
+print "\\# You should edit those files rather than editing this one.\n\n";
+
+printf "\\define{shortcopyrightdetails} %s\n\n",
+ &halibutescape($shortdetails);
+
+close $out;
+
+sub halibutescape {
+ my ($text) = @_;
+ $text =~ s![\\{}]!\\$&!g; # Halibut escaping
+ $text =~ s!"([^"]*)"!\\q{$1}!g; # convert quoted strings to \q{}
+ return $text;
+}