# # This file is part of the LibreOffice project. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # This file incorporates work covered by the following license notice: # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed # with this work for additional information regarding copyright # ownership. The ASF licenses this file to you under the Apache # License, Version 2.0 (the "License"); you may not use this file # except in compliance with the License. You may obtain a copy of # the License at http://www.apache.org/licenses/LICENSE-2.0 . # # configure.pl - a perl script to set a minimal environment for the SDK. # # Copyright 2000, 2010 Oracle and/or its affiliates. #
if ( ! -d "$main::OFFICE_HOME" )
{
$main::OFFICE_HOME = "";
print " Error: An office installation is required, please specify the path to a valid installation.\n";
}
while ( (! -d "$main::OFFICE_HOME" ) ||
((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/program")) )
{
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;
}
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 program directory but a link to the soffice binary if ( (! -d "$main::OFFICE_HOME/program") && (-e "$main::OFFICE_HOME/soffice") )
{
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;
}
}
}
}
}
# prepare GNU make path while ( (!$main::correctVersion) &&
((! -d "$main::OO_SDK_MAKE_HOME" ) ||
((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName"))) )
{
print " Enter GNU make ($main::makeVersion or higher) tools directory [$main::OO_SDK_MAKE_HOME_SUGGESTION]: ";
$main::OO_SDK_MAKE_HOME = readStdIn();
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") ||
((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName")) )
{
$main::OO_SDK_MAKE_HOME = "";
print " Error: GNU make is required, please specify a GNU make tools directory.\n";
} else
{ #check version
my $testVersion = `$OO_SDK_MAKE_HOME/$main::makeName --version`; if ( $testVersion eq "")
{
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";
} else
{ if ($testVersion =~ m#((\d+\.)+\d+)# )
{
$testVersion = $1;
}
$main::correctVersion = testVersion($main::makeVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/$main::makeName", 1); if ( !$main::correctVersion )
{
print " The '$main::makeName' command found at '$main::OO_SDK_MAKE_HOME' has a wrong version\n";
$main::OO_SDK_MAKE_HOME = "";
}
}
}
}
# 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 | grep -E 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 = "";
}
}
}
}
# prepare cat path
$main::correctVersion = 0; while ( (!$main::correctVersion) &&
((! -d "$main::OO_SDK_CAT_HOME" ) ||
((-d "$main::OO_SDK_CAT_HOME") && (! -e "$main::OO_SDK_CAT_HOME/cat"))) )
{
print " Enter cat tool directory [$main::OO_SDK_CAT_HOME_SUGGESTION]: ";
$main::OO_SDK_CAT_HOME = readStdIn();
chop($main::OO_SDK_CAT_HOME); if ( $main::OO_SDK_CAT_HOME eq "" )
{
$main::OO_SDK_CAT_HOME = $main::OO_SDK_CAT_HOME_SUGGESTION;
} if ( (! -d "$main::OO_SDK_CAT_HOME") ||
((-d "$main::OO_SDK_CAT_HOME") && (! -e "$main::OO_SDK_CAT_HOME/cat")) )
{
$main::OO_SDK_CAT_HOME = "";
print " Error: cat tool is required, please specify a cat tool directory.\n";
} # else ... # TODO check version # NOTE: only Linux cat understands --version
}
# prepare sed path
$main::correctVersion = 0; while ( (!$main::correctVersion) &&
((! -d "$main::OO_SDK_SED_HOME" ) ||
((-d "$main::OO_SDK_SED_HOME") && (! -e "$main::OO_SDK_SED_HOME/sed"))) )
{
print " Enter sed tool directory [$main::OO_SDK_SED_HOME_SUGGESTION]: ";
$main::OO_SDK_SED_HOME = readStdIn();
chop($main::OO_SDK_SED_HOME); if ( $main::OO_SDK_SED_HOME eq "" )
{
$main::OO_SDK_SED_HOME = $main::OO_SDK_SED_HOME_SUGGESTION;
} if ( (! -d "$main::OO_SDK_SED_HOME") ||
((-d "$main::OO_SDK_SED_HOME") && (! -e "$main::OO_SDK_SED_HOME/sed")) )
{
$main::OO_SDK_SED_HOME = "";
print " Error: sed tool is required, please specify a sed tool directory.\n";
} # else ... # TODO check version # NOTE: only Linux sed understands --version
}
# prepare C++ compiler path
$main::correctVersion = 0; while ( (!$main::correctVersion) &&
((! -d "$main::OO_SDK_CPP_HOME" ) ||
((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cpp"))) )
{
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 4.0.1 or higher\n";
print " - MacOS, GNU C++ compiler, gcc version 4.0.1 or higher\n";
print " Enter the directory of the C++ compiler, the directory\n";
print " where the compiler is located (optional) [$main::OO_SDK_CPP_HOME_SUGGESTION]: ";
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")) )
{
print " Error: Could not find directory '$main::OO_SDK_CPP_HOME'.\n"; if ( skipChoice("C++ compiler") == 1 )
{
$main::correctVersion = 1;
}
$main::OO_SDK_CPP_HOME = "";
} else
{ #check version if ( $main::cppName eq "gcc" )
{
my $testVersion = `$OO_SDK_CPP_HOME/$main::cppName -dumpversion`; if ( $testVersion eq "")
{
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";
} else
{
$main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1); if ( !$main::correctVersion )
{
print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n"; if ( skipChoice("C++ compiler") == 1 )
{
$main::correctVersion = 1;
}
$main::OO_SDK_CPP_HOME = "";
}
}
}
}
} else
{ # the C++ compiler is optional
$main::correctVersion = 1;
}
}
# prepare .NET SDK path
$main::correctVersion = 0; while ( (!$main::correctVersion) &&
((! -d "$main::OO_SDK_DOTNET_ROOT" ) ||
((-d "$main::OO_SDK_DOTNET_ROOT") && (! -e "$main::OO_SDK_DOTNET_ROOT/dotnet"))) )
{
print " Enter .NET SDK (8 or higher) installation directory (optional) [$main::OO_SDK_DOTNET_ROOT_SUGGESTION]: ";
$main::OO_SDK_DOTNET_ROOT = readStdIn();
chop($main::OO_SDK_DOTNET_ROOT); if ( $main::OO_SDK_DOTNET_ROOT eq "" )
{
$main::OO_SDK_DOTNET_ROOT = $main::OO_SDK_DOTNET_ROOT_SUGGESTION;
} if ( ! $main::OO_SDK_DOTNET_ROOT eq "" )
{ if ( (! -d "$main::OO_SDK_DOTNET_ROOT") ||
((-d "$main::OO_SDK_DOTNET_ROOT") && (! -e "$main::OO_SDK_DOTNET_ROOT/dotnet")) )
{
print " Error: Could not find directory '$main::OO_SDK_DOTNET_ROOT' or '$main::OO_SDK_DOTNET_ROOT/dotnet'.\n"; if ( skipChoice(".NET SDK") == 1 )
{
$main::correctVersion = 1;
}
$main::OO_SDK_DOTNET_ROOT = "";
} else
{ #check version
my $testVersion = `"$main::OO_SDK_DOTNET_ROOT/dotnet" --version | awk -F. '{ print $1 }'`;
$main::correctVersion = testVersion($main::dotnetSdkVersion, $testVersion, "$main::OO_SDK_DOTNET_ROOT/dotnet", 1); if ( !$main::correctVersion )
{
print " The 'dotnet' command found at '$main::OO_SDK_DOTNET_ROOT' has a wrong version\n"; if ( skipChoice(".NET SDK") == 1 )
{
$main::correctVersion = 1;
}
$main::OO_SDK_DOTNET_ROOT = "";
}
}
}else
{ # the .NET SDK is optional
$main::correctVersion = 1;
}
}
# prepare Java path
$main::correctVersion = 0;
# prepare Java suggestion (cut bin directory to be in the root of the Java SDK)
$main::offset = rindex($main::OO_SDK_JAVA_HOME_SUGGESTION, "/bin"); if ( $main::offset != -1 )
{
$main::OO_SDK_JAVA_HOME_SUGGESTION = substr($main::OO_SDK_JAVA_HOME_SUGGESTION, 0, $main::offset);
}
while ( (!$main::correctVersion) &&
((! -d "$main::OO_SDK_JAVA_HOME" ) ||
((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/bin/javac"))) )
{
print " Enter Java SDK (1.6 or higher) installation directory (optional) [$main::OO_SDK_JAVA_HOME_SUGGESTION]: ";
$main::OO_SDK_JAVA_HOME = readStdIn();
chop($main::OO_SDK_JAVA_HOME); if ( $main::OO_SDK_JAVA_HOME eq "" )
{
$main::OO_SDK_JAVA_HOME = $main::OO_SDK_JAVA_HOME_SUGGESTION;
} if ( ! $main::OO_SDK_JAVA_HOME eq "" )
{ if ( (! -d "$main::OO_SDK_JAVA_HOME") ||
((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/bin/javac")) )
{
print " Error: Could not find directory '$main::OO_SDK_JAVA_HOME' or '$main::OO_SDK_JAVA_HOME/bin/javac'.\n"; if ( skipChoice("JAVA SDK") == 1 )
{
$main::correctVersion = 1;
}
$main::OO_SDK_JAVA_HOME = "";
} else
{ #check version
my $testVersion = `$main::OO_SDK_JAVA_HOME/bin/java -version 2>&1 | grep -E "java version" | head -n 1 | sed -e 's#.*version "##' | sed -e 's#".*##'`;
$testVersion =~ s#([^\n]+)\n#$1#go;
# prepare output directory (optional) while ( (!$main::skipOutputDir) &&
(! -d "$main::OO_SDK_OUTPUT_DIR") )
{
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]: ";
$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 while ( $main::SDK_AUTO_DEPLOYMENT eq "" ||
((! $main::SDK_AUTO_DEPLOYMENT eq "YES") &&
(! $main::SDK_AUTO_DEPLOYMENT eq "NO")) )
{
print " Automatic deployment of UNO components (YES/NO) [$main::SDK_AUTO_DEPLOYMENT_SUGGESTION]: ";
$main::SDK_AUTO_DEPLOYMENT = uc <STDIN>;
chop($main::SDK_AUTO_DEPLOYMENT); if ( $main::SDK_AUTO_DEPLOYMENT eq "" )
{
$main::SDK_AUTO_DEPLOYMENT = "YES";
}
}
print "\n";
print " ************************************************************************\n";
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";
print " * Alternatively can you source one of the scripts\n";
print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh\"\n";
print " * to get an environment without starting a new shell.\n";
print " ************************************************************************\n\n";
exit $return;
sub skipChoice
{
my $msg = shift;
my $skip = ""; while ( !( $skip eq "yes" || $skip eq "no") )
{
print " Do you want to skip the choice of the '$msg' (YES/NO): [YES] ";
$skip = lc <STDIN>;
chop($skip); if ( $skip eq "" ) { $skip = "yes"; } # default if ( $skip eq "yes" )
{
return 1;
}
}
return 0;
}
sub resolveLink
{
my $base= shift;
my $link= shift;
my $resolvedpath = "$base/$link";
my $linktarget = readlink "$resolvedpath";
my $resolvedlink = "";
sub searchMacOffice
{ if (-d "/Applications/LibreOffice.app" ) {
return "/Applications/LibreOffice.app"
} if (-d "/Applications/OpenOffice.org.app" ) {
return "/Applications/OpenOffice.org.app"
} if (-d "/Applications/Oracle Open Office.app" ) {
return "/Applications/Oracle Open Office.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, "/libreoffice");
my $tmpOffice = substr($main::sdkpath, 0, $offset);
my $officepath = "$tmpOffice/libreoffice";
# Before trying versioned directories, check if the sdk is directly under # the office path.
$officepath = $main::sdkpath . "/.."; if (-d $officepath && -e "$officepath/program/soffice") {
return $officepath;
}
my $tmpversion = $main::OO_MAJORVERSION + 6; if ( $main::OO_MINORVERSION > 0) {
$tmpversion = "$tmpversion.$main::OO_MINORVERSION";
}
# 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) {
my $dotnetRootDir = `dirname "$dotnetSdkDir"`;
chomp($dotnetRootDir);
if (! -d "$dotnetRootDir")
{
return "";
}
return $dotnetRootDir;
}
sub testVersion
{
my $tmpMustBeVersion = shift;
my $tmpTestVersion = shift;
my $toolName = shift; # 1=check + message 2=check only
my $checkOnly = shift;
my @mustBeVersion = split(/\.|_|-/,$tmpMustBeVersion);
my @testVersion = split(/\.|_|-/,$tmpTestVersion);
my $length = $#mustBeVersion;
if ($#testVersion < $#mustBeVersion) {
$length = $#testVersion;
}
for ($i=0; $i <= $length; $i++ )
{ if ( $testVersion[$i] > $mustBeVersion[$i] )
{
return 1; # 1 indicates a correct version
}
if ( $testVersion[$i] < $mustBeVersion[$i] )
{ if ( $#checkOnly == 1 ) {
print " The command '$toolName' has the version $tmpTestVersion.\n";
print " The SDK requires at least the version $tmpMustBeVersion.\n";
}
return 0;
}
}
return 1; # 1 indicates a correct version
}
sub readStdIn
{
my $tmpstdin = <STDIN>; if ( index($tmpstdin, "\$") != -1)
{
return `echo $tmpstdin`;
}
return $tmpstdin;
}
sub prepareScriptFile()
{
my $inputFile = shift;
my $outputFile = shift;
open ( FILEIN, "$main::sdkpath/$inputFile" ) || die "\nERROR: could not open '$main::sdkpath/$inputFile' for reading";
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";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.