update dev300-m58
[ooovba.git] / odk / configure.pl
blob9a6228792097eb1e515b3c3ab09c650ac6945400
2 # configure.pl - a perl script to set a minimal environment for the SDK.
4 # Copyright (c) 2000 Sun Microsystems, Inc.
7 use IO::File;
9 $main::hostname= $ARGV[0];
10 $main::sdkpath= $ARGV[1];
11 $main::OO_SDK_NAME= $ARGV[2];
13 $main::OO_MAJORVERSION=$main::OO_SDK_NAME;
14 $main::OO_MINORVERSION=$main::OO_SDK_NAME;
15 $main::OO_MAJORVERSION =~ s#[^\d]+(\d).(\d).+#$1#go;
16 $main::OO_MINORVERSION =~ s#[^\d]+(\d).(\d).+#$2#go;
18 $main::OO_SDK_CONFIG_HOME= "$ENV{HOME}/$main::OO_SDK_NAME";
20 $main::operatingSystem = `$main::sdkpath/config.guess | cut -d"-" -f3,4`;
21 chomp ($main::operatingSystem);
23 $main::OO_SDK_HOME = $main::sdkpath;
24 #$main::OO_SDK_HOME = "";
25 $main::OO_SDK_HOME_SUGGESTION = $main::sdkpath;
27 $main::OFFICE_OR_URE = "Office";
28 $main::OFFICE_OR_URE_SUGGESTION = "Office";
30 $main::OFFICE_HOME = "";
32 $main::OFFICE_BASE_HOME = substr($main::sdkpath, 0, rindex($main::sdkpath, "/sdk"));
34 if ( $main::operatingSystem =~ m/darwin/ )
36 # $main::OO_SDK_URE_HOME = `cd $main::sdkpath/../ure-link && pwd`;
37 } else {
38 $main::OO_SDK_URE_HOME = `cd $main::sdkpath/../../ure && pwd`;
41 $main::OO_SDK_MAKE_HOME = "";
42 $main::makeName = "make";
43 if ( $main::operatingSystem =~ m/solaris/ ||
44 $main::operatingSystem =~ m/freebsd/ )
46 $main::makeName = "gmake";
48 $main::OO_SDK_MAKE_HOME_SUGGESTION = searchprog($main::makeName);
49 $main::makeVersion = "3.79.1";
50 $main::correctVersion = 0;
52 $main::OO_SDK_ZIP_HOME = "";
53 $main::OO_SDK_ZIP_HOME_SUGGESTION = searchprog("zip");
54 $main::zipVersion = "2.3";
56 $main::OO_SDK_CPP_HOME = "";
57 $main::cppName = "gcc";
58 $main::cppVersion = "3.0.1";
59 if ( $main::operatingSystem =~ m/solaris/ )
61 $main::cppName = "CC";
62 $main::cppVersion = "5.2";
64 $main::OO_SDK_CC_55_OR_HIGHER = "";
65 $main::OO_SDK_CPP_HOME_SUGGESTION = searchprog($main::cppName);
67 $main::OO_SDK_JAVA_HOME = "";
68 $main::OO_SDK_JAVA_BIN_DIR = "bin";
69 if ( $main::operatingSystem =~ m/darwin/ )
71 $main::OO_SDK_JAVA_BIN_DIR="Commands";
73 $main::OO_SDK_JAVA_HOME_SUGGESTION = searchprog("javac");
74 $main::javaVersion = "1.4.1_01";
76 $main::SDK_AUTO_DEPLOYMENT = "";
77 $main::SDK_AUTO_DEPLOYMENT_SUGGESTION = "YES";
79 $main::OO_SDK_OUTPUT_DIR_SUGGESTION = "$ENV{HOME}";
80 $main::OO_SDK_OUTPUT_DIR = "";
81 $main::skipOutputDir = 0;
83 $main::return = 0;
85 if ( $main::OFFICE_OR_URE eq "Office" )
87 if ( $main::operatingSystem =~ m/darwin/ )
89 # used for a SDK as part of the office installation
90 # $main::OFFICE_HOME = `cd $main::sdkpath/../../.. && pwd`;
91 # chomp($main::OFFICE_HOME);
92 # print " Used Office = $main::OFFICE_HOME\n";
93 print " Used SDK = $main::OO_SDK_HOME\n\n";
95 $main::OFFICE_HOME_SUGGESTION = searchMacOffice();
96 while ( (! -d "$main::OFFICE_HOME" ) ||
97 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/Contents/MacOS")) )
99 print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: ";
100 $main::OFFICE_HOME = readStdIn();
101 chop($main::OFFICE_HOME);
102 if ( $main::OFFICE_HOME eq "" )
104 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION;
107 if ( ! -d "$main::OFFICE_HOME" )
109 $main::OFFICE_HOME = "";
110 print " Error: An office installation is required, please specify the path to a valid installation.\n";
113 # check more details
114 if ( -d "$main::OFFICE_HOME/Contents/basis-link" ) {
115 $main::OFFICE_BASE_HOME = "$main::OFFICE_HOME/Contents/basis-link";
116 if ( -d "$main::OFFICE_BASE_HOME/ure-link" ) {
117 $main::OO_SDK_URE_HOME = "$main::OFFICE_BASE_HOME/ure-link";
118 } else {
119 $main::OFFICE_HOME = "";
120 $main::OFFICE_BASE_HOME = "";
121 $main::OO_SDK_URE_HOME = "";
122 print " Error: no URE found in office installation, please specify the path to a valid installation.\n";
124 } else {
125 $main::OFFICE_HOME = "";
126 $main::OFFICE_BASE_HOME = "";
127 $main::OO_SDK_URE_HOME = "";
128 print " Error: no base layer found in office installation, please specify the path to a valid installation.\n";
131 } else
133 $main::OFFICE_HOME_SUGGESTION = searchoffice();
135 if ( $main::OFFICE_HOME_SUGGESTION eq "" ) {
136 # prepare Office path
137 $main::OFFICE_HOME_SUGGESTION = searchprog("soffice");
140 if ( ! $main::OFFICE_HOME_SUGGESTION eq "" )
142 my $tmpOffice = readlink "$main::OFFICE_HOME_SUGGESTION/soffice";
144 if ( $tmpOffice eq "" )
146 $tmpOffice = "$main::OFFICE_HOME_SUGGESTION/soffice";
149 my $offset = rindex($tmpOffice, "/program/soffice");
150 if ( $offset != -1 )
152 $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset);
153 } else
155 $offset = rindex($tmpOffice, "/soffice");
156 if ( $offset != -1 )
158 $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset);
159 } else
161 $main::OFFICE_HOME_SUGGESTION = "";
166 while ( (! -d "$main::OFFICE_HOME" ) ||
167 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/program")) )
169 print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: ";
170 $main::OFFICE_HOME = readStdIn();
171 chop($main::OFFICE_HOME);
172 if ( $main::OFFICE_HOME eq "" )
174 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION;
177 if ( ! -d "$main::OFFICE_HOME" )
179 $main::OFFICE_HOME = "";
180 print " Error: An office installation is required, please specify the path to a valid installation.\n";
181 } else
183 # special work for a network installation, no prgram directory but a link to the soffice binary
184 if ( (! -d "$main::OFFICE_HOME/program") && (-e "$main::OFFICE_HOME/soffice") )
186 my $soserver = `ls -l $OFFICE_HOME_SUGGESTION/soffice | sed -n 's/.* -> //p'`;
187 $soserver= substr($soserver, 0, rindex($soserver, "program") - 1);
189 if ( ! -d $soserver )
191 $main::OFFICE_HOME = "";
192 print " Error: An office installation is required, please specify the path to a valid installation.\n";
193 } else
195 $main::OFFICE_HOME = $soserver;
202 else
204 # prepare URE path
205 $main::OO_SDK_URE_HOME_SUGGESTION = "/opt/openoffice.org/ure";
206 $main::OO_SDK_URE_HOME_SUGGESTION = "" unless
207 -e "$main::OO_SDK_URE_HOME_SUGGESTION/bin/uno";
208 for (;;)
210 print " Enter the URE installation directory",
211 " [$main::OO_SDK_URE_HOME_SUGGESTION]: ";
212 $main::OO_SDK_URE_HOME = readStdIn();
213 chop $main::OO_SDK_URE_HOME;
214 $main::OO_SDK_URE_HOME = $main::OO_SDK_URE_HOME_SUGGESTION if
215 $main::OO_SDK_URE_HOME eq "" &&
216 $main::OO_SDK_URE_HOME_SUGGESTION ne "";
217 last if -e "$main::OO_SDK_URE_HOME/bin/uno";
218 print " Error: A valid URE installation is required.\n";
222 # prepare GNU make path
223 while ( (!$main::correctVersion) &&
224 ((! -d "$main::OO_SDK_MAKE_HOME" ) ||
225 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName"))) )
227 print " Enter GNU make ($main::makeVersion or higher) tools directory [$main::OO_SDK_MAKE_HOME_SUGGESTION]: ";
228 $main::OO_SDK_MAKE_HOME = readStdIn();
229 chop($main::OO_SDK_MAKE_HOME);
230 if ( $main::OO_SDK_MAKE_HOME eq "" )
232 $main::OO_SDK_MAKE_HOME = $main::OO_SDK_MAKE_HOME_SUGGESTION;
234 if ( (! -d "$main::OO_SDK_MAKE_HOME") ||
235 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName")) )
237 $main::OO_SDK_MAKE_HOME = "";
238 print " Error: GNU make is required, please specify a GNU make tools directory.\n";
239 } else
241 #check version
242 my $testVersion = `$OO_SDK_MAKE_HOME/$main::makeName --version`;
243 if ( $testVersion eq "")
245 print " Set the environment variable OO_SDK_MAKE_HOME to your GNU build tools directory.\n";
246 print " GNU make version $main::makeVersion can be obtained at ftp://ftp.gnu.org/gnu/make/\n";
247 } else
249 if ($testVersion =~ m#((\d+\.)+\d+)# )
251 $testVersion = $1;
253 $main::correctVersion = testVersion($main::makeVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/$main::makeName", 1);
254 if ( !$main::correctVersion )
256 print " The '$main::makeName' command found at '$main::OO_SDK_MAKE_HOME' has a wrong version\n";
257 $main::OO_SDK_MAKE_HOME = "";
263 # prepare zip path
264 $main::correctVersion = 0;
265 while ( (!$main::correctVersion) &&
266 ((! -d "$main::OO_SDK_ZIP_HOME" ) ||
267 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip"))) )
269 print " Enter zip ($main::zipVersion or higher) tool directory [$main::OO_SDK_ZIP_HOME_SUGGESTION]: ";
270 $main::OO_SDK_ZIP_HOME = readStdIn();
271 chop($main::OO_SDK_ZIP_HOME);
272 if ( $main::OO_SDK_ZIP_HOME eq "" )
274 $main::OO_SDK_ZIP_HOME = $main::OO_SDK_ZIP_HOME_SUGGESTION;
276 if ( (! -d "$main::OO_SDK_ZIP_HOME") ||
277 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip")) )
279 $main::OO_SDK_ZIP_HOME = "";
280 print " Error: zip tool is required, please specify a zip tool directory.\n";
281 } else
283 #check version
284 my $testVersion = `$OO_SDK_ZIP_HOME/zip -h 2>&1 | egrep Zip | head -n 1`;
285 $testVersion =~ s#Zip ([\d.]+) .*#$1#go;
286 if ( $testVersion eq "")
288 print " Set the environment variable OO_SDK_ZIP_HOME to your zip tool directory.\n";
289 print " zip version $main::zipVersion can be obtained at ftp://www.info-zip.org/\n";
290 } else
292 if ($testVersion =~ m#((\d+\.)+\d+)# )
294 $testVersion = $1;
296 $main::correctVersion = testVersion($main::zipVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/zip", 1);
297 if ( !$main::correctVersion )
299 print " The 'zip' command found at '$main::OO_SDK_ZIP_HOME' has a wrong version\n";
300 $main::OO_SDK_ZIP_HOME = "";
306 # prepare C++ compiler path
307 $main::correctVersion = 0;
308 while ( (!$main::correctVersion) &&
309 ((! -d "$main::OO_SDK_CPP_HOME" ) ||
310 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cpp"))) )
312 print " C++ compilers where for example a language binding exist:\n";
313 print " - Solaris, Sun WorkShop 6 update 1 C++ 5.2 2000/09/11 or higher\n";
314 print " - Linux, GNU C++ compiler, gcc version 3.0.1 or higher\n";
315 print " - MacOS, GNU C++ compiler, gcc version 4.0.1 or higher\n";
316 print " Enter the directory of the C++ compiler, the directory\n";
317 print " where the compiler is located (optional) [$main::OO_SDK_CPP_HOME_SUGGESTION]: ";
319 $main::OO_SDK_CPP_HOME = readStdIn();
320 chop($main::OO_SDK_CPP_HOME);
321 if ( $main::OO_SDK_CPP_HOME eq "" )
323 $main::OO_SDK_CPP_HOME = $main::OO_SDK_CPP_HOME_SUGGESTION;
326 if ( ! $main::OO_SDK_CPP_HOME eq "" )
328 if ( (! -d "$main::OO_SDK_CPP_HOME") ||
329 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cppName")) )
331 print " Error: Could not find directory '$main::OO_SDK_CPP_HOME'.\n";
332 if ( skipChoice("C++ compiler") == 1 )
334 $main::correctVersion = 1;
336 $main::OO_SDK_CPP_HOME = "";
337 } else
339 #check version
340 if ( $main::cppName eq "gcc" )
342 my $testVersion = `$OO_SDK_CPP_HOME/$main::cppName -dumpversion`;
343 if ( $testVersion eq "")
345 print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a ";
346 print " GNU compiler.\nSet the environment variable OO_SDK_CPP_HOME to your GNU build tools ";
347 print " directory.\nA GNU compiler version $main::cppVersion can be obtained at ";
348 print " ftp://ftp.gnu.org/gnu/gcc/\n";
349 } else
351 $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1);
352 if ( !$main::correctVersion )
354 print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n";
355 if ( skipChoice("C++ compiler") == 1 )
357 $main::correctVersion = 1;
360 $main::OO_SDK_CPP_HOME = "";
363 } else
365 # for Solaris we have to check the version too
366 open(FILE, "$OO_SDK_CPP_HOME/$main::cppName -V 2>&1 |");
367 my @lines = <FILE>;
368 my $testVersion = $lines[0];
369 if ( $testVersion eq "")
371 print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a ";
372 print " Solaris C++ compiler.\nSet the environment variable OO_SDK_CPP_HOME to your Solaris C++ compiler directory.\n";
373 } else
375 if ($testVersion =~ m#((\d+\.)+\d+)# )
377 $testVersion = $1;
379 $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1);
380 if ( !$main::correctVersion )
382 print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n";
383 if ( skipChoice("C++ compiler") == 1 )
385 $main::correctVersion = 1;
388 $main::OO_SDK_CPP_HOME = "";
389 } else {
390 $main::correctVersion = testVersion("5.5", $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 2);
391 if ( $main::correctVersion ) {
392 $main::OO_SDK_CC_55_OR_HIGHER = $testVersion;
398 } else
400 # the C++ compiler is optional
401 $main::correctVersion = 1;
406 # prepare Java path
407 $main::correctVersion = 0;
409 # prepare Java suggestion (cut bin or Commands directory to be in the root of the Java SDK)
410 $main::offset = rindex($main::OO_SDK_JAVA_HOME_SUGGESTION, "/$main::OO_SDK_JAVA_BIN_DIR");
411 if ( $main::offset != -1 )
413 $main::OO_SDK_JAVA_HOME_SUGGESTION = substr($main::OO_SDK_JAVA_HOME_SUGGESTION, 0, $main::offset);
416 while ( (!$main::correctVersion) &&
417 ((! -d "$main::OO_SDK_JAVA_HOME" ) ||
418 ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac"))) )
420 print " Enter Java SDK (1.4.1_01 or higher) installation directory (optional) [$main::OO_SDK_JAVA_HOME_SUGGESTION]: ";
421 $main::OO_SDK_JAVA_HOME = readStdIn();
422 chop($main::OO_SDK_JAVA_HOME);
423 if ( $main::OO_SDK_JAVA_HOME eq "" )
425 $main::OO_SDK_JAVA_HOME = $main::OO_SDK_JAVA_HOME_SUGGESTION;
427 if ( ! $main::OO_SDK_JAVA_HOME eq "" )
429 if ( (! -d "$main::OO_SDK_JAVA_HOME") ||
430 ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac")) )
432 print " Error: Could not find directory '$main::OO_SDK_JAVA_HOME' or '$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac'.\n";
433 if ( skipChoice("JAVA SDK") == 1 )
435 $main::correctVersion = 1;
437 $main::OO_SDK_JAVA_HOME = "";
438 } else
440 #check version
441 my $testVersion = `$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/java -version 2>&1 | egrep "java version" | head -n 1 | sed -e 's#.*version "##' | sed -e 's#".*##'`;
442 $testVersion =~ s#([^\n]+)\n#$1#go;
444 $main::correctVersion = testVersion($main::javaVersion, $testVersion, "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/java", 1);
445 if ( !$main::correctVersion )
447 if ( skipChoice("JAVA SDK") == 1 )
449 $main::correctVersion = 1;
451 $main::OO_SDK_JAVA_HOME = "";
454 }else
456 # the Java SDK is optional
457 $main::correctVersion = 1;
462 # prepare output directory (optional)
463 while ( (!$main::skipOutputDir) &&
464 (! -d "$main::OO_SDK_OUTPUT_DIR") )
466 print " Default output directory is in your HOME directory.\n";
467 print " Enter an existent directory if you prefer a different output directory (optional) [$main::OO_SDK_OUTPUT_DIR_SUGGESTION]: ";
469 $main::OO_SDK_OUTPUT_DIR = readStdIn();
471 chop($main::OO_SDK_OUTPUT_DIR);
472 if ( $main::OO_SDK_OUTPUT_DIR eq "" )
474 $main::OO_SDK_OUTPUT_DIR = $main::OO_SDK_OUTPUT_DIR_SUGGESTION;
476 if ( ! $main::OO_SDK_OUTPUT_DIR eq "" )
478 if ( ! -d "$main::OO_SDK_OUTPUT_DIR" )
480 print " Error: Could not find directory '$main::OO_SDK_OUTPUT_DIR'.\n";
481 if ( skipChoice("optional output directory") == 1 )
483 $main::skipOutputDir = 1;
485 $main::OO_SDK_OUTPUT_DIR = "";
487 } else
489 # the output directory is optional
490 $main::skipOutputDir = 1;
494 # prepare auto deployment
495 if ( $main::OFFICE_OR_URE eq "Office" )
497 while ( $main::SDK_AUTO_DEPLOYMENT eq "" ||
498 ((! $main::SDK_AUTO_DEPLOYMENT eq "YES") &&
499 (! $main::SDK_AUTO_DEPLOYMENT eq "NO")) )
501 print " Automatic deployment of UNO components (YES/NO) [$main::SDK_AUTO_DEPLOYMENT_SUGGESTION]: ";
502 $main::SDK_AUTO_DEPLOYMENT = uc <STDIN>;
503 chop($main::SDK_AUTO_DEPLOYMENT);
504 if ( $main::SDK_AUTO_DEPLOYMENT eq "" )
506 $main::SDK_AUTO_DEPLOYMENT = "YES";
510 else
512 $main::SDK_AUTO_DEPLOYMENT = "NO";
515 prepareScriptFile("setsdkenv_unix.sh.in", "setsdkenv_unix.sh", 1);
516 chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh";
518 prepareScriptFile("setsdkenv_unix.csh.in", "setsdkenv_unix.csh", 2);
519 chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.csh";
521 print "\n";
522 print " ************************************************************************\n";
523 print " * ... your SDK environment has been prepared.\n";
524 print " * For each time you want to use this configured SDK environment, you\n";
525 print " * have to run the \"setsdkenv_unix\" script file!\n";
526 print " * Alternatively can you source one of the scripts\n";
527 print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh\"\n";
528 print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.csh\"\n";
529 print " * to get an environment without starting a new shell.\n";
530 print " ************************************************************************\n\n";
532 exit $return;
534 sub skipChoice
536 my $msg = shift;
537 my $skip = "";
538 while ( !( $skip eq "yes" || $skip eq "no") )
540 print " Do you want to skip the choice of the '$msg' (YES/NO): [YES] ";
541 $skip = lc <STDIN>;
542 chop($skip);
543 if ( $skip eq "" ) { $skip = "yes"; } # default
544 if ( $skip eq "yes" )
546 return 1;
549 return 0;
552 sub resolveLink
554 my $base= shift;
555 my $link= shift;
556 my $linktarget = readlink "$base/$link";
557 my $resolvedlink = "";
559 while ( $linktarget ne "") {
560 $link = $linktarget;
561 $linktarget = readlink "$base/$link";
564 $resolvedlink = `cd $base/$link; pwd`;
565 chop $resolvedlink;
566 return $resolvedlink;
569 sub searchprog
571 my $_search= shift;
572 my $tmpPath = `echo "\$PATH"`;
573 my @pathList = split(":" , $tmpPath);
574 my $progDir = "";
576 if ( $_search eq "javac" )
578 if ( $main::operatingSystem =~ m/darwin/ ) {
579 $progDir = resolveLink("/System/Library/Frameworks/JavaVM.Framework/Versions", "CurrentJDK");
580 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
582 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR";
586 if ( $main::operatingSystem =~ m/solaris/ ) {
587 $progDir = resolveLink("/usr/jdk", "latest");
588 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
590 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR";
595 if ( $_search eq "gmake" && $main::operatingSystem =~ m/solaris/ ) {
596 if ( -e "/usr/sfw/bin/gmake" )
598 return "/usr/sfw/bin";
602 foreach $i (@pathList)
604 chomp ($i);
606 if ( -e "$i/$_search" )
609 if ( index($i, "/") == 0 )
611 # # absolute path; leave unchanged
612 $progDir = $i;
613 } else
615 $progDir = `cd "$i"; pwd`;
617 return $progDir
620 return $progDir
623 sub searchMacOffice
625 if (-d "/Applications/OpenOffice.org.app" ) {
626 return "/Applications/OpenOffice.org.app"
628 if (-d "/Applications/StarOffice.app" ) {
629 return "/Applications/StarOffice.app";
631 if (-d "/Applications/StarSuite.app" ) {
632 return "/Applications/StarSuite.app";
635 return "";
638 sub searchoffice
640 my $offset = rindex($main::sdkpath, "/openoffice.org");
641 my $tmpOffice = substr($main::sdkpath, 0, $offset);
642 my $officepath = "$tmpOffice/openoffice.org$main::OO_MAJORVERSION";
644 # if ( $main::OO_MINORVERSION > 0) {
645 # $officepath = "$officepath$main::OO_MINORVERSION";
646 # }
648 # search corresponding office for this SDK
649 if (-d $officepath && -e "$officepath/program/soffice") {
650 return $officepath;
652 # fallback
653 my $tmpversion = $main::OO_MAJORVERSION + 6;
654 if ( $main::OO_MINORVERSION > 0) {
655 $tmpversion = "$tmpversion.$main::OO_MINORVERSION";
658 $officepath = "$tmpOffice/staroffice$tmpversion";
659 if (-d $officepath && -e "$officepath/program/soffice") {
660 return $officepath;
662 $officepath = "$tmpOffice/StarOffice$tmpversion";
663 if (-d $officepath && -e "$officepath/program/soffice") {
664 return $officepath;
666 $officepath = "$tmpOffice/starsuite$tmpversion";
667 if (-d $officepath && -e "$officepath/program/soffice") {
668 return $officepath;
670 $officepath = "$tmpOffice/StarSuite$tmpversion";
671 if (-d $officepath && -e "$officepath/program/soffice") {
672 return $officepath;
674 $officepath = "";
676 # search other potential matching office versions
677 my $path = "/opt/";
678 my $entry = "";
679 my $version = "0";
680 for $entry (glob($path.'*')) {
681 ## if the file is a directory
682 if( -d $entry) {
684 if ($entry =~ m#(.+(o|O)ffice(\.org){0,1}(\d([\d\.]){0,2}))# ||
685 $entry =~ m#(.+(s|S)uite(.*)(\d([\d\.]){0,2}))# )
687 if ($4 > $version) {
688 $version = $4;
689 $officepath = $entry;
694 return $officepath;
699 sub testVersion
701 my $tmpMustBeVersion = shift;
702 my $tmpTestVersion = shift;
703 my $toolName = shift;
704 # 1=check + message 2=check only
705 my $checkOnly = shift;
706 my @mustBeVersion = split(/\.|_|-/,$tmpMustBeVersion);
707 my @testVersion = split(/\.|_|-/,$tmpTestVersion);
708 my $length = $#mustBeVersion;
710 if ($#testVersion < $#mustBeVersion) {
711 $length = $#testVersion;
714 for ($i=0; $i <= $length; $i++ )
716 if ( @testVersion->[$i] > @mustBeVersion->[$i] )
718 return 1; # 1 indicates a correct version
721 if ( @testVersion->[$i] < @mustBeVersion->[$i] )
723 if ( $#checkOnly == 1 ) {
724 print " The command '$toolName' has the version $tmpTestVersion.\n";
725 print " The SDK requires at least the version $tmpMustBeVersion.\n";
727 return 0;
731 return 1; # 1 indicates a correct version
734 sub readStdIn
736 my $tmpstdin = <STDIN>;
737 if ( index($tmpstdin, "\$") != -1)
739 return `echo $tmpstdin`;
742 return $tmpstdin;
745 sub prepareScriptFile()
747 my $inputFile = shift;
748 my $outputFile = shift;
749 # shell mode 1 = sh
750 # 2 = csh
751 my $shellMode = shift;
753 if ( ! -d "$main::OO_SDK_CONFIG_HOME/$main::hostname" )
755 system("mkdir -p $main::OO_SDK_CONFIG_HOME/$main::hostname");
758 open ( FILEIN, "$main::sdkpath/$inputFile" ) || die "\nERROR: could not open '$main::sdkpath/$inputFile' for reading";
759 open ( FILEOUT, ">$main::OO_SDK_CONFIG_HOME/$main::hostname/$outputFile" ) || die "\nERROR: could not open '$main::OO_SDK_CONFIG_HOME/$main::hostname/$outputFile' for writing";
761 while ( <FILEIN> )
763 $_ =~ s#\@OO_SDK_NAME\@#$main::OO_SDK_NAME#go;
764 $_ =~ s#\@OO_SDK_HOME\@#$main::OO_SDK_HOME#go;
765 $_ =~ s#\@OFFICE_HOME\@#$main::OFFICE_HOME#go;
766 $_ =~ s#\@OFFICE_BASE_HOME\@#$main::OFFICE_BASE_HOME#go;
767 $_ =~ s#\@OO_SDK_URE_HOME\@#$main::OO_SDK_URE_HOME#go;
768 $_ =~ s#\@OO_SDK_MAKE_HOME\@#$main::OO_SDK_MAKE_HOME#go;
769 $_ =~ s#\@OO_SDK_ZIP_HOME\@#$main::OO_SDK_ZIP_HOME#go;
770 $_ =~ s#\@OO_SDK_CPP_HOME\@#$main::OO_SDK_CPP_HOME#go;
771 $_ =~ s#\@OO_SDK_CC_55_OR_HIGHER\@#$main::OO_SDK_CC_55_OR_HIGHER#go;
772 $_ =~ s#\@OO_SDK_JAVA_HOME\@#$main::OO_SDK_JAVA_HOME#go;
773 $_ =~ s#\@SDK_AUTO_DEPLOYMENT\@#$main::SDK_AUTO_DEPLOYMENT#go;
774 $_ =~ s#\@OO_SDK_OUTPUT_DIR\@#$main::OO_SDK_OUTPUT_DIR#go;
776 print FILEOUT $_;
779 close FILEIN;
780 close FILEOUT;