enable support for import custom menu ( on builtin bar only )
[ooovba.git] / helpcontent2 / helpers / createmakefile.pl
blob90231e04df7e4624a52ece6c48afa91a35daad6d
1 #!/usr/bin/perl
3 use File::Find;
4 use File::Basename;
6 # creates the help2 makefile for a given
7 # directory including all help xhp files
8 # in that and the subordinate directories
9 # Only help files with the following
11 # status values are included:
12 # PUBLISH DEPRECATED
14 # The following status values are
15 # disregarded:
16 # DRAFT FINAL STALLED
18 $makefiletemplate = 'helpers/makefile.template';
19 $linkmakefiletemplate = 'helpers/linkmakefile.template';
20 $prj = "helpcontent2";
21 $helpdirprefix = "$prj/source/";
23 undef @sbasic;
24 undef @scalc;
25 undef @schart;
26 undef @sdraw;
27 undef @shared;
28 undef @simpress;
29 undef @smath;
30 undef @swriter;
32 $params = join "|", "",@ARGV,"";
33 ($params =~ /-dir/) ? ($startdir = $params) =~ (s/.*-dir=([^\|]*).*$/$1/gs) : (($startdir = `pwd`) =~ s/\n//gs);
34 ($startdir = $startdir."/source/text") if ($startdir =~ /$prj$/);
35 ($params =~ /-linkdir/) ? ($linkdir = $params) =~ (s/.*-linkdir=([^\|]*).*$/$1/gs) : (($linkdir = `pwd`) =~ s/\n//gs);
36 ($linkdir = $linkdir."/util") if ($linkdir =~ /$prj$/);
37 $recursive = $params =~ /-recursive/ || 0;
38 $all = $params =~ /-all/ || 0;
40 if (open TMPL, $makefiletemplate) {
41 undef $/;
42 $tmpl = <TMPL>;
43 close TMPL;
44 } else {
45 &terminate("Cannot open $makefiletemplate");
48 if (open LINKTMPL, $linkmakefiletemplate) {
49 undef $/;
50 $linktmpl = <LINKTMPL>;
51 close LINKTMPL;
52 } else {
53 &terminate("Cannot open $linkmakefiletemplate");
56 print "Start Directory: $startdir\n";
57 print "Link Directory : $linkdir\n";
58 print "Recursive : ". ($recursive ? "yes" : "no") . "\n";
59 print "All files : ". ($all ? "yes" : "no") . "\n";
61 if ($recursive) {
62 find(sub{push @dirs, $File::Find::name if (-d and ($File::Find::name!~/\/CVS/));},$startdir);
63 } else {
64 push @dirs, $startdir;
67 #print join "\n", @dirs;
68 #die;
70 for $d(@dirs) {
71 opendir DIR, $d;
72 @files = grep {/xhp$/} readdir DIR;
73 undef @files2;
74 closedir DIR;
76 ($helpdir = $d) =~ s/.*\/$helpdirprefix/source\//gis;
78 ($package = $helpdir) =~ s/^source\///gi;
80 ($target = $package) =~ s/\//_/g; $target =~ s/_$//;
81 ($module = $package) =~ s/^\/*text\/([^\/]+)\/*.*$/$1/;
83 for $f(@files) {
84 ($n,$p,$e) = fileparse($f,".xhp");
85 if (not $all) {
86 if (open XML, $d.'/'.$f) {
87 undef $/;
88 ($status = <XML>) =~ s/.*<topic[^>]*status="([^"]*)"[^>]*>.*$/$1/gs;
89 close XML;
90 } else {
91 die "Error: Cannot open ${d}/$f:$!\n";
93 if ($status =~ /(DEPRECATED|PUBLISH)/i) {
94 ($p2=$package) =~ s,/,\$/,gis;
95 push @{$module}, $p2.'$/'.$n.'.xhp';
96 push @files2, ' '.$n.'.xhp ';
98 } else {
99 ($p2=$package) =~ s,/,\$/,gis;
100 push @{$module}, $p2.'$/'.$n.'.xhp';
101 push @files2, ' '.$n.'.xhp ';
105 printf "%s: %4d files, %4d included in makefile -> ",$d,scalar @files,scalar @files2;
107 if (scalar @files2 > 0) { # don't write makefiles where there are no files to make
108 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
110 $auth = "script";
111 $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
112 $prj = '..$/' x ((split "/", $helpdir) -1); $prj = $prj . "..";
115 $xhpfiles = join "\\\n", sort @files2;
117 ($makefile = $tmpl) =~ s/%([^%]*)%/$$1/gise;
119 if (open(MK, ">$d/makefile.mk")) {
120 print MK $makefile;
121 close MK;
122 print "makefile created\n";
123 } else {
124 &terminate("Cannot write to ${d}/makefile.mk\n");
126 } else {
127 print "NO makefile created\n";
131 @sbasic = sort @sbasic;
132 @schart = sort @schart;
133 @scalc = sort @scalc;
134 @shared = sort @shared;
135 @sdraw = sort @sdraw;
136 @simpress = sort @simpress;
137 @smath = sort @smath;
138 @swriter = sort @swriter;
140 # now create the link makefiles
142 #----------------------------------
143 # sbasic
144 $module = "sbasic";
146 $linkaddedfiles = <<"LAF";
147 -add $module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
148 -add $module.tree \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
149 -add $module.jar \$(BIN)\$/xhp_${module}_LANGUAGE.zip
152 $linkaddeddeps = <<"LAD";
153 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
154 \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
155 \$(BIN)\$/xhp_${module}_LANGUAGE.zip
158 $linklinkfiles = '';
159 for (@sbasic) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
160 for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
162 $auth = "script";
163 $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
164 $prj = '..$/..' ;
166 ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
167 &writelinkmakefile($module,$linkmakefile);
170 #-------------------------------------
171 # scalc
172 $module = "scalc";
174 $linkaddedfiles = <<"LAF";
175 -add $module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
176 -add $module.tree \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
177 -add $module.jar \$(BIN)\$/xhp_${module}_LANGUAGE.zip
180 $linkaddeddeps = <<"LAD";
181 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
182 \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
183 \$(BIN)\$/xhp_${module}_LANGUAGE.zip
186 $linklinkfiles = '';
187 for (@scalc) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
188 for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
189 for (@schart) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
191 $auth = "script";
192 $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
193 $prj = '..$/..' ;
195 ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
196 &writelinkmakefile($module,$linkmakefile);
198 #--------------------------------
199 # schart
200 $module = "schart";
202 $linkaddedfiles = <<"LAF";
203 -add $module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
204 -add $module.tree \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
205 -add $module.jar \$(BIN)\$/xhp_${module}_LANGUAGE.zip
208 $linkaddeddeps = <<"LAD";
209 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
210 \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
211 \$(BIN)\$/xhp_${module}_LANGUAGE.zip
214 $linklinkfiles = '';
216 for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
217 for (@schart) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
220 $auth = "script";
221 $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
222 $prj = '..$/..' ;
224 ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
225 &writelinkmakefile($module,$linkmakefile);
227 #------------------------------
228 # sdraw
229 $module = "sdraw";
231 $linkaddedfiles = <<"LAF";
232 -add $module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
233 -add $module.jar \$(BIN)\$/xhp_${module}_LANGUAGE.zip
236 $linkaddeddeps = <<"LAD";
237 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
238 \$(BIN)\$/xhp_${module}_LANGUAGE.zip
241 $linklinkfiles = '';
242 for (@sdraw) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
243 for (@simpress) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
244 for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
245 for (@schart) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
247 $auth = "script";
248 $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
249 $prj = '..$/..' ;
251 ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
252 &writelinkmakefile($module,$linkmakefile);
254 #-------------------------------------
255 # shared
257 $module = "shared";
259 $linkaddedfiles = <<"LAF";
260 -add $module.tree \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
261 -add $module.jar \$(BIN)\$/xhp_${module}_LANGUAGE.zip \\
262 -add default.css \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/default.css \\
263 -add highcontrast1.css \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrast1.css \\
264 -add highcontrast2.css \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrast2.css \\
265 -add highcontrastwhite.css \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrastwhite.css \\
266 -add highcontrastblack.css \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrastblack.css \\
267 -add err.html \$(COMMONMISC)\$/LANGUAGE\$/text\$/shared\$/05\$/err_html.xhp
270 $linkaddeddeps = <<"LAD";
271 \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
272 \$(BIN)\$/xhp_${module}_LANGUAGE.zip \\
273 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/default.css \\
274 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrast1.css \\
275 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrast2.css \\
276 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrastwhite.css \\
277 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/highcontrastblack.css \\
278 \$(COMMONMISC)\$/LANGUAGE\$/text\$/shared\$/05\$/err_html.xhp
281 $linklinkfiles = '';
283 $auth = "script";
284 $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
285 $prj = '..$/..' ;
287 ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
288 &writelinkmakefile($module,$linkmakefile);
290 #-------------------------------
291 # simpress
292 $module = "simpress";
294 $linkaddedfiles = <<"LAF";
295 -add $module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
296 -add $module.tree \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
297 -add $module.jar \$(BIN)\$/xhp_${module}_LANGUAGE.zip
300 $linkaddeddeps = <<"LAD";
301 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
302 \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
303 \$(BIN)\$/xhp_${module}_LANGUAGE.zip
306 $linklinkfiles = '';
308 for (@sdraw) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
309 for (@simpress) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
310 for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
311 for (@schart) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
313 $auth = "script";
314 $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
315 $prj = '..$/..' ;
317 ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
318 &writelinkmakefile($module,$linkmakefile);
320 #-------------------------------------
321 # smath
322 $module = "smath";
324 $linkaddedfiles = <<"LAF";
325 -add $module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
326 -add $module.tree \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
327 -add $module.jar \$(BIN)\$/xhp_${module}_LANGUAGE.zip
330 $linkaddeddeps = <<"LAD";
331 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
332 \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
333 \$(BIN)\$/xhp_${module}_LANGUAGE.zip
336 $linklinkfiles = '';
337 for (@smath) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
338 for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
340 $auth = "script";
341 $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
342 $prj = '..$/..' ;
344 ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
345 &writelinkmakefile($module,$linkmakefile);
347 #-------------------------------
348 # swriter
349 $module = "swriter";
351 $linkaddedfiles = <<"LAF";
352 -add $module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
353 -add $module.tree \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
354 -add $module.jar \$(BIN)\$/xhp_${module}_LANGUAGE.zip
357 $linkaddeddeps = <<"LAD";
358 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
359 \$(COMMONMISC)\$/LANGUAGE\$/$module.tree \\
360 \$(BIN)\$/xhp_${module}_LANGUAGE.zip
363 $linklinkfiles = '';
364 for (@swriter) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
365 for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
366 for (@schart) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
367 $auth = "script";
368 $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
369 $prj = '..$/..' ;
371 ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
372 &writelinkmakefile($module,$linkmakefile);
374 #-------------------------------
375 # sdatabase
376 $module = "sdatabase";
378 $linkaddedfiles = <<"LAF";
379 -add $module.cfg \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
380 -add $module.jar \$(BIN)\$/xhp_${module}_LANGUAGE.zip
383 $linkaddeddeps = <<"LAD";
384 \$(PRJ)\$/source\$/auxiliary\$/LANGUAGE\$/$module.cfg \\
385 \$(BIN)\$/xhp_${module}_LANGUAGE.zip
388 $linklinkfiles = '';
389 for (@shared) { $linklinkfiles = $linklinkfiles . " $_ \\\n"; }
390 $auth = "script";
391 $date = sprintf "%4d/%02d/%02d %02d:%02d:%02d",$year+1900,$mon,$mday,$hour,$min,$sec;
392 $prj = '..$/..' ;
394 ($linkmakefile = $linktmpl) =~ s/%([^%]*)%/$$1/gise;
396 # remove zip1 targets
397 $linkmakefile =~ s,\n(ZIP1LIST=.*)\n,\nZIP1LIST=\$(LANGDIR)\$/text\$/shared\$/explorer\$/database\$/main.xhp\n,gi;
398 &writelinkmakefile($module,$linkmakefile);
402 print "sbasic: $#sbasic\n";
403 print "scalc : $#scalc\n";
404 print "schart: $#schart\n";
405 print "sdraw : $#sdraw\n";
406 print "shared: $#shared\n";
407 print "simpr : $#simpress\n";
408 print "smath : $#smath\n";
409 print "swrit : $#swriter\n";
410 print "sdbase: $#sdatabase\n";
412 sub terminate {
413 $err = shift;
414 print "$err\n\n";
415 $msg = <<"MSG";
416 createmakefile.pl -dir=[directory name] -linkdir=[directory name] [-recursive] [-all]
417 -dir Directory to start
418 -linkdir Directory to write the link makefiles
419 -recursive Write makefiles recursively
420 -all include files with all status values
422 die "$msg\n";
426 sub writelinkmakefile {
427 $module = shift;
428 $content = shift;
429 if (open(MK, ">$linkdir/$module/makefile.mk")) {
430 print MK $content;
431 close MK;
432 } else {
433 &terminate("Cannot write makefile to ${linkdir}/$module\n");