initial setup of thesis repository
[cluster_expansion_thesis.git] / little_helpers / tikz / sketch-0.2.161 / Doc / make.pl
blobf43bcfd23347a09e901beb5c05115bf3b4a8087d
2 # make sketch documentation with Windows and Cygwin
4 use strict;
5 use File::Copy;
7 our $GS = "gswin32.exe";
8 our $MEM_OPTION = "--extra-mem-top=5000000"; # MikTeX 2.7
9 # our $MEM_OPTION = ""; # MikTeX 2.6
11 sub make_example {
12 my $ex = shift;
13 die "missing example name" unless $ex;
14 my %arg = map { $_ => 1 } @_;
16 unless ($arg{nosketch}) {
17 my $cmd = "sketch -D $ex manexamples.sk > $ex.tex";
18 print STDERR "$cmd\n";
19 system($cmd) == 0 or die;
21 unless ($arg{nobitmaps}) {
22 print STDERR "latex example '$ex-tmp.tex':\n";
23 system("sed -e s/TEXFILE/$ex/ makeex-tmp.tex > $ex-tmp.tex") == 0 or die;
24 system("latex $MEM_OPTION $ex-tmp.tex") == 0 or die;
25 system("dvips -E $ex-tmp -o tmp.eps") == 0 or die;
26 # fix up bounding box (originally this was not necessary; something was "improved")
27 system("epstool --copy --bbox tmp.eps $ex.eps") == 0 or die;
28 unlink "tmp.eps";
29 local *F;
30 open(F, "> $ex.txt") or die;
31 print F "Image $ex omitted in text version of this document.";
32 close F;
33 system("$GS -q -dQUIET -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -sOutputFile=$ex.pdf -r120 $ex.eps") == 0 or die;
34 system("$GS -q -dQUIET -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=png256 -sOutputFile=$ex.png -r120 $ex.eps") == 0 or die;
35 unlink <$ex-tmp.*>;
39 sub make_all {
40 my %arg = map { $_ => 1 } @_;
41 if ($arg{examples}) {
42 local *F;
43 open(F, "tags.sk") or die;
44 while (<F>) {
45 if (/<([^>]*)>/) {
46 make_example $1, @_;
49 close(F);
51 unless ($arg{notypeset}) {
52 print "info:\n";
53 system("makeinfo sketch.texi") == 0 or die;
55 print "html, one page per node:\n";
56 system("makeinfo --html sketch.texi") == 0 or die;
57 while (<*.png>) {
58 copy($_, "sketch/$_");
61 print "html, single page:\n";
62 system("makeinfo --html --no-split sketch.texi") == 0 or die;
64 # run twice to ensure labels are ok
65 print "TeX DVI\n";
66 system("texi2dvi sketch.texi") == 0 or die;
67 system("texi2dvi sketch.texi") == 0 or die;
69 print "Postscript:\n";
70 system("dvips sketch.dvi -o sketch.ps") == 0 or die;
72 # texi2dvi finds PNG before the PDF graphics, so delete...
73 my @unlink_list = <ex???.png>;
74 unlink @unlink_list;
76 # make PDF manual
77 print "PDF:\n";
78 system("texi2dvi --pdf sketch.texi") == 0 or die;
80 # ... and restore
81 for (@unlink_list) {
82 copy("sketch/$_", $_);
87 if (grep { /help/ } @ARGV) {
88 print "usage: perl make.pl [examples] [nosketch] [nobitmaps] [notypeset]\n";
90 elsif ($ARGV[0] =~ /^ex[0-9]+/ ) {
91 make_example @ARGV
93 else {
94 make_all @ARGV