lilypond-0.1.18
[lilypond.git] / bin / make-website
blob8f00d4f9cc2630006458f38fa0c4879b4b9c71e0
1 #!/usr/bin/perl -w
2 # stupid script to generate WWW site.
4 use FileHandle;
5 use Getopt::Long;
6 my $lily_version;
7 my $footstr;
8 my $mw_id = "<!make_website!>";
9 my $id_str = "make-website 0.3";
11 my $TAR="tar";
12 my $MAKE="make";
14 sub get_version
16 my ($vstr)=("");
17 open V, "$depth/.version";
18 while (<V>) {
19 s/#.*$//g;
20 next if (/^ *$/);
21 s/^/\$/;
22 s/= *(.*)$/=\"$1\";/;
23 $vstr .= $_;
25 eval ($vstr);
27 $lily_version= "$TOPLEVEL_MAJOR_VERSION.$TOPLEVEL_MINOR_VERSION.$TOPLEVEL_PATCH_LEVEL$TOPLEVEL_MY_PATCH_LEVEL";
29 # stupid checks.
30 $lily_version= "$TOPLEVEL_MAJOR_VERSION.$TOPLEVEL_MINOR_VERSION.$TOPLEVEL_PATCH_LEVEL$TOPLEVEL_MY_PATCH_LEVEL";
33 close V;
36 sub set_html_footer
38 my $MAILADRESS=$ENV{MAILADRESS};
39 my @pw=(getpwuid($<));
40 my $username=$pw[6];
42 $footstr =
43 "\n<hr>Please take me <a href=index.html>back to the index</a>\n<hr>
44 <font size=-1>
45 This page was generated by <code>" . $id_str . "</code> from lilypond-$lily_version by
46 <p>
47 <address><br>$username <a href=mailto:$MAILADRESS>&lt<!bla>$MAILADRESS</a>&gt</address>
48 <p>" . `date` . "
49 <p></font>";
53 # do something, check return status
54 sub my_system
56 my (@cmds) = @_;
57 foreach $cmd (@cmds) {
58 my ($ignoreret)=0;
59 if ( $cmd =~ /^-/ ) {
60 $ignoreret = 1;
61 $cmd = substr ($cmd, 1);
64 my $ret = ( system ($cmd));
65 if ($ret) {
66 if ($ignoreret) {
67 print STDERR "ignoring failed command \`$cmd\' (status $ret)\n";
68 }else {
69 print STDERR "\nmake_website: failed on command \`$cmd\' (status $ret)\n";
70 exit 2;
77 local $base="lilypond/";
78 local @examples=("twinkle", "multi", "wohltemperirt" ,"standchen", "toccata-fuga-E",
79 "scsii-menuetto", "collisions", "cadenza", "scales");
81 # rhythm, scales,
84 sub gen_html
86 print "generating HTML\n";
87 my_system "$MAKE -kC .. html";
90 sub gen_examples
92 print "generating examples: \n";
93 my @todo=();
94 foreach $a (@examples) {
95 push @todo, "out/$a.ps.gz", "out/$a.gif", "out/$a.ly.txt";
98 my_system ("$MAKE -C .. " . join(' ', @todo));
101 my @texstuff = ("mudela-man", "mudela-course");
103 sub gen_manuals
105 print "generating TeX doco list\n";
106 open HTMLLIST, ">tex_manuals.html";
107 print HTMLLIST "<html><body><title>LilyPond manuals in TeX</title>\n" .
108 "<ul>\n";
109 my @todo=();
110 foreach $a (@texstuff) {
111 push @todo , "out/$a.ps.gz";
112 print HTMLLIST "<li><a href=$a.ps.gz>$a.ps.gz</a>";
114 print HTMLLIST "</ul>";
115 close HTMLLIST;
117 my_system( "$MAKE -C .. " . join(' ', @todo));
120 sub gen_list
122 print "generating HTML list\n";
123 open HTMLLIST, ">example_output.html";
124 print HTMLLIST "<html><body><title>LilyPond examples</title>\n
125 These example files are taken from the LilyPond distribution.\n
126 LilyPond currently only outputs TeX and MIDI. The pictures and\n
127 PostScript files were generated using TeX, Ghostscript and some graphics tools. \n
128 The GIF files have been scaled to eliminate aliasing.";
129 foreach $a (@examples) {
130 $name=$a;
131 print HTMLLIST "<h1>example file: $name</h1>\n<XMP>\n";
133 open IF, "$depth/input/$a.ly";
134 input_record_separator IF "%}";
136 $desc = <IF>;
137 close IF;
139 print HTMLLIST "$desc\n</XMP>";
141 $inputf="$a.ly.txt";
142 $giff="$a.gif";
143 $jpegf="$a.jpeg";
144 $pngf = "$a.png";
145 $psf="$a.ps.gz";
146 $midif="$a.midi";
148 print HTMLLIST "<ul>";
150 print HTMLLIST "<li><a href=$inputf> The input file</a>"
151 if ( -f $inputf );
153 print HTMLLIST "<li><a href=$giff>The output (picture)</a>"
154 if ( -f $giff );
156 print HTMLLIST "<li><a href=$psf>The output (PS)</a>\n"
157 if ( -f $psf );
159 print HTMLLIST "<li><a href=$midif>The output (MIDI)</a>\n"
160 if ( -f $midif );
161 print HTMLLIST "</ul>";
163 print HTMLLIST "</BODY></HTML>";
164 close HTMLLIST;
167 sub edit_html
169 print STDERR "adding footer\n";
171 OUTER:
172 foreach $a (<*.html>) {
173 open H, "$a";
174 my $sep="</BODY>";
175 input_record_separator H $sep;
176 my $file="";
178 while (<H>) {
179 if (/$mw_id/) {
180 close H;
181 next OUTER;
183 $file .= $_;
186 close H;
188 my $subst = $footstr;
189 $subst .= $back if (! $a =~ /index.html/ );
190 $file =~ s/$sep/$subst$sep/g ;
191 $file =~ s/\.gif/\.$image/g;
192 open H, ">$a";
193 print H $mw_id;
194 print H $file;
195 close H;
199 sub copy_txt_file
201 my ($f) = @_;
202 my $d = $f;
203 $d =~ s!^.*\/!!;
204 if (! $f =~ /.txt$/) {
205 $d = "$f.txt";
207 print $f, $d;
210 sub copy_files
212 print "copying files\n";
213 print `ln -s $depth/out ./docxx` if ( ! -x "docxx" ) ;
214 my_system "cp $depth/TODO ./TODO.txt",
215 "cp $depth/ANNOUNCE ./ANNOUNCE.txt",
216 "cp $depth/NEWS ./NEWS.txt",
217 "cp $depth/DEDICATION ./DEDICATION.txt",
218 "cp ../lelie*gif .";
221 sub set_images
223 for $a (<*.gif>) {
224 if ($opt_png) {
225 my_system "gif2png -d $a";
227 if ($opt_jpeg) {
228 my $b=$a;
229 $b =~ s/.gif/.jpeg/;
230 my_system "cjpeg -o $b $a";
235 sub docxx_update
237 my_system "$MAKE -C $depth doc++";
240 sub do_tar
242 print "tarring.\n";
243 $files = join (' ', < *.html *.$image *.ps.gz *.txt *.midi docxx/*>);
244 my_system
245 "-$TAR zvhcf website.tar.gz $files;",
246 # "gzip -f9 website.tar;";
249 sub identify
251 print STDERR "This is " . $id_str . "\n";
254 sub main
256 identify;
257 GetOptions("jpeg", "gif", "png", "noexamples");
259 local $image="gif" ;
260 $image = "png" if ($opt_png);
261 $image = "jpeg" if ($opt_jpeg);
263 $depth = "../";
264 my $cwd;
265 chomp($cwd = `pwd`);
266 die "need to be in directory Documentation\n" if ( ! ($cwd =~ /Documentation$/));
267 get_version;
268 set_html_footer;
271 $depth = "../../";
273 chdir ("out");
274 $ENV{"TEXINPUTS"} .= ":$depth/input/:";
275 $ENV{"LILYINCLUDE"} = "$depth/input/";
278 gen_html;
279 copy_files;
280 if (! $opt_noexamples) {
281 gen_examples;
282 gen_list;
284 gen_manuals;
285 set_images;
287 edit_html;
288 docxx_update;
289 do_tar;
292 main;