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_SUGGESTION = $main::sdkpath; 47 48$main::OFFICE_HOME = ""; 49 50#$main::OFFICE_BASE_HOME = substr($main::sdkpath, 0, rindex($main::sdkpath, "/sdk")); 51 52$main::OO_SDK_MAKE_HOME = ""; 53$main::makeName = "make"; 54if ( $main::operatingSystem =~ m/solaris/ || 55 $main::operatingSystem =~ m/freebsd/ ) 56{ 57 $main::makeName = "gmake"; 58} 59$main::OO_SDK_MAKE_HOME_SUGGESTION = searchprog($main::makeName); 60$main::makeVersion = "3.79.1"; 61$main::correctVersion = 0; 62 63$main::OO_SDK_ZIP_HOME = ""; 64$main::OO_SDK_ZIP_HOME_SUGGESTION = searchprog("zip"); 65$main::zipVersion = "2.3"; 66 67$main::OO_SDK_CAT_HOME = ""; 68$main::OO_SDK_CAT_HOME_SUGGESTION = searchprog("cat"); 69# TODO cat version 70# $main::catVersion = ""; 71 72$main::OO_SDK_SED_HOME = ""; 73$main::OO_SDK_SED_HOME_SUGGESTION = searchprog("sed"); 74# TODO sed version 75# $main::sedVersion = ""; 76 77$main::OO_SDK_CPP_HOME = ""; 78$main::cppName = "gcc"; 79$main::cppVersion = "4.0.1"; 80if ( $main::operatingSystem =~ m/solaris/ ) 81{ 82 $main::cppName = "CC"; 83 $main::cppVersion = "5.2"; 84} 85$main::OO_SDK_CC_55_OR_HIGHER = ""; 86$main::OO_SDK_CPP_HOME_SUGGESTION = searchprog($main::cppName); 87 88$main::OO_SDK_JAVA_HOME = ""; 89$main::OO_SDK_JAVA_BIN_DIR = "bin"; 90if ( $main::operatingSystem =~ m/darwin/ ) 91{ 92 $main::OO_SDK_JAVA_BIN_DIR="Commands"; 93} 94$main::OO_SDK_JAVA_HOME_SUGGESTION = searchprog("javac"); 95$main::javaVersion = "1.5.0_01"; 96 97$main::SDK_AUTO_DEPLOYMENT = ""; 98$main::SDK_AUTO_DEPLOYMENT_SUGGESTION = "YES"; 99 100$main::OO_SDK_OUTPUT_DIR_SUGGESTION = "$ENV{HOME}"; 101$main::OO_SDK_OUTPUT_DIR = ""; 102$main::skipOutputDir = 0; 103 104$main::return = 0; 105 106if ( $main::operatingSystem =~ m/darwin/ ) 107{ 108# used for a SDK as part of the office installation 109# $main::OFFICE_HOME = `cd $main::sdkpath/../../.. && pwd`; 110# chomp($main::OFFICE_HOME); 111# print " Used Office = $main::OFFICE_HOME\n"; 112 print " Used SDK = $main::OO_SDK_HOME\n\n"; 113 114 $main::OFFICE_HOME_SUGGESTION = searchMacOffice(); 115 while ( (! -d "$main::OFFICE_HOME" ) || 116 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/Contents/MacOS")) ) 117 { 118 print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: "; 119 $main::OFFICE_HOME = readStdIn(); 120 chop($main::OFFICE_HOME); 121 if ( $main::OFFICE_HOME eq "" ) 122 { 123 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION; 124 } 125 126 if ( ! -d "$main::OFFICE_HOME" ) 127 { 128 $main::OFFICE_HOME = ""; 129 print " Error: An office installation is required, please specify the path to a valid installation.\n"; 130 } 131 132# $main::OFFICE_BASE_HOME = "$main::OFFICE_HOME/Contents"; 133 } 134} else 135{ 136 $main::OFFICE_HOME_SUGGESTION = searchoffice(); 137 138 if ( $main::OFFICE_HOME_SUGGESTION eq "" ) { 139 # prepare Office path 140 $main::OFFICE_HOME_SUGGESTION = searchprog("soffice"); 141 } 142 143 if ( ! $main::OFFICE_HOME_SUGGESTION eq "" ) 144 { 145 my $tmpOffice = readlink "$main::OFFICE_HOME_SUGGESTION/soffice"; 146 147 if ( $tmpOffice eq "" ) 148 { 149 $tmpOffice = "$main::OFFICE_HOME_SUGGESTION/soffice"; 150 } 151 152 my $offset = rindex($tmpOffice, "/program/soffice"); 153 if ( $offset != -1 ) 154 { 155 $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset); 156 } else 157 { 158 $offset = rindex($tmpOffice, "/soffice"); 159 if ( $offset != -1 ) 160 { 161 $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset); 162 } else 163 { 164 $main::OFFICE_HOME_SUGGESTION = ""; 165 } 166 } 167 } 168 169 while ( (! -d "$main::OFFICE_HOME" ) || 170 ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/program")) ) 171 { 172 print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: "; 173 $main::OFFICE_HOME = readStdIn(); 174 chop($main::OFFICE_HOME); 175 if ( $main::OFFICE_HOME eq "" ) 176 { 177 $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION; 178 } 179 180 if ( ! -d "$main::OFFICE_HOME" ) 181 { 182 $main::OFFICE_HOME = ""; 183 print " Error: An office installation is required, please specify the path to a valid installation.\n"; 184 } else 185 { 186 # special work for a network installation, no prgram directory but a link to the soffice binary 187 if ( (! -d "$main::OFFICE_HOME/program") && (-e "$main::OFFICE_HOME/soffice") ) 188 { 189 my $soserver = `ls -l $OFFICE_HOME_SUGGESTION/soffice | sed -n 's/.* -> //p'`; 190 $soserver= substr($soserver, 0, rindex($soserver, "program") - 1); 191 192 if ( ! -d $soserver ) 193 { 194 $main::OFFICE_HOME = ""; 195 print " Error: An office installation is required, please specify the path to a valid installation.\n"; 196 } else 197 { 198 $main::OFFICE_HOME = $soserver; 199 } 200 } 201 } 202 } 203} 204 205 206# prepare GNU make path 207while ( (!$main::correctVersion) && 208 ((! -d "$main::OO_SDK_MAKE_HOME" ) || 209 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName"))) ) 210{ 211 print " Enter GNU make ($main::makeVersion or higher) tools directory [$main::OO_SDK_MAKE_HOME_SUGGESTION]: "; 212 $main::OO_SDK_MAKE_HOME = readStdIn(); 213 chop($main::OO_SDK_MAKE_HOME); 214 if ( $main::OO_SDK_MAKE_HOME eq "" ) 215 { 216 $main::OO_SDK_MAKE_HOME = $main::OO_SDK_MAKE_HOME_SUGGESTION; 217 } 218 if ( (! -d "$main::OO_SDK_MAKE_HOME") || 219 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName")) ) 220 { 221 $main::OO_SDK_MAKE_HOME = ""; 222 print " Error: GNU make is required, please specify a GNU make tools directory.\n"; 223 } else 224 { 225 #check version 226 my $testVersion = `$OO_SDK_MAKE_HOME/$main::makeName --version`; 227 if ( $testVersion eq "") 228 { 229 print " Set the environment variable OO_SDK_MAKE_HOME to your GNU build tools directory.\n"; 230 print " GNU make version $main::makeVersion can be obtained at ftp://ftp.gnu.org/gnu/make/\n"; 231 } else 232 { 233 if ($testVersion =~ m#((\d+\.)+\d+)# ) 234 { 235 $testVersion = $1; 236 } 237 $main::correctVersion = testVersion($main::makeVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/$main::makeName", 1); 238 if ( !$main::correctVersion ) 239 { 240 print " The '$main::makeName' command found at '$main::OO_SDK_MAKE_HOME' has a wrong version\n"; 241 $main::OO_SDK_MAKE_HOME = ""; 242 } 243 } 244 } 245} 246 247# prepare zip path 248$main::correctVersion = 0; 249while ( (!$main::correctVersion) && 250 ((! -d "$main::OO_SDK_ZIP_HOME" ) || 251 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip"))) ) 252{ 253 print " Enter zip ($main::zipVersion or higher) tool directory [$main::OO_SDK_ZIP_HOME_SUGGESTION]: "; 254 $main::OO_SDK_ZIP_HOME = readStdIn(); 255 chop($main::OO_SDK_ZIP_HOME); 256 if ( $main::OO_SDK_ZIP_HOME eq "" ) 257 { 258 $main::OO_SDK_ZIP_HOME = $main::OO_SDK_ZIP_HOME_SUGGESTION; 259 } 260 if ( (! -d "$main::OO_SDK_ZIP_HOME") || 261 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip")) ) 262 { 263 $main::OO_SDK_ZIP_HOME = ""; 264 print " Error: zip tool is required, please specify a zip tool directory.\n"; 265 } else 266 { 267 #check version 268 my $testVersion = `$OO_SDK_ZIP_HOME/zip -h 2>&1 | egrep Zip | head -n 1`; 269 $testVersion =~ s#Zip ([\d.]+) .*#$1#go; 270 if ( $testVersion eq "") 271 { 272 print " Set the environment variable OO_SDK_ZIP_HOME to your zip tool directory.\n"; 273 print " zip version $main::zipVersion can be obtained at ftp://www.info-zip.org/\n"; 274 } else 275 { 276 if ($testVersion =~ m#((\d+\.)+\d+)# ) 277 { 278 $testVersion = $1; 279 } 280 $main::correctVersion = testVersion($main::zipVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/zip", 1); 281 if ( !$main::correctVersion ) 282 { 283 print " The 'zip' command found at '$main::OO_SDK_ZIP_HOME' has a wrong version\n"; 284 $main::OO_SDK_ZIP_HOME = ""; 285 } 286 } 287 } 288} 289 290# prepare cat path 291$main::correctVersion = 0; 292while ( (!$main::correctVersion) && 293 ((! -d "$main::OO_SDK_CAT_HOME" ) || 294 ((-d "$main::OO_SDK_CAT_HOME") && (! -e "$main::OO_SDK_CAT_HOME/cat"))) ) 295{ 296 print " Enter cat tool directory [$main::OO_SDK_CAT_HOME_SUGGESTION]: "; 297 $main::OO_SDK_CAT_HOME = readStdIn(); 298 chop($main::OO_SDK_CAT_HOME); 299 if ( $main::OO_SDK_CAT_HOME eq "" ) 300 { 301 $main::OO_SDK_CAT_HOME = $main::OO_SDK_CAT_HOME_SUGGESTION; 302 } 303 if ( (! -d "$main::OO_SDK_CAT_HOME") || 304 ((-d "$main::OO_SDK_CAT_HOME") && (! -e "$main::OO_SDK_CAT_HOME/cat")) ) 305 { 306 $main::OO_SDK_CAT_HOME = ""; 307 print " Error: cat tool is required, please specify a cat tool directory.\n"; 308 } 309 # else ... 310 # TODO check version 311 # NOTE: only Linux cat understands --version 312} 313 314# prepare sed path 315$main::correctVersion = 0; 316while ( (!$main::correctVersion) && 317 ((! -d "$main::OO_SDK_SED_HOME" ) || 318 ((-d "$main::OO_SDK_SED_HOME") && (! -e "$main::OO_SDK_SED_HOME/sed"))) ) 319{ 320 print " Enter sed tool directory [$main::OO_SDK_SED_HOME_SUGGESTION]: "; 321 $main::OO_SDK_SED_HOME = readStdIn(); 322 chop($main::OO_SDK_SED_HOME); 323 if ( $main::OO_SDK_SED_HOME eq "" ) 324 { 325 $main::OO_SDK_SED_HOME = $main::OO_SDK_SED_HOME_SUGGESTION; 326 } 327 if ( (! -d "$main::OO_SDK_SED_HOME") || 328 ((-d "$main::OO_SDK_SED_HOME") && (! -e "$main::OO_SDK_SED_HOME/sed")) ) 329 { 330 $main::OO_SDK_SED_HOME = ""; 331 print " Error: sed tool is required, please specify a sed tool directory.\n"; 332 } 333 # else ... 334 # TODO check version 335 # NOTE: only Linux sed understands --version 336} 337 338# prepare C++ compiler path 339$main::correctVersion = 0; 340while ( (!$main::correctVersion) && 341 ((! -d "$main::OO_SDK_CPP_HOME" ) || 342 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cpp"))) ) 343{ 344 print " C++ compilers where for example a language binding exist:\n"; 345 print " - Solaris, Sun WorkShop 6 update 1 C++ 5.2 2000/09/11 or higher\n"; 346 print " - Linux, GNU C++ compiler, gcc version 4.0.1 or higher\n"; 347 print " - MacOS, GNU C++ compiler, gcc version 4.0.1 or higher\n"; 348 print " Enter the directory of the C++ compiler, the directory\n"; 349 print " where the compiler is located (optional) [$main::OO_SDK_CPP_HOME_SUGGESTION]: "; 350 351 $main::OO_SDK_CPP_HOME = readStdIn(); 352 chop($main::OO_SDK_CPP_HOME); 353 if ( $main::OO_SDK_CPP_HOME eq "" ) 354 { 355 $main::OO_SDK_CPP_HOME = $main::OO_SDK_CPP_HOME_SUGGESTION; 356 } 357 358 if ( ! $main::OO_SDK_CPP_HOME eq "" ) 359 { 360 if ( (! -d "$main::OO_SDK_CPP_HOME") || 361 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cppName")) ) 362 { 363 print " Error: Could not find directory '$main::OO_SDK_CPP_HOME'.\n"; 364 if ( skipChoice("C++ compiler") == 1 ) 365 { 366 $main::correctVersion = 1; 367 } 368 $main::OO_SDK_CPP_HOME = ""; 369 } else 370 { 371 #check version 372 if ( $main::cppName eq "gcc" ) 373 { 374 my $testVersion = `$OO_SDK_CPP_HOME/$main::cppName -dumpversion`; 375 if ( $testVersion eq "") 376 { 377 print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a "; 378 print " GNU compiler.\nSet the environment variable OO_SDK_CPP_HOME to your GNU build tools "; 379 print " directory.\nA GNU compiler version $main::cppVersion can be obtained at "; 380 print " ftp://ftp.gnu.org/gnu/gcc/\n"; 381 } else 382 { 383 $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1); 384 if ( !$main::correctVersion ) 385 { 386 print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n"; 387 if ( skipChoice("C++ compiler") == 1 ) 388 { 389 $main::correctVersion = 1; 390 } 391 392 $main::OO_SDK_CPP_HOME = ""; 393 } 394 } 395 } else 396 { 397 # for Solaris we have to check the version too 398 open(FILE, "$OO_SDK_CPP_HOME/$main::cppName -V 2>&1 |"); 399 my @lines = <FILE>; 400 my $testVersion = $lines[0]; 401 if ( $testVersion eq "") 402 { 403 print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a "; 404 print " Solaris C++ compiler.\nSet the environment variable OO_SDK_CPP_HOME to your Solaris C++ compiler directory.\n"; 405 } else 406 { 407 if ($testVersion =~ m#((\d+\.)+\d+)# ) 408 { 409 $testVersion = $1; 410 } 411 $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1); 412 if ( !$main::correctVersion ) 413 { 414 print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n"; 415 if ( skipChoice("C++ compiler") == 1 ) 416 { 417 $main::correctVersion = 1; 418 } 419 420 $main::OO_SDK_CPP_HOME = ""; 421 } else { 422 $main::correctVersion = testVersion("5.5", $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 2); 423 if ( $main::correctVersion ) { 424 $main::OO_SDK_CC_55_OR_HIGHER = $testVersion; 425 } 426 } 427 } 428 } 429 } 430 } else 431 { 432 # the C++ compiler is optional 433 $main::correctVersion = 1; 434 } 435} 436 437 438# prepare Java path 439$main::correctVersion = 0; 440 441# prepare Java suggestion (cut bin or Commands directory to be in the root of the Java SDK) 442$main::offset = rindex($main::OO_SDK_JAVA_HOME_SUGGESTION, "/$main::OO_SDK_JAVA_BIN_DIR"); 443if ( $main::offset != -1 ) 444{ 445 $main::OO_SDK_JAVA_HOME_SUGGESTION = substr($main::OO_SDK_JAVA_HOME_SUGGESTION, 0, $main::offset); 446} 447 448while ( (!$main::correctVersion) && 449 ((! -d "$main::OO_SDK_JAVA_HOME" ) || 450 ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac"))) ) 451{ 452 print " Enter Java SDK (1.5, recommendation is 1.6 or higher) installation directory (optional) [$main::OO_SDK_JAVA_HOME_SUGGESTION]: "; 453 $main::OO_SDK_JAVA_HOME = readStdIn(); 454 chop($main::OO_SDK_JAVA_HOME); 455 if ( $main::OO_SDK_JAVA_HOME eq "" ) 456 { 457 $main::OO_SDK_JAVA_HOME = $main::OO_SDK_JAVA_HOME_SUGGESTION; 458 } 459 if ( ! $main::OO_SDK_JAVA_HOME eq "" ) 460 { 461 if ( (! -d "$main::OO_SDK_JAVA_HOME") || 462 ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac")) ) 463 { 464 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"; 465 if ( skipChoice("JAVA SDK") == 1 ) 466 { 467 $main::correctVersion = 1; 468 } 469 $main::OO_SDK_JAVA_HOME = ""; 470 } else 471 { 472 #check version 473 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#".*##'`; 474 $testVersion =~ s#([^\n]+)\n#$1#go; 475 476 $main::correctVersion = testVersion($main::javaVersion, $testVersion, "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/java", 1); 477 if ( !$main::correctVersion ) 478 { 479 if ( skipChoice("JAVA SDK") == 1 ) 480 { 481 $main::correctVersion = 1; 482 } 483 $main::OO_SDK_JAVA_HOME = ""; 484 } 485 } 486 }else 487 { 488 # the Java SDK is optional 489 $main::correctVersion = 1; 490 } 491} 492 493 494# prepare output directory (optional) 495while ( (!$main::skipOutputDir) && 496 (! -d "$main::OO_SDK_OUTPUT_DIR") ) 497{ 498 print " Default output directory is in your HOME directory.\n"; 499 print " Enter an existent directory if you prefer a different output directory (optional) [$main::OO_SDK_OUTPUT_DIR_SUGGESTION]: "; 500 501 $main::OO_SDK_OUTPUT_DIR = readStdIn(); 502 503 chop($main::OO_SDK_OUTPUT_DIR); 504 if ( $main::OO_SDK_OUTPUT_DIR eq "" ) 505 { 506 $main::OO_SDK_OUTPUT_DIR = $main::OO_SDK_OUTPUT_DIR_SUGGESTION; 507 } 508 if ( ! $main::OO_SDK_OUTPUT_DIR eq "" ) 509 { 510 if ( ! -d "$main::OO_SDK_OUTPUT_DIR" ) 511 { 512 print " Error: Could not find directory '$main::OO_SDK_OUTPUT_DIR'.\n"; 513 if ( skipChoice("optional output directory") == 1 ) 514 { 515 $main::skipOutputDir = 1; 516 } 517 $main::OO_SDK_OUTPUT_DIR = ""; 518 } 519 } else 520 { 521 # the output directory is optional 522 $main::skipOutputDir = 1; 523 } 524} 525 526# prepare auto deployment 527while ( $main::SDK_AUTO_DEPLOYMENT eq "" || 528 ((! $main::SDK_AUTO_DEPLOYMENT eq "YES") && 529 (! $main::SDK_AUTO_DEPLOYMENT eq "NO")) ) 530{ 531 print " Automatic deployment of UNO components (YES/NO) [$main::SDK_AUTO_DEPLOYMENT_SUGGESTION]: "; 532 $main::SDK_AUTO_DEPLOYMENT = uc <STDIN>; 533 chop($main::SDK_AUTO_DEPLOYMENT); 534 if ( $main::SDK_AUTO_DEPLOYMENT eq "" ) 535 { 536 $main::SDK_AUTO_DEPLOYMENT = "YES"; 537 } 538} 539 540prepareScriptFile("setsdkenv_unix.sh.in", "setsdkenv_unix.sh"); 541chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh"; 542 543print "\n"; 544print " ************************************************************************\n"; 545print " * ... your SDK environment has been prepared.\n"; 546print " * For each time you want to use this configured SDK environment, you\n"; 547print " * have to run the \"setsdkenv_unix\" script file!\n"; 548print " * Alternatively can you source one of the scripts\n"; 549print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh\"\n"; 550print " * to get an environment without starting a new shell.\n"; 551print " ************************************************************************\n\n"; 552 553exit $return; 554 555sub skipChoice 556{ 557 my $msg = shift; 558 my $skip = ""; 559 while ( !( $skip eq "yes" || $skip eq "no") ) 560 { 561 print " Do you want to skip the choice of the '$msg' (YES/NO): [YES] "; 562 $skip = lc <STDIN>; 563 chop($skip); 564 if ( $skip eq "" ) { $skip = "yes"; } # default 565 if ( $skip eq "yes" ) 566 { 567 return 1; 568 } 569 } 570 return 0; 571} 572 573sub resolveLink 574{ 575 my $base= shift; 576 my $link= shift; 577 578 my $resolvedpath = "$base/$link"; 579 my $linktarget = readlink "$resolvedpath"; 580 my $resolvedlink = ""; 581 582 while ( $linktarget ne "") { 583 584 if ( $linktarget =~ m/^\/.*/ ) 585 { 586 $resolvedpath = "$linktarget"; 587 } else { 588 $resolvedpath = `cd $base/$linktarget; pwd`; 589 chop $resolvedpath; 590 } 591 $base = dirname("$resolvedpath"); 592 593 $linktarget = readlink "$resolvedpath"; 594 } 595 596 $resolvedlink = `cd $resolvedpath; pwd`; 597 chop $resolvedlink; 598 return $resolvedlink; 599} 600 601sub searchprog 602{ 603 my $_search= shift; 604 my $tmpPath = `echo "\$PATH"`; 605 my @pathList = split(":" , $tmpPath); 606 my $progDir = ""; 607 608 if ( $_search eq "javac" ) 609 { 610 if ( $main::operatingSystem =~ m/darwin/ ) { 611 $progDir = resolveLink("/System/Library/Frameworks/JavaVM.Framework/Versions", "CurrentJDK"); 612 613 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" ) 614 { 615 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR"; 616 } 617 } 618 619 if ( $main::operatingSystem =~ m/solaris/ ) { 620 $progDir = resolveLink("/usr/jdk", "latest"); 621 if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" ) 622 { 623 return "$progDir/$main::OO_SDK_JAVA_BIN_DIR"; 624 } 625 } 626 } 627 628 if ( $_search eq "gmake" && $main::operatingSystem =~ m/solaris/ ) { 629 if ( -e "/usr/sfw/bin/gmake" ) 630 { 631 return "/usr/sfw/bin"; 632 } 633 } 634 635 foreach $i (@pathList) 636 { 637 chomp ($i); 638 639 if ( -e "$i/$_search" ) 640 { 641 642 if ( index($i, "/") == 0 ) 643 { 644 # # absolute path; leave unchanged 645 $progDir = $i; 646 } else 647 { 648 $progDir = `cd "$i"; pwd`; 649 } 650 return $progDir 651 } 652 } 653 return $progDir 654} 655 656sub searchMacOffice 657{ 658 if (-d "/Applications/OpenOffice.app" ) { 659 return "/Applications/OpenOffice.app" 660 } 661 return ""; 662} 663 664sub searchoffice 665{ 666 my $offset = rindex($main::sdkpath, "/openoffice"); 667 my $tmpOffice = substr($main::sdkpath, 0, $offset); 668 my $officepath = "$tmpOffice/openoffice$main::OO_MAJORVERSION"; 669 670# if ( $main::OO_MINORVERSION > 0) { 671# $officepath = "$officepath$main::OO_MINORVERSION"; 672# } 673 674 # search corresponding office for this SDK 675 if (-d $officepath && -e "$officepath/program/soffice") { 676 return $officepath; 677 } 678 return ""; 679} 680 681 682 683sub testVersion 684{ 685 my $tmpMustBeVersion = shift; 686 my $tmpTestVersion = shift; 687 my $toolName = shift; 688 # 1=check + message 2=check only 689 my $checkOnly = shift; 690 my @mustBeVersion = split(/\.|_|-/,$tmpMustBeVersion); 691 my @testVersion = split(/\.|_|-/,$tmpTestVersion); 692 my $length = $#mustBeVersion; 693 694 if ($#testVersion < $#mustBeVersion) { 695 $length = $#testVersion; 696 } 697 698 for ($i=0; $i <= $length; $i++ ) 699 { 700 if ( @testVersion[$i] > @mustBeVersion[$i] ) 701 { 702 return 1; # 1 indicates a correct version 703 } 704 705 if ( @testVersion[$i] < @mustBeVersion[$i] ) 706 { 707 if ( $#checkOnly == 1 ) { 708 print " The command '$toolName' has the version $tmpTestVersion.\n"; 709 print " The SDK requires at least the version $tmpMustBeVersion.\n"; 710 } 711 return 0; 712 } 713 } 714 715 return 1; # 1 indicates a correct version 716} 717 718sub readStdIn 719{ 720 my $tmpstdin = <STDIN>; 721 if ( index($tmpstdin, "\$") != -1) 722 { 723 return `echo $tmpstdin`; 724 } 725 726 return $tmpstdin; 727} 728 729sub prepareScriptFile() 730{ 731 my $inputFile = shift; 732 my $outputFile = shift; 733 734 if ( ! -d "$main::OO_SDK_CONFIG_HOME/$main::hostname" ) 735 { 736 system("mkdir -p $main::OO_SDK_CONFIG_HOME/$main::hostname"); 737 } 738 739 open ( FILEIN, "$main::sdkpath/$inputFile" ) || die "\nERROR: could not open '$main::sdkpath/$inputFile' for reading"; 740 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"; 741 742 while ( <FILEIN> ) 743 { 744 $_ =~ s#\@OO_SDK_NAME\@#$main::OO_SDK_NAME#go; 745 $_ =~ s#\@OO_SDK_HOME\@#$main::OO_SDK_HOME#go; 746 $_ =~ s#\@OFFICE_HOME\@#$main::OFFICE_HOME#go; 747# $_ =~ s#\@OFFICE_BASE_HOME\@#$main::OFFICE_BASE_HOME#go; 748 $_ =~ s#\@OO_SDK_MAKE_HOME\@#$main::OO_SDK_MAKE_HOME#go; 749 $_ =~ s#\@OO_SDK_ZIP_HOME\@#$main::OO_SDK_ZIP_HOME#go; 750 $_ =~ s#\@OO_SDK_CAT_HOME\@#$main::OO_SDK_CAT_HOME#go; 751 $_ =~ s#\@OO_SDK_SED_HOME\@#$main::OO_SDK_SED_HOME#go; 752 $_ =~ s#\@OO_SDK_CPP_HOME\@#$main::OO_SDK_CPP_HOME#go; 753 $_ =~ s#\@OO_SDK_CC_55_OR_HIGHER\@#$main::OO_SDK_CC_55_OR_HIGHER#go; 754 $_ =~ s#\@OO_SDK_JAVA_HOME\@#$main::OO_SDK_JAVA_HOME#go; 755 $_ =~ s#\@SDK_AUTO_DEPLOYMENT\@#$main::SDK_AUTO_DEPLOYMENT#go; 756 $_ =~ s#\@OO_SDK_OUTPUT_DIR\@#$main::OO_SDK_OUTPUT_DIR#go; 757 758 print FILEOUT $_; 759 } 760 761 close FILEIN; 762 close FILEOUT; 763} 764