1# 2# configure.pl - a perl script to set a minimal environment for the SDK. 3# 4# Copyright 2000, 2010 Oracle and/or its affiliates. 5# 6 7use IO::File; 8use File::Basename; 9 10$main::hostname= $ARGV[0]; 11$main::sdkpath= $ARGV[1]; 12$main::OO_SDK_NAME= $ARGV[2]; 13 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; 18 19$main::OO_SDK_CONFIG_HOME= "$ENV{HOME}/$main::OO_SDK_NAME"; 20 21$main::operatingSystem = `$main::sdkpath/config.guess | cut -d"-" -f3,4`; 22chomp ($main::operatingSystem); 23 24$main::OO_SDK_HOME = $main::sdkpath; 25#$main::OO_SDK_HOME = ""; 26$main::OO_SDK_HOME_SUGGESTION = $main::sdkpath; 27 28$main::OFFICE_OR_URE = "Office"; 29$main::OFFICE_OR_URE_SUGGESTION = "Office"; 30 31$main::OFFICE_HOME = ""; 32 33$main::OFFICE_BASE_HOME = substr($main::sdkpath, 0, rindex($main::sdkpath, "/sdk")); 34 35if ( $main::operatingSystem =~ m/darwin/ ) 36{ 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`; 40} 41chomp($main::OO_SDK_URE_HOME); 42 43$main::OO_SDK_MAKE_HOME = ""; 44$main::makeName = "make"; 45if ( $main::operatingSystem =~ m/solaris/ || 46 $main::operatingSystem =~ m/freebsd/ ) 47{ 48 $main::makeName = "gmake"; 49} 50$main::OO_SDK_MAKE_HOME_SUGGESTION = searchprog($main::makeName); 51$main::makeVersion = "3.79.1"; 52$main::correctVersion = 0; 53 54$main::OO_SDK_ZIP_HOME = ""; 55$main::OO_SDK_ZIP_HOME_SUGGESTION = searchprog("zip"); 56$main::zipVersion = "2.3"; 57 58$main::OO_SDK_CPP_HOME = ""; 59$main::cppName = "gcc"; 60$main::cppVersion = "4.0.1"; 61if ( $main::operatingSystem =~ m/solaris/ ) 62{ 63 $main::cppName = "CC"; 64 $main::cppVersion = "5.2"; 65} 66$main::OO_SDK_CC_55_OR_HIGHER = ""; 67$main::OO_SDK_CPP_HOME_SUGGESTION = searchprog($main::cppName); 68 69$main::OO_SDK_JAVA_HOME = ""; 70$main::OO_SDK_JAVA_BIN_DIR = "bin"; 71if ( $main::operatingSystem =~ m/darwin/ ) 72{ 73 $main::OO_SDK_JAVA_BIN_DIR="Commands"; 74} 75$main::OO_SDK_JAVA_HOME_SUGGESTION = searchprog("javac"); 76$main::javaVersion = "1.5.0_01"; 77 78$main::SDK_AUTO_DEPLOYMENT = ""; 79$main::SDK_AUTO_DEPLOYMENT_SUGGESTION = "YES"; 80 81$main::OO_SDK_OUTPUT_DIR_SUGGESTION = "$ENV{HOME}"; 82$main::OO_SDK_OUTPUT_DIR = ""; 83$main::skipOutputDir = 0; 84 85$main::return = 0; 86 87if ( $main::OFFICE_OR_URE eq "Office" ) 88{ 89 if ( $main::operatingSystem =~ m/darwin/ ) 90 { 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"; 96 97 $main::OFFICE_HOME_SUGGESTION = searchMacOffice(); 98 while ( (! -d "$main::OFFICE_HOME" ) || 99 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/Contents/MacOS")) ) 100 { 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 "" ) 105 { 106 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION; 107 } 108 109 if ( ! -d "$main::OFFICE_HOME" ) 110 { 111 $main::OFFICE_HOME = ""; 112 print " Error: An office installation is required, please specify the path to a valid installation.\n"; 113 } 114 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"; 125 } 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"; 131 } 132 } 133 } else 134 { 135 $main::OFFICE_HOME_SUGGESTION = searchoffice(); 136 137 if ( $main::OFFICE_HOME_SUGGESTION eq "" ) { 138 # prepare Office path 139 $main::OFFICE_HOME_SUGGESTION = searchprog("soffice"); 140 } 141 142 if ( ! $main::OFFICE_HOME_SUGGESTION eq "" ) 143 { 144 my $tmpOffice = readlink "$main::OFFICE_HOME_SUGGESTION/soffice"; 145 146 if ( $tmpOffice eq "" ) 147 { 148 $tmpOffice = "$main::OFFICE_HOME_SUGGESTION/soffice"; 149 } 150 151 my $offset = rindex($tmpOffice, "/program/soffice"); 152 if ( $offset != -1 ) 153 { 154 $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset); 155 } else 156 { 157 $offset = rindex($tmpOffice, "/soffice"); 158 if ( $offset != -1 ) 159 { 160 $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset); 161 } else 162 { 163 $main::OFFICE_HOME_SUGGESTION = ""; 164 } 165 } 166 } 167 168 while ( (! -d "$main::OFFICE_HOME" ) || 169 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/program")) ) 170 { 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 "" ) 175 { 176 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION; 177 } 178 179 if ( ! -d "$main::OFFICE_HOME" ) 180 { 181 $main::OFFICE_HOME = ""; 182 print " Error: An office installation is required, please specify the path to a valid installation.\n"; 183 } else 184 { 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") ) 187 { 188 my $soserver = `ls -l $OFFICE_HOME_SUGGESTION/soffice | sed -n 's/.* -> //p'`; 189 $soserver= substr($soserver, 0, rindex($soserver, "program") - 1); 190 191 if ( ! -d $soserver ) 192 { 193 $main::OFFICE_HOME = ""; 194 print " Error: An office installation is required, please specify the path to a valid installation.\n"; 195 } else 196 { 197 $main::OFFICE_HOME = $soserver; 198 } 199 } 200 } 201 } 202 } 203} 204else 205{ 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 (;;) 211 { 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"; 221 } 222} 223 224# prepare GNU make path 225while ( (!$main::correctVersion) && 226 ((! -d "$main::OO_SDK_MAKE_HOME" ) || 227 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName"))) ) 228{ 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 "" ) 233 { 234 $main::OO_SDK_MAKE_HOME = $main::OO_SDK_MAKE_HOME_SUGGESTION; 235 } 236 if ( (! -d "$main::OO_SDK_MAKE_HOME") || 237 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName")) ) 238 { 239 $main::OO_SDK_MAKE_HOME = ""; 240 print " Error: GNU make is required, please specify a GNU make tools directory.\n"; 241 } else 242 { 243 #check version 244 my $testVersion = `$OO_SDK_MAKE_HOME/$main::makeName --version`; 245 if ( $testVersion eq "") 246 { 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 250 { 251 if ($testVersion =~ m#((\d+\.)+\d+)# ) 252 { 253 $testVersion = $1; 254 } 255 $main::correctVersion = testVersion($main::makeVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/$main::makeName", 1); 256 if ( !$main::correctVersion ) 257 { 258 print " The '$main::makeName' command found at '$main::OO_SDK_MAKE_HOME' has a wrong version\n"; 259 $main::OO_SDK_MAKE_HOME = ""; 260 } 261 } 262 } 263} 264 265# prepare zip path 266$main::correctVersion = 0; 267while ( (!$main::correctVersion) && 268 ((! -d "$main::OO_SDK_ZIP_HOME" ) || 269 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip"))) ) 270{ 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 "" ) 275 { 276 $main::OO_SDK_ZIP_HOME = $main::OO_SDK_ZIP_HOME_SUGGESTION; 277 } 278 if ( (! -d "$main::OO_SDK_ZIP_HOME") || 279 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip")) ) 280 { 281 $main::OO_SDK_ZIP_HOME = ""; 282 print " Error: zip tool is required, please specify a zip tool directory.\n"; 283 } else 284 { 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 "") 289 { 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 293 { 294 if ($testVersion =~ m#((\d+\.)+\d+)# ) 295 { 296 $testVersion = $1; 297 } 298 $main::correctVersion = testVersion($main::zipVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/zip", 1); 299 if ( !$main::correctVersion ) 300 { 301 print " The 'zip' command found at '$main::OO_SDK_ZIP_HOME' has a wrong version\n"; 302 $main::OO_SDK_ZIP_HOME = ""; 303 } 304 } 305 } 306} 307 308# prepare C++ compiler path 309$main::correctVersion = 0; 310while ( (!$main::correctVersion) && 311 ((! -d "$main::OO_SDK_CPP_HOME" ) || 312 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cpp"))) ) 313{ 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]: "; 320 321 $main::OO_SDK_CPP_HOME = readStdIn(); 322 chop($main::OO_SDK_CPP_HOME); 323 if ( $main::OO_SDK_CPP_HOME eq "" ) 324 { 325 $main::OO_SDK_CPP_HOME = $main::OO_SDK_CPP_HOME_SUGGESTION; 326 } 327 328 if ( ! $main::OO_SDK_CPP_HOME eq "" ) 329 { 330 if ( (! -d "$main::OO_SDK_CPP_HOME") || 331 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cppName")) ) 332 { 333 print " Error: Could not find directory '$main::OO_SDK_CPP_HOME'.\n"; 334 if ( skipChoice("C++ compiler") == 1 ) 335 { 336 $main::correctVersion = 1; 337 } 338 $main::OO_SDK_CPP_HOME = ""; 339 } else 340 { 341 #check version 342 if ( $main::cppName eq "gcc" ) 343 { 344 my $testVersion = `$OO_SDK_CPP_HOME/$main::cppName -dumpversion`; 345 if ( $testVersion eq "") 346 { 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 352 { 353 $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1); 354 if ( !$main::correctVersion ) 355 { 356 print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n"; 357 if ( skipChoice("C++ compiler") == 1 ) 358 { 359 $main::correctVersion = 1; 360 } 361 362 $main::OO_SDK_CPP_HOME = ""; 363 } 364 } 365 } else 366 { 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 "") 372 { 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 376 { 377 if ($testVersion =~ m#((\d+\.)+\d+)# ) 378 { 379 $testVersion = $1; 380 } 381 $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1); 382 if ( !$main::correctVersion ) 383 { 384 print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n"; 385 if ( skipChoice("C++ compiler") == 1 ) 386 { 387 $main::correctVersion = 1; 388 } 389 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; 395 } 396 } 397 } 398 } 399 } 400 } else 401 { 402 # the C++ compiler is optional 403 $main::correctVersion = 1; 404 } 405} 406 407 408# prepare Java path 409$main::correctVersion = 0; 410 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"); 413if ( $main::offset != -1 ) 414{ 415 $main::OO_SDK_JAVA_HOME_SUGGESTION = substr($main::OO_SDK_JAVA_HOME_SUGGESTION, 0, $main::offset); 416} 417 418while ( (!$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"))) ) 421{ 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 "" ) 426 { 427 $main::OO_SDK_JAVA_HOME = $main::OO_SDK_JAVA_HOME_SUGGESTION; 428 } 429 if ( ! $main::OO_SDK_JAVA_HOME eq "" ) 430 { 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")) ) 433 { 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 ) 436 { 437 $main::correctVersion = 1; 438 } 439 $main::OO_SDK_JAVA_HOME = ""; 440 } else 441 { 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; 445 446 $main::correctVersion = testVersion($main::javaVersion, $testVersion, "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/java", 1); 447 if ( !$main::correctVersion ) 448 { 449 if ( skipChoice("JAVA SDK") == 1 ) 450 { 451 $main::correctVersion = 1; 452 } 453 $main::OO_SDK_JAVA_HOME = ""; 454 } 455 } 456 }else 457 { 458 # the Java SDK is optional 459 $main::correctVersion = 1; 460 } 461} 462 463 464# prepare output directory (optional) 465while ( (!$main::skipOutputDir) && 466 (! -d "$main::OO_SDK_OUTPUT_DIR") ) 467{ 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]: "; 470 471 $main::OO_SDK_OUTPUT_DIR = readStdIn(); 472 473 chop($main::OO_SDK_OUTPUT_DIR); 474 if ( $main::OO_SDK_OUTPUT_DIR eq "" ) 475 { 476 $main::OO_SDK_OUTPUT_DIR = $main::OO_SDK_OUTPUT_DIR_SUGGESTION; 477 } 478 if ( ! $main::OO_SDK_OUTPUT_DIR eq "" ) 479 { 480 if ( ! -d "$main::OO_SDK_OUTPUT_DIR" ) 481 { 482 print " Error: Could not find directory '$main::OO_SDK_OUTPUT_DIR'.\n"; 483 if ( skipChoice("optional output directory") == 1 ) 484 { 485 $main::skipOutputDir = 1; 486 } 487 $main::OO_SDK_OUTPUT_DIR = ""; 488 } 489 } else 490 { 491 # the output directory is optional 492 $main::skipOutputDir = 1; 493 } 494} 495 496# prepare auto deployment 497if ( $main::OFFICE_OR_URE eq "Office" ) 498{ 499 while ( $main::SDK_AUTO_DEPLOYMENT eq "" || 500 ((! $main::SDK_AUTO_DEPLOYMENT eq "YES") && 501 (! $main::SDK_AUTO_DEPLOYMENT eq "NO")) ) 502 { 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 "" ) 507 { 508 $main::SDK_AUTO_DEPLOYMENT = "YES"; 509 } 510 } 511} 512else 513{ 514 $main::SDK_AUTO_DEPLOYMENT = "NO"; 515} 516 517prepareScriptFile("setsdkenv_unix.sh.in", "setsdkenv_unix.sh", 1); 518chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh"; 519 520prepareScriptFile("setsdkenv_unix.csh.in", "setsdkenv_unix.csh", 2); 521chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.csh"; 522 523print "\n"; 524print " ************************************************************************\n"; 525print " * ... your SDK environment has been prepared.\n"; 526print " * For each time you want to use this configured SDK environment, you\n"; 527print " * have to run the \"setsdkenv_unix\" script file!\n"; 528print " * Alternatively can you source one of the scripts\n"; 529print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh\"\n"; 530print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.csh\"\n"; 531print " * to get an environment without starting a new shell.\n"; 532print " ************************************************************************\n\n"; 533 534exit $return; 535 536sub skipChoice 537{ 538 my $msg = shift; 539 my $skip = ""; 540 while ( !( $skip eq "yes" || $skip eq "no") ) 541 { 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" ) 547 { 548 return 1; 549 } 550 } 551 return 0; 552} 553 554sub resolveLink 555{ 556 my $base= shift; 557 my $link= shift; 558 559 my $resolvedpath = "$base/$link"; 560 my $linktarget = readlink "$resolvedpath"; 561 my $resolvedlink = ""; 562 563 while ( $linktarget ne "") { 564 565 if ( $linktarget =~ m/^\/.*/ ) 566 { 567 $resolvedpath = "$linktarget"; 568 } else { 569 $resolvedpath = `cd $base/$linktarget; pwd`; 570 chop $resolvedpath; 571 } 572 $base = dirname("$resolvedpath"); 573 574 $linktarget = readlink "$resolvedpath"; 575 } 576 577 $resolvedlink = `cd $resolvedpath; pwd`; 578 chop $resolvedlink; 579 return $resolvedlink; 580} 581 582sub searchprog 583{ 584 my $_search= shift; 585 my $tmpPath = `echo "\$PATH"`; 586 my @pathList = split(":" , $tmpPath); 587 my $progDir = ""; 588 589 if ( $_search eq "javac" ) 590 { 591 if ( $main::operatingSystem =~ m/darwin/ ) { 592 $progDir = resolveLink("/System/Library/Frameworks/JavaVM.Framework/Versions", "CurrentJDK"); 593 594 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" ) 595 { 596 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR"; 597 } 598 } 599 600 if ( $main::operatingSystem =~ m/solaris/ ) { 601 $progDir = resolveLink("/usr/jdk", "latest"); 602 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" ) 603 { 604 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR"; 605 } 606 } 607 } 608 609 if ( $_search eq "gmake" && $main::operatingSystem =~ m/solaris/ ) { 610 if ( -e "/usr/sfw/bin/gmake" ) 611 { 612 return "/usr/sfw/bin"; 613 } 614 } 615 616 foreach $i (@pathList) 617 { 618 chomp ($i); 619 620 if ( -e "$i/$_search" ) 621 { 622 623 if ( index($i, "/") == 0 ) 624 { 625 # # absolute path; leave unchanged 626 $progDir = $i; 627 } else 628 { 629 $progDir = `cd "$i"; pwd`; 630 } 631 return $progDir 632 } 633 } 634 return $progDir 635} 636 637sub searchMacOffice 638{ 639 if (-d "/Applications/OpenOffice.org.app" ) { 640 return "/Applications/OpenOffice.org.app" 641 } 642 if (-d "/Applications/Oracle Open Office.app" ) { 643 return "/Applications/Oracle Open Office.app"; 644 } 645 if (-d "/Applications/StarOffice.app" ) { 646 return "/Applications/StarOffice.app"; 647 } 648 if (-d "/Applications/StarSuite.app" ) { 649 return "/Applications/StarSuite.app"; 650 } 651 652 return ""; 653} 654 655sub searchoffice 656{ 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"; 660 661# if ( $main::OO_MINORVERSION > 0) { 662# $officepath = "$officepath$main::OO_MINORVERSION"; 663# } 664 665 # search corresponding office for this SDK 666 if (-d $officepath && -e "$officepath/program/soffice") { 667 return $officepath; 668 } 669 # fallback 670 my $tmpversion = $main::OO_MAJORVERSION; 671# if ( $main::OO_MINORVERSION > 0) { 672# $tmpversion = "$tmpversion.$main::OO_MINORVERSION"; 673# } 674 675 $officepath = "$tmpOffice/oracle_open_office$tmpversion"; 676 if (-d $officepath && -e "$officepath/program/soffice") { 677 return $officepath; 678 } 679 680 my $tmpversion = $main::OO_MAJORVERSION + 6; 681 if ( $main::OO_MINORVERSION > 0) { 682 $tmpversion = "$tmpversion.$main::OO_MINORVERSION"; 683 } 684 685 $officepath = "$tmpOffice/staroffice$tmpversion"; 686 if (-d $officepath && -e "$officepath/program/soffice") { 687 return $officepath; 688 } 689 $officepath = "$tmpOffice/StarOffice$tmpversion"; 690 if (-d $officepath && -e "$officepath/program/soffice") { 691 return $officepath; 692 } 693 $officepath = "$tmpOffice/starsuite$tmpversion"; 694 if (-d $officepath && -e "$officepath/program/soffice") { 695 return $officepath; 696 } 697 $officepath = "$tmpOffice/StarSuite$tmpversion"; 698 if (-d $officepath && -e "$officepath/program/soffice") { 699 return $officepath; 700 } 701 $officepath = ""; 702 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) { 710 711 if ($entry =~ m#(.+(o|O)ffice(\.org){0,1}(\d([\d\.]){0,2}))# || 712 $entry =~ m#(.+(s|S)uite(.*)(\d([\d\.]){0,2}))# ) 713 { 714 if ($4 > $version) { 715 $version = $4; 716 $officepath = $entry; 717 } 718 } 719 } 720 } 721 return $officepath; 722} 723 724 725 726sub testVersion 727{ 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; 736 737 if ($#testVersion < $#mustBeVersion) { 738 $length = $#testVersion; 739 } 740 741 for ($i=0; $i <= $length; $i++ ) 742 { 743 if ( @testVersion->[$i] > @mustBeVersion->[$i] ) 744 { 745 return 1; # 1 indicates a correct version 746 } 747 748 if ( @testVersion->[$i] < @mustBeVersion->[$i] ) 749 { 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"; 753 } 754 return 0; 755 } 756 } 757 758 return 1; # 1 indicates a correct version 759} 760 761sub readStdIn 762{ 763 my $tmpstdin = <STDIN>; 764 if ( index($tmpstdin, "\$") != -1) 765 { 766 return `echo $tmpstdin`; 767 } 768 769 return $tmpstdin; 770} 771 772sub prepareScriptFile() 773{ 774 my $inputFile = shift; 775 my $outputFile = shift; 776 # shell mode 1 = sh 777 # 2 = csh 778 my $shellMode = shift; 779 780 if ( ! -d "$main::OO_SDK_CONFIG_HOME/$main::hostname" ) 781 { 782 system("mkdir -p $main::OO_SDK_CONFIG_HOME/$main::hostname"); 783 } 784 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"; 787 788 while ( <FILEIN> ) 789 { 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; 802 803 print FILEOUT $_; 804 } 805 806 close FILEIN; 807 close FILEOUT; 808} 809