summaryrefslogtreecommitdiff
path: root/helpcontent2/helpers/createmakefile.pl
diff options
context:
space:
mode:
Diffstat (limited to 'helpcontent2/helpers/createmakefile.pl')
-rw-r--r--helpcontent2/helpers/createmakefile.pl397
1 files changed, 397 insertions, 0 deletions
diff --git a/helpcontent2/helpers/createmakefile.pl b/helpcontent2/helpers/createmakefile.pl
new file mode 100644
index 0000000000..6eea23c82c
--- /dev/null
+++ b/helpcontent2/helpers/createmakefile.pl
@@ -0,0 +1,397 @@
+#!/usr/bin/perl
+
+use File::Find;
+use File::Basename;
+
+# creates the help2 makefile for a given
+# directory including all help xhp files
+# in that and the subordinate directories
+# Only help files with the following
+#
+# status values are included:
+# PUBLISH DEPRECATED
+#
+# The following status values are
+# disregarded:
+# DRAFT FINAL STALLED
+
+$makefiletemplate = 'helpers/makefile.template';
+$linkmakefiletemplate = 'helpers/linkmakefile.template';
+$helpdirprefix = "helpcontent2/source/";
+
+undef @sbasic;
+undef @scalc;
+undef @schart;
+undef @sdraw;
+undef @shared;
+undef @simpress;
+undef @smath;
+undef @swriter;
+
+$params = join "|", "",@ARGV,"";
+($params =~ /-dir/) ? ($startdir = $params) =~ (s/.*-dir=([^\|]*).*$/$1/gs) : (($startdir = `pwd`) =~ s/\n//gs);
+($params =~ /-linkdir/) ? ($linkdir = $params) =~ (s/.*-linkdir=([^\|]*).*$/$1/gs) : (($linkdir = `pwd`) =~ s/\n//gs);
+$recursive = $params =~ /-recursive/ || 0;
+$all = $params =~ /-all/ || 0;
+
+if (open TMPL, $makefiletemplate) {
+ undef $/;
+ $tmpl = <TMPL>;
+ close TMPL;
+} else {
+ &terminate("Cannot open $makefiletemplate");
+}
+
+if (open LINKTMPL, $linkmakefiletemplate) {
+ undef $/;
+ $linktmpl = <LINKTMPL>;
+ close LINKTMPL;
+} else {
+ &terminate("Cannot open $linkmakefiletemplate");
+}
+
+print "Start Directory: $startdir\n";
+print "Link Directory : $linkdir\n";
+print "Recursive : ". ($recursive ? "yes" : "no") . "\n";
+print "All files : ". ($all ? "yes" : "no") . "\n";
+
+if ($recursive) {
+ find(sub{push @dirs, $File::Find::name if (-d and ($File::Find::name!~/\/CVS/));},$startdir);
+} else {
+ push @dirs, $startdir;
+}
+
+#print join "\n", @dirs;
+#die;
+
+for $d(@dirs) {
+ opendir DIR, $d;
+ @files = grep {/xhp$/} readdir DIR;
+ undef @files2;
+ closedir DIR;
+
+ ($helpdir = $d) =~ s/.*\/$helpdirprefix/source\//gis;
+
+ ($package = $helpdir) =~ s/^source\///gi; $package = $package;
+ ($target = $package) =~ s/\//_/g; $target =~ s/_$//;
+ ($module = $package) =~ s/^\/*text\/([^\/]+)\/.*$/$1/;
+
+ for $f(@files) {
+ ($n,$p,$e) = fileparse($f,".xhp");
+ if (not $all) {
+ if (open XML, $d.'/'.$f) {
+ undef $/;
+ ($status = <XML>) =~ s/.*<topic[^>]*status="([^"]*)"[^>]*>.*$/$1/gs;
+ close XML;
+ } else {
+ die "Error: Cannot open ${d}/$f:$!\n";
+ }
+ if ($status =~ /(DEPRECATED|PUBLISH)/i) {
+ ($p2=$package) =~ s,/,\$/,gis;
+ push @{$module}, $p2.'$/'.$n.'.hzip';
+ push @files2, ' '.$n.'.hzip ';
+ }
+ } else {
+ ($p2=$package) =~ s,/,\$/,gis;
+ push @{$module}, $p2.'$/'.$n.'.hzip';
+ push @files2, ' '.$n.'.hzip ';
+ }
+ }
+
+ printf "%s: %4d files, %4d included in makefile -> ",$d,scalar @files,scalar @files2;
+
+ if (scalar @files2 > 0) { # don't write makefiles where there are no files to make
+ ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+
+ $auth = "script";
+ $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
+ $prj = '..$/' x ((split "/", $helpdir) -1); $prj = $prj . "..";
+
+
+ $hzipfiles = join "\\\n", sort @files2;
+
+ ($makefile = $tmpl) =~ s/%([^%]*)%/$$1/gise;
+
+ if (open(MK, ">$d/makefile.mk")) {
+ print MK $makefile;
+ close MK;
+ print "makefile created\n";
+ } else {
+ &terminate("Cannot write to ${d}makefile.mk\n");
+ }
+ } else {
+ print "NO makefile created\n";
+ }
+}
+
+@sbasic = sort @sbasic;
+@schart = sort @schart;
+@scalc = sort @scalc;
+@shared = sort @shared;
+@sdraw = sort @sdraw;
+@simpress = sort @simpress;
+@smath = sort @smath;
+@swriter = sort @swriter;
+
+# now create the link makefiles
+
+#----------------------------------
+# sbasic
+ $module = "sbasic";
+
+ $linkaddedfiles = <<"LAF";
+ -add help\$/LANGUAGE\$/$module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ -add help\$/LANGUAGE\$/$module.tree \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ -add help\$/LANGUAGE\$/$module.jar \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAF
+
+ $linkaddeddeps = <<"LAD";
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAD
+
+ $linklinkfiles = '';
+ for (@sbasic) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+
+ $auth = "script";
+ $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
+ $prj = '..$/..' ;
+
+ ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
+ &writelinkmakefile($module,$linkmakefile);
+
+
+#-------------------------------------
+# scalc
+ $module = "scalc";
+
+ $linkaddedfiles = <<"LAF";
+ -add help\$/LANGUAGE\$/$module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ -add help\$/LANGUAGE\$/$module.tree \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ -add help\$/LANGUAGE\$/$module.jar \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAF
+
+ $linkaddeddeps = <<"LAD";
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAD
+
+ $linklinkfiles = '';
+ for (@scalc) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@schart) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+
+ $auth = "script";
+ $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
+ $prj = '..$/..' ;
+
+ ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
+ &writelinkmakefile($module,$linkmakefile);
+
+#--------------------------------
+# schart
+ $module = "schart";
+
+ $linkaddedfiles = <<"LAF";
+ -add help\$/LANGUAGE\$/$module.tree \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ -add help\$/LANGUAGE\$/$module.jar \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAF
+
+ $linkaddeddeps = <<"LAD";
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAD
+
+ $linklinkfiles = '';
+
+ $auth = "script";
+ $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
+ $prj = '..$/..' ;
+
+ ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
+ &writelinkmakefile($module,$linkmakefile);
+
+#------------------------------
+# sdraw
+ $module = "sdraw";
+
+ $linkaddedfiles = <<"LAF";
+ -add help\$/LANGUAGE\$/$module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ -add help\$/LANGUAGE\$/$module.jar \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAF
+
+ $linkaddeddeps = <<"LAD";
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAD
+
+ $linklinkfiles = '';
+ for (@sdraw) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@simpress) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@schart) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+
+ $auth = "script";
+ $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
+ $prj = '..$/..' ;
+
+ ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
+ &writelinkmakefile($module,$linkmakefile);
+
+#-------------------------------------
+# shared
+ $module = "shared";
+
+ $linkaddedfiles = <<"LAF";
+ -add help\$/LANGUAGE\$/$module.tree \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ -add help\$/LANGUAGE\$/$module.jar \$(BIN)\$/${module}_xhp_LANGUAGE.zip \\
+ -add help\$/LANGUAGE\$/default.css \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/default.css \\
+ -add help\$/LANGUAGE\$/highcontrast1.css \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrast1.css \\
+ -add help\$/LANGUAGE\$/highcontrast2.css \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrast2.css \\
+ -add help\$/LANGUAGE\$/highcontrastwhite.css \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrastwhite.css \\
+ -add help\$/LANGUAGE\$/highcontrastblack.css \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrastblack.css \\
+ -add help\$/LANGUAGE\$/err.html \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/err.html \\
+ -add help\$/main_transform.xsl \$(PRJ)\$/source\$/auxiliary\$/main_transform.xsl
+LAF
+
+ $linkaddeddeps = <<"LAD";
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ \$(BIN)\$/${module}_xhp_LANGUAGE.zip \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/default.css \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrast1.css \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrast2.css \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrastwhite.css \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrastblack.css \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/err.html \\
+ \$(PRJ)\$/source\$/auxiliary\$/main_transform.xsl
+LAD
+
+ $linklinkfiles = '';
+
+ $auth = "script";
+ $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
+ $prj = '..$/..' ;
+
+ ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
+ &writelinkmakefile($module,$linkmakefile);
+
+#-------------------------------
+# simpress
+ $module = "simpress";
+
+ $linkaddedfiles = <<"LAF";
+ -add help\$/LANGUAGE\$/$module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ -add help\$/LANGUAGE\$/$module.tree \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ -add help\$/LANGUAGE\$/$module.jar \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAF
+
+ $linkaddeddeps = <<"LAD";
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAD
+
+ $linklinkfiles = '';
+
+ for (@sdraw) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@simpress) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@schart) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+
+ $auth = "script";
+ $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
+ $prj = '..$/..' ;
+
+ ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
+ &writelinkmakefile($module,$linkmakefile);
+
+#-------------------------------------
+# smath
+ $module = "smath";
+
+ $linkaddedfiles = <<"LAF";
+ -add help\$/LANGUAGE\$/$module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ -add help\$/LANGUAGE\$/$module.tree \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ -add help\$/LANGUAGE\$/$module.jar \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAF
+
+ $linkaddeddeps = <<"LAD";
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAD
+
+ $linklinkfiles = '';
+ for (@smath) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+
+ $auth = "script";
+ $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
+ $prj = '..$/..' ;
+
+ ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
+ &writelinkmakefile($module,$linkmakefile);
+
+#-------------------------------
+# swriter
+ $module = "swriter";
+
+ $linkaddedfiles = <<"LAF";
+ -add help\$/LANGUAGE\$/$module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ -add help\$/LANGUAGE\$/$module.tree \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ -add help\$/LANGUAGE\$/$module.jar \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAF
+
+ $linkaddeddeps = <<"LAD";
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
+ \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.tree \\
+ \$(BIN)\$/${module}_xhp_LANGUAGE.zip
+LAD
+
+ $linklinkfiles = '';
+ for (@swriter) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ for (@schart) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
+ $auth = "script";
+ $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
+ $prj = '..$/..' ;
+
+ ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
+ &writelinkmakefile($module,$linkmakefile);
+
+print "sbasic: $#sbasic\n";
+print "scalc : $#scalc\n";
+print "schart: $#schart\n";
+print "sdraw : $#sdraw\n";
+print "shared: $#shared\n";
+print "simpr : $#simpress\n";
+print "smath : $#smath\n";
+print "swrit : $#swriter\n";
+
+sub terminate {
+ $err = shift;
+ print "$err\n\n";
+ $msg = <<"MSG";
+createmakefile.pl -dir=[directory name] -linkdir=[directory name] [-recursive] [-all]
+ -dir Directory to start
+ -linkdir Directory to write the link makefiles
+ -recursive Write makefiles recursively
+ -all include files with all status values
+MSG
+ die "$msg\n";
+}
+
+
+sub writelinkmakefile {
+ $module = shift;
+ $content = shift;
+ if (open(MK, ">$linkdir/$module/makefile.mk")) {
+ print MK $content;
+ close MK;
+ } else {
+ &terminate("Cannot write makefile to ${linkdir}/$module\n");
+ }
+}