xref: /aoo41x/main/odk/configure.pl (revision b3ba5bc7)
1122c3632SJürgen Schmidt#**************************************************************
2985d02c7SAriel Constenla-Haile#
3122c3632SJürgen Schmidt#  Licensed to the Apache Software Foundation (ASF) under one
4122c3632SJürgen Schmidt#  or more contributor license agreements.  See the NOTICE file
5122c3632SJürgen Schmidt#  distributed with this work for additional information
6122c3632SJürgen Schmidt#  regarding copyright ownership.  The ASF licenses this file
7122c3632SJürgen Schmidt#  to you under the Apache License, Version 2.0 (the
8122c3632SJürgen Schmidt#  "License"); you may not use this file except in compliance
9122c3632SJürgen Schmidt#  with the License.  You may obtain a copy of the License at
10985d02c7SAriel Constenla-Haile#
11122c3632SJürgen Schmidt#    http://www.apache.org/licenses/LICENSE-2.0
12985d02c7SAriel Constenla-Haile#
13122c3632SJürgen Schmidt#  Unless required by applicable law or agreed to in writing,
14122c3632SJürgen Schmidt#  software distributed under the License is distributed on an
15122c3632SJürgen Schmidt#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16122c3632SJürgen Schmidt#  KIND, either express or implied.  See the License for the
17122c3632SJürgen Schmidt#  specific language governing permissions and limitations
18122c3632SJürgen Schmidt#  under the License.
19985d02c7SAriel Constenla-Haile#
20122c3632SJürgen Schmidt#**************************************************************
21122c3632SJürgen Schmidt
22cdf0e10cSrcweir#
23cdf0e10cSrcweir# configure.pl - a perl script to set a minimal environment for the SDK.
24cdf0e10cSrcweir#
25cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates.
26cdf0e10cSrcweir#
27cdf0e10cSrcweir
28cdf0e10cSrcweiruse IO::File;
29cdf0e10cSrcweiruse File::Basename;
30cdf0e10cSrcweir
31cdf0e10cSrcweir$main::hostname= $ARGV[0];
32cdf0e10cSrcweir$main::sdkpath= $ARGV[1];
33cdf0e10cSrcweir$main::OO_SDK_NAME= $ARGV[2];
34cdf0e10cSrcweir
35cdf0e10cSrcweir$main::OO_MAJORVERSION=$main::OO_SDK_NAME;
36cdf0e10cSrcweir$main::OO_MINORVERSION=$main::OO_SDK_NAME;
37cdf0e10cSrcweir$main::OO_MAJORVERSION =~ s#[^\d]+(\d).(\d).+#$1#go;
38cdf0e10cSrcweir$main::OO_MINORVERSION =~ s#[^\d]+(\d).(\d).+#$2#go;
39cdf0e10cSrcweir
40cdf0e10cSrcweir$main::OO_SDK_CONFIG_HOME= "$ENV{HOME}/$main::OO_SDK_NAME";
41cdf0e10cSrcweir
42cdf0e10cSrcweir$main::operatingSystem = `$main::sdkpath/config.guess | cut -d"-" -f3,4`;
43cdf0e10cSrcweirchomp ($main::operatingSystem);
44cdf0e10cSrcweir
45cdf0e10cSrcweir$main::OO_SDK_HOME = $main::sdkpath;
46cdf0e10cSrcweir$main::OO_SDK_HOME_SUGGESTION = $main::sdkpath;
47cdf0e10cSrcweir
48cdf0e10cSrcweir$main::OFFICE_HOME = "";
49cdf0e10cSrcweir
50*b3ba5bc7SJürgen Schmidt#$main::OFFICE_BASE_HOME = substr($main::sdkpath, 0, rindex($main::sdkpath, "/sdk"));
51cdf0e10cSrcweir
52cdf0e10cSrcweir$main::OO_SDK_MAKE_HOME = "";
53cdf0e10cSrcweir$main::makeName = "make";
54cdf0e10cSrcweirif ( $main::operatingSystem =~ m/solaris/ ||
55cdf0e10cSrcweir	 $main::operatingSystem =~ m/freebsd/ )
56cdf0e10cSrcweir{
57cdf0e10cSrcweir    $main::makeName = "gmake";
58cdf0e10cSrcweir}
59cdf0e10cSrcweir$main::OO_SDK_MAKE_HOME_SUGGESTION = searchprog($main::makeName);
60cdf0e10cSrcweir$main::makeVersion = "3.79.1";
61cdf0e10cSrcweir$main::correctVersion = 0;
62cdf0e10cSrcweir
63cdf0e10cSrcweir$main::OO_SDK_ZIP_HOME = "";
64cdf0e10cSrcweir$main::OO_SDK_ZIP_HOME_SUGGESTION = searchprog("zip");
65cdf0e10cSrcweir$main::zipVersion = "2.3";
66cdf0e10cSrcweir
67985d02c7SAriel Constenla-Haile$main::OO_SDK_CAT_HOME = "";
68985d02c7SAriel Constenla-Haile$main::OO_SDK_CAT_HOME_SUGGESTION = searchprog("cat");
69985d02c7SAriel Constenla-Haile# TODO cat version
70985d02c7SAriel Constenla-Haile# $main::catVersion = "";
71985d02c7SAriel Constenla-Haile
72985d02c7SAriel Constenla-Haile$main::OO_SDK_SED_HOME = "";
73985d02c7SAriel Constenla-Haile$main::OO_SDK_SED_HOME_SUGGESTION = searchprog("sed");
74985d02c7SAriel Constenla-Haile# TODO sed version
75985d02c7SAriel Constenla-Haile# $main::sedVersion = "";
76985d02c7SAriel Constenla-Haile
77cdf0e10cSrcweir$main::OO_SDK_CPP_HOME = "";
78cdf0e10cSrcweir$main::cppName = "gcc";
79cdf0e10cSrcweir$main::cppVersion = "4.0.1";
80cdf0e10cSrcweirif ( $main::operatingSystem =~ m/solaris/ )
81cdf0e10cSrcweir{
82cdf0e10cSrcweir	$main::cppName = "CC";
83cdf0e10cSrcweir	$main::cppVersion = "5.2";
84cdf0e10cSrcweir}
85cdf0e10cSrcweir$main::OO_SDK_CC_55_OR_HIGHER = "";
86cdf0e10cSrcweir$main::OO_SDK_CPP_HOME_SUGGESTION = searchprog($main::cppName);
87cdf0e10cSrcweir
88cdf0e10cSrcweir$main::OO_SDK_JAVA_HOME = "";
89cdf0e10cSrcweir$main::OO_SDK_JAVA_BIN_DIR = "bin";
90cdf0e10cSrcweirif ( $main::operatingSystem =~ m/darwin/ )
91cdf0e10cSrcweir{
92cdf0e10cSrcweir    $main::OO_SDK_JAVA_BIN_DIR="Commands";
93cdf0e10cSrcweir}
94cdf0e10cSrcweir$main::OO_SDK_JAVA_HOME_SUGGESTION = searchprog("javac");
95cdf0e10cSrcweir$main::javaVersion = "1.5.0_01";
96cdf0e10cSrcweir
97cdf0e10cSrcweir$main::SDK_AUTO_DEPLOYMENT = "";
98cdf0e10cSrcweir$main::SDK_AUTO_DEPLOYMENT_SUGGESTION = "YES";
99cdf0e10cSrcweir
100cdf0e10cSrcweir$main::OO_SDK_OUTPUT_DIR_SUGGESTION = "$ENV{HOME}";
101cdf0e10cSrcweir$main::OO_SDK_OUTPUT_DIR = "";
102cdf0e10cSrcweir$main::skipOutputDir = 0;
103cdf0e10cSrcweir
104cdf0e10cSrcweir$main::return = 0;
105cdf0e10cSrcweir
106*b3ba5bc7SJürgen Schmidtif ( $main::operatingSystem =~ m/darwin/ )
107cdf0e10cSrcweir{
108cdf0e10cSrcweir# used for a SDK as part of the office installation
109*b3ba5bc7SJürgen Schmidt#    $main::OFFICE_HOME = `cd $main::sdkpath/../../.. && pwd`;
110*b3ba5bc7SJürgen Schmidt#    chomp($main::OFFICE_HOME);
111*b3ba5bc7SJürgen Schmidt#    print " Used Office = $main::OFFICE_HOME\n";
112*b3ba5bc7SJürgen Schmidt    print " Used SDK = $main::OO_SDK_HOME\n\n";
113*b3ba5bc7SJürgen Schmidt
114*b3ba5bc7SJürgen Schmidt    $main::OFFICE_HOME_SUGGESTION = searchMacOffice();
115*b3ba5bc7SJürgen Schmidt    while ( (! -d "$main::OFFICE_HOME" ) ||
116*b3ba5bc7SJürgen Schmidt	    ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/Contents/MacOS")) )
117*b3ba5bc7SJürgen Schmidt    {
118*b3ba5bc7SJürgen Schmidt	print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: ";
119*b3ba5bc7SJürgen Schmidt	$main::OFFICE_HOME = readStdIn();
120*b3ba5bc7SJürgen Schmidt	chop($main::OFFICE_HOME);
121*b3ba5bc7SJürgen Schmidt	if ( $main::OFFICE_HOME eq "" )
122*b3ba5bc7SJürgen Schmidt	{
123*b3ba5bc7SJürgen Schmidt	    $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION;
124*b3ba5bc7SJürgen Schmidt	}
125*b3ba5bc7SJürgen Schmidt
126*b3ba5bc7SJürgen Schmidt	if ( ! -d "$main::OFFICE_HOME" )
127*b3ba5bc7SJürgen Schmidt	{
128*b3ba5bc7SJürgen Schmidt	    $main::OFFICE_HOME = "";
129*b3ba5bc7SJürgen Schmidt	    print " Error: An office installation is required, please specify the path to a valid installation.\n";
130*b3ba5bc7SJürgen Schmidt	}
131*b3ba5bc7SJürgen Schmidt
132*b3ba5bc7SJürgen Schmidt#	$main::OFFICE_BASE_HOME = "$main::OFFICE_HOME/Contents";
133*b3ba5bc7SJürgen Schmidt    }
134*b3ba5bc7SJürgen Schmidt} else
135*b3ba5bc7SJürgen Schmidt{
136*b3ba5bc7SJürgen Schmidt    $main::OFFICE_HOME_SUGGESTION = searchoffice();
137*b3ba5bc7SJürgen Schmidt
138*b3ba5bc7SJürgen Schmidt    if ( $main::OFFICE_HOME_SUGGESTION eq "" ) {
139*b3ba5bc7SJürgen Schmidt	# prepare Office path
140*b3ba5bc7SJürgen Schmidt	$main::OFFICE_HOME_SUGGESTION = searchprog("soffice");
141*b3ba5bc7SJürgen Schmidt    }
142*b3ba5bc7SJürgen Schmidt
143*b3ba5bc7SJürgen Schmidt    if ( ! $main::OFFICE_HOME_SUGGESTION eq "" )
144*b3ba5bc7SJürgen Schmidt    {
145*b3ba5bc7SJürgen Schmidt	my $tmpOffice = readlink "$main::OFFICE_HOME_SUGGESTION/soffice";
146*b3ba5bc7SJürgen Schmidt
147*b3ba5bc7SJürgen Schmidt	if ( $tmpOffice eq "" )
148*b3ba5bc7SJürgen Schmidt	{
149*b3ba5bc7SJürgen Schmidt	    $tmpOffice = "$main::OFFICE_HOME_SUGGESTION/soffice";
150*b3ba5bc7SJürgen Schmidt	}
151*b3ba5bc7SJürgen Schmidt
152*b3ba5bc7SJürgen Schmidt	my $offset = rindex($tmpOffice, "/program/soffice");
153*b3ba5bc7SJürgen Schmidt	if ( $offset != -1 )
154*b3ba5bc7SJürgen Schmidt	{
155*b3ba5bc7SJürgen Schmidt	    $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset);
156cdf0e10cSrcweir	} else
157cdf0e10cSrcweir	{
158*b3ba5bc7SJürgen Schmidt	    $offset = rindex($tmpOffice, "/soffice");
159*b3ba5bc7SJürgen Schmidt	    if ( $offset != -1 )
160*b3ba5bc7SJürgen Schmidt	    {
161*b3ba5bc7SJürgen Schmidt		$main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset);
162*b3ba5bc7SJürgen Schmidt	    } else
163*b3ba5bc7SJürgen Schmidt	    {
164*b3ba5bc7SJürgen Schmidt		$main::OFFICE_HOME_SUGGESTION = "";
165*b3ba5bc7SJürgen Schmidt	    }
166*b3ba5bc7SJürgen Schmidt	}
167*b3ba5bc7SJürgen Schmidt    }
168*b3ba5bc7SJürgen Schmidt
169*b3ba5bc7SJürgen Schmidt    while ( (! -d "$main::OFFICE_HOME" ) ||
170*b3ba5bc7SJürgen Schmidt	    ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/program")) )
171*b3ba5bc7SJürgen Schmidt    {
172*b3ba5bc7SJürgen Schmidt	print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: ";
173*b3ba5bc7SJürgen Schmidt	$main::OFFICE_HOME = readStdIn();
174*b3ba5bc7SJürgen Schmidt	chop($main::OFFICE_HOME);
175*b3ba5bc7SJürgen Schmidt	if ( $main::OFFICE_HOME eq "" )
176*b3ba5bc7SJürgen Schmidt	{
177*b3ba5bc7SJürgen Schmidt	    $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION;
178*b3ba5bc7SJürgen Schmidt	}
179*b3ba5bc7SJürgen Schmidt
180*b3ba5bc7SJürgen Schmidt	if ( ! -d "$main::OFFICE_HOME" )
181*b3ba5bc7SJürgen Schmidt	{
182*b3ba5bc7SJürgen Schmidt	    $main::OFFICE_HOME = "";
183*b3ba5bc7SJürgen Schmidt	    print " Error: An office installation is required, please specify the path to a valid installation.\n";
184*b3ba5bc7SJürgen Schmidt	} else
185*b3ba5bc7SJürgen Schmidt	{
186*b3ba5bc7SJürgen Schmidt	    # special work for a network installation, no prgram directory but a link to the soffice binary
187*b3ba5bc7SJürgen Schmidt	    if ( (! -d "$main::OFFICE_HOME/program") && (-e "$main::OFFICE_HOME/soffice") )
188*b3ba5bc7SJürgen Schmidt	    {
189*b3ba5bc7SJürgen Schmidt		my $soserver = `ls -l $OFFICE_HOME_SUGGESTION/soffice | sed -n 's/.* -> //p'`;
190*b3ba5bc7SJürgen Schmidt		$soserver= substr($soserver, 0, rindex($soserver, "program") - 1);
191cdf0e10cSrcweir
192*b3ba5bc7SJürgen Schmidt		if ( ! -d $soserver )
193cdf0e10cSrcweir		{
194*b3ba5bc7SJürgen Schmidt		    $main::OFFICE_HOME = "";
195*b3ba5bc7SJürgen Schmidt		    print " Error: An office installation is required, please specify the path to a valid installation.\n";
196*b3ba5bc7SJürgen Schmidt		} else
197*b3ba5bc7SJürgen Schmidt		{
198*b3ba5bc7SJürgen Schmidt		    $main::OFFICE_HOME = $soserver;
199cdf0e10cSrcweir		}
200*b3ba5bc7SJürgen Schmidt	    }
201cdf0e10cSrcweir	}
202cdf0e10cSrcweir    }
203cdf0e10cSrcweir}
204cdf0e10cSrcweir
205*b3ba5bc7SJürgen Schmidt
206cdf0e10cSrcweir# prepare GNU make path
207cdf0e10cSrcweirwhile ( (!$main::correctVersion) &&
208cdf0e10cSrcweir		((! -d "$main::OO_SDK_MAKE_HOME" ) ||
209cdf0e10cSrcweir		 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName"))) )
210cdf0e10cSrcweir{
211cdf0e10cSrcweir    print " Enter GNU make ($main::makeVersion or higher) tools directory [$main::OO_SDK_MAKE_HOME_SUGGESTION]: ";
212cdf0e10cSrcweir    $main::OO_SDK_MAKE_HOME = readStdIn();
213cdf0e10cSrcweir    chop($main::OO_SDK_MAKE_HOME);
214cdf0e10cSrcweir    if ( $main::OO_SDK_MAKE_HOME eq "" )
215cdf0e10cSrcweir    {
216cdf0e10cSrcweir		$main::OO_SDK_MAKE_HOME = $main::OO_SDK_MAKE_HOME_SUGGESTION;
217cdf0e10cSrcweir    }
218cdf0e10cSrcweir    if ( (! -d "$main::OO_SDK_MAKE_HOME") ||
219cdf0e10cSrcweir		 ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName")) )
220cdf0e10cSrcweir    {
221cdf0e10cSrcweir		$main::OO_SDK_MAKE_HOME = "";
222cdf0e10cSrcweir		print " Error: GNU make is required, please specify a GNU make tools directory.\n";
223cdf0e10cSrcweir    } else
224cdf0e10cSrcweir    {
225cdf0e10cSrcweir		#check version
226cdf0e10cSrcweir		my $testVersion = `$OO_SDK_MAKE_HOME/$main::makeName --version`;
227cdf0e10cSrcweir		if ( $testVersion eq "")
228cdf0e10cSrcweir		{
229cdf0e10cSrcweir			print " Set the environment variable OO_SDK_MAKE_HOME to your GNU build tools directory.\n";
230cdf0e10cSrcweir			print " GNU make version $main::makeVersion can be obtained at ftp://ftp.gnu.org/gnu/make/\n";
231cdf0e10cSrcweir		} else
232cdf0e10cSrcweir		{
233cdf0e10cSrcweir		    if ($testVersion =~ m#((\d+\.)+\d+)# )
234cdf0e10cSrcweir			{
235cdf0e10cSrcweir				$testVersion = $1;
236cdf0e10cSrcweir			}
237cdf0e10cSrcweir			$main::correctVersion = testVersion($main::makeVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/$main::makeName", 1);
238cdf0e10cSrcweir			if ( !$main::correctVersion )
239cdf0e10cSrcweir			{
240cdf0e10cSrcweir				print " The '$main::makeName' command found at '$main::OO_SDK_MAKE_HOME' has a wrong version\n";
241cdf0e10cSrcweir				$main::OO_SDK_MAKE_HOME = "";
242cdf0e10cSrcweir			}
243cdf0e10cSrcweir		}
244cdf0e10cSrcweir	}
245cdf0e10cSrcweir}
246cdf0e10cSrcweir
247cdf0e10cSrcweir# prepare zip path
248cdf0e10cSrcweir$main::correctVersion = 0;
249cdf0e10cSrcweirwhile ( (!$main::correctVersion) &&
250cdf0e10cSrcweir		((! -d "$main::OO_SDK_ZIP_HOME" ) ||
251cdf0e10cSrcweir		 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip"))) )
252cdf0e10cSrcweir{
253cdf0e10cSrcweir    print " Enter zip ($main::zipVersion or higher) tool directory [$main::OO_SDK_ZIP_HOME_SUGGESTION]: ";
254cdf0e10cSrcweir    $main::OO_SDK_ZIP_HOME = readStdIn();
255cdf0e10cSrcweir    chop($main::OO_SDK_ZIP_HOME);
256cdf0e10cSrcweir    if ( $main::OO_SDK_ZIP_HOME eq "" )
257cdf0e10cSrcweir    {
258cdf0e10cSrcweir		$main::OO_SDK_ZIP_HOME = $main::OO_SDK_ZIP_HOME_SUGGESTION;
259cdf0e10cSrcweir    }
260cdf0e10cSrcweir    if ( (! -d "$main::OO_SDK_ZIP_HOME") ||
261cdf0e10cSrcweir		 ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip")) )
262cdf0e10cSrcweir    {
263cdf0e10cSrcweir		$main::OO_SDK_ZIP_HOME = "";
264cdf0e10cSrcweir		print " Error: zip tool is required, please specify a zip tool directory.\n";
265cdf0e10cSrcweir    } else
266cdf0e10cSrcweir    {
267cdf0e10cSrcweir		#check version
268cdf0e10cSrcweir		my $testVersion = `$OO_SDK_ZIP_HOME/zip -h 2>&1 | egrep Zip | head -n 1`;
269cdf0e10cSrcweir		$testVersion =~ s#Zip ([\d.]+) .*#$1#go;
270cdf0e10cSrcweir		if ( $testVersion eq "")
271cdf0e10cSrcweir		{
272cdf0e10cSrcweir			print " Set the environment variable OO_SDK_ZIP_HOME to your zip tool directory.\n";
273cdf0e10cSrcweir			print " zip version $main::zipVersion can be obtained at ftp://www.info-zip.org/\n";
274cdf0e10cSrcweir		} else
275cdf0e10cSrcweir		{
276cdf0e10cSrcweir		    if ($testVersion =~ m#((\d+\.)+\d+)# )
277cdf0e10cSrcweir			{
278cdf0e10cSrcweir				$testVersion = $1;
279cdf0e10cSrcweir			}
280cdf0e10cSrcweir			$main::correctVersion = testVersion($main::zipVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/zip", 1);
281cdf0e10cSrcweir			if ( !$main::correctVersion )
282cdf0e10cSrcweir			{
283cdf0e10cSrcweir				print " The 'zip' command found at '$main::OO_SDK_ZIP_HOME' has a wrong version\n";
284cdf0e10cSrcweir				$main::OO_SDK_ZIP_HOME = "";
285cdf0e10cSrcweir			}
286cdf0e10cSrcweir		}
287cdf0e10cSrcweir	}
288cdf0e10cSrcweir}
289cdf0e10cSrcweir
290985d02c7SAriel Constenla-Haile# prepare cat path
291985d02c7SAriel Constenla-Haile$main::correctVersion = 0;
292985d02c7SAriel Constenla-Hailewhile ( (!$main::correctVersion) &&
293985d02c7SAriel Constenla-Haile        ((! -d "$main::OO_SDK_CAT_HOME" ) ||
294985d02c7SAriel Constenla-Haile         ((-d "$main::OO_SDK_CAT_HOME") && (! -e "$main::OO_SDK_CAT_HOME/cat"))) )
295985d02c7SAriel Constenla-Haile{
296985d02c7SAriel Constenla-Haile    print " Enter cat tool directory [$main::OO_SDK_CAT_HOME_SUGGESTION]: ";
297985d02c7SAriel Constenla-Haile    $main::OO_SDK_CAT_HOME = readStdIn();
298985d02c7SAriel Constenla-Haile    chop($main::OO_SDK_CAT_HOME);
299985d02c7SAriel Constenla-Haile    if ( $main::OO_SDK_CAT_HOME eq "" )
300985d02c7SAriel Constenla-Haile    {
301985d02c7SAriel Constenla-Haile        $main::OO_SDK_CAT_HOME = $main::OO_SDK_CAT_HOME_SUGGESTION;
302985d02c7SAriel Constenla-Haile    }
303985d02c7SAriel Constenla-Haile    if ( (! -d "$main::OO_SDK_CAT_HOME") ||
304985d02c7SAriel Constenla-Haile         ((-d "$main::OO_SDK_CAT_HOME") && (! -e "$main::OO_SDK_CAT_HOME/cat")) )
305985d02c7SAriel Constenla-Haile    {
306985d02c7SAriel Constenla-Haile        $main::OO_SDK_CAT_HOME = "";
307985d02c7SAriel Constenla-Haile        print " Error: cat tool is required, please specify a cat tool directory.\n";
308985d02c7SAriel Constenla-Haile    }
309985d02c7SAriel Constenla-Haile    # else ...
310985d02c7SAriel Constenla-Haile    # TODO check version
311985d02c7SAriel Constenla-Haile    # NOTE: only Linux cat understands --version
312985d02c7SAriel Constenla-Haile}
313985d02c7SAriel Constenla-Haile
314985d02c7SAriel Constenla-Haile# prepare sed path
315985d02c7SAriel Constenla-Haile$main::correctVersion = 0;
316985d02c7SAriel Constenla-Hailewhile ( (!$main::correctVersion) &&
317985d02c7SAriel Constenla-Haile        ((! -d "$main::OO_SDK_SED_HOME" ) ||
318985d02c7SAriel Constenla-Haile         ((-d "$main::OO_SDK_SED_HOME") && (! -e "$main::OO_SDK_SED_HOME/sed"))) )
319985d02c7SAriel Constenla-Haile{
320985d02c7SAriel Constenla-Haile    print " Enter sed tool directory [$main::OO_SDK_SED_HOME_SUGGESTION]: ";
321985d02c7SAriel Constenla-Haile    $main::OO_SDK_SED_HOME = readStdIn();
322985d02c7SAriel Constenla-Haile    chop($main::OO_SDK_SED_HOME);
323985d02c7SAriel Constenla-Haile    if ( $main::OO_SDK_SED_HOME eq "" )
324985d02c7SAriel Constenla-Haile    {
325985d02c7SAriel Constenla-Haile        $main::OO_SDK_SED_HOME = $main::OO_SDK_SED_HOME_SUGGESTION;
326985d02c7SAriel Constenla-Haile    }
327985d02c7SAriel Constenla-Haile    if ( (! -d "$main::OO_SDK_SED_HOME") ||
328985d02c7SAriel Constenla-Haile         ((-d "$main::OO_SDK_SED_HOME") && (! -e "$main::OO_SDK_SED_HOME/sed")) )
329985d02c7SAriel Constenla-Haile    {
330985d02c7SAriel Constenla-Haile        $main::OO_SDK_SED_HOME = "";
331985d02c7SAriel Constenla-Haile        print " Error: sed tool is required, please specify a sed tool directory.\n";
332985d02c7SAriel Constenla-Haile    }
333985d02c7SAriel Constenla-Haile    # else ...
334985d02c7SAriel Constenla-Haile    # TODO check version
335985d02c7SAriel Constenla-Haile    # NOTE: only Linux sed understands --version
336985d02c7SAriel Constenla-Haile}
337985d02c7SAriel Constenla-Haile
338cdf0e10cSrcweir# prepare C++ compiler path
339cdf0e10cSrcweir$main::correctVersion = 0;
340cdf0e10cSrcweirwhile ( (!$main::correctVersion) &&
341cdf0e10cSrcweir		((! -d "$main::OO_SDK_CPP_HOME" ) ||
342cdf0e10cSrcweir		 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cpp"))) )
343cdf0e10cSrcweir{
344cdf0e10cSrcweir	print " C++ compilers where for example a language binding exist:\n";
345cdf0e10cSrcweir	print "  - Solaris, Sun WorkShop 6 update 1 C++ 5.2 2000/09/11 or higher\n";
346cdf0e10cSrcweir	print "  - Linux, GNU C++ compiler, gcc version 4.0.1 or higher\n";
347cdf0e10cSrcweir	print "  - MacOS, GNU C++ compiler, gcc version 4.0.1 or higher\n";
348cdf0e10cSrcweir	print " Enter the directory of the C++ compiler, the directory\n";
349cdf0e10cSrcweir	print " where the compiler is located (optional) [$main::OO_SDK_CPP_HOME_SUGGESTION]: ";
350cdf0e10cSrcweir
351cdf0e10cSrcweir	$main::OO_SDK_CPP_HOME = readStdIn();
352cdf0e10cSrcweir	chop($main::OO_SDK_CPP_HOME);
353cdf0e10cSrcweir	if ( $main::OO_SDK_CPP_HOME eq "" )
354cdf0e10cSrcweir	{
355cdf0e10cSrcweir		$main::OO_SDK_CPP_HOME = $main::OO_SDK_CPP_HOME_SUGGESTION;
356cdf0e10cSrcweir	}
357cdf0e10cSrcweir
358cdf0e10cSrcweir	if ( ! $main::OO_SDK_CPP_HOME eq "" )
359cdf0e10cSrcweir	{
360cdf0e10cSrcweir		if ( (! -d "$main::OO_SDK_CPP_HOME") ||
361cdf0e10cSrcweir			 ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cppName")) )
362cdf0e10cSrcweir		{
363cdf0e10cSrcweir			print " Error: Could not find directory '$main::OO_SDK_CPP_HOME'.\n";
364cdf0e10cSrcweir			if ( skipChoice("C++ compiler") == 1 )
365cdf0e10cSrcweir			{
366cdf0e10cSrcweir				$main::correctVersion = 1;
367cdf0e10cSrcweir			}
368cdf0e10cSrcweir			$main::OO_SDK_CPP_HOME = "";
369cdf0e10cSrcweir		} else
370cdf0e10cSrcweir		{
371cdf0e10cSrcweir			#check version
372cdf0e10cSrcweir			if ( $main::cppName eq "gcc" )
373cdf0e10cSrcweir			{
374cdf0e10cSrcweir				my $testVersion = `$OO_SDK_CPP_HOME/$main::cppName -dumpversion`;
375cdf0e10cSrcweir				if ( $testVersion eq "")
376cdf0e10cSrcweir				{
377cdf0e10cSrcweir					print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a ";
378cdf0e10cSrcweir					print " GNU compiler.\nSet the environment variable OO_SDK_CPP_HOME to your GNU build tools ";
379cdf0e10cSrcweir					print " directory.\nA GNU compiler version $main::cppVersion can be obtained at ";
380cdf0e10cSrcweir					print " ftp://ftp.gnu.org/gnu/gcc/\n";
381cdf0e10cSrcweir				} else
382cdf0e10cSrcweir				{
383cdf0e10cSrcweir					$main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1);
384cdf0e10cSrcweir					if ( !$main::correctVersion )
385cdf0e10cSrcweir					{
386cdf0e10cSrcweir						print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n";
387cdf0e10cSrcweir						if ( skipChoice("C++ compiler") == 1 )
388cdf0e10cSrcweir						{
389cdf0e10cSrcweir							$main::correctVersion = 1;
390cdf0e10cSrcweir						}
391cdf0e10cSrcweir
392cdf0e10cSrcweir						$main::OO_SDK_CPP_HOME = "";
393cdf0e10cSrcweir					}
394cdf0e10cSrcweir				}
395cdf0e10cSrcweir			} else
396cdf0e10cSrcweir			{
397cdf0e10cSrcweir				# for Solaris we have to check the version too
398cdf0e10cSrcweir				open(FILE, "$OO_SDK_CPP_HOME/$main::cppName -V 2>&1 |");
399cdf0e10cSrcweir				my @lines = <FILE>;
400cdf0e10cSrcweir				my $testVersion = $lines[0];
401cdf0e10cSrcweir				if ( $testVersion eq "")
402cdf0e10cSrcweir				{
403cdf0e10cSrcweir					print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a ";
404cdf0e10cSrcweir					print " Solaris C++ compiler.\nSet the environment variable OO_SDK_CPP_HOME to your Solaris C++ compiler directory.\n";
405cdf0e10cSrcweir				} else
406cdf0e10cSrcweir				{
407cdf0e10cSrcweir				    if ($testVersion =~ m#((\d+\.)+\d+)# )
408cdf0e10cSrcweir					{
409cdf0e10cSrcweir						$testVersion = $1;
410cdf0e10cSrcweir					}
411cdf0e10cSrcweir					$main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1);
412cdf0e10cSrcweir					if ( !$main::correctVersion )
413cdf0e10cSrcweir					{
414cdf0e10cSrcweir						print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n";
415cdf0e10cSrcweir						if ( skipChoice("C++ compiler") == 1 )
416cdf0e10cSrcweir						{
417cdf0e10cSrcweir							$main::correctVersion = 1;
418cdf0e10cSrcweir						}
419cdf0e10cSrcweir
420cdf0e10cSrcweir						$main::OO_SDK_CPP_HOME = "";
421cdf0e10cSrcweir					} else {
422cdf0e10cSrcweir						$main::correctVersion = testVersion("5.5", $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 2);
423cdf0e10cSrcweir						if ( $main::correctVersion ) {
424cdf0e10cSrcweir							$main::OO_SDK_CC_55_OR_HIGHER = $testVersion;
425cdf0e10cSrcweir						}
426cdf0e10cSrcweir					}
427cdf0e10cSrcweir				}
428cdf0e10cSrcweir			}
429cdf0e10cSrcweir		}
430cdf0e10cSrcweir	} else
431cdf0e10cSrcweir	{
432cdf0e10cSrcweir		# the C++ compiler is optional
433cdf0e10cSrcweir		$main::correctVersion = 1;
434cdf0e10cSrcweir	}
435cdf0e10cSrcweir}
436cdf0e10cSrcweir
437cdf0e10cSrcweir
438cdf0e10cSrcweir# prepare Java path
439cdf0e10cSrcweir$main::correctVersion = 0;
440cdf0e10cSrcweir
441cdf0e10cSrcweir# prepare Java suggestion (cut bin or Commands directory to be in the root of the Java SDK)
442cdf0e10cSrcweir$main::offset = rindex($main::OO_SDK_JAVA_HOME_SUGGESTION, "/$main::OO_SDK_JAVA_BIN_DIR");
443cdf0e10cSrcweirif ( $main::offset != -1 )
444cdf0e10cSrcweir{
445cdf0e10cSrcweir	$main::OO_SDK_JAVA_HOME_SUGGESTION = substr($main::OO_SDK_JAVA_HOME_SUGGESTION, 0, $main::offset);
446cdf0e10cSrcweir}
447cdf0e10cSrcweir
448cdf0e10cSrcweirwhile ( (!$main::correctVersion) &&
449cdf0e10cSrcweir		((! -d "$main::OO_SDK_JAVA_HOME" ) ||
450cdf0e10cSrcweir		 ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac"))) )
451cdf0e10cSrcweir{
452cdf0e10cSrcweir	print " Enter Java SDK (1.5, recommendation is 1.6 or higher) installation directory  (optional) [$main::OO_SDK_JAVA_HOME_SUGGESTION]: ";
453cdf0e10cSrcweir	$main::OO_SDK_JAVA_HOME = readStdIn();
454cdf0e10cSrcweir	chop($main::OO_SDK_JAVA_HOME);
455cdf0e10cSrcweir	if ( $main::OO_SDK_JAVA_HOME eq "" )
456cdf0e10cSrcweir	{
457cdf0e10cSrcweir		$main::OO_SDK_JAVA_HOME = $main::OO_SDK_JAVA_HOME_SUGGESTION;
458cdf0e10cSrcweir	}
459cdf0e10cSrcweir	if ( ! $main::OO_SDK_JAVA_HOME eq "" )
460cdf0e10cSrcweir	{
461cdf0e10cSrcweir		if ( (! -d "$main::OO_SDK_JAVA_HOME") ||
462cdf0e10cSrcweir			 ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac")) )
463cdf0e10cSrcweir		{
464cdf0e10cSrcweir			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";
465cdf0e10cSrcweir			if ( skipChoice("JAVA SDK") == 1 )
466cdf0e10cSrcweir			{
467cdf0e10cSrcweir				$main::correctVersion = 1;
468cdf0e10cSrcweir			}
469cdf0e10cSrcweir			$main::OO_SDK_JAVA_HOME = "";
470cdf0e10cSrcweir		} else
471cdf0e10cSrcweir		{
472cdf0e10cSrcweir			#check version
473cdf0e10cSrcweir			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#".*##'`;
474cdf0e10cSrcweir			$testVersion =~ s#([^\n]+)\n#$1#go;
475cdf0e10cSrcweir
476cdf0e10cSrcweir			$main::correctVersion = testVersion($main::javaVersion, $testVersion, "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/java", 1);
477cdf0e10cSrcweir			if ( !$main::correctVersion )
478cdf0e10cSrcweir			{
479cdf0e10cSrcweir				if ( skipChoice("JAVA SDK") == 1 )
480cdf0e10cSrcweir				{
481cdf0e10cSrcweir					$main::correctVersion = 1;
482cdf0e10cSrcweir				}
483cdf0e10cSrcweir				$main::OO_SDK_JAVA_HOME = "";
484cdf0e10cSrcweir			}
485cdf0e10cSrcweir		}
486cdf0e10cSrcweir	}else
487cdf0e10cSrcweir	{
488cdf0e10cSrcweir		# the Java SDK is optional
489cdf0e10cSrcweir		$main::correctVersion = 1;
490cdf0e10cSrcweir	}
491cdf0e10cSrcweir}
492cdf0e10cSrcweir
493cdf0e10cSrcweir
494cdf0e10cSrcweir# prepare output directory (optional)
495cdf0e10cSrcweirwhile ( (!$main::skipOutputDir) &&
496cdf0e10cSrcweir		(! -d "$main::OO_SDK_OUTPUT_DIR") )
497cdf0e10cSrcweir{
498cdf0e10cSrcweir	print " Default output directory is in your HOME directory.\n";
499cdf0e10cSrcweir	print " Enter an existent directory if you prefer a different output directory (optional) [$main::OO_SDK_OUTPUT_DIR_SUGGESTION]: ";
500cdf0e10cSrcweir
501cdf0e10cSrcweir	$main::OO_SDK_OUTPUT_DIR = readStdIn();
502cdf0e10cSrcweir
503cdf0e10cSrcweir	chop($main::OO_SDK_OUTPUT_DIR);
504cdf0e10cSrcweir	if ( $main::OO_SDK_OUTPUT_DIR eq "" )
505cdf0e10cSrcweir	{
506cdf0e10cSrcweir		$main::OO_SDK_OUTPUT_DIR = $main::OO_SDK_OUTPUT_DIR_SUGGESTION;
507cdf0e10cSrcweir	}
508cdf0e10cSrcweir	if ( ! $main::OO_SDK_OUTPUT_DIR eq "" )
509cdf0e10cSrcweir	{
510cdf0e10cSrcweir		if ( ! -d "$main::OO_SDK_OUTPUT_DIR" )
511cdf0e10cSrcweir		{
512cdf0e10cSrcweir			print " Error: Could not find directory '$main::OO_SDK_OUTPUT_DIR'.\n";
513cdf0e10cSrcweir			if ( skipChoice("optional output directory") == 1 )
514cdf0e10cSrcweir			{
515cdf0e10cSrcweir				$main::skipOutputDir = 1;
516cdf0e10cSrcweir			}
517cdf0e10cSrcweir			$main::OO_SDK_OUTPUT_DIR = "";
518cdf0e10cSrcweir		}
519cdf0e10cSrcweir	} else
520cdf0e10cSrcweir	{
521cdf0e10cSrcweir		# the output directory is optional
522cdf0e10cSrcweir		$main::skipOutputDir = 1;
523cdf0e10cSrcweir	}
524cdf0e10cSrcweir}
525cdf0e10cSrcweir
526cdf0e10cSrcweir# prepare auto deployment
527*b3ba5bc7SJürgen Schmidtwhile ( $main::SDK_AUTO_DEPLOYMENT eq "" ||
528*b3ba5bc7SJürgen Schmidt	((! $main::SDK_AUTO_DEPLOYMENT eq "YES") &&
529*b3ba5bc7SJürgen Schmidt	 (! $main::SDK_AUTO_DEPLOYMENT eq "NO")) )
530cdf0e10cSrcweir{
531*b3ba5bc7SJürgen Schmidt    print " Automatic deployment of UNO components (YES/NO) [$main::SDK_AUTO_DEPLOYMENT_SUGGESTION]: ";
532*b3ba5bc7SJürgen Schmidt    $main::SDK_AUTO_DEPLOYMENT = uc <STDIN>;
533*b3ba5bc7SJürgen Schmidt    chop($main::SDK_AUTO_DEPLOYMENT);
534*b3ba5bc7SJürgen Schmidt    if ( $main::SDK_AUTO_DEPLOYMENT eq "" )
535cdf0e10cSrcweir    {
536*b3ba5bc7SJürgen Schmidt	$main::SDK_AUTO_DEPLOYMENT = "YES";
537cdf0e10cSrcweir    }
538cdf0e10cSrcweir}
539cdf0e10cSrcweir
540985d02c7SAriel Constenla-HaileprepareScriptFile("setsdkenv_unix.sh.in", "setsdkenv_unix.sh");
541cdf0e10cSrcweirchmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh";
542cdf0e10cSrcweir
543cdf0e10cSrcweirprint "\n";
544cdf0e10cSrcweirprint " ************************************************************************\n";
545cdf0e10cSrcweirprint " * ... your SDK environment has been prepared.\n";
546cdf0e10cSrcweirprint " * For each time you want to use this configured SDK environment, you\n";
547cdf0e10cSrcweirprint " * have to run the \"setsdkenv_unix\" script file!\n";
548cdf0e10cSrcweirprint " * Alternatively can you source one of the scripts\n";
549cdf0e10cSrcweirprint " *   \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh\"\n";
550cdf0e10cSrcweirprint " * to get an environment without starting a new shell.\n";
551cdf0e10cSrcweirprint " ************************************************************************\n\n";
552cdf0e10cSrcweir
553cdf0e10cSrcweirexit $return;
554cdf0e10cSrcweir
555cdf0e10cSrcweirsub skipChoice
556cdf0e10cSrcweir{
557cdf0e10cSrcweir	my $msg = shift;
558cdf0e10cSrcweir	my $skip = "";
559cdf0e10cSrcweir	while ( !( $skip eq "yes" || $skip eq "no") )
560cdf0e10cSrcweir	{
561cdf0e10cSrcweir		print " Do you want to skip the choice of the '$msg' (YES/NO): [YES] ";
562cdf0e10cSrcweir		$skip = lc <STDIN>;
563cdf0e10cSrcweir		chop($skip);
564cdf0e10cSrcweir		if ( $skip eq "" ) { $skip = "yes"; } # default
565cdf0e10cSrcweir		if ( $skip eq "yes" )
566cdf0e10cSrcweir		{
567cdf0e10cSrcweir			return 1;
568cdf0e10cSrcweir		}
569cdf0e10cSrcweir	}
570cdf0e10cSrcweir	return 0;
571cdf0e10cSrcweir}
572cdf0e10cSrcweir
573cdf0e10cSrcweirsub resolveLink
574cdf0e10cSrcweir{
575cdf0e10cSrcweir    my $base= shift;
576cdf0e10cSrcweir    my $link= shift;
577cdf0e10cSrcweir
578cdf0e10cSrcweir    my $resolvedpath = "$base/$link";
579cdf0e10cSrcweir    my $linktarget =  readlink "$resolvedpath";
580cdf0e10cSrcweir    my $resolvedlink = "";
581cdf0e10cSrcweir
582cdf0e10cSrcweir    while ( $linktarget ne "") {
583cdf0e10cSrcweir
584cdf0e10cSrcweir	if ( $linktarget =~ m/^\/.*/ )
585cdf0e10cSrcweir	{
586cdf0e10cSrcweir	    $resolvedpath = "$linktarget";
587cdf0e10cSrcweir	} else {
588cdf0e10cSrcweir	    $resolvedpath = `cd $base/$linktarget; pwd`;
589cdf0e10cSrcweir	    chop $resolvedpath;
590cdf0e10cSrcweir	}
591cdf0e10cSrcweir	$base = dirname("$resolvedpath");
592cdf0e10cSrcweir
593cdf0e10cSrcweir	$linktarget = readlink "$resolvedpath";
594cdf0e10cSrcweir    }
595cdf0e10cSrcweir
596cdf0e10cSrcweir    $resolvedlink = `cd $resolvedpath; pwd`;
597cdf0e10cSrcweir    chop $resolvedlink;
598cdf0e10cSrcweir    return $resolvedlink;
599cdf0e10cSrcweir}
600cdf0e10cSrcweir
601cdf0e10cSrcweirsub searchprog
602cdf0e10cSrcweir{
603cdf0e10cSrcweir	my $_search= shift;
604cdf0e10cSrcweir	my $tmpPath = `echo "\$PATH"`;
605cdf0e10cSrcweir	my @pathList = split(":" , $tmpPath);
606cdf0e10cSrcweir	my $progDir = "";
607cdf0e10cSrcweir
608cdf0e10cSrcweir    if ( $_search eq "javac" )
609cdf0e10cSrcweir    {
610cdf0e10cSrcweir		if ( $main::operatingSystem =~ m/darwin/ ) {
611cdf0e10cSrcweir			$progDir = resolveLink("/System/Library/Frameworks/JavaVM.Framework/Versions", "CurrentJDK");
612cdf0e10cSrcweir
613cdf0e10cSrcweir			if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
614cdf0e10cSrcweir			{
615cdf0e10cSrcweir				return "$progDir/$main::OO_SDK_JAVA_BIN_DIR";
616cdf0e10cSrcweir			}
617cdf0e10cSrcweir		}
618cdf0e10cSrcweir
619cdf0e10cSrcweir		if ( $main::operatingSystem =~ m/solaris/ ) {
620cdf0e10cSrcweir			$progDir = resolveLink("/usr/jdk", "latest");
621cdf0e10cSrcweir			if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
622cdf0e10cSrcweir			{
623cdf0e10cSrcweir				return "$progDir/$main::OO_SDK_JAVA_BIN_DIR";
624cdf0e10cSrcweir			}
625cdf0e10cSrcweir		}
626cdf0e10cSrcweir    }
627cdf0e10cSrcweir
628cdf0e10cSrcweir    if ( $_search eq "gmake" && $main::operatingSystem =~ m/solaris/ ) {
629cdf0e10cSrcweir		if ( -e "/usr/sfw/bin/gmake" )
630cdf0e10cSrcweir		{
631cdf0e10cSrcweir			return "/usr/sfw/bin";
632cdf0e10cSrcweir		}
633cdf0e10cSrcweir    }
634cdf0e10cSrcweir
635cdf0e10cSrcweir	foreach $i (@pathList)
636cdf0e10cSrcweir	{
637cdf0e10cSrcweir	    chomp ($i);
638cdf0e10cSrcweir
639cdf0e10cSrcweir		if ( -e "$i/$_search" )
640cdf0e10cSrcweir		{
641cdf0e10cSrcweir
642cdf0e10cSrcweir			if ( index($i, "/") == 0 )
643cdf0e10cSrcweir			{
644cdf0e10cSrcweir				# # absolute path; leave unchanged
645cdf0e10cSrcweir				$progDir = $i;
646cdf0e10cSrcweir			} else
647cdf0e10cSrcweir			{
648cdf0e10cSrcweir				$progDir = `cd "$i"; pwd`;
649cdf0e10cSrcweir			}
650cdf0e10cSrcweir			return $progDir
651cdf0e10cSrcweir		}
652cdf0e10cSrcweir	}
653cdf0e10cSrcweir	return $progDir
654cdf0e10cSrcweir}
655cdf0e10cSrcweir
656cdf0e10cSrcweirsub searchMacOffice
657cdf0e10cSrcweir{
658599cc5b4SOliver-Rainer Wittmann	if (-d "/Applications/OpenOffice.app" ) {
659599cc5b4SOliver-Rainer Wittmann		return "/Applications/OpenOffice.app"
660ff3f4ebcSOliver-Rainer Wittmann	}
661cdf0e10cSrcweir	return "";
662cdf0e10cSrcweir}
663cdf0e10cSrcweir
664cdf0e10cSrcweirsub searchoffice
665cdf0e10cSrcweir{
666599cc5b4SOliver-Rainer Wittmann	my $offset = rindex($main::sdkpath, "/openoffice");
667cdf0e10cSrcweir	my $tmpOffice = substr($main::sdkpath, 0, $offset);
668599cc5b4SOliver-Rainer Wittmann	my $officepath = "$tmpOffice/openoffice$main::OO_MAJORVERSION";
669cdf0e10cSrcweir
670cdf0e10cSrcweir#	if ( $main::OO_MINORVERSION > 0) {
671cdf0e10cSrcweir#		$officepath = "$officepath$main::OO_MINORVERSION";
672cdf0e10cSrcweir#	}
673cdf0e10cSrcweir
674cdf0e10cSrcweir	# search corresponding office for this SDK
675cdf0e10cSrcweir	if (-d $officepath && -e "$officepath/program/soffice") {
676cdf0e10cSrcweir		return $officepath;
677cdf0e10cSrcweir	}
678*b3ba5bc7SJürgen Schmidt	return "";
679cdf0e10cSrcweir}
680cdf0e10cSrcweir
681cdf0e10cSrcweir
682cdf0e10cSrcweir
683cdf0e10cSrcweirsub testVersion
684cdf0e10cSrcweir{
685cdf0e10cSrcweir	my $tmpMustBeVersion = shift;
686cdf0e10cSrcweir	my $tmpTestVersion = shift;
687cdf0e10cSrcweir	my $toolName = shift;
688cdf0e10cSrcweir	# 1=check + message 2=check only
689cdf0e10cSrcweir	my $checkOnly = shift;
690cdf0e10cSrcweir	my @mustBeVersion = split(/\.|_|-/,$tmpMustBeVersion);
691cdf0e10cSrcweir	my @testVersion = split(/\.|_|-/,$tmpTestVersion);
692cdf0e10cSrcweir	my $length = $#mustBeVersion;
693cdf0e10cSrcweir
694cdf0e10cSrcweir	if ($#testVersion < $#mustBeVersion) {
695cdf0e10cSrcweir	    $length = $#testVersion;
696cdf0e10cSrcweir	}
697cdf0e10cSrcweir
698cdf0e10cSrcweir	for ($i=0; $i <= $length; $i++ )
699cdf0e10cSrcweir	{
700985d02c7SAriel Constenla-Haile		if ( @testVersion[$i] > @mustBeVersion[$i] )
701cdf0e10cSrcweir		{
702cdf0e10cSrcweir			return 1; # 1 indicates a correct version
703cdf0e10cSrcweir		}
704cdf0e10cSrcweir
705985d02c7SAriel Constenla-Haile		if ( @testVersion[$i] < @mustBeVersion[$i] )
706cdf0e10cSrcweir		{
707cdf0e10cSrcweir			if ( $#checkOnly == 1 ) {
708cdf0e10cSrcweir				print " The command '$toolName' has the version $tmpTestVersion.\n";
709cdf0e10cSrcweir				print " The SDK requires at least the version $tmpMustBeVersion.\n";
710cdf0e10cSrcweir			}
711cdf0e10cSrcweir			return 0;
712cdf0e10cSrcweir		}
713cdf0e10cSrcweir	}
714cdf0e10cSrcweir
715cdf0e10cSrcweir	return 1; # 1 indicates a correct version
716cdf0e10cSrcweir}
717cdf0e10cSrcweir
718cdf0e10cSrcweirsub readStdIn
719cdf0e10cSrcweir{
720cdf0e10cSrcweir	my $tmpstdin = <STDIN>;
721cdf0e10cSrcweir	if ( index($tmpstdin, "\$") != -1)
722cdf0e10cSrcweir	{
723cdf0e10cSrcweir	    return `echo $tmpstdin`;
724cdf0e10cSrcweir	}
725cdf0e10cSrcweir
726cdf0e10cSrcweir	return $tmpstdin;
727cdf0e10cSrcweir}
728cdf0e10cSrcweir
729cdf0e10cSrcweirsub prepareScriptFile()
730cdf0e10cSrcweir{
731cdf0e10cSrcweir	my $inputFile = shift;
732cdf0e10cSrcweir	my $outputFile = shift;
733cdf0e10cSrcweir
734cdf0e10cSrcweir	if ( ! -d "$main::OO_SDK_CONFIG_HOME/$main::hostname" )
735cdf0e10cSrcweir	{
736cdf0e10cSrcweir		system("mkdir -p $main::OO_SDK_CONFIG_HOME/$main::hostname");
737cdf0e10cSrcweir	}
738cdf0e10cSrcweir
739cdf0e10cSrcweir	open ( FILEIN, "$main::sdkpath/$inputFile" ) || die "\nERROR: could not open '$main::sdkpath/$inputFile' for reading";
740cdf0e10cSrcweir	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";
741cdf0e10cSrcweir
742cdf0e10cSrcweir	while ( <FILEIN> )
743cdf0e10cSrcweir	{
744cdf0e10cSrcweir		$_ =~ s#\@OO_SDK_NAME\@#$main::OO_SDK_NAME#go;
745cdf0e10cSrcweir		$_ =~ s#\@OO_SDK_HOME\@#$main::OO_SDK_HOME#go;
746cdf0e10cSrcweir		$_ =~ s#\@OFFICE_HOME\@#$main::OFFICE_HOME#go;
747*b3ba5bc7SJürgen Schmidt#		$_ =~ s#\@OFFICE_BASE_HOME\@#$main::OFFICE_BASE_HOME#go;
748cdf0e10cSrcweir		$_ =~ s#\@OO_SDK_MAKE_HOME\@#$main::OO_SDK_MAKE_HOME#go;
749cdf0e10cSrcweir		$_ =~ s#\@OO_SDK_ZIP_HOME\@#$main::OO_SDK_ZIP_HOME#go;
750*b3ba5bc7SJürgen Schmidt		$_ =~ s#\@OO_SDK_CAT_HOME\@#$main::OO_SDK_CAT_HOME#go;
751*b3ba5bc7SJürgen Schmidt		$_ =~ s#\@OO_SDK_SED_HOME\@#$main::OO_SDK_SED_HOME#go;
752cdf0e10cSrcweir		$_ =~ s#\@OO_SDK_CPP_HOME\@#$main::OO_SDK_CPP_HOME#go;
753cdf0e10cSrcweir		$_ =~ s#\@OO_SDK_CC_55_OR_HIGHER\@#$main::OO_SDK_CC_55_OR_HIGHER#go;
754cdf0e10cSrcweir		$_ =~ s#\@OO_SDK_JAVA_HOME\@#$main::OO_SDK_JAVA_HOME#go;
755cdf0e10cSrcweir		$_ =~ s#\@SDK_AUTO_DEPLOYMENT\@#$main::SDK_AUTO_DEPLOYMENT#go;
756cdf0e10cSrcweir		$_ =~ s#\@OO_SDK_OUTPUT_DIR\@#$main::OO_SDK_OUTPUT_DIR#go;
757cdf0e10cSrcweir
758cdf0e10cSrcweir		print FILEOUT $_;
759cdf0e10cSrcweir	}
760cdf0e10cSrcweir
761cdf0e10cSrcweir	close FILEIN;
762cdf0e10cSrcweir	close FILEOUT;
763cdf0e10cSrcweir}
764