1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22# 23# configure.pl - a perl script to set a minimal environment for the SDK. 24# 25# Copyright 2000, 2010 Oracle and/or its affiliates. 26# 27 28use IO::File; 29use File::Basename; 30 31$main::hostname= $ARGV[0]; 32$main::sdkpath= $ARGV[1]; 33$main::OO_SDK_NAME= $ARGV[2]; 34 35$main::OO_MAJORVERSION=$main::OO_SDK_NAME; 36$main::OO_MINORVERSION=$main::OO_SDK_NAME; 37$main::OO_MAJORVERSION =~ s#[^\d]+(\d).(\d).+#$1#go; 38$main::OO_MINORVERSION =~ s#[^\d]+(\d).(\d).+#$2#go; 39 40$main::OO_SDK_CONFIG_HOME= "$ENV{HOME}/$main::OO_SDK_NAME"; 41 42$main::operatingSystem = `$main::sdkpath/config.guess | cut -d"-" -f3,4`; 43chomp ($main::operatingSystem); 44 45$main::OO_SDK_HOME = $main::sdkpath; 46#$main::OO_SDK_HOME = ""; 47$main::OO_SDK_HOME_SUGGESTION = $main::sdkpath; 48 49$main::OFFICE_OR_URE = "Office"; 50$main::OFFICE_OR_URE_SUGGESTION = "Office"; 51 52$main::OFFICE_HOME = ""; 53 54$main::OFFICE_BASE_HOME = substr($main::sdkpath, 0, rindex($main::sdkpath, "/sdk")); 55 56if ( $main::operatingSystem =~ m/darwin/ ) 57{ 58# $main::OO_SDK_URE_HOME = `cd $main::sdkpath/../ure-link && pwd`; 59} else { 60 $main::OO_SDK_URE_HOME = `cd $main::sdkpath/../ure-link && pwd`; 61} 62chomp($main::OO_SDK_URE_HOME); 63 64$main::OO_SDK_MAKE_HOME = ""; 65$main::makeName = "make"; 66if ( $main::operatingSystem =~ m/solaris/ || 67 $main::operatingSystem =~ m/freebsd/ ) 68{ 69 $main::makeName = "gmake"; 70} 71$main::OO_SDK_MAKE_HOME_SUGGESTION = searchprog($main::makeName); 72$main::makeVersion = "3.79.1"; 73$main::correctVersion = 0; 74 75$main::OO_SDK_ZIP_HOME = ""; 76$main::OO_SDK_ZIP_HOME_SUGGESTION = searchprog("zip"); 77$main::zipVersion = "2.3"; 78 79$main::OO_SDK_CAT_HOME = ""; 80$main::OO_SDK_CAT_HOME_SUGGESTION = searchprog("cat"); 81# TODO cat version 82# $main::catVersion = ""; 83 84$main::OO_SDK_SED_HOME = ""; 85$main::OO_SDK_SED_HOME_SUGGESTION = searchprog("sed"); 86# TODO sed version 87# $main::sedVersion = ""; 88 89$main::OO_SDK_CPP_HOME = ""; 90$main::cppName = "gcc"; 91$main::cppVersion = "4.0.1"; 92if ( $main::operatingSystem =~ m/solaris/ ) 93{ 94 $main::cppName = "CC"; 95 $main::cppVersion = "5.2"; 96} 97$main::OO_SDK_CC_55_OR_HIGHER = ""; 98$main::OO_SDK_CPP_HOME_SUGGESTION = searchprog($main::cppName); 99 100$main::OO_SDK_JAVA_HOME = ""; 101$main::OO_SDK_JAVA_BIN_DIR = "bin"; 102if ( $main::operatingSystem =~ m/darwin/ ) 103{ 104 $main::OO_SDK_JAVA_BIN_DIR="Commands"; 105} 106$main::OO_SDK_JAVA_HOME_SUGGESTION = searchprog("javac"); 107$main::javaVersion = "1.5.0_01"; 108 109$main::SDK_AUTO_DEPLOYMENT = ""; 110$main::SDK_AUTO_DEPLOYMENT_SUGGESTION = "YES"; 111 112$main::OO_SDK_OUTPUT_DIR_SUGGESTION = "$ENV{HOME}"; 113$main::OO_SDK_OUTPUT_DIR = ""; 114$main::skipOutputDir = 0; 115 116$main::return = 0; 117 118if ( $main::OFFICE_OR_URE eq "Office" ) 119{ 120 if ( $main::operatingSystem =~ m/darwin/ ) 121 { 122# used for a SDK as part of the office installation 123# $main::OFFICE_HOME = `cd $main::sdkpath/../../.. && pwd`; 124# chomp($main::OFFICE_HOME); 125# print " Used Office = $main::OFFICE_HOME\n"; 126 print " Used SDK = $main::OO_SDK_HOME\n\n"; 127 128 $main::OFFICE_HOME_SUGGESTION = searchMacOffice(); 129 while ( (! -d "$main::OFFICE_HOME" ) || 130 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/Contents/MacOS")) ) 131 { 132 print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: "; 133 $main::OFFICE_HOME = readStdIn(); 134 chop($main::OFFICE_HOME); 135 if ( $main::OFFICE_HOME eq "" ) 136 { 137 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION; 138 } 139 140 if ( ! -d "$main::OFFICE_HOME" ) 141 { 142 $main::OFFICE_HOME = ""; 143 print " Error: An office installation is required, please specify the path to a valid installation.\n"; 144 } 145 146 # check more details 147 if ( -d "$main::OFFICE_HOME/Contents/basis-link" ) { 148 $main::OFFICE_BASE_HOME = "$main::OFFICE_HOME/Contents/basis-link"; 149 if ( -d "$main::OFFICE_BASE_HOME/ure-link" ) { 150 $main::OO_SDK_URE_HOME = "$main::OFFICE_BASE_HOME/ure-link"; 151 } else { 152 $main::OFFICE_HOME = ""; 153 $main::OFFICE_BASE_HOME = ""; 154 $main::OO_SDK_URE_HOME = ""; 155 print " Error: no URE found in office installation, please specify the path to a valid installation.\n"; 156 } 157 } else { 158 $main::OFFICE_HOME = ""; 159 $main::OFFICE_BASE_HOME = ""; 160 $main::OO_SDK_URE_HOME = ""; 161 print " Error: no base layer found in office installation, please specify the path to a valid installation.\n"; 162 } 163 } 164 } else 165 { 166 $main::OFFICE_HOME_SUGGESTION = searchoffice(); 167 168 if ( $main::OFFICE_HOME_SUGGESTION eq "" ) { 169 # prepare Office path 170 $main::OFFICE_HOME_SUGGESTION = searchprog("soffice"); 171 } 172 173 if ( ! $main::OFFICE_HOME_SUGGESTION eq "" ) 174 { 175 my $tmpOffice = readlink "$main::OFFICE_HOME_SUGGESTION/soffice"; 176 177 if ( $tmpOffice eq "" ) 178 { 179 $tmpOffice = "$main::OFFICE_HOME_SUGGESTION/soffice"; 180 } 181 182 my $offset = rindex($tmpOffice, "/program/soffice"); 183 if ( $offset != -1 ) 184 { 185 $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset); 186 } else 187 { 188 $offset = rindex($tmpOffice, "/soffice"); 189 if ( $offset != -1 ) 190 { 191 $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset); 192 } else 193 { 194 $main::OFFICE_HOME_SUGGESTION = ""; 195 } 196 } 197 } 198 199 while ( (! -d "$main::OFFICE_HOME" ) || 200 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/program")) ) 201 { 202 print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: "; 203 $main::OFFICE_HOME = readStdIn(); 204 chop($main::OFFICE_HOME); 205 if ( $main::OFFICE_HOME eq "" ) 206 { 207 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION; 208 } 209 210 if ( ! -d "$main::OFFICE_HOME" ) 211 { 212 $main::OFFICE_HOME = ""; 213 print " Error: An office installation is required, please specify the path to a valid installation.\n"; 214 } else 215 { 216 # special work for a network installation, no prgram directory but a link to the soffice binary 217 if ( (! -d "$main::OFFICE_HOME/program") && (-e "$main::OFFICE_HOME/soffice") ) 218 { 219 my $soserver = `ls -l $OFFICE_HOME_SUGGESTION/soffice | sed -n 's/.* -> //p'`; 220 $soserver= substr($soserver, 0, rindex($soserver, "program") - 1); 221 222 if ( ! -d $soserver ) 223 { 224 $main::OFFICE_HOME = ""; 225 print " Error: An office installation is required, please specify the path to a valid installation.\n"; 226 } else 227 { 228 $main::OFFICE_HOME = $soserver; 229 } 230 } 231 } 232 } 233 } 234} 235else 236{ 237 # prepare URE path 238 $main::OO_SDK_URE_HOME_SUGGESTION = "/opt/openoffice/ure"; 239 $main::OO_SDK_URE_HOME_SUGGESTION = "" unless 240 -e "$main::OO_SDK_URE_HOME_SUGGESTION/bin/uno"; 241 for (;;) 242 { 243 print " Enter the URE installation directory", 244 " [$main::OO_SDK_URE_HOME_SUGGESTION]: "; 245 $main::OO_SDK_URE_HOME = readStdIn(); 246 chop $main::OO_SDK_URE_HOME; 247 $main::OO_SDK_URE_HOME = $main::OO_SDK_URE_HOME_SUGGESTION if 248 $main::OO_SDK_URE_HOME eq "" && 249 $main::OO_SDK_URE_HOME_SUGGESTION ne ""; 250 last if -e "$main::OO_SDK_URE_HOME/bin/uno"; 251 print " Error: A valid URE installation is required.\n"; 252 } 253} 254 255# prepare GNU make path 256while ( (!$main::correctVersion) && 257 ((! -d "$main::OO_SDK_MAKE_HOME" ) || 258 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName"))) ) 259{ 260 print " Enter GNU make ($main::makeVersion or higher) tools directory [$main::OO_SDK_MAKE_HOME_SUGGESTION]: "; 261 $main::OO_SDK_MAKE_HOME = readStdIn(); 262 chop($main::OO_SDK_MAKE_HOME); 263 if ( $main::OO_SDK_MAKE_HOME eq "" ) 264 { 265 $main::OO_SDK_MAKE_HOME = $main::OO_SDK_MAKE_HOME_SUGGESTION; 266 } 267 if ( (! -d "$main::OO_SDK_MAKE_HOME") || 268 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName")) ) 269 { 270 $main::OO_SDK_MAKE_HOME = ""; 271 print " Error: GNU make is required, please specify a GNU make tools directory.\n"; 272 } else 273 { 274 #check version 275 my $testVersion = `$OO_SDK_MAKE_HOME/$main::makeName --version`; 276 if ( $testVersion eq "") 277 { 278 print " Set the environment variable OO_SDK_MAKE_HOME to your GNU build tools directory.\n"; 279 print " GNU make version $main::makeVersion can be obtained at ftp://ftp.gnu.org/gnu/make/\n"; 280 } else 281 { 282 if ($testVersion =~ m#((\d+\.)+\d+)# ) 283 { 284 $testVersion = $1; 285 } 286 $main::correctVersion = testVersion($main::makeVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/$main::makeName", 1); 287 if ( !$main::correctVersion ) 288 { 289 print " The '$main::makeName' command found at '$main::OO_SDK_MAKE_HOME' has a wrong version\n"; 290 $main::OO_SDK_MAKE_HOME = ""; 291 } 292 } 293 } 294} 295 296# prepare zip path 297$main::correctVersion = 0; 298while ( (!$main::correctVersion) && 299 ((! -d "$main::OO_SDK_ZIP_HOME" ) || 300 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip"))) ) 301{ 302 print " Enter zip ($main::zipVersion or higher) tool directory [$main::OO_SDK_ZIP_HOME_SUGGESTION]: "; 303 $main::OO_SDK_ZIP_HOME = readStdIn(); 304 chop($main::OO_SDK_ZIP_HOME); 305 if ( $main::OO_SDK_ZIP_HOME eq "" ) 306 { 307 $main::OO_SDK_ZIP_HOME = $main::OO_SDK_ZIP_HOME_SUGGESTION; 308 } 309 if ( (! -d "$main::OO_SDK_ZIP_HOME") || 310 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip")) ) 311 { 312 $main::OO_SDK_ZIP_HOME = ""; 313 print " Error: zip tool is required, please specify a zip tool directory.\n"; 314 } else 315 { 316 #check version 317 my $testVersion = `$OO_SDK_ZIP_HOME/zip -h 2>&1 | egrep Zip | head -n 1`; 318 $testVersion =~ s#Zip ([\d.]+) .*#$1#go; 319 if ( $testVersion eq "") 320 { 321 print " Set the environment variable OO_SDK_ZIP_HOME to your zip tool directory.\n"; 322 print " zip version $main::zipVersion can be obtained at ftp://www.info-zip.org/\n"; 323 } else 324 { 325 if ($testVersion =~ m#((\d+\.)+\d+)# ) 326 { 327 $testVersion = $1; 328 } 329 $main::correctVersion = testVersion($main::zipVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/zip", 1); 330 if ( !$main::correctVersion ) 331 { 332 print " The 'zip' command found at '$main::OO_SDK_ZIP_HOME' has a wrong version\n"; 333 $main::OO_SDK_ZIP_HOME = ""; 334 } 335 } 336 } 337} 338 339# prepare cat path 340$main::correctVersion = 0; 341while ( (!$main::correctVersion) && 342 ((! -d "$main::OO_SDK_CAT_HOME" ) || 343 ((-d "$main::OO_SDK_CAT_HOME") && (! -e "$main::OO_SDK_CAT_HOME/cat"))) ) 344{ 345 print " Enter cat tool directory [$main::OO_SDK_CAT_HOME_SUGGESTION]: "; 346 $main::OO_SDK_CAT_HOME = readStdIn(); 347 chop($main::OO_SDK_CAT_HOME); 348 if ( $main::OO_SDK_CAT_HOME eq "" ) 349 { 350 $main::OO_SDK_CAT_HOME = $main::OO_SDK_CAT_HOME_SUGGESTION; 351 } 352 if ( (! -d "$main::OO_SDK_CAT_HOME") || 353 ((-d "$main::OO_SDK_CAT_HOME") && (! -e "$main::OO_SDK_CAT_HOME/cat")) ) 354 { 355 $main::OO_SDK_CAT_HOME = ""; 356 print " Error: cat tool is required, please specify a cat tool directory.\n"; 357 } 358 # else ... 359 # TODO check version 360 # NOTE: only Linux cat understands --version 361} 362 363# prepare sed path 364$main::correctVersion = 0; 365while ( (!$main::correctVersion) && 366 ((! -d "$main::OO_SDK_SED_HOME" ) || 367 ((-d "$main::OO_SDK_SED_HOME") && (! -e "$main::OO_SDK_SED_HOME/sed"))) ) 368{ 369 print " Enter sed tool directory [$main::OO_SDK_SED_HOME_SUGGESTION]: "; 370 $main::OO_SDK_SED_HOME = readStdIn(); 371 chop($main::OO_SDK_SED_HOME); 372 if ( $main::OO_SDK_SED_HOME eq "" ) 373 { 374 $main::OO_SDK_SED_HOME = $main::OO_SDK_SED_HOME_SUGGESTION; 375 } 376 if ( (! -d "$main::OO_SDK_SED_HOME") || 377 ((-d "$main::OO_SDK_SED_HOME") && (! -e "$main::OO_SDK_SED_HOME/sed")) ) 378 { 379 $main::OO_SDK_SED_HOME = ""; 380 print " Error: sed tool is required, please specify a sed tool directory.\n"; 381 } 382 # else ... 383 # TODO check version 384 # NOTE: only Linux sed understands --version 385} 386 387# prepare C++ compiler path 388$main::correctVersion = 0; 389while ( (!$main::correctVersion) && 390 ((! -d "$main::OO_SDK_CPP_HOME" ) || 391 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cpp"))) ) 392{ 393 print " C++ compilers where for example a language binding exist:\n"; 394 print " - Solaris, Sun WorkShop 6 update 1 C++ 5.2 2000/09/11 or higher\n"; 395 print " - Linux, GNU C++ compiler, gcc version 4.0.1 or higher\n"; 396 print " - MacOS, GNU C++ compiler, gcc version 4.0.1 or higher\n"; 397 print " Enter the directory of the C++ compiler, the directory\n"; 398 print " where the compiler is located (optional) [$main::OO_SDK_CPP_HOME_SUGGESTION]: "; 399 400 $main::OO_SDK_CPP_HOME = readStdIn(); 401 chop($main::OO_SDK_CPP_HOME); 402 if ( $main::OO_SDK_CPP_HOME eq "" ) 403 { 404 $main::OO_SDK_CPP_HOME = $main::OO_SDK_CPP_HOME_SUGGESTION; 405 } 406 407 if ( ! $main::OO_SDK_CPP_HOME eq "" ) 408 { 409 if ( (! -d "$main::OO_SDK_CPP_HOME") || 410 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cppName")) ) 411 { 412 print " Error: Could not find directory '$main::OO_SDK_CPP_HOME'.\n"; 413 if ( skipChoice("C++ compiler") == 1 ) 414 { 415 $main::correctVersion = 1; 416 } 417 $main::OO_SDK_CPP_HOME = ""; 418 } else 419 { 420 #check version 421 if ( $main::cppName eq "gcc" ) 422 { 423 my $testVersion = `$OO_SDK_CPP_HOME/$main::cppName -dumpversion`; 424 if ( $testVersion eq "") 425 { 426 print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a "; 427 print " GNU compiler.\nSet the environment variable OO_SDK_CPP_HOME to your GNU build tools "; 428 print " directory.\nA GNU compiler version $main::cppVersion can be obtained at "; 429 print " ftp://ftp.gnu.org/gnu/gcc/\n"; 430 } else 431 { 432 $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1); 433 if ( !$main::correctVersion ) 434 { 435 print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n"; 436 if ( skipChoice("C++ compiler") == 1 ) 437 { 438 $main::correctVersion = 1; 439 } 440 441 $main::OO_SDK_CPP_HOME = ""; 442 } 443 } 444 } else 445 { 446 # for Solaris we have to check the version too 447 open(FILE, "$OO_SDK_CPP_HOME/$main::cppName -V 2>&1 |"); 448 my @lines = <FILE>; 449 my $testVersion = $lines[0]; 450 if ( $testVersion eq "") 451 { 452 print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a "; 453 print " Solaris C++ compiler.\nSet the environment variable OO_SDK_CPP_HOME to your Solaris C++ compiler directory.\n"; 454 } else 455 { 456 if ($testVersion =~ m#((\d+\.)+\d+)# ) 457 { 458 $testVersion = $1; 459 } 460 $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1); 461 if ( !$main::correctVersion ) 462 { 463 print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n"; 464 if ( skipChoice("C++ compiler") == 1 ) 465 { 466 $main::correctVersion = 1; 467 } 468 469 $main::OO_SDK_CPP_HOME = ""; 470 } else { 471 $main::correctVersion = testVersion("5.5", $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 2); 472 if ( $main::correctVersion ) { 473 $main::OO_SDK_CC_55_OR_HIGHER = $testVersion; 474 } 475 } 476 } 477 } 478 } 479 } else 480 { 481 # the C++ compiler is optional 482 $main::correctVersion = 1; 483 } 484} 485 486 487# prepare Java path 488$main::correctVersion = 0; 489 490# prepare Java suggestion (cut bin or Commands directory to be in the root of the Java SDK) 491$main::offset = rindex($main::OO_SDK_JAVA_HOME_SUGGESTION, "/$main::OO_SDK_JAVA_BIN_DIR"); 492if ( $main::offset != -1 ) 493{ 494 $main::OO_SDK_JAVA_HOME_SUGGESTION = substr($main::OO_SDK_JAVA_HOME_SUGGESTION, 0, $main::offset); 495} 496 497while ( (!$main::correctVersion) && 498 ((! -d "$main::OO_SDK_JAVA_HOME" ) || 499 ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac"))) ) 500{ 501 print " Enter Java SDK (1.5, recommendation is 1.6 or higher) installation directory (optional) [$main::OO_SDK_JAVA_HOME_SUGGESTION]: "; 502 $main::OO_SDK_JAVA_HOME = readStdIn(); 503 chop($main::OO_SDK_JAVA_HOME); 504 if ( $main::OO_SDK_JAVA_HOME eq "" ) 505 { 506 $main::OO_SDK_JAVA_HOME = $main::OO_SDK_JAVA_HOME_SUGGESTION; 507 } 508 if ( ! $main::OO_SDK_JAVA_HOME eq "" ) 509 { 510 if ( (! -d "$main::OO_SDK_JAVA_HOME") || 511 ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac")) ) 512 { 513 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"; 514 if ( skipChoice("JAVA SDK") == 1 ) 515 { 516 $main::correctVersion = 1; 517 } 518 $main::OO_SDK_JAVA_HOME = ""; 519 } else 520 { 521 #check version 522 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#".*##'`; 523 $testVersion =~ s#([^\n]+)\n#$1#go; 524 525 $main::correctVersion = testVersion($main::javaVersion, $testVersion, "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/java", 1); 526 if ( !$main::correctVersion ) 527 { 528 if ( skipChoice("JAVA SDK") == 1 ) 529 { 530 $main::correctVersion = 1; 531 } 532 $main::OO_SDK_JAVA_HOME = ""; 533 } 534 } 535 }else 536 { 537 # the Java SDK is optional 538 $main::correctVersion = 1; 539 } 540} 541 542 543# prepare output directory (optional) 544while ( (!$main::skipOutputDir) && 545 (! -d "$main::OO_SDK_OUTPUT_DIR") ) 546{ 547 print " Default output directory is in your HOME directory.\n"; 548 print " Enter an existent directory if you prefer a different output directory (optional) [$main::OO_SDK_OUTPUT_DIR_SUGGESTION]: "; 549 550 $main::OO_SDK_OUTPUT_DIR = readStdIn(); 551 552 chop($main::OO_SDK_OUTPUT_DIR); 553 if ( $main::OO_SDK_OUTPUT_DIR eq "" ) 554 { 555 $main::OO_SDK_OUTPUT_DIR = $main::OO_SDK_OUTPUT_DIR_SUGGESTION; 556 } 557 if ( ! $main::OO_SDK_OUTPUT_DIR eq "" ) 558 { 559 if ( ! -d "$main::OO_SDK_OUTPUT_DIR" ) 560 { 561 print " Error: Could not find directory '$main::OO_SDK_OUTPUT_DIR'.\n"; 562 if ( skipChoice("optional output directory") == 1 ) 563 { 564 $main::skipOutputDir = 1; 565 } 566 $main::OO_SDK_OUTPUT_DIR = ""; 567 } 568 } else 569 { 570 # the output directory is optional 571 $main::skipOutputDir = 1; 572 } 573} 574 575# prepare auto deployment 576if ( $main::OFFICE_OR_URE eq "Office" ) 577{ 578 while ( $main::SDK_AUTO_DEPLOYMENT eq "" || 579 ((! $main::SDK_AUTO_DEPLOYMENT eq "YES") && 580 (! $main::SDK_AUTO_DEPLOYMENT eq "NO")) ) 581 { 582 print " Automatic deployment of UNO components (YES/NO) [$main::SDK_AUTO_DEPLOYMENT_SUGGESTION]: "; 583 $main::SDK_AUTO_DEPLOYMENT = uc <STDIN>; 584 chop($main::SDK_AUTO_DEPLOYMENT); 585 if ( $main::SDK_AUTO_DEPLOYMENT eq "" ) 586 { 587 $main::SDK_AUTO_DEPLOYMENT = "YES"; 588 } 589 } 590} 591else 592{ 593 $main::SDK_AUTO_DEPLOYMENT = "NO"; 594} 595 596prepareScriptFile("setsdkenv_unix.sh.in", "setsdkenv_unix.sh"); 597chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh"; 598 599print "\n"; 600print " ************************************************************************\n"; 601print " * ... your SDK environment has been prepared.\n"; 602print " * For each time you want to use this configured SDK environment, you\n"; 603print " * have to run the \"setsdkenv_unix\" script file!\n"; 604print " * Alternatively can you source one of the scripts\n"; 605print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh\"\n"; 606print " * to get an environment without starting a new shell.\n"; 607print " ************************************************************************\n\n"; 608 609exit $return; 610 611sub skipChoice 612{ 613 my $msg = shift; 614 my $skip = ""; 615 while ( !( $skip eq "yes" || $skip eq "no") ) 616 { 617 print " Do you want to skip the choice of the '$msg' (YES/NO): [YES] "; 618 $skip = lc <STDIN>; 619 chop($skip); 620 if ( $skip eq "" ) { $skip = "yes"; } # default 621 if ( $skip eq "yes" ) 622 { 623 return 1; 624 } 625 } 626 return 0; 627} 628 629sub resolveLink 630{ 631 my $base= shift; 632 my $link= shift; 633 634 my $resolvedpath = "$base/$link"; 635 my $linktarget = readlink "$resolvedpath"; 636 my $resolvedlink = ""; 637 638 while ( $linktarget ne "") { 639 640 if ( $linktarget =~ m/^\/.*/ ) 641 { 642 $resolvedpath = "$linktarget"; 643 } else { 644 $resolvedpath = `cd $base/$linktarget; pwd`; 645 chop $resolvedpath; 646 } 647 $base = dirname("$resolvedpath"); 648 649 $linktarget = readlink "$resolvedpath"; 650 } 651 652 $resolvedlink = `cd $resolvedpath; pwd`; 653 chop $resolvedlink; 654 return $resolvedlink; 655} 656 657sub searchprog 658{ 659 my $_search= shift; 660 my $tmpPath = `echo "\$PATH"`; 661 my @pathList = split(":" , $tmpPath); 662 my $progDir = ""; 663 664 if ( $_search eq "javac" ) 665 { 666 if ( $main::operatingSystem =~ m/darwin/ ) { 667 $progDir = resolveLink("/System/Library/Frameworks/JavaVM.Framework/Versions", "CurrentJDK"); 668 669 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" ) 670 { 671 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR"; 672 } 673 } 674 675 if ( $main::operatingSystem =~ m/solaris/ ) { 676 $progDir = resolveLink("/usr/jdk", "latest"); 677 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" ) 678 { 679 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR"; 680 } 681 } 682 } 683 684 if ( $_search eq "gmake" && $main::operatingSystem =~ m/solaris/ ) { 685 if ( -e "/usr/sfw/bin/gmake" ) 686 { 687 return "/usr/sfw/bin"; 688 } 689 } 690 691 foreach $i (@pathList) 692 { 693 chomp ($i); 694 695 if ( -e "$i/$_search" ) 696 { 697 698 if ( index($i, "/") == 0 ) 699 { 700 # # absolute path; leave unchanged 701 $progDir = $i; 702 } else 703 { 704 $progDir = `cd "$i"; pwd`; 705 } 706 return $progDir 707 } 708 } 709 return $progDir 710} 711 712sub searchMacOffice 713{ 714 if (-d "/Applications/OpenOffice.app" ) { 715 return "/Applications/OpenOffice.app" 716 } 717 if (-d "/Applications/OpenOffice.org.app" ) { 718 return "/Applications/OpenOffice.org.app" 719 } 720 if (-d "/Applications/Oracle Open Office.app" ) { 721 return "/Applications/Oracle Open Office.app"; 722 } 723 if (-d "/Applications/StarOffice.app" ) { 724 return "/Applications/StarOffice.app"; 725 } 726 if (-d "/Applications/StarSuite.app" ) { 727 return "/Applications/StarSuite.app"; 728 } 729 730 return ""; 731} 732 733sub searchoffice 734{ 735 my $offset = rindex($main::sdkpath, "/openoffice"); 736 my $tmpOffice = substr($main::sdkpath, 0, $offset); 737 my $officepath = "$tmpOffice/openoffice$main::OO_MAJORVERSION"; 738 739# if ( $main::OO_MINORVERSION > 0) { 740# $officepath = "$officepath$main::OO_MINORVERSION"; 741# } 742 743 # search corresponding office for this SDK 744 if (-d $officepath && -e "$officepath/program/soffice") { 745 return $officepath; 746 } 747 # fallback 748 my $tmpversion = $main::OO_MAJORVERSION; 749# if ( $main::OO_MINORVERSION > 0) { 750# $tmpversion = "$tmpversion.$main::OO_MINORVERSION"; 751# } 752 753 $officepath = "$tmpOffice/oracle_open_office$tmpversion"; 754 if (-d $officepath && -e "$officepath/program/soffice") { 755 return $officepath; 756 } 757 758 my $tmpversion = $main::OO_MAJORVERSION + 6; 759 if ( $main::OO_MINORVERSION > 0) { 760 $tmpversion = "$tmpversion.$main::OO_MINORVERSION"; 761 } 762 763 $officepath = "$tmpOffice/staroffice$tmpversion"; 764 if (-d $officepath && -e "$officepath/program/soffice") { 765 return $officepath; 766 } 767 $officepath = "$tmpOffice/StarOffice$tmpversion"; 768 if (-d $officepath && -e "$officepath/program/soffice") { 769 return $officepath; 770 } 771 $officepath = "$tmpOffice/starsuite$tmpversion"; 772 if (-d $officepath && -e "$officepath/program/soffice") { 773 return $officepath; 774 } 775 $officepath = "$tmpOffice/StarSuite$tmpversion"; 776 if (-d $officepath && -e "$officepath/program/soffice") { 777 return $officepath; 778 } 779 $officepath = ""; 780 781 # search other potential matching office versions 782 my $path = "/opt/"; 783 my $entry = ""; 784 my $version = "0"; 785 for $entry (glob($path.'*')) { 786 ## if the file is a directory 787 if( -d $entry) { 788 789 if ($entry =~ m#(.+(o|O)ffice(\.org){0,1}(\d([\d\.]){0,2}))# || 790 $entry =~ m#(.+(s|S)uite(.*)(\d([\d\.]){0,2}))# ) 791 { 792 if ($4 > $version) { 793 $version = $4; 794 $officepath = $entry; 795 } 796 } 797 } 798 } 799 return $officepath; 800} 801 802 803 804sub testVersion 805{ 806 my $tmpMustBeVersion = shift; 807 my $tmpTestVersion = shift; 808 my $toolName = shift; 809 # 1=check + message 2=check only 810 my $checkOnly = shift; 811 my @mustBeVersion = split(/\.|_|-/,$tmpMustBeVersion); 812 my @testVersion = split(/\.|_|-/,$tmpTestVersion); 813 my $length = $#mustBeVersion; 814 815 if ($#testVersion < $#mustBeVersion) { 816 $length = $#testVersion; 817 } 818 819 for ($i=0; $i <= $length; $i++ ) 820 { 821 if ( @testVersion[$i] > @mustBeVersion[$i] ) 822 { 823 return 1; # 1 indicates a correct version 824 } 825 826 if ( @testVersion[$i] < @mustBeVersion[$i] ) 827 { 828 if ( $#checkOnly == 1 ) { 829 print " The command '$toolName' has the version $tmpTestVersion.\n"; 830 print " The SDK requires at least the version $tmpMustBeVersion.\n"; 831 } 832 return 0; 833 } 834 } 835 836 return 1; # 1 indicates a correct version 837} 838 839sub readStdIn 840{ 841 my $tmpstdin = <STDIN>; 842 if ( index($tmpstdin, "\$") != -1) 843 { 844 return `echo $tmpstdin`; 845 } 846 847 return $tmpstdin; 848} 849 850sub prepareScriptFile() 851{ 852 my $inputFile = shift; 853 my $outputFile = shift; 854 855 if ( ! -d "$main::OO_SDK_CONFIG_HOME/$main::hostname" ) 856 { 857 system("mkdir -p $main::OO_SDK_CONFIG_HOME/$main::hostname"); 858 } 859 860 open ( FILEIN, "$main::sdkpath/$inputFile" ) || die "\nERROR: could not open '$main::sdkpath/$inputFile' for reading"; 861 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"; 862 863 while ( <FILEIN> ) 864 { 865 $_ =~ s#\@OO_SDK_NAME\@#$main::OO_SDK_NAME#go; 866 $_ =~ s#\@OO_SDK_HOME\@#$main::OO_SDK_HOME#go; 867 $_ =~ s#\@OFFICE_HOME\@#$main::OFFICE_HOME#go; 868 $_ =~ s#\@OFFICE_BASE_HOME\@#$main::OFFICE_BASE_HOME#go; 869 $_ =~ s#\@OO_SDK_URE_HOME\@#$main::OO_SDK_URE_HOME#go; 870 $_ =~ s#\@OO_SDK_MAKE_HOME\@#$main::OO_SDK_MAKE_HOME#go; 871 $_ =~ s#\@OO_SDK_ZIP_HOME\@#$main::OO_SDK_ZIP_HOME#go; 872 $_ =~ s#\@OO_SDK_CAT_HOME\@#$main::OO_SDK_CAT_HOME#go; 873 $_ =~ s#\@OO_SDK_SED_HOME\@#$main::OO_SDK_SED_HOME#go; 874 $_ =~ s#\@OO_SDK_CPP_HOME\@#$main::OO_SDK_CPP_HOME#go; 875 $_ =~ s#\@OO_SDK_CC_55_OR_HIGHER\@#$main::OO_SDK_CC_55_OR_HIGHER#go; 876 $_ =~ s#\@OO_SDK_JAVA_HOME\@#$main::OO_SDK_JAVA_HOME#go; 877 $_ =~ s#\@SDK_AUTO_DEPLOYMENT\@#$main::SDK_AUTO_DEPLOYMENT#go; 878 $_ =~ s#\@OO_SDK_OUTPUT_DIR\@#$main::OO_SDK_OUTPUT_DIR#go; 879 880 print FILEOUT $_; 881 } 882 883 close FILEIN; 884 close FILEOUT; 885} 886