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