1# -*-perl-*- hey - emacs - this is a perl file 2 3# Adjust path for your docbook installation in buildenv.pl 4 5# src/tools/msvc/builddoc.pl 6# translated from an earlier .bat file 7 8use strict; 9use File::Copy; 10use Cwd qw(abs_path getcwd); 11 12my $startdir = getcwd(); 13 14my $openjade = 'openjade-1.3.1'; 15my $dsssl = 'docbook-dsssl-1.79'; 16 17chdir '../../..' if (-d '../msvc' && -d '../../../src'); 18 19noversion() unless -e 'doc/src/sgml/version.sgml'; 20 21do 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl'; 22 23my $docroot = $ENV{DOCROOT}; 24die "bad DOCROOT '$docroot'" unless ($docroot && -d $docroot); 25 26my @notfound; 27foreach my $dir ('docbook', $openjade, $dsssl) 28{ 29 push(@notfound, $dir) unless -d "$docroot/$dir"; 30} 31missing() if @notfound; 32 33my $arg = shift; 34renamefiles(); 35 36chdir 'doc/src/sgml'; 37 38$ENV{SGML_CATALOG_FILES} = 39 "$docroot/$openjade/dsssl/catalog;" . "$docroot/docbook/docbook.cat"; 40 41my $cmd; 42 43# openjade exits below with a harmless non-zero status, so we 44# can't die on "failure" 45 46$cmd = 47 "perl mk_feature_tables.pl YES " 48 . "../../../src/backend/catalog/sql_feature_packages.txt " 49 . "../../../src/backend/catalog/sql_features.txt " 50 . "> features-supported.sgml"; 51system($cmd); 52die "features_supported" if $?; 53$cmd = 54 "perl mk_feature_tables.pl NO " 55 . "\"../../../src/backend/catalog/sql_feature_packages.txt\" " 56 . "\"../../../src/backend/catalog/sql_features.txt\" " 57 . "> features-unsupported.sgml"; 58system($cmd); 59die "features_unsupported" if $?; 60$cmd = 61"perl generate-errcodes-table.pl \"../../../src/backend/utils/errcodes.txt\" " 62 . "> errcodes-table.sgml"; 63system($cmd); 64die "errcodes-table" if $?; 65 66print "Running first build...\n"; 67$cmd = 68 "\"$docroot/$openjade/bin/openjade\" -V html-index -wall " 69 . "-wno-unused-param -wno-empty -D . -c \"$docroot/$dsssl/catalog\" " 70 . "-d stylesheet.dsl -i output-html -t sgml postgres.sgml 2>&1 " 71 . "| findstr /V \"DTDDECL catalog entries are not supported\" "; 72system($cmd); # die "openjade" if $?; 73print "Running collateindex...\n"; 74$cmd = "perl \"$docroot/$dsssl/bin/collateindex.pl\" -f -g -i bookindex " 75 . "-o bookindex.sgml HTML.index"; 76system($cmd); 77die "collateindex" if $?; 78mkdir "html"; 79print "Running second build...\n"; 80$cmd = 81 "\"$docroot/$openjade/bin/openjade\" -wall -wno-unused-param -wno-empty " 82 . "-D . -c \"$docroot/$dsssl/catalog\" -d stylesheet.dsl -t sgml " 83 . "-i output-html -i include-index postgres.sgml 2>&1 " 84 . "| findstr /V \"DTDDECL catalog entries are not supported\" "; 85 86system($cmd); # die "openjade" if $?; 87 88copy "stylesheet.css", "html/stylesheet.css"; 89 90print "Docs build complete.\n"; 91 92exit; 93 94######################################################## 95 96sub renamefiles 97{ 98 99 # Rename ISO entity files 100 my $savedir = getcwd(); 101 chdir "$docroot/docbook"; 102 foreach my $f (glob('ISO*')) 103 { 104 next if $f =~ /\.gml$/i; 105 my $nf = $f; 106 $nf =~ s/ISO(.*)/ISO-$1.gml/; 107 move $f, $nf; 108 } 109 chdir $savedir; 110 111} 112 113sub missing 114{ 115 print STDERR "could not find $docroot/$_\n" foreach (@notfound); 116 exit 1; 117} 118 119sub noversion 120{ 121 print STDERR "Could not find version.sgml. ", 122 "Please run mkvcbuild.pl first!\n"; 123 exit 1; 124} 125