update credits
[LibreOffice.git] / odk / config / configure.pl
blob9a460c89066bfeb51a6c021a27de1e7785e22934
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 # configure.pl - a perl script to set a minimal environment for the SDK.
20 # Copyright 2000, 2010 Oracle and/or its affiliates.
23 use IO::File;
24 use File::Basename;
26 $main::hostname= $ARGV[0];
27 $main::sdkpath= $ARGV[1];
28 $main::OO_SDK_NAME= $ARGV[2];
30 $main::OO_MAJORVERSION=$main::OO_SDK_NAME;
31 $main::OO_MINORVERSION=$main::OO_SDK_NAME;
32 $main::OO_MAJORVERSION =~ s#[^\d]+(\d).(\d).+#$1#go;
33 $main::OO_MINORVERSION =~ s#[^\d]+(\d).(\d).+#$2#go;
35 $main::OO_SDK_CONFIG_HOME= "$ENV{HOME}/$main::OO_SDK_NAME";
37 $main::operatingSystem = `$main::sdkpath/config.guess | cut -d"-" -f3,4`;
38 chomp ($main::operatingSystem);
40 $main::OO_SDK_HOME = $main::sdkpath;
41 #$main::OO_SDK_HOME = "";
42 $main::OO_SDK_HOME_SUGGESTION = $main::sdkpath;
44 $main::OFFICE_OR_URE = "Office";
45 $main::OFFICE_OR_URE_SUGGESTION = "Office";
47 $main::OFFICE_HOME = "";
49 $main::OO_SDK_URE_HOME = `cd $main::sdkpath/../ure-link && pwd`;
50 chomp($main::OO_SDK_URE_HOME);
52 $main::OO_SDK_MAKE_HOME = "";
53 $main::makeName = "make";
54 if ( $main::operatingSystem =~ m/solaris/ ||
55 $main::operatingSystem =~ m/freebsd/ )
57 $main::makeName = "gmake";
59 $main::OO_SDK_MAKE_HOME_SUGGESTION = searchprog($main::makeName);
60 $main::makeVersion = "3.79.1";
61 $main::correctVersion = 0;
63 $main::OO_SDK_ZIP_HOME = "";
64 $main::OO_SDK_ZIP_HOME_SUGGESTION = searchprog("zip");
65 $main::zipVersion = "2.3";
67 $main::OO_SDK_CPP_HOME = "";
68 $main::cppName = "gcc";
69 $main::cppVersion = "4.0.1";
70 if ( $main::operatingSystem =~ m/solaris/ )
72 $main::cppName = "CC";
73 $main::cppVersion = "5.2";
75 $main::OO_SDK_CC_55_OR_HIGHER = "";
76 $main::OO_SDK_CPP_HOME_SUGGESTION = searchprog($main::cppName);
78 $main::OO_SDK_JAVA_HOME = "";
79 $main::OO_SDK_JAVA_BIN_DIR = "bin";
80 if ( $main::operatingSystem =~ m/darwin/ )
82 $main::OO_SDK_JAVA_BIN_DIR="Commands";
84 $main::OO_SDK_JAVA_HOME_SUGGESTION = searchprog("javac");
85 $main::javaVersion = "1.5.0_01";
87 $main::SDK_AUTO_DEPLOYMENT = "";
88 $main::SDK_AUTO_DEPLOYMENT_SUGGESTION = "YES";
90 $main::OO_SDK_OUTPUT_DIR_SUGGESTION = "$ENV{HOME}";
91 $main::OO_SDK_OUTPUT_DIR = "";
92 $main::skipOutputDir = 0;
94 $main::return = 0;
96 if ( $main::OFFICE_OR_URE eq "Office" )
98 if ( $main::operatingSystem =~ m/darwin/ )
100 # used for a SDK as part of the office installation
101 # $main::OFFICE_HOME = `cd $main::sdkpath/../../.. && pwd`;
102 # chomp($main::OFFICE_HOME);
103 # print " Used Office = $main::OFFICE_HOME\n";
104 print " Used SDK = $main::OO_SDK_HOME\n\n";
106 $main::OFFICE_HOME_SUGGESTION = searchMacOffice();
107 while ( (! -d "$main::OFFICE_HOME" ) ||
108 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/Contents/MacOS")) )
110 print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: ";
111 $main::OFFICE_HOME = readStdIn();
112 chop($main::OFFICE_HOME);
113 if ( $main::OFFICE_HOME eq "" )
115 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION;
118 if ( ! -d "$main::OFFICE_HOME" )
120 $main::OFFICE_HOME = "";
121 print " Error: An office installation is required, please specify the path to a valid installation.\n";
124 # check more details
125 if ( -d "$main::OFFICE_HOME/Contents/ure-link" ) {
126 $main::OO_SDK_URE_HOME = "$main::OFFICE_HOME/Contents/ure-link";
127 } else {
128 $main::OFFICE_HOME = "";
129 $main::OO_SDK_URE_HOME = "";
130 print " Error: no URE 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");
518 chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh";
520 print "\n";
521 print " ************************************************************************\n";
522 print " * ... your SDK environment has been prepared.\n";
523 print " * For each time you want to use this configured SDK environment, you\n";
524 print " * have to run the \"setsdkenv_unix\" script file!\n";
525 print " * Alternatively can you source one of the scripts\n";
526 print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh\"\n";
527 print " * to get an environment without starting a new shell.\n";
528 print " ************************************************************************\n\n";
530 exit $return;
532 sub skipChoice
534 my $msg = shift;
535 my $skip = "";
536 while ( !( $skip eq "yes" || $skip eq "no") )
538 print " Do you want to skip the choice of the '$msg' (YES/NO): [YES] ";
539 $skip = lc <STDIN>;
540 chop($skip);
541 if ( $skip eq "" ) { $skip = "yes"; } # default
542 if ( $skip eq "yes" )
544 return 1;
547 return 0;
550 sub resolveLink
552 my $base= shift;
553 my $link= shift;
555 my $resolvedpath = "$base/$link";
556 my $linktarget = readlink "$resolvedpath";
557 my $resolvedlink = "";
559 while ( $linktarget ne "") {
561 if ( $linktarget =~ m/^\/.*/ )
563 $resolvedpath = "$linktarget";
564 } else {
565 $resolvedpath = `cd $base/$linktarget; pwd`;
566 chop $resolvedpath;
568 $base = dirname("$resolvedpath");
570 $linktarget = readlink "$resolvedpath";
573 $resolvedlink = `cd $resolvedpath; pwd`;
574 chop $resolvedlink;
575 return $resolvedlink;
578 sub searchprog
580 my $_search= shift;
581 my $tmpPath = `echo "\$PATH"`;
582 my @pathList = split(":" , $tmpPath);
583 my $progDir = "";
585 if ( $_search eq "javac" )
587 if ( $main::operatingSystem =~ m/darwin/ ) {
588 $progDir = resolveLink("/System/Library/Frameworks/JavaVM.Framework/Versions", "CurrentJDK");
590 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
592 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR";
596 if ( $main::operatingSystem =~ m/solaris/ ) {
597 $progDir = resolveLink("/usr/jdk", "latest");
598 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
600 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR";
605 if ( $_search eq "gmake" && $main::operatingSystem =~ m/solaris/ ) {
606 if ( -e "/usr/sfw/bin/gmake" )
608 return "/usr/sfw/bin";
612 foreach $i (@pathList)
614 chomp ($i);
616 if ( -e "$i/$_search" )
619 if ( index($i, "/") == 0 )
621 # # absolute path; leave unchanged
622 $progDir = $i;
623 } else
625 $progDir = `cd "$i"; pwd`;
627 return $progDir
630 return $progDir
633 sub searchMacOffice
635 if (-d "/Applications/LibreOffice.app" ) {
636 return "/Applications/LibreOffice.app"
638 if (-d "/Applications/OpenOffice.org.app" ) {
639 return "/Applications/OpenOffice.org.app"
641 if (-d "/Applications/Oracle Open Office.app" ) {
642 return "/Applications/Oracle Open Office.app";
644 if (-d "/Applications/StarOffice.app" ) {
645 return "/Applications/StarOffice.app";
647 if (-d "/Applications/StarSuite.app" ) {
648 return "/Applications/StarSuite.app";
651 return "";
654 sub searchoffice
656 my $offset = rindex($main::sdkpath, "/libreoffice");
657 my $tmpOffice = substr($main::sdkpath, 0, $offset);
658 my $officepath = "$tmpOffice/libreoffice";
660 # if ( $main::OO_MINORVERSION > 0) {
661 # $officepath = "$officepath$main::OO_MINORVERSION";
664 # search corresponding office for this SDK
665 if (-d $officepath && -e "$officepath/program/soffice") {
666 return $officepath;
668 # fallback
669 my $tmpversion = $main::OO_MAJORVERSION;
670 # if ( $main::OO_MINORVERSION > 0) {
671 # $tmpversion = "$tmpversion.$main::OO_MINORVERSION";
674 $officepath = "$tmpOffice/oracle_open_office$tmpversion";
675 if (-d $officepath && -e "$officepath/program/soffice") {
676 return $officepath;
679 my $tmpversion = $main::OO_MAJORVERSION + 6;
680 if ( $main::OO_MINORVERSION > 0) {
681 $tmpversion = "$tmpversion.$main::OO_MINORVERSION";
684 $officepath = "$tmpOffice/staroffice$tmpversion";
685 if (-d $officepath && -e "$officepath/program/soffice") {
686 return $officepath;
688 $officepath = "$tmpOffice/StarOffice$tmpversion";
689 if (-d $officepath && -e "$officepath/program/soffice") {
690 return $officepath;
692 $officepath = "$tmpOffice/starsuite$tmpversion";
693 if (-d $officepath && -e "$officepath/program/soffice") {
694 return $officepath;
696 $officepath = "$tmpOffice/StarSuite$tmpversion";
697 if (-d $officepath && -e "$officepath/program/soffice") {
698 return $officepath;
700 $officepath = "";
702 # search other potential matching office versions
703 my $path = "/opt/";
704 my $entry = "";
705 my $version = "0";
706 for $entry (glob($path.'*')) {
707 ## if the file is a directory
708 if( -d $entry) {
710 if ($entry =~ m#(.+(o|O)ffice(\.org){0,1}(\d([\d\.]){0,2}))# ||
711 $entry =~ m#(.+(s|S)uite(.*)(\d([\d\.]){0,2}))# )
713 if ($4 > $version) {
714 $version = $4;
715 $officepath = $entry;
720 return $officepath;
725 sub testVersion
727 my $tmpMustBeVersion = shift;
728 my $tmpTestVersion = shift;
729 my $toolName = shift;
730 # 1=check + message 2=check only
731 my $checkOnly = shift;
732 my @mustBeVersion = split(/\.|_|-/,$tmpMustBeVersion);
733 my @testVersion = split(/\.|_|-/,$tmpTestVersion);
734 my $length = $#mustBeVersion;
736 if ($#testVersion < $#mustBeVersion) {
737 $length = $#testVersion;
740 for ($i=0; $i <= $length; $i++ )
742 if ( $testVersion[$i] > $mustBeVersion[$i] )
744 return 1; # 1 indicates a correct version
747 if ( $testVersion[$i] < $mustBeVersion[$i] )
749 if ( $#checkOnly == 1 ) {
750 print " The command '$toolName' has the version $tmpTestVersion.\n";
751 print " The SDK requires at least the version $tmpMustBeVersion.\n";
753 return 0;
757 return 1; # 1 indicates a correct version
760 sub readStdIn
762 my $tmpstdin = <STDIN>;
763 if ( index($tmpstdin, "\$") != -1)
765 return `echo $tmpstdin`;
768 return $tmpstdin;
771 sub prepareScriptFile()
773 my $inputFile = shift;
774 my $outputFile = shift;
776 if ( ! -d "$main::OO_SDK_CONFIG_HOME/$main::hostname" )
778 system("mkdir -p $main::OO_SDK_CONFIG_HOME/$main::hostname");
781 open ( FILEIN, "$main::sdkpath/$inputFile" ) || die "\nERROR: could not open '$main::sdkpath/$inputFile' for reading";
782 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";
784 while ( <FILEIN> )
786 $_ =~ s#\@OO_SDK_NAME\@#$main::OO_SDK_NAME#go;
787 $_ =~ s#\@OO_SDK_HOME\@#$main::OO_SDK_HOME#go;
788 $_ =~ s#\@OFFICE_HOME\@#$main::OFFICE_HOME#go;
789 $_ =~ s#\@OO_SDK_URE_HOME\@#$main::OO_SDK_URE_HOME#go;
790 $_ =~ s#\@OO_SDK_MAKE_HOME\@#$main::OO_SDK_MAKE_HOME#go;
791 $_ =~ s#\@OO_SDK_ZIP_HOME\@#$main::OO_SDK_ZIP_HOME#go;
792 $_ =~ s#\@OO_SDK_CPP_HOME\@#$main::OO_SDK_CPP_HOME#go;
793 $_ =~ s#\@OO_SDK_CC_55_OR_HIGHER\@#$main::OO_SDK_CC_55_OR_HIGHER#go;
794 $_ =~ s#\@OO_SDK_JAVA_HOME\@#$main::OO_SDK_JAVA_HOME#go;
795 $_ =~ s#\@SDK_AUTO_DEPLOYMENT\@#$main::SDK_AUTO_DEPLOYMENT#go;
796 $_ =~ s#\@OO_SDK_OUTPUT_DIR\@#$main::OO_SDK_OUTPUT_DIR#go;
798 print FILEOUT $_;
801 close FILEIN;
802 close FILEOUT;