lilypond-1.5.5
[lilypond.git] / bin / make-website.pl
blob2159716e965e7f82c4de323c28ea02b98ed683dd
1 #!@PERL@ -w
2 # -*-Perl-*-
5 # stupid script to generate WWW site. The WWW site is my
6 # test-suite for LilyPond, I usually don't distribute versions that
7 # fail to make the website
9 use FileHandle;
10 use Getopt::Long;
12 my $lily_version;
13 my $footstr;
14 my $mw_id = "<!make_website!>";
15 my $id_str = "make-website 0.4";
16 my $TAR="tar";
17 my $MAKE="make";
19 sub get_version
21 my ($vstr)=("");
22 open V, "$depth/VERSION";
23 while (<V>) {
24 s/#.*$//g;
25 next if (/^ *$/);
26 s/^/\$/;
27 s/= *(.*)$/=\"$1\";/;
28 $vstr .= $_;
30 eval ($vstr);
32 $lily_version= "$TOPLEVEL_MAJOR_VERSION.$TOPLEVEL_MINOR_VERSION.$TOPLEVEL_PATCH_LEVEL$TOPLEVEL_MY_PATCH_LEVEL";
34 # stupid checks.
35 $lily_version= $lily_version;
37 close V;
40 sub set_html_footer
42 my $MAILADDRESS=$ENV{MAILADDRESS};
43 my @pw=(getpwuid($<));
44 my $username=$pw[6];
46 $footstr =
47 "\n<hr>Please take me <a href=index.html>back to the index</a>\n
48 of LilyPond -- The GNU Project Music typesetter
49 <hr>
50 <font size=-1>
51 This page was built using <code>" . $id_str . "</code> from lilypond-"
52 . $lily_version .
53 " by<p>
54 <address><br>$username <a href=mailto:"
55 . $MAILADDRESS . ">&lt<!bla>" . $MAILADDRESS ."</a>&gt</address>
56 <p></font>";
60 # do something, check return status
61 sub my_system
63 my (@cmds) = @_;
64 foreach $cmd (@cmds) {
65 my ($ignoreret)=0;
66 if ( $cmd =~ /^-/ ) {
67 $ignoreret = 1;
68 $cmd = substr ($cmd, 1);
71 my $ret = ( system ($cmd));
72 if ($ret) {
73 if ($ignoreret) {
74 print STDERR "ignoring failed command \`$cmd\' (status $ret)\n";
75 }else {
76 print STDERR "\nmake_website: failed on command \`$cmd\' (status $ret)\n";
77 exit 2;
84 local $base="lilypond/";
86 local @examples=("twinkle-pop",
87 "wtk1-fugue2",
88 "standchen-16",
89 "standchen-20",
90 "wtk1-prelude1",
91 "toccata-fuga-E",
92 "scsii-menuetto",
93 "cadenza",
94 "gallina",
95 "twinkle",
96 "collisions",
97 "font",
98 "font20",
99 #"scales",
100 "rhythm",
101 "multi" );
104 sub gen_html
106 print "generating HTML\n";
107 my_system "$MAKE -kC .. html";
110 sub gen_examples
112 print "generating examples: \n";
113 my @todo=();
114 foreach $a (@examples) {
115 push @todo, "out/$a.ps.gz", "out/$a.gif", "out/$a.ly.txt";
118 my_system ("$MAKE -C .. " . join(' ', @todo));
121 my @texstuff = ("mudela-man", "mudela-course");
123 sub gen_manuals
125 print "generating TeX doco list\n";
126 open HTMLLIST, ">tex_manuals.html";
127 print HTMLLIST "<HTML><TITLE>PostScript Manuals</TITLE>\n" ;
128 print HTMLLIST "<BODY><h1>LilyPond manuals (in PostScript)</h1>";
129 print HTMLLIST "<ul>\n";
130 my @todo=();
131 foreach $a (@texstuff) {
132 push @todo , "out/$a.ps.gz";
133 print HTMLLIST "<li><a href=$a.ps.gz>$a.ps.gz</a>";
135 print HTMLLIST "</ul>";
137 print HTMLLIST "</BODY></HTML>";
138 close HTMLLIST;
140 my_system( "$MAKE -C .. " . join(' ', @todo));
143 sub gen_list
145 print "generating HTML list\n";
146 open HTMLLIST, ">example_output.html";
148 print HTMLLIST "<html><body><TITLE>Rendered Examples</TITLE>\n
149 These example files are taken from the LilyPond distribution.
150 LilyPond currently only outputs TeX and MIDI. The pictures and
151 PostScript files were generated using TeX, Ghostscript and some
152 graphics tools. The papersize used for these examples is A4. The GIF
153 files have been scaled to eliminate aliasing.";
157 foreach $a (@examples)
159 $name=$a; print HTMLLIST "<h1>example file: $name</h1>\n<XMP>\n";
161 open IF, "$depth/input/$a.ly";
162 input_record_separator IF "\n}";
164 $desc = <IF>;
165 close IF;
167 print HTMLLIST "$desc\n</XMP>";
169 $inputf="$a.ly.txt";
170 $giff="$a.gif";
171 $jpegf="$a.jpeg";
172 $pngf = "$a.png";
173 $psf="$a.ps.gz";
174 $midif="$a.midi";
176 print HTMLLIST "<ul>";
178 print HTMLLIST "<li><a href=$inputf> The input file</a>"
179 if ( -f $inputf );
181 print HTMLLIST "<li><a href=$giff>The output (picture)</a>"
182 if ( -f $giff );
184 print HTMLLIST "<li><a href=$psf>The output (PS)</a>\n"
185 if ( -f $psf );
187 print HTMLLIST "<li><a href=$midif>The output (MIDI)</a>\n"
188 if ( -f $midif );
189 print HTMLLIST "</ul>";
191 print HTMLLIST "</BODY></HTML>";
192 close HTMLLIST;
195 sub edit_html
197 print STDERR "adding footer\n";
199 OUTER:
200 foreach $a (<*.html>) {
201 open H, "$a";
202 my $sep="</BODY>";
203 input_record_separator H $sep;
204 my $file="";
206 while (<H>) {
207 if (/$mw_id/) {
208 close H;
209 next OUTER;
211 $file .= $_;
214 close H;
216 my $subst = $footstr;
217 $subst .= $back if (! $a =~ /index.html/ );
218 $file =~ s/$sep/$subst$sep/g ;
219 $file =~ s/\.gif/\.$image/g;
220 $file =~ s!<TITLE>(.*)</TITLE>!<TITLE>LilyPond WWW: $1</TITLE>!g;
221 open H, ">$a";
222 print H $mw_id;
224 print H $file;
225 close H;
229 sub copy_txt_file
231 my ($f) = @_;
232 my $d = $f;
233 $d =~ s!^.*\/!!;
234 if (! $f =~ /.txt$/) {
235 $d = "$f.txt";
237 print, $d;
240 sub top_of_NEWS
242 open NEWS, "NEWS.txt";
243 input_record_separator NEWS "****";
244 $desc = <NEWS>;
245 chop ($desc);
246 close NEWS;
248 return $desc;
251 sub edit_index
253 $ton = top_of_NEWS();
254 $ton = "\n<XMP>\n$ton\n</XMP>\n";
255 open INDEX, "index.html";
256 input_record_separator NEWS undef;
257 $index = <INDEX>;
258 close INDEX;
259 $index =~ s/top_of_NEWS/$ton/;
260 open INDEX, ">index.html";
261 print INDEX $index;
262 close INDEX;
266 sub copy_files
268 print "copying files\n";
269 my_system "ln -s $depth/out ./docxx" if ( ! -x "docxx" ) ;
270 my_system "cp $depth/TODO ./TODO.txt",
271 "cp $depth/ANNOUNCE ./ANNOUNCE.txt",
272 "cp $depth/NEWS ./NEWS.txt",
273 "cp $depth/DEDICATION ./DEDICATION.txt";
274 my_system "make -C .. gifs";
278 sub set_images
280 for $a (<*.gif>) {
281 if ($opt_png) {
282 my_system "gif2png -d $a";
284 if ($opt_jpeg) {
285 my $b=$a;
286 $b =~ s/.gif/.jpeg/;
287 my_system "cjpeg -o $b $a";
292 sub docxx_update
294 open BANNER, ">/tmp/lilybanner.html";
295 my $ban = $footstr;
296 $ban =~ s!index.html!../index.html!g;
297 print BANNER $ban;
298 close BANNER;
299 my_system("BANNEROPT=\"-B /tmp/lilybanner.html\" $depth/bin/out/make-docxx");
300 unlink "/tmp/lilybanner.html";
303 sub do_tar
305 print "tarring.\n";
306 $files = join (' ', < *.html *.$image *.ps.gz *.txt *.midi docxx/*>);
307 my_system
308 "-$TAR zvhcf website.tar.gz $files;",
309 # "gzip -f9 website.tar;";
312 sub identify
314 print STDERR "This is " . $id_str . "\n";
317 sub clean_tmp
319 @a = </tmp/gs*>;
320 unlink @a;
323 sub main
325 identify;
326 GetOptions("jpeg", "gif", "png", "noexamples");
328 local $image="gif" ;
329 $image = "png" if ($opt_png);
330 $image = "jpeg" if ($opt_jpeg);
332 $depth = "../";
333 my $cwd;
334 chomp($cwd = `pwd`);
335 die "need to be in directory Documentation\n" if ( ! ($cwd =~ /Documentation$/));
336 get_version;
337 print "lily v. " . $lily_version . "\n";
338 set_html_footer;
341 $depth = "../../";
343 chdir ("out");
344 $ENV{"TEXINPUTS"} .= ":$depth/input/:";
345 $ENV{"LILYINCLUDE"} = "$depth/input/";
346 $ENV{"LILYTOP"} = $depth;
348 gen_html;
349 copy_files;
351 if (! $opt_noexamples) {
352 gen_examples;
353 gen_list;
354 gen_manuals;
356 set_images;
358 edit_html;
359 edit_index;
360 docxx_update;
361 do_tar;
362 clean_tmp;
365 main;