2003-04-17 03:37:10 -05:00
#
# configure.pl - a perl script to set a minimal environment for the SDK.
#
# Copyright (c) 2000 Sun Microsystems, Inc.
#
use IO::File ;
2008-07-11 08:13:21 -05:00
$ main:: hostname = $ ARGV [ 0 ] ;
$ main:: sdkpath = $ ARGV [ 1 ] ;
$ main:: OO_SDK_NAME = $ ARGV [ 2 ] ;
$ main:: OO_MAJORVERSION = $ main:: OO_SDK_NAME ;
$ main:: OO_MINORVERSION = $ main:: OO_SDK_NAME ;
$ main:: OO_MAJORVERSION =~ s #[^\d]+(\d).(\d).+#$1#go;
$ main:: OO_MINORVERSION =~ s #[^\d]+(\d).(\d).+#$2#go;
2005-11-09 02:28:37 -06:00
$ main:: OO_SDK_CONFIG_HOME = "$ENV{HOME}/$main::OO_SDK_NAME" ;
2005-03-29 05:03:00 -06:00
$ main:: operatingSystem = `$main::sdkpath/config.guess | cut -d"-" -f3,4` ;
2003-04-17 03:37:10 -05:00
chop ( $ main:: operatingSystem ) ;
2008-07-11 08:13:21 -05:00
$ main:: OO_SDK_HOME = $ main:: sdkpath ;
#$main::OO_SDK_HOME = "";
2005-03-29 05:03:00 -06:00
$ main:: OO_SDK_HOME_SUGGESTION = $ main:: sdkpath ;
2003-04-17 03:37:10 -05:00
2008-07-11 08:13:21 -05:00
$ main:: OFFICE_OR_URE = "Office" ;
2005-06-17 03:37:25 -05:00
$ main:: OFFICE_OR_URE_SUGGESTION = "Office" ;
2003-04-17 03:37:10 -05:00
$ main:: OFFICE_HOME = "" ;
2005-01-31 08:53:51 -06:00
2008-07-11 08:13:21 -05:00
$ main:: OFFICE_BASE_HOME = substr ( $ main:: sdkpath , 0 , rindex ( $ main:: sdkpath , "/sdk" ) ) ;
if ( $ main:: operatingSystem =~ m/darwin/ )
{
# $main::OO_SDK_URE_HOME = `cd $main::sdkpath/../ure-link && pwd`;
} else {
$ main:: OO_SDK_URE_HOME = `cd $main::sdkpath/../../ure && pwd` ;
}
2003-04-17 03:37:10 -05:00
$ main:: OO_SDK_MAKE_HOME = "" ;
2005-03-29 05:03:00 -06:00
$ main:: makeName = "make" ;
2008-07-11 08:13:21 -05:00
if ( $ main:: operatingSystem =~ m/freebsd/ )
2005-03-29 05:03:00 -06:00
{
$ main:: makeName = "gmake" ;
}
$ main:: OO_SDK_MAKE_HOME_SUGGESTION = searchprog ( $ main:: makeName ) ;
2003-04-17 03:37:10 -05:00
$ main:: makeVersion = "3.79.1" ;
$ main:: correctVersion = 0 ;
2005-01-31 08:53:51 -06:00
$ main:: OO_SDK_ZIP_HOME = "" ;
$ main:: OO_SDK_ZIP_HOME_SUGGESTION = searchprog ( "zip" ) ;
$ main:: zipVersion = "2.3" ;
2003-04-17 03:37:10 -05:00
$ main:: OO_SDK_CPP_HOME = "" ;
$ main:: cppName = "gcc" ;
$ main:: cppVersion = "3.0.1" ;
2005-03-07 10:30:04 -06:00
if ( $ main:: operatingSystem =~ m/solaris/ )
2003-04-17 03:37:10 -05:00
{
$ main:: cppName = "CC" ;
2003-07-09 04:36:22 -05:00
$ main:: cppVersion = "5.2" ;
2003-04-17 03:37:10 -05:00
}
2005-01-31 08:53:51 -06:00
$ main:: OO_SDK_CC_55_OR_HIGHER = "" ;
2003-04-17 03:37:10 -05:00
$ main:: OO_SDK_CPP_HOME_SUGGESTION = searchprog ( $ main:: cppName ) ;
$ main:: OO_SDK_JAVA_HOME = "" ;
2008-07-11 08:13:21 -05:00
$ main:: OO_SDK_JAVA_BIN_DIR = "bin" ;
if ( $ main:: operatingSystem =~ m/darwin/ )
{
$ main:: OO_SDK_JAVA_BIN_DIR = "Commands" ;
}
2003-04-17 03:37:10 -05:00
$ main:: OO_SDK_JAVA_HOME_SUGGESTION = searchprog ( "javac" ) ;
$ main:: javaVersion = "1.4.1_01" ;
$ main:: SDK_AUTO_DEPLOYMENT = "" ;
$ main:: SDK_AUTO_DEPLOYMENT_SUGGESTION = "YES" ;
2005-11-09 02:28:37 -06:00
$ main:: OO_SDK_OUTPUT_DIR_SUGGESTION = "$ENV{HOME}" ;
2004-05-18 07:17:41 -05:00
$ main:: OO_SDK_OUTPUT_DIR = "" ;
$ main:: skipOutputDir = 0 ;
2003-04-17 03:37:10 -05:00
$ main:: return = 0 ;
2008-07-11 08:13:21 -05:00
if ( $ main:: OFFICE_OR_URE eq "Office" )
2003-04-17 03:37:10 -05:00
{
2008-07-11 08:13:21 -05:00
if ( $ main:: operatingSystem =~ m/darwin/ )
2003-04-17 03:37:10 -05:00
{
2008-07-11 08:13:21 -05:00
# used for a SDK as part of the office installation
# $main::OFFICE_HOME = `cd $main::sdkpath/../../.. && pwd`;
# chop($main::OFFICE_HOME);
# print " Used Office = $main::OFFICE_HOME\n";
print " Used SDK = $main::OO_SDK_HOME\n\n" ;
$ main:: OFFICE_HOME_SUGGESTION = searchMacOffice ( ) ;
while ( ( ! - d "$main::OFFICE_HOME" ) ||
( ( - d "$main::OFFICE_HOME" ) && ( ! - d "$main::OFFICE_HOME/Contents/MacOS" ) ) )
{
print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: " ;
$ main:: OFFICE_HOME = readStdIn ( ) ;
chop ( $ main:: OFFICE_HOME ) ;
if ( $ main:: OFFICE_HOME eq "" )
{
$ main:: OFFICE_HOME = $ main:: OFFICE_HOME_SUGGESTION ;
}
2003-04-17 03:37:10 -05:00
2008-07-11 08:13:21 -05:00
if ( ! - d "$main::OFFICE_HOME" )
{
$ main:: OFFICE_HOME = "" ;
print " Error: An office installation is required, please specify the path to a valid installation.\n" ;
}
2003-04-17 03:37:10 -05:00
2008-07-11 08:13:21 -05:00
# check more details
if ( - d "$main::OFFICE_HOME/Contents/basis-link" ) {
$ main:: OFFICE_BASE_HOME = "$main::OFFICE_HOME/Contents/basis-link" ;
if ( - d "$main::OFFICE_BASE_HOME/ure-link" ) {
$ main:: OO_SDK_URE_HOME = "$main::OFFICE_BASE_HOME/ure-link" ;
} else {
$ main:: OFFICE_HOME = "" ;
$ main:: OFFICE_BASE_HOME = "" ;
$ main:: OO_SDK_URE_HOME = "" ;
print " Error: no URE found in office installation, please specify the path to a valid installation.\n" ;
}
} else {
$ main:: OFFICE_HOME = "" ;
$ main:: OFFICE_BASE_HOME = "" ;
$ main:: OO_SDK_URE_HOME = "" ;
print " Error: no base layer found in office installation, please specify the path to a valid installation.\n" ;
}
}
} else
2003-04-17 03:37:10 -05:00
{
2008-07-11 08:13:21 -05:00
$ main:: OFFICE_HOME_SUGGESTION = searchoffice ( ) ;
2005-06-17 03:37:25 -05:00
2008-07-11 08:13:21 -05:00
if ( $ main:: OFFICE_HOME_SUGGESTION eq "" ) {
# prepare Office path
$ main:: OFFICE_HOME_SUGGESTION = searchprog ( "soffice" ) ;
2005-06-17 03:37:25 -05:00
}
2003-04-17 03:37:10 -05:00
2008-07-11 08:13:21 -05:00
if ( ! $ main:: OFFICE_HOME_SUGGESTION eq "" )
2005-06-17 03:37:25 -05:00
{
2008-07-11 08:13:21 -05:00
my $ tmpOffice = readlink "$main::OFFICE_HOME_SUGGESTION/soffice" ;
if ( $ tmpOffice eq "" )
{
$ tmpOffice = "$main::OFFICE_HOME_SUGGESTION/soffice" ;
}
my $ offset = rindex ( $ tmpOffice , "/program/soffice" ) ;
2005-06-17 03:37:25 -05:00
if ( $ offset != - 1 )
2003-04-17 03:37:10 -05:00
{
2005-06-17 03:37:25 -05:00
$ main:: OFFICE_HOME_SUGGESTION = substr ( $ tmpOffice , 0 , $ offset ) ;
2003-04-17 03:37:10 -05:00
} else
{
2008-07-11 08:13:21 -05:00
$ offset = rindex ( $ tmpOffice , "/soffice" ) ;
if ( $ offset != - 1 )
{
$ main:: OFFICE_HOME_SUGGESTION = substr ( $ tmpOffice , 0 , $ offset ) ;
} else
{
$ main:: OFFICE_HOME_SUGGESTION = "" ;
}
2005-06-17 03:37:25 -05:00
}
}
2008-07-11 08:13:21 -05:00
while ( ( ! - d "$main::OFFICE_HOME" ) ||
( ( - d "$main::OFFICE_HOME" ) && ( ! - d "$main::OFFICE_HOME/program" ) ) )
2005-06-17 03:37:25 -05:00
{
2008-07-11 08:13:21 -05:00
print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: " ;
$ main:: OFFICE_HOME = readStdIn ( ) ;
chop ( $ main:: OFFICE_HOME ) ;
if ( $ main:: OFFICE_HOME eq "" )
2005-06-17 03:37:25 -05:00
{
2008-07-11 08:13:21 -05:00
$ main:: OFFICE_HOME = $ main:: OFFICE_HOME_SUGGESTION ;
}
2005-06-17 03:37:25 -05:00
2008-07-11 08:13:21 -05:00
if ( ! - d "$main::OFFICE_HOME" )
{
$ main:: OFFICE_HOME = "" ;
print " Error: An office installation is required, please specify the path to a valid installation.\n" ;
} else
{
# special work for a network installation, no prgram directory but a link to the soffice binary
if ( ( ! - d "$main::OFFICE_HOME/program" ) && ( - e "$main::OFFICE_HOME/soffice" ) )
2005-06-17 03:37:25 -05:00
{
2008-07-11 08:13:21 -05:00
my $ soserver = `ls -l $OFFICE_HOME_SUGGESTION/soffice | sed -n 's/.* -> //p'` ;
$ soserver = substr ( $ soserver , 0 , rindex ( $ soserver , "program" ) - 1 ) ;
if ( ! - d $ soserver )
{
$ main:: OFFICE_HOME = "" ;
print " Error: An office installation is required, please specify the path to a valid installation.\n" ;
} else
{
$ main:: OFFICE_HOME = $ soserver ;
}
2005-06-17 03:37:25 -05:00
}
2003-04-17 03:37:10 -05:00
}
}
}
}
2005-06-17 03:37:25 -05:00
else
{
# prepare URE path
$ main:: OO_SDK_URE_HOME_SUGGESTION = "/opt/openoffice.org/ure" ;
$ main:: OO_SDK_URE_HOME_SUGGESTION = "" unless
- e "$main::OO_SDK_URE_HOME_SUGGESTION/bin/uno" ;
for ( ; ; )
{
print " Enter the URE installation directory" ,
" [$main::OO_SDK_URE_HOME_SUGGESTION]: " ;
$ main:: OO_SDK_URE_HOME = readStdIn ( ) ;
chop $ main:: OO_SDK_URE_HOME ;
$ main:: OO_SDK_URE_HOME = $ main:: OO_SDK_URE_HOME_SUGGESTION if
$ main:: OO_SDK_URE_HOME eq "" &&
$ main:: OO_SDK_URE_HOME_SUGGESTION ne "" ;
last if - e "$main::OO_SDK_URE_HOME/bin/uno" ;
print " Error: A valid URE installation is required.\n" ;
}
}
2003-04-17 03:37:10 -05:00
# prepare GNU make path
while ( ( ! $ main:: correctVersion ) &&
2003-07-09 04:36:22 -05:00
( ( ! - d "$main::OO_SDK_MAKE_HOME" ) ||
2005-03-29 05:03:00 -06:00
( ( - d "$main::OO_SDK_MAKE_HOME" ) && ( ! - e "$main::OO_SDK_MAKE_HOME/$main::makeName" ) ) ) )
2003-04-17 03:37:10 -05:00
{
2004-05-18 07:17:41 -05:00
print " Enter GNU make ($main::makeVersion or higher) tools directory [$main::OO_SDK_MAKE_HOME_SUGGESTION]: " ;
$ main:: OO_SDK_MAKE_HOME = readStdIn ( ) ;
2003-04-17 03:37:10 -05:00
chop ( $ main:: OO_SDK_MAKE_HOME ) ;
if ( $ main:: OO_SDK_MAKE_HOME eq "" )
{
$ main:: OO_SDK_MAKE_HOME = $ main:: OO_SDK_MAKE_HOME_SUGGESTION ;
}
if ( ( ! - d "$main::OO_SDK_MAKE_HOME" ) ||
2005-03-29 05:03:00 -06:00
( ( - d "$main::OO_SDK_MAKE_HOME" ) && ( ! - e "$main::OO_SDK_MAKE_HOME/$main::makeName" ) ) )
2003-04-17 03:37:10 -05:00
{
$ main:: OO_SDK_MAKE_HOME = "" ;
2004-05-18 07:17:41 -05:00
print " Error: GNU make is required, please specify a GNU make tools directory.\n" ;
2003-04-17 03:37:10 -05:00
} else
{
#check version
2005-03-29 05:03:00 -06:00
my $ testVersion = `$OO_SDK_MAKE_HOME/$main::makeName --version` ;
2003-04-17 03:37:10 -05:00
if ( $ testVersion eq "" )
{
2004-05-18 07:17:41 -05:00
print " Set the environment variable OO_SDK_MAKE_HOME to your GNU build tools directory.\n" ;
print " GNU make version $main::makeVersion can be obtained at ftp://ftp.gnu.org/gnu/make/\n" ;
2003-04-17 03:37:10 -05:00
} else
{
2003-07-09 04:36:22 -05:00
if ( $ testVersion =~ m #((\d+\.)+\d+)# )
{
$ testVersion = $ 1 ;
}
2005-03-29 05:03:00 -06:00
$ main:: correctVersion = testVersion ( $ main:: makeVersion , $ testVersion , "$main::OO_SDK_MAKE_HOME/$main::makeName" , 1 ) ;
2003-04-17 03:37:10 -05:00
if ( ! $ main:: correctVersion )
{
2005-03-29 05:03:00 -06:00
print " The '$main::makeName' command found at '$main::OO_SDK_MAKE_HOME' has a wrong version\n" ;
2003-04-17 03:37:10 -05:00
$ main:: OO_SDK_MAKE_HOME = "" ;
}
}
}
}
2005-01-31 08:53:51 -06:00
# prepare zip path
$ main:: correctVersion = 0 ;
while ( ( ! $ main:: correctVersion ) &&
( ( ! - d "$main::OO_SDK_ZIP_HOME" ) ||
( ( - d "$main::OO_SDK_ZIP_HOME" ) && ( ! - e "$main::OO_SDK_ZIP_HOME/zip" ) ) ) )
{
print " Enter zip ($main::zipVersion or higher) tool directory [$main::OO_SDK_ZIP_HOME_SUGGESTION]: " ;
$ main:: OO_SDK_ZIP_HOME = readStdIn ( ) ;
chop ( $ main:: OO_SDK_ZIP_HOME ) ;
if ( $ main:: OO_SDK_ZIP_HOME eq "" )
{
$ main:: OO_SDK_ZIP_HOME = $ main:: OO_SDK_ZIP_HOME_SUGGESTION ;
}
if ( ( ! - d "$main::OO_SDK_ZIP_HOME" ) ||
( ( - d "$main::OO_SDK_ZIP_HOME" ) && ( ! - e "$main::OO_SDK_ZIP_HOME/zip" ) ) )
{
$ main:: OO_SDK_ZIP_HOME = "" ;
print " Error: zip tool is required, please specify a zip tool directory.\n" ;
} else
{
#check version
my $ testVersion = `$OO_SDK_ZIP_HOME/zip -h 2>&1 | egrep Zip | head -n 1` ;
$ testVersion =~ s #Zip ([\d.]+) .*#$1#go;
if ( $ testVersion eq "" )
{
print " Set the environment variable OO_SDK_ZIP_HOME to your zip tool directory.\n" ;
print " zip version $main::zipVersion can be obtained at ftp://www.info-zip.org/\n" ;
} else
{
if ( $ testVersion =~ m #((\d+\.)+\d+)# )
{
$ testVersion = $ 1 ;
}
$ main:: correctVersion = testVersion ( $ main:: zipVersion , $ testVersion , "$main::OO_SDK_MAKE_HOME/zip" , 1 ) ;
if ( ! $ main:: correctVersion )
{
print " The 'zip' command found at '$main::OO_SDK_ZIP_HOME' has a wrong version\n" ;
$ main:: OO_SDK_ZIP_HOME = "" ;
}
}
}
}
2003-04-17 03:37:10 -05:00
# prepare C++ compiler path
$ main:: correctVersion = 0 ;
while ( ( ! $ main:: correctVersion ) &&
2003-07-09 04:36:22 -05:00
( ( ! - d "$main::OO_SDK_CPP_HOME" ) ||
( ( - d "$main::OO_SDK_CPP_HOME" ) && ( ! - e "$main::OO_SDK_CPP_HOME/$main::cpp" ) ) ) )
2003-04-17 03:37:10 -05:00
{
2004-05-18 07:17:41 -05:00
print " C++ compilers where for example a language binding exist:\n" ;
print " - Solaris, Sun WorkShop 6 update 1 C++ 5.2 2000/09/11 or higher\n" ;
print " - Linux, GNU C++ compiler, gcc version 3.0.1 or higher\n" ;
2008-07-11 08:13:21 -05:00
print " - MacOS, GNU C++ compiler, gcc version 4.0.1 or higher\n" ;
2004-05-18 07:17:41 -05:00
print " Enter the directory of the C++ compiler, the directory\n" ;
print " where the compiler is located (optional) [$main::OO_SDK_CPP_HOME_SUGGESTION]: " ;
2003-04-17 03:37:10 -05:00
2004-05-18 07:17:41 -05:00
$ main:: OO_SDK_CPP_HOME = readStdIn ( ) ;
2003-04-17 03:37:10 -05:00
chop ( $ main:: OO_SDK_CPP_HOME ) ;
if ( $ main:: OO_SDK_CPP_HOME eq "" )
{
$ main:: OO_SDK_CPP_HOME = $ main:: OO_SDK_CPP_HOME_SUGGESTION ;
2005-01-31 08:53:51 -06:00
}
2004-05-18 07:17:41 -05:00
2003-04-17 03:37:10 -05:00
if ( ! $ main:: OO_SDK_CPP_HOME eq "" )
{
if ( ( ! - d "$main::OO_SDK_CPP_HOME" ) ||
( ( - d "$main::OO_SDK_CPP_HOME" ) && ( ! - e "$main::OO_SDK_CPP_HOME/$main::cppName" ) ) )
{
2004-05-18 07:17:41 -05:00
print " Error: Could not find directory '$main::OO_SDK_CPP_HOME'.\n" ;
2003-04-17 03:37:10 -05:00
if ( skipChoice ( "C++ compiler" ) == 1 )
{
$ main:: correctVersion = 1 ;
}
$ main:: OO_SDK_CPP_HOME = "" ;
} else
{
#check version
if ( $ main:: cppName eq "gcc" )
{
2003-07-09 04:36:22 -05:00
my $ testVersion = `$OO_SDK_CPP_HOME/$main::cppName -dumpversion` ;
2003-04-17 03:37:10 -05:00
if ( $ testVersion eq "" )
{
2004-05-18 07:17:41 -05:00
print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a " ;
print " GNU compiler.\nSet the environment variable OO_SDK_CPP_HOME to your GNU build tools " ;
print " directory.\nA GNU compiler version $main::cppVersion can be obtained at " ;
print " ftp://ftp.gnu.org/gnu/gcc/\n" ;
2003-04-17 03:37:10 -05:00
} else
{
2005-01-31 08:53:51 -06:00
$ main:: correctVersion = testVersion ( $ main:: cppVersion , $ testVersion , "$main::OO_SDK_CPP_HOME/$main::cppName" , 1 ) ;
2003-04-17 03:37:10 -05:00
if ( ! $ main:: correctVersion )
{
2004-05-18 07:17:41 -05:00
print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n" ;
2003-04-17 03:37:10 -05:00
if ( skipChoice ( "C++ compiler" ) == 1 )
{
$ main:: correctVersion = 1 ;
}
$ main:: OO_SDK_CPP_HOME = "" ;
}
}
} else
{
# for Solaris we have to check the version too
2003-07-09 04:36:22 -05:00
open ( FILE , "$OO_SDK_CPP_HOME/$main::cppName -V 2>&1 |" ) ;
my @ lines = <FILE> ;
my $ testVersion = $ lines [ 0 ] ;
if ( $ testVersion eq "" )
{
2004-05-18 07:17:41 -05:00
print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a " ;
print " Solaris C++ compiler.\nSet the environment variable OO_SDK_CPP_HOME to your Solaris C++ compiler directory.\n" ;
2003-07-09 04:36:22 -05:00
} else
{
if ( $ testVersion =~ m #((\d+\.)+\d+)# )
{
$ testVersion = $ 1 ;
}
2005-01-31 08:53:51 -06:00
$ main:: correctVersion = testVersion ( $ main:: cppVersion , $ testVersion , "$main::OO_SDK_CPP_HOME/$main::cppName" , 1 ) ;
2003-07-09 04:36:22 -05:00
if ( ! $ main:: correctVersion )
{
2004-05-18 07:17:41 -05:00
print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n" ;
2003-07-09 04:36:22 -05:00
if ( skipChoice ( "C++ compiler" ) == 1 )
{
$ main:: correctVersion = 1 ;
}
$ main:: OO_SDK_CPP_HOME = "" ;
2005-01-31 08:53:51 -06:00
} else {
$ main:: correctVersion = testVersion ( "5.5" , $ testVersion , "$main::OO_SDK_CPP_HOME/$main::cppName" , 2 ) ;
if ( $ main:: correctVersion ) {
$ main:: OO_SDK_CC_55_OR_HIGHER = $ testVersion ;
}
2003-07-09 04:36:22 -05:00
}
}
2003-04-17 03:37:10 -05:00
}
}
} else
{
# the C++ compiler is optional
$ main:: correctVersion = 1 ;
}
}
2008-07-11 08:13:21 -05:00
2003-04-17 03:37:10 -05:00
# prepare Java path
$ main:: correctVersion = 0 ;
2004-05-18 07:17:41 -05:00
2008-07-11 08:13:21 -05:00
# prepare Java suggestion (cut bin or Commands directory to be in the root of the Java SDK)
$ main:: offset = rindex ( $ main:: OO_SDK_JAVA_HOME_SUGGESTION , "/$main::OO_SDK_JAVA_BIN_DIR" ) ;
2004-05-18 07:17:41 -05:00
if ( $ main:: offset != - 1 )
{
$ main:: OO_SDK_JAVA_HOME_SUGGESTION = substr ( $ main:: OO_SDK_JAVA_HOME_SUGGESTION , 0 , $ main:: offset ) ;
}
2003-04-17 03:37:10 -05:00
while ( ( ! $ main:: correctVersion ) &&
2008-07-11 08:13:21 -05:00
( ( ! - d "$main::OO_SDK_JAVA_HOME" ) ||
( ( - d "$main::OO_SDK_JAVA_HOME" ) && ( ! - e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac" ) ) ) )
2003-04-17 03:37:10 -05:00
{
2008-07-11 08:13:21 -05:00
print " Enter Java SDK (1.4.1_01 or higher) installation directory (optional) [$main::OO_SDK_JAVA_HOME_SUGGESTION]: " ;
2004-05-18 07:17:41 -05:00
$ main:: OO_SDK_JAVA_HOME = readStdIn ( ) ;
2003-04-17 03:37:10 -05:00
chop ( $ main:: OO_SDK_JAVA_HOME ) ;
if ( $ main:: OO_SDK_JAVA_HOME eq "" )
{
$ main:: OO_SDK_JAVA_HOME = $ main:: OO_SDK_JAVA_HOME_SUGGESTION ;
}
2005-01-31 08:53:51 -06:00
if ( ! $ main:: OO_SDK_JAVA_HOME eq "" )
2003-04-17 03:37:10 -05:00
{
2005-01-31 08:53:51 -06:00
if ( ( ! - d "$main::OO_SDK_JAVA_HOME" ) ||
2008-07-11 08:13:21 -05:00
( ( - d "$main::OO_SDK_JAVA_HOME" ) && ( ! - e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac" ) ) )
2003-04-17 03:37:10 -05:00
{
2008-07-11 08:13:21 -05:00
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" ;
2005-01-31 08:53:51 -06:00
if ( skipChoice ( "JAVA SDK" ) == 1 )
{
$ main:: correctVersion = 1 ;
}
2003-04-17 03:37:10 -05:00
$ main:: OO_SDK_JAVA_HOME = "" ;
2005-01-31 08:53:51 -06:00
} else
{
#check version
2008-07-11 08:13:21 -05:00
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#".*##'` ;
2005-01-31 08:53:51 -06:00
$ testVersion =~ s #([^\n]+)\n#$1#go;
2008-07-11 08:13:21 -05:00
$ main:: correctVersion = testVersion ( $ main:: javaVersion , $ testVersion , "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/java" , 1 ) ;
2005-01-31 08:53:51 -06:00
if ( ! $ main:: correctVersion )
{
if ( skipChoice ( "JAVA SDK" ) == 1 )
{
$ main:: correctVersion = 1 ;
}
$ main:: OO_SDK_JAVA_HOME = "" ;
}
2003-04-17 03:37:10 -05:00
}
2005-01-31 08:53:51 -06:00
} else
{
# the Java SDK is optional
$ main:: correctVersion = 1 ;
2003-04-17 03:37:10 -05:00
}
}
2008-07-11 08:13:21 -05:00
2004-05-18 07:17:41 -05:00
# prepare output directory (optional)
while ( ( ! $ main:: skipOutputDir ) &&
( ! - d "$main::OO_SDK_OUTPUT_DIR" ) )
{
2005-11-09 02:28:37 -06:00
print " Default output directory is in your HOME directory.\n" ;
print " Enter an existent directory if you prefer a different output directory (optional) [$main::OO_SDK_OUTPUT_DIR_SUGGESTION]: " ;
2004-05-18 07:17:41 -05:00
$ main:: OO_SDK_OUTPUT_DIR = readStdIn ( ) ;
chop ( $ main:: OO_SDK_OUTPUT_DIR ) ;
if ( $ main:: OO_SDK_OUTPUT_DIR eq "" )
{
$ main:: OO_SDK_OUTPUT_DIR = $ main:: OO_SDK_OUTPUT_DIR_SUGGESTION ;
}
if ( ! $ main:: OO_SDK_OUTPUT_DIR eq "" )
{
if ( ! - d "$main::OO_SDK_OUTPUT_DIR" )
{
print " Error: Could not find directory '$main::OO_SDK_OUTPUT_DIR'.\n" ;
if ( skipChoice ( "optional output directory" ) == 1 )
{
$ main:: skipOutputDir = 1 ;
}
$ main:: OO_SDK_OUTPUT_DIR = "" ;
}
} else
{
# the output directory is optional
$ main:: skipOutputDir = 1 ;
}
}
# prepare auto deployment
2008-07-11 08:13:21 -05:00
if ( $ main:: OFFICE_OR_URE eq "Office" )
2003-04-17 03:37:10 -05:00
{
2005-06-17 03:37:25 -05:00
while ( $ main:: SDK_AUTO_DEPLOYMENT eq "" ||
( ( ! $ main:: SDK_AUTO_DEPLOYMENT eq "YES" ) &&
( ! $ main:: SDK_AUTO_DEPLOYMENT eq "NO" ) ) )
2003-04-17 03:37:10 -05:00
{
2005-06-17 03:37:25 -05:00
print " Automatic deployment of UNO components (YES/NO) [$main::SDK_AUTO_DEPLOYMENT_SUGGESTION]: " ;
2008-07-11 08:13:21 -05:00
$ main:: SDK_AUTO_DEPLOYMENT = uc <STDIN> ;
2005-06-17 03:37:25 -05:00
chop ( $ main:: SDK_AUTO_DEPLOYMENT ) ;
if ( $ main:: SDK_AUTO_DEPLOYMENT eq "" )
{
2008-07-11 08:13:21 -05:00
$ main:: SDK_AUTO_DEPLOYMENT = "YES" ;
2005-06-17 03:37:25 -05:00
}
2003-04-17 03:37:10 -05:00
}
}
2005-06-17 03:37:25 -05:00
else
{
$ main:: SDK_AUTO_DEPLOYMENT = "NO" ;
}
2003-04-17 03:37:10 -05:00
2005-01-31 08:53:51 -06:00
prepareScriptFile ( "setsdkenv_unix.sh.in" , "setsdkenv_unix.sh" , 1 ) ;
2008-07-11 08:13:21 -05:00
chmod 0644 , "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh" ;
2003-04-17 03:37:10 -05:00
2005-01-31 08:53:51 -06:00
prepareScriptFile ( "setsdkenv_unix.csh.in" , "setsdkenv_unix.csh" , 2 ) ;
2008-07-11 08:13:21 -05:00
chmod 0644 , "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.csh" ;
2003-04-17 03:37:10 -05:00
2004-05-18 07:17:41 -05:00
print "\n" ;
2005-11-09 02:28:37 -06:00
print " ************************************************************************\n" ;
2005-01-31 08:53:51 -06:00
print " * ... your SDK environment has been prepared.\n" ;
print " * For each time you want to use this configured SDK environment, you\n" ;
print " * have to run the \"setsdkenv_unix\" script file!\n" ;
2005-11-09 02:28:37 -06:00
print " * Alternatively can you source one of the scripts\n" ;
2008-12-11 07:10:39 -06:00
print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh\"\n" ;
print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.csh\"\n" ;
2005-11-09 02:28:37 -06:00
print " * to get an environment without starting a new shell.\n" ;
print " ************************************************************************\n\n" ;
2003-07-09 04:36:22 -05:00
2003-04-17 03:37:10 -05:00
exit $ return ;
sub skipChoice
{
my $ msg = shift ;
my $ skip = "" ;
2008-07-11 08:13:21 -05:00
while ( ! ( $ skip eq "yes" || $ skip eq "no" ) )
2003-04-17 03:37:10 -05:00
{
2004-05-18 07:17:41 -05:00
print " Do you want to skip the choice of the '$msg' (YES/NO): [YES] " ;
2008-07-11 08:13:21 -05:00
$ skip = lc <STDIN> ;
2003-04-17 03:37:10 -05:00
chop ( $ skip ) ;
2008-07-11 08:13:21 -05:00
if ( $ skip eq "" ) { $ skip = "yes" ; } # default
if ( $ skip eq "yes" )
2003-04-17 03:37:10 -05:00
{
return 1 ;
}
}
return 0 ;
}
2008-07-11 08:13:21 -05:00
sub resolveLink
{
my $ base = shift ;
my $ link = shift ;
my $ linktarget = readlink "$base/$link" ;
my $ resolvedlink = "" ;
while ( $ linktarget ne "" ) {
$ link = $ linktarget ;
$ linktarget = readlink "$base/$link" ;
}
$ resolvedlink = `cd $base/$link; pwd` ;
chop $ resolvedlink ;
return $ resolvedlink ;
}
2003-04-17 03:37:10 -05:00
sub searchprog
{
my $ _search = shift ;
my $ tmpPath = `echo "\$PATH"` ;
my @ pathList = split ( ":" , $ tmpPath ) ;
my $ progDir = "" ;
2008-07-11 08:13:21 -05:00
if ( $ _search eq "javac" && $ main:: operatingSystem =~ m/darwin/ )
{
$ progDir = resolveLink ( "/System/Library/Frameworks/JavaVM.Framework/Versions" , "CurrentJDK" ) ;
if ( - e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
{
return "$progDir/$main::OO_SDK_JAVA_BIN_DIR" ;
}
}
2003-04-17 03:37:10 -05:00
foreach $ i ( @ pathList )
{
if ( - e "$i/$_search" )
{
if ( index ( $ i , "/" ) == 0 )
{
# # absolute path; leave unchanged
$ progDir = $ i ;
} else
{
$ progDir = `cd "$i"; pwd` ;
}
return $ progDir
}
}
return $ progDir
}
2008-07-11 08:13:21 -05:00
sub searchMacOffice
{
if ( - d "/Applications/OpenOffice.org.app" ) {
return "/Applications/OpenOffice.org.app"
}
if ( - d "/Applications/StarOffice.app" ) {
return "/Applications/StarOffice.app" ;
}
if ( - d "/Applications/StarSuite.app" ) {
return "/Applications/StarSuite.app" ;
}
return "" ;
}
sub searchoffice
{
my $ offset = rindex ( $ main:: sdkpath , "/openoffice.org" ) ;
my $ tmpOffice = substr ( $ main:: sdkpath , 0 , $ offset ) ;
my $ officepath = "$tmpOffice/openoffice.org$main::OO_MAJORVERSION" ;
if ( $ main:: OO_MINORVERSION > 0 ) {
$ officepath = "$officepath$main::OO_MINORVERSION" ;
}
# search corresponding office for this SDK
if ( - d $ officepath && - e "$officepath/program/soffice" ) {
return $ officepath ;
}
# fallback
my $ tmpversion = $ main:: OO_MAJORVERSION + 6 ;
if ( $ main:: OO_MINORVERSION > 0 ) {
$ tmpversion = "$tmpversion.$main::OO_MINORVERSION" ;
}
$ officepath = "$tmpOffice/staroffice$tmpversion" ;
if ( - d $ officepath && - e "$officepath/program/soffice" ) {
return $ officepath ;
}
$ officepath = "$tmpOffice/StarOffice$tmpversion" ;
if ( - d $ officepath && - e "$officepath/program/soffice" ) {
return $ officepath ;
}
$ officepath = "$tmpOffice/starsuite$tmpversion" ;
if ( - d $ officepath && - e "$officepath/program/soffice" ) {
return $ officepath ;
}
$ officepath = "$tmpOffice/StarSuite$tmpversion" ;
if ( - d $ officepath && - e "$officepath/program/soffice" ) {
return $ officepath ;
}
$ officepath = "" ;
# search other potential matching office versions
my $ path = "/opt/" ;
my $ entry = "" ;
my $ version = "0" ;
for $ entry ( glob ( $ path . '*' ) ) {
## if the file is a directory
if ( - d $ entry ) {
if ( $ entry =~ m #(.+(o|O)ffice(\.org){0,1}(\d([\d\.]){0,2}))# ||
$ entry =~ m #(.+(s|S)uite(.*)(\d([\d\.]){0,2}))# )
{
if ( $ 4 > $ version ) {
$ version = $ 4 ;
$ officepath = $ entry ;
}
}
}
}
return $ officepath ;
}
2003-04-17 03:37:10 -05:00
sub testVersion
{
my $ tmpMustBeVersion = shift ;
my $ tmpTestVersion = shift ;
my $ toolName = shift ;
2005-01-31 08:53:51 -06:00
# 1=check + message 2=check only
my $ checkOnly = shift ;
2004-05-18 07:17:41 -05:00
my @ mustBeVersion = split ( /\.|_|-/ , $ tmpMustBeVersion ) ;
my @ testVersion = split ( /\.|_|-/ , $ tmpTestVersion ) ;
2003-04-17 03:37:10 -05:00
my $ length = $# mustBeVersion ;
2003-07-09 04:36:22 -05:00
if ( $# testVersion < $# mustBeVersion ) {
$ length = $# testVersion ;
}
for ( $ i = 0 ; $ i <= $ length ; $ i + + )
2003-04-17 03:37:10 -05:00
{
2007-07-31 07:52:13 -05:00
if ( @ testVersion - > [ $ i ] > @ mustBeVersion - > [ $ i ] )
{
return 1 ; # 1 indicates a correct version
}
2003-06-10 04:02:00 -05:00
if ( @ testVersion - > [ $ i ] < @ mustBeVersion - > [ $ i ] )
2003-04-17 03:37:10 -05:00
{
2005-01-31 08:53:51 -06:00
if ( $# checkOnly == 1 ) {
print " The command '$toolName' has the version $tmpTestVersion.\n" ;
print " The SDK requires at least the version $tmpMustBeVersion.\n" ;
}
2003-04-17 03:37:10 -05:00
return 0 ;
}
}
return 1 ; # 1 indicates a correct version
}
2004-05-18 07:17:41 -05:00
sub readStdIn
{
my $ tmpstdin = <STDIN> ;
if ( index ( $ tmpstdin , "\$" ) != - 1 )
{
return `echo $tmpstdin` ;
}
return $ tmpstdin ;
}
2005-01-31 08:53:51 -06:00
sub prepareScriptFile ()
{
my $ inputFile = shift ;
my $ outputFile = shift ;
# shell mode 1 = sh
# 2 = csh
my $ shellMode = shift ;
2008-07-11 08:13:21 -05:00
if ( ! - d "$main::OO_SDK_CONFIG_HOME/$main::hostname" )
2005-11-09 02:28:37 -06:00
{
2008-07-11 08:13:21 -05:00
system ( "mkdir -p $main::OO_SDK_CONFIG_HOME/$main::hostname" ) ;
2005-11-09 02:28:37 -06:00
}
2005-03-29 05:03:00 -06:00
open ( FILEIN , "$main::sdkpath/$inputFile" ) || die "\nERROR: could not open '$main::sdkpath/$inputFile' for reading" ;
2008-07-11 08:13:21 -05:00
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" ;
2005-01-31 08:53:51 -06:00
while ( <FILEIN> )
{
$ _ =~ s #\@OO_SDK_NAME\@#$main::OO_SDK_NAME#go;
$ _ =~ s #\@OO_SDK_HOME\@#$main::OO_SDK_HOME#go;
$ _ =~ s #\@OFFICE_HOME\@#$main::OFFICE_HOME#go;
2008-07-11 08:13:21 -05:00
$ _ =~ s #\@OFFICE_BASE_HOME\@#$main::OFFICE_BASE_HOME#go;
2005-06-17 03:37:25 -05:00
$ _ =~ s #\@OO_SDK_URE_HOME\@#$main::OO_SDK_URE_HOME#go;
2005-01-31 08:53:51 -06:00
$ _ =~ s #\@OO_SDK_MAKE_HOME\@#$main::OO_SDK_MAKE_HOME#go;
$ _ =~ s #\@OO_SDK_ZIP_HOME\@#$main::OO_SDK_ZIP_HOME#go;
$ _ =~ s #\@OO_SDK_CPP_HOME\@#$main::OO_SDK_CPP_HOME#go;
$ _ =~ s #\@OO_SDK_CC_55_OR_HIGHER\@#$main::OO_SDK_CC_55_OR_HIGHER#go;
$ _ =~ s #\@OO_SDK_JAVA_HOME\@#$main::OO_SDK_JAVA_HOME#go;
$ _ =~ s #\@SDK_AUTO_DEPLOYMENT\@#$main::SDK_AUTO_DEPLOYMENT#go;
$ _ =~ s #\@OO_SDK_OUTPUT_DIR\@#$main::OO_SDK_OUTPUT_DIR#go;
print FILEOUT $ _ ;
}
close FILEIN ;
close FILEOUT ;
}