merged tag ooo/DEV300_m102
[LibreOffice.git] / odk / configure.pl
blobe1a1cfb99924c21389cb1627aaac1381c289a06e
2 # configure.pl - a perl script to set a minimal environment for the SDK.
4 # Copyright 2000, 2010 Oracle and/or its affiliates.
7 use IO::File;
8 use File::Basename;
10 $main::hostname= $ARGV[0];
11 $main::sdkpath= $ARGV[1];
12 $main::OO_SDK_NAME= $ARGV[2];
14 $main::OO_MAJORVERSION=$main::OO_SDK_NAME;
15 $main::OO_MINORVERSION=$main::OO_SDK_NAME;
16 $main::OO_MAJORVERSION =~ s#[^\d]+(\d).(\d).+#$1#go;
17 $main::OO_MINORVERSION =~ s#[^\d]+(\d).(\d).+#$2#go;
19 $main::OO_SDK_CONFIG_HOME= "$ENV{HOME}/$main::OO_SDK_NAME";
21 $main::operatingSystem = `$main::sdkpath/config.guess | cut -d"-" -f3,4`;
22 chomp ($main::operatingSystem);
24 $main::OO_SDK_HOME = $main::sdkpath;
25 #$main::OO_SDK_HOME = "";
26 $main::OO_SDK_HOME_SUGGESTION = $main::sdkpath;
28 $main::OFFICE_OR_URE = "Office";
29 $main::OFFICE_OR_URE_SUGGESTION = "Office";
31 $main::OFFICE_HOME = "";
33 $main::OFFICE_BASE_HOME = substr($main::sdkpath, 0, rindex($main::sdkpath, "/sdk"));
35 if ( $main::operatingSystem =~ m/darwin/ )
37 # $main::OO_SDK_URE_HOME = `cd $main::sdkpath/../ure-link && pwd`;
38 } else {
39 $main::OO_SDK_URE_HOME = `cd $main::sdkpath/../ure-link && pwd`;
41 chomp($main::OO_SDK_URE_HOME);
43 $main::OO_SDK_MAKE_HOME = "";
44 $main::makeName = "make";
45 if ( $main::operatingSystem =~ m/solaris/ ||
46 $main::operatingSystem =~ m/freebsd/ )
48 $main::makeName = "gmake";
50 $main::OO_SDK_MAKE_HOME_SUGGESTION = searchprog($main::makeName);
51 $main::makeVersion = "3.79.1";
52 $main::correctVersion = 0;
54 $main::OO_SDK_ZIP_HOME = "";
55 $main::OO_SDK_ZIP_HOME_SUGGESTION = searchprog("zip");
56 $main::zipVersion = "2.3";
58 $main::OO_SDK_CPP_HOME = "";
59 $main::cppName = "gcc";
60 $main::cppVersion = "4.0.1";
61 if ( $main::operatingSystem =~ m/solaris/ )
63 $main::cppName = "CC";
64 $main::cppVersion = "5.2";
66 $main::OO_SDK_CC_55_OR_HIGHER = "";
67 $main::OO_SDK_CPP_HOME_SUGGESTION = searchprog($main::cppName);
69 $main::OO_SDK_JAVA_HOME = "";
70 $main::OO_SDK_JAVA_BIN_DIR = "bin";
71 if ( $main::operatingSystem =~ m/darwin/ )
73 $main::OO_SDK_JAVA_BIN_DIR="Commands";
75 $main::OO_SDK_JAVA_HOME_SUGGESTION = searchprog("javac");
76 $main::javaVersion = "1.5.0_01";
78 $main::SDK_AUTO_DEPLOYMENT = "";
79 $main::SDK_AUTO_DEPLOYMENT_SUGGESTION = "YES";
81 $main::OO_SDK_OUTPUT_DIR_SUGGESTION = "$ENV{HOME}";
82 $main::OO_SDK_OUTPUT_DIR = "";
83 $main::skipOutputDir = 0;
85 $main::return = 0;
87 if ( $main::OFFICE_OR_URE eq "Office" )
89 if ( $main::operatingSystem =~ m/darwin/ )
91 # used for a SDK as part of the office installation
92 # $main::OFFICE_HOME = `cd $main::sdkpath/../../.. && pwd`;
93 # chomp($main::OFFICE_HOME);
94 # print " Used Office = $main::OFFICE_HOME\n";
95 print " Used SDK = $main::OO_SDK_HOME\n\n";
97 $main::OFFICE_HOME_SUGGESTION = searchMacOffice();
98 while ( (! -d "$main::OFFICE_HOME" ) ||
99 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/Contents/MacOS")) )
101 print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: ";
102 $main::OFFICE_HOME = readStdIn();
103 chop($main::OFFICE_HOME);
104 if ( $main::OFFICE_HOME eq "" )
106 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION;
109 if ( ! -d "$main::OFFICE_HOME" )
111 $main::OFFICE_HOME = "";
112 print " Error: An office installation is required, please specify the path to a valid installation.\n";
115 # check more details
116 if ( -d "$main::OFFICE_HOME/Contents/basis-link" ) {
117 $main::OFFICE_BASE_HOME = "$main::OFFICE_HOME/Contents/basis-link";
118 if ( -d "$main::OFFICE_BASE_HOME/ure-link" ) {
119 $main::OO_SDK_URE_HOME = "$main::OFFICE_BASE_HOME/ure-link";
120 } else {
121 $main::OFFICE_HOME = "";
122 $main::OFFICE_BASE_HOME = "";
123 $main::OO_SDK_URE_HOME = "";
124 print " Error: no URE found in office installation, please specify the path to a valid installation.\n";
126 } else {
127 $main::OFFICE_HOME = "";
128 $main::OFFICE_BASE_HOME = "";
129 $main::OO_SDK_URE_HOME = "";
130 print " Error: no base layer found in office installation, please specify the path to a valid installation.\n";
133 } else
135 $main::OFFICE_HOME_SUGGESTION = searchoffice();
137 if ( $main::OFFICE_HOME_SUGGESTION eq "" ) {
138 # prepare Office path
139 $main::OFFICE_HOME_SUGGESTION = searchprog("soffice");
142 if ( ! $main::OFFICE_HOME_SUGGESTION eq "" )
144 my $tmpOffice = readlink "$main::OFFICE_HOME_SUGGESTION/soffice";
146 if ( $tmpOffice eq "" )
148 $tmpOffice = "$main::OFFICE_HOME_SUGGESTION/soffice";
151 my $offset = rindex($tmpOffice, "/program/soffice");
152 if ( $offset != -1 )
154 $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset);
155 } else
157 $offset = rindex($tmpOffice, "/soffice");
158 if ( $offset != -1 )
160 $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset);
161 } else
163 $main::OFFICE_HOME_SUGGESTION = "";
168 while ( (! -d "$main::OFFICE_HOME" ) ||
169 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/program")) )
171 print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: ";
172 $main::OFFICE_HOME = readStdIn();
173 chop($main::OFFICE_HOME);
174 if ( $main::OFFICE_HOME eq "" )
176 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION;
179 if ( ! -d "$main::OFFICE_HOME" )
181 $main::OFFICE_HOME = "";
182 print " Error: An office installation is required, please specify the path to a valid installation.\n";
183 } else
185 # special work for a network installation, no prgram directory but a link to the soffice binary
186 if ( (! -d "$main::OFFICE_HOME/program") && (-e "$main::OFFICE_HOME/soffice") )
188 my $soserver = `ls -l $OFFICE_HOME_SUGGESTION/soffice | sed -n 's/.* -> //p'`;
189 $soserver= substr($soserver, 0, rindex($soserver, "program") - 1);
191 if ( ! -d $soserver )
193 $main::OFFICE_HOME = "";
194 print " Error: An office installation is required, please specify the path to a valid installation.\n";
195 } else
197 $main::OFFICE_HOME = $soserver;
204 else
206 # prepare URE path
207 $main::OO_SDK_URE_HOME_SUGGESTION = "/opt/openoffice.org/ure";
208 $main::OO_SDK_URE_HOME_SUGGESTION = "" unless
209 -e "$main::OO_SDK_URE_HOME_SUGGESTION/bin/uno";
210 for (;;)
212 print " Enter the URE installation directory",
213 " [$main::OO_SDK_URE_HOME_SUGGESTION]: ";
214 $main::OO_SDK_URE_HOME = readStdIn();
215 chop $main::OO_SDK_URE_HOME;
216 $main::OO_SDK_URE_HOME = $main::OO_SDK_URE_HOME_SUGGESTION if
217 $main::OO_SDK_URE_HOME eq "" &&
218 $main::OO_SDK_URE_HOME_SUGGESTION ne "";
219 last if -e "$main::OO_SDK_URE_HOME/bin/uno";
220 print " Error: A valid URE installation is required.\n";
224 # prepare GNU make path
225 while ( (!$main::correctVersion) &&
226 ((! -d "$main::OO_SDK_MAKE_HOME" ) ||
227 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName"))) )
229 print " Enter GNU make ($main::makeVersion or higher) tools directory [$main::OO_SDK_MAKE_HOME_SUGGESTION]: ";
230 $main::OO_SDK_MAKE_HOME = readStdIn();
231 chop($main::OO_SDK_MAKE_HOME);
232 if ( $main::OO_SDK_MAKE_HOME eq "" )
234 $main::OO_SDK_MAKE_HOME = $main::OO_SDK_MAKE_HOME_SUGGESTION;
236 if ( (! -d "$main::OO_SDK_MAKE_HOME") ||
237 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName")) )
239 $main::OO_SDK_MAKE_HOME = "";
240 print " Error: GNU make is required, please specify a GNU make tools directory.\n";
241 } else
243 #check version
244 my $testVersion = `$OO_SDK_MAKE_HOME/$main::makeName --version`;
245 if ( $testVersion eq "")
247 print " Set the environment variable OO_SDK_MAKE_HOME to your GNU build tools directory.\n";
248 print " GNU make version $main::makeVersion can be obtained at ftp://ftp.gnu.org/gnu/make/\n";
249 } else
251 if ($testVersion =~ m#((\d+\.)+\d+)# )
253 $testVersion = $1;
255 $main::correctVersion = testVersion($main::makeVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/$main::makeName", 1);
256 if ( !$main::correctVersion )
258 print " The '$main::makeName' command found at '$main::OO_SDK_MAKE_HOME' has a wrong version\n";
259 $main::OO_SDK_MAKE_HOME = "";
265 # prepare zip path
266 $main::correctVersion = 0;
267 while ( (!$main::correctVersion) &&
268 ((! -d "$main::OO_SDK_ZIP_HOME" ) ||
269 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip"))) )
271 print " Enter zip ($main::zipVersion or higher) tool directory [$main::OO_SDK_ZIP_HOME_SUGGESTION]: ";
272 $main::OO_SDK_ZIP_HOME = readStdIn();
273 chop($main::OO_SDK_ZIP_HOME);
274 if ( $main::OO_SDK_ZIP_HOME eq "" )
276 $main::OO_SDK_ZIP_HOME = $main::OO_SDK_ZIP_HOME_SUGGESTION;
278 if ( (! -d "$main::OO_SDK_ZIP_HOME") ||
279 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip")) )
281 $main::OO_SDK_ZIP_HOME = "";
282 print " Error: zip tool is required, please specify a zip tool directory.\n";
283 } else
285 #check version
286 my $testVersion = `$OO_SDK_ZIP_HOME/zip -h 2>&1 | egrep Zip | head -n 1`;
287 $testVersion =~ s#Zip ([\d.]+) .*#$1#go;
288 if ( $testVersion eq "")
290 print " Set the environment variable OO_SDK_ZIP_HOME to your zip tool directory.\n";
291 print " zip version $main::zipVersion can be obtained at ftp://www.info-zip.org/\n";
292 } else
294 if ($testVersion =~ m#((\d+\.)+\d+)# )
296 $testVersion = $1;
298 $main::correctVersion = testVersion($main::zipVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/zip", 1);
299 if ( !$main::correctVersion )
301 print " The 'zip' command found at '$main::OO_SDK_ZIP_HOME' has a wrong version\n";
302 $main::OO_SDK_ZIP_HOME = "";
308 # prepare C++ compiler path
309 $main::correctVersion = 0;
310 while ( (!$main::correctVersion) &&
311 ((! -d "$main::OO_SDK_CPP_HOME" ) ||
312 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cpp"))) )
314 print " C++ compilers where for example a language binding exist:\n";
315 print " - Solaris, Sun WorkShop 6 update 1 C++ 5.2 2000/09/11 or higher\n";
316 print " - Linux, GNU C++ compiler, gcc version 4.0.1 or higher\n";
317 print " - MacOS, GNU C++ compiler, gcc version 4.0.1 or higher\n";
318 print " Enter the directory of the C++ compiler, the directory\n";
319 print " where the compiler is located (optional) [$main::OO_SDK_CPP_HOME_SUGGESTION]: ";
321 $main::OO_SDK_CPP_HOME = readStdIn();
322 chop($main::OO_SDK_CPP_HOME);
323 if ( $main::OO_SDK_CPP_HOME eq "" )
325 $main::OO_SDK_CPP_HOME = $main::OO_SDK_CPP_HOME_SUGGESTION;
328 if ( ! $main::OO_SDK_CPP_HOME eq "" )
330 if ( (! -d "$main::OO_SDK_CPP_HOME") ||
331 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cppName")) )
333 print " Error: Could not find directory '$main::OO_SDK_CPP_HOME'.\n";
334 if ( skipChoice("C++ compiler") == 1 )
336 $main::correctVersion = 1;
338 $main::OO_SDK_CPP_HOME = "";
339 } else
341 #check version
342 if ( $main::cppName eq "gcc" )
344 my $testVersion = `$OO_SDK_CPP_HOME/$main::cppName -dumpversion`;
345 if ( $testVersion eq "")
347 print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a ";
348 print " GNU compiler.\nSet the environment variable OO_SDK_CPP_HOME to your GNU build tools ";
349 print " directory.\nA GNU compiler version $main::cppVersion can be obtained at ";
350 print " ftp://ftp.gnu.org/gnu/gcc/\n";
351 } else
353 $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1);
354 if ( !$main::correctVersion )
356 print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n";
357 if ( skipChoice("C++ compiler") == 1 )
359 $main::correctVersion = 1;
362 $main::OO_SDK_CPP_HOME = "";
365 } else
367 # for Solaris we have to check the version too
368 open(FILE, "$OO_SDK_CPP_HOME/$main::cppName -V 2>&1 |");
369 my @lines = <FILE>;
370 my $testVersion = $lines[0];
371 if ( $testVersion eq "")
373 print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a ";
374 print " Solaris C++ compiler.\nSet the environment variable OO_SDK_CPP_HOME to your Solaris C++ compiler directory.\n";
375 } else
377 if ($testVersion =~ m#((\d+\.)+\d+)# )
379 $testVersion = $1;
381 $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1);
382 if ( !$main::correctVersion )
384 print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n";
385 if ( skipChoice("C++ compiler") == 1 )
387 $main::correctVersion = 1;
390 $main::OO_SDK_CPP_HOME = "";
391 } else {
392 $main::correctVersion = testVersion("5.5", $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 2);
393 if ( $main::correctVersion ) {
394 $main::OO_SDK_CC_55_OR_HIGHER = $testVersion;
400 } else
402 # the C++ compiler is optional
403 $main::correctVersion = 1;
408 # prepare Java path
409 $main::correctVersion = 0;
411 # prepare Java suggestion (cut bin or Commands directory to be in the root of the Java SDK)
412 $main::offset = rindex($main::OO_SDK_JAVA_HOME_SUGGESTION, "/$main::OO_SDK_JAVA_BIN_DIR");
413 if ( $main::offset != -1 )
415 $main::OO_SDK_JAVA_HOME_SUGGESTION = substr($main::OO_SDK_JAVA_HOME_SUGGESTION, 0, $main::offset);
418 while ( (!$main::correctVersion) &&
419 ((! -d "$main::OO_SDK_JAVA_HOME" ) ||
420 ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac"))) )
422 print " Enter Java SDK (1.5, recommendation is 1.6 or higher) installation directory (optional) [$main::OO_SDK_JAVA_HOME_SUGGESTION]: ";
423 $main::OO_SDK_JAVA_HOME = readStdIn();
424 chop($main::OO_SDK_JAVA_HOME);
425 if ( $main::OO_SDK_JAVA_HOME eq "" )
427 $main::OO_SDK_JAVA_HOME = $main::OO_SDK_JAVA_HOME_SUGGESTION;
429 if ( ! $main::OO_SDK_JAVA_HOME eq "" )
431 if ( (! -d "$main::OO_SDK_JAVA_HOME") ||
432 ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac")) )
434 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";
435 if ( skipChoice("JAVA SDK") == 1 )
437 $main::correctVersion = 1;
439 $main::OO_SDK_JAVA_HOME = "";
440 } else
442 #check version
443 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#".*##'`;
444 $testVersion =~ s#([^\n]+)\n#$1#go;
446 $main::correctVersion = testVersion($main::javaVersion, $testVersion, "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/java", 1);
447 if ( !$main::correctVersion )
449 if ( skipChoice("JAVA SDK") == 1 )
451 $main::correctVersion = 1;
453 $main::OO_SDK_JAVA_HOME = "";
456 }else
458 # the Java SDK is optional
459 $main::correctVersion = 1;
464 # prepare output directory (optional)
465 while ( (!$main::skipOutputDir) &&
466 (! -d "$main::OO_SDK_OUTPUT_DIR") )
468 print " Default output directory is in your HOME directory.\n";
469 print " Enter an existent directory if you prefer a different output directory (optional) [$main::OO_SDK_OUTPUT_DIR_SUGGESTION]: ";
471 $main::OO_SDK_OUTPUT_DIR = readStdIn();
473 chop($main::OO_SDK_OUTPUT_DIR);
474 if ( $main::OO_SDK_OUTPUT_DIR eq "" )
476 $main::OO_SDK_OUTPUT_DIR = $main::OO_SDK_OUTPUT_DIR_SUGGESTION;
478 if ( ! $main::OO_SDK_OUTPUT_DIR eq "" )
480 if ( ! -d "$main::OO_SDK_OUTPUT_DIR" )
482 print " Error: Could not find directory '$main::OO_SDK_OUTPUT_DIR'.\n";
483 if ( skipChoice("optional output directory") == 1 )
485 $main::skipOutputDir = 1;
487 $main::OO_SDK_OUTPUT_DIR = "";
489 } else
491 # the output directory is optional
492 $main::skipOutputDir = 1;
496 # prepare auto deployment
497 if ( $main::OFFICE_OR_URE eq "Office" )
499 while ( $main::SDK_AUTO_DEPLOYMENT eq "" ||
500 ((! $main::SDK_AUTO_DEPLOYMENT eq "YES") &&
501 (! $main::SDK_AUTO_DEPLOYMENT eq "NO")) )
503 print " Automatic deployment of UNO components (YES/NO) [$main::SDK_AUTO_DEPLOYMENT_SUGGESTION]: ";
504 $main::SDK_AUTO_DEPLOYMENT = uc <STDIN>;
505 chop($main::SDK_AUTO_DEPLOYMENT);
506 if ( $main::SDK_AUTO_DEPLOYMENT eq "" )
508 $main::SDK_AUTO_DEPLOYMENT = "YES";
512 else
514 $main::SDK_AUTO_DEPLOYMENT = "NO";
517 prepareScriptFile("setsdkenv_unix.sh.in", "setsdkenv_unix.sh", 1);
518 chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh";
520 prepareScriptFile("setsdkenv_unix.csh.in", "setsdkenv_unix.csh", 2);
521 chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.csh";
523 print "\n";
524 print " ************************************************************************\n";
525 print " * ... your SDK environment has been prepared.\n";
526 print " * For each time you want to use this configured SDK environment, you\n";
527 print " * have to run the \"setsdkenv_unix\" script file!\n";
528 print " * Alternatively can you source one of the scripts\n";
529 print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh\"\n";
530 print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.csh\"\n";
531 print " * to get an environment without starting a new shell.\n";
532 print " ************************************************************************\n\n";
534 exit $return;
536 sub skipChoice
538 my $msg = shift;
539 my $skip = "";
540 while ( !( $skip eq "yes" || $skip eq "no") )
542 print " Do you want to skip the choice of the '$msg' (YES/NO): [YES] ";
543 $skip = lc <STDIN>;
544 chop($skip);
545 if ( $skip eq "" ) { $skip = "yes"; } # default
546 if ( $skip eq "yes" )
548 return 1;
551 return 0;
554 sub resolveLink
556 my $base= shift;
557 my $link= shift;
559 my $resolvedpath = "$base/$link";
560 my $linktarget = readlink "$resolvedpath";
561 my $resolvedlink = "";
563 while ( $linktarget ne "") {
565 if ( $linktarget =~ m/^\/.*/ )
567 $resolvedpath = "$linktarget";
568 } else {
569 $resolvedpath = `cd $base/$linktarget; pwd`;
570 chop $resolvedpath;
572 $base = dirname("$resolvedpath");
574 $linktarget = readlink "$resolvedpath";
577 $resolvedlink = `cd $resolvedpath; pwd`;
578 chop $resolvedlink;
579 return $resolvedlink;
582 sub searchprog
584 my $_search= shift;
585 my $tmpPath = `echo "\$PATH"`;
586 my @pathList = split(":" , $tmpPath);
587 my $progDir = "";
589 if ( $_search eq "javac" )
591 if ( $main::operatingSystem =~ m/darwin/ ) {
592 $progDir = resolveLink("/System/Library/Frameworks/JavaVM.Framework/Versions", "CurrentJDK");
594 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
596 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR";
600 if ( $main::operatingSystem =~ m/solaris/ ) {
601 $progDir = resolveLink("/usr/jdk", "latest");
602 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
604 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR";
609 if ( $_search eq "gmake" && $main::operatingSystem =~ m/solaris/ ) {
610 if ( -e "/usr/sfw/bin/gmake" )
612 return "/usr/sfw/bin";
616 foreach $i (@pathList)
618 chomp ($i);
620 if ( -e "$i/$_search" )
623 if ( index($i, "/") == 0 )
625 # # absolute path; leave unchanged
626 $progDir = $i;
627 } else
629 $progDir = `cd "$i"; pwd`;
631 return $progDir
634 return $progDir
637 sub searchMacOffice
639 if (-d "/Applications/OpenOffice.org.app" ) {
640 return "/Applications/OpenOffice.org.app"
642 if (-d "/Applications/Oracle Open Office.app" ) {
643 return "/Applications/Oracle Open Office.app";
645 if (-d "/Applications/StarOffice.app" ) {
646 return "/Applications/StarOffice.app";
648 if (-d "/Applications/StarSuite.app" ) {
649 return "/Applications/StarSuite.app";
652 return "";
655 sub searchoffice
657 my $offset = rindex($main::sdkpath, "/openoffice.org");
658 my $tmpOffice = substr($main::sdkpath, 0, $offset);
659 my $officepath = "$tmpOffice/openoffice.org$main::OO_MAJORVERSION";
661 # if ( $main::OO_MINORVERSION > 0) {
662 # $officepath = "$officepath$main::OO_MINORVERSION";
665 # search corresponding office for this SDK
666 if (-d $officepath && -e "$officepath/program/soffice") {
667 return $officepath;
669 # fallback
670 my $tmpversion = $main::OO_MAJORVERSION;
671 # if ( $main::OO_MINORVERSION > 0) {
672 # $tmpversion = "$tmpversion.$main::OO_MINORVERSION";
675 $officepath = "$tmpOffice/oracle_open_office$tmpversion";
676 if (-d $officepath && -e "$officepath/program/soffice") {
677 return $officepath;
680 my $tmpversion = $main::OO_MAJORVERSION + 6;
681 if ( $main::OO_MINORVERSION > 0) {
682 $tmpversion = "$tmpversion.$main::OO_MINORVERSION";
685 $officepath = "$tmpOffice/staroffice$tmpversion";
686 if (-d $officepath && -e "$officepath/program/soffice") {
687 return $officepath;
689 $officepath = "$tmpOffice/StarOffice$tmpversion";
690 if (-d $officepath && -e "$officepath/program/soffice") {
691 return $officepath;
693 $officepath = "$tmpOffice/starsuite$tmpversion";
694 if (-d $officepath && -e "$officepath/program/soffice") {
695 return $officepath;
697 $officepath = "$tmpOffice/StarSuite$tmpversion";
698 if (-d $officepath && -e "$officepath/program/soffice") {
699 return $officepath;
701 $officepath = "";
703 # search other potential matching office versions
704 my $path = "/opt/";
705 my $entry = "";
706 my $version = "0";
707 for $entry (glob($path.'*')) {
708 ## if the file is a directory
709 if( -d $entry) {
711 if ($entry =~ m#(.+(o|O)ffice(\.org){0,1}(\d([\d\.]){0,2}))# ||
712 $entry =~ m#(.+(s|S)uite(.*)(\d([\d\.]){0,2}))# )
714 if ($4 > $version) {
715 $version = $4;
716 $officepath = $entry;
721 return $officepath;
726 sub testVersion
728 my $tmpMustBeVersion = shift;
729 my $tmpTestVersion = shift;
730 my $toolName = shift;
731 # 1=check + message 2=check only
732 my $checkOnly = shift;
733 my @mustBeVersion = split(/\.|_|-/,$tmpMustBeVersion);
734 my @testVersion = split(/\.|_|-/,$tmpTestVersion);
735 my $length = $#mustBeVersion;
737 if ($#testVersion < $#mustBeVersion) {
738 $length = $#testVersion;
741 for ($i=0; $i <= $length; $i++ )
743 if ( @testVersion->[$i] > @mustBeVersion->[$i] )
745 return 1; # 1 indicates a correct version
748 if ( @testVersion->[$i] < @mustBeVersion->[$i] )
750 if ( $#checkOnly == 1 ) {
751 print " The command '$toolName' has the version $tmpTestVersion.\n";
752 print " The SDK requires at least the version $tmpMustBeVersion.\n";
754 return 0;
758 return 1; # 1 indicates a correct version
761 sub readStdIn
763 my $tmpstdin = <STDIN>;
764 if ( index($tmpstdin, "\$") != -1)
766 return `echo $tmpstdin`;
769 return $tmpstdin;
772 sub prepareScriptFile()
774 my $inputFile = shift;
775 my $outputFile = shift;
776 # shell mode 1 = sh
777 # 2 = csh
778 my $shellMode = shift;
780 if ( ! -d "$main::OO_SDK_CONFIG_HOME/$main::hostname" )
782 system("mkdir -p $main::OO_SDK_CONFIG_HOME/$main::hostname");
785 open ( FILEIN, "$main::sdkpath/$inputFile" ) || die "\nERROR: could not open '$main::sdkpath/$inputFile' for reading";
786 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";
788 while ( <FILEIN> )
790 $_ =~ s#\@OO_SDK_NAME\@#$main::OO_SDK_NAME#go;
791 $_ =~ s#\@OO_SDK_HOME\@#$main::OO_SDK_HOME#go;
792 $_ =~ s#\@OFFICE_HOME\@#$main::OFFICE_HOME#go;
793 $_ =~ s#\@OFFICE_BASE_HOME\@#$main::OFFICE_BASE_HOME#go;
794 $_ =~ s#\@OO_SDK_URE_HOME\@#$main::OO_SDK_URE_HOME#go;
795 $_ =~ s#\@OO_SDK_MAKE_HOME\@#$main::OO_SDK_MAKE_HOME#go;
796 $_ =~ s#\@OO_SDK_ZIP_HOME\@#$main::OO_SDK_ZIP_HOME#go;
797 $_ =~ s#\@OO_SDK_CPP_HOME\@#$main::OO_SDK_CPP_HOME#go;
798 $_ =~ s#\@OO_SDK_CC_55_OR_HIGHER\@#$main::OO_SDK_CC_55_OR_HIGHER#go;
799 $_ =~ s#\@OO_SDK_JAVA_HOME\@#$main::OO_SDK_JAVA_HOME#go;
800 $_ =~ s#\@SDK_AUTO_DEPLOYMENT\@#$main::SDK_AUTO_DEPLOYMENT#go;
801 $_ =~ s#\@OO_SDK_OUTPUT_DIR\@#$main::OO_SDK_OUTPUT_DIR#go;
803 print FILEOUT $_;
806 close FILEIN;
807 close FILEOUT;