xref: /aoo41x/main/set_soenv.in (revision 5a0f8c8d)
1#!@PERL@ -w
2#
3###############################################################
4#
5#  Licensed to the Apache Software Foundation (ASF) under one
6#  or more contributor license agreements.  See the NOTICE file
7#  distributed with this work for additional information
8#  regarding copyright ownership.  The ASF licenses this file
9#  to you under the Apache License, Version 2.0 (the
10#  "License"); you may not use this file except in compliance
11#  with the License.  You may obtain a copy of the License at
12#
13#    http://www.apache.org/licenses/LICENSE-2.0
14#
15#  Unless required by applicable law or agreed to in writing,
16#  software distributed under the License is distributed on an
17#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18#  KIND, either express or implied.  See the License for the
19#  specific language governing permissions and limitations
20#  under the License.
21#
22###############################################################
23
24#---------------------------------------------------------------------------
25# Description:
26# set_soenv generates a file that contains all necessary
27# environment variables for the build proces of OpenOffice
28# on Linux, NetBSD, Solaris, Windows NT and Mac OS X/Darwin.
29#
30# Program steps.
31#
32# I.    Checking the command-line arguments.
33# IIa.  Declaring variables for the system commands, etc.
34# IIb.  Declaring the environment variables.
35# III.  Initialising the variables for the system commands, etc.
36# IV.   Print out some important messages etc.
37# V.    Initialising the environment variables.
38# VI.   Open the output file.
39# VII.  Writing the data to the output file.
40# VIII. Closing output file.
41# IX.   Sourcing the output file.
42# X.    Set up the build environment.
43# XI.   Moving the output file to the build home directory.
44#
45#---------------------------------------------------------------------------
46#
47use strict;                        # pragma
48use File::Basename;
49
50
51#
52#--------------------------------------------------------
53# IIa. Declaring variables for the system commands, etc.
54#--------------------------------------------------------
55#
56my ( $outfile, $outfile_sh, $outfile_bat, $bootfile, $newline, $comment,
57     $compiler, $unsetenv, $setenv, $unset, $set, $ds, $ps,
58     $wps, $cur_dir, $par_dir, $I, $L, $D, $buildenv, $answer, $tmp, $MINGW,
59     $USE_MINGW, $platform,
60     $cygwinver, $empty, $no_ant, $no_stl, $no_gcc_include,
61     $no_gxx_include, $warnfile, $Warning, $result, $unsetvars, $unsetvarssh, $unsetvarsbat, $exportvars, $win_format_var, $perl_os, @mingw_lib_include_paths, $mingw_lib_include_path);
62#
63#-------------------------------------------------
64# IIb. Declaring environment values (constants).
65#-------------------------------------------------
66#
67# Platform independent constant values.
68my @DICTIONARIES = ("DADK", "DEDE", "ENGB", "ENUS", "HUHU", "ITIT", "RURU", "THTH", "SWTZ" );
69my ( $CALL_CDECL, $COMMON_OUTDIR, $BMP_WRITES_FLAG,
70     $common_build, $NO_REC_RES, $SO3, $SOLAR_JAVA,
71     $SOLAR_PLUGIN, $UPDATER, $BUILD_DELIVER, $VCL,
72     $CC, $CXX,
73     $BUILD_SOSL, $ENABLEUNICODE, $NEW_JAR_PACK, $NO_BSYMBOLIC,
74     $BUILD_SOSL_RELEASE, $RSC_ONCE );
75#
76# Platform dependent constant values.
77my ( $BIG_SVX, $COM, $ARCH, $CPU, $CPUNAME, $CVER, $GLIBC, $GUI, $GUIBASE,
78      $GVER, $OS, $OSVERSION, $OUTPATH, $INPATH, $PATH_SEPERATOR,
79      $DYNAMIC_CRT, $SET_EXCEPTIONS, $use_shl_versions, $CDPATHx, $JRELIBDIR,
80      $JRETOOLKITDIR, $JRETHREADDIR,
81      $FLIPCMD );
82#
83#-------------------------------------------
84# IIc. Declaring the environment variables.
85#-------------------------------------------
86#
87# Help variables.
88my ( $USR, $ETC, $BIN, $LIB, $LIB64, $INC, $INCLUDE, $DEV, $OPT, $LOCAL, $SOLENV, $SOLVER, $CONFIG,
89     $USR_BIN, $USR_LIB, $USR_LOCAL, $USR_CCS, $JAVA_BIN, $JAVA_LIB, $JAVA_INCLUDE,
90     $SOLARENVINC, $USR_DT, $USR_OPENWIN, $XLIB, $XINC,
91     $CYGWIN_PATH, $language, $dict, $ASM_PATH, $NASM_PATH, $NSIS_PATH, $PERL_PATH );
92
93# Environment variables.
94my ( $oldPATH, $SRC_ROOT, $SO_HOME, $JAVA_HOME, $JDK, $JAVAFLAGS, $OOO_SHELL,
95     $UPD, $WORK_STAMP, $SOURCE_ROOT_DIR , $gb_REPOS,
96     $SOLARSRC, $DEVROOT, $SOLARVER, $SOLARVERSION, $WORKDIR, $OUTDIR, $SOLARENV,
97     $STAR_INIROOT, $STAR_INIROOTOLD, $STAR_STANDLST, $STAR_SSCOMMON, $STAR_SSOLARINI,
98     $DMAKEROOT, $CLASSPATH, $XCLASSPATH, $COMPATH, $CXX_X64_BINARY, $LINK_X64_BINARY, $LIBMGR_X64_BINARY,
99     $MSPDB_PATH, $MIDL_PATH, $CSC_PATH, $MACOSX_DEPLOYMENT_TARGET, $MACOSX_SDK_PATH,
100     $PATH, $SOLAREXTRAINC, $SOLAREXTRALIB, $SOLARLIB,
101     $SOLARINC, $LOCALINI, $FRAMEWORKSHOME, $COMEX, $PERL,
102     $COMP_ENV, $ILIB, $JAVAHOME, $PSDK_HOME, $DIRECTXSDK_LIB, $USE_NEW_SDK, $FRAME_HOME,
103     $USE_DIRECTX5, $ATL_LIB, $ATL_LIB_X64, $HAVE_ATLTHUNK, $ATL_INCLUDE, $MFC_LIB, $MFC_INCLUDE, $TMPDIR,
104     $COMMON_BUILD_TOOLS, $WIN_GREP, $WIN_FIND, $WIN_LS,
105     $WIN_GNUCOPY, $WIN_TOUCH, $MOZILLABUILD,
106	 $PROEXT, $TARFILE_LOCATION,
107     $ENABLE_HUNSPELL, $ENABLE_HYPHEN,
108     $SYSTEM_PYTHON, $EPM_FLAGS);
109#
110#-------------------------------------------
111# IId. Declaring the aliases.
112#-------------------------------------------
113#
114my ( $dmake, $build, $build_client, $nmake, $mkout, $deliver, $zipdep );
115#
116
117#-------------------------------------------------------------
118# IIIa. Initialising constants.
119#-------------------------------------------------------------
120#
121# $platform is needed for PathFormat()
122#
123$platform          = `./config.guess`;
124chomp( $platform );
125
126$UPD            = '@UPD@';          # the project's UPD
127$newline        = "\n";             # Perl newline character
128$unsetenv       = "unsetenv";       # c-shell command
129$setenv         = "setenv";         # c-shell command
130$unset          = "unset";          # msdos batch file command
131$set            = "set";            # msdos batch file command
132$ds             = "/";              # directory separator
133$ps             = ":";              # path separator
134$wps            = ":";              # path separator, will be set to ';' for windows later.
135$cur_dir        = ".";              # current directory
136$par_dir        = "..";             # parrent directory
137$I              = " -I";            # include search path
138$L              = " -L";            # library search path
139$D              = " -D";            # define search path
140$empty          = "";               # used as argument
141$warnfile       = "warn";           # logfile configure warnings.
142$Warning        = "";               # container for warning messages
143$SYSTEM_PYTHON	= '@SYSTEM_PYTHON@';
144$JDK 		= '@JDK@';
145$JAVAFLAGS 		= '@JAVAFLAGS@';
146$MINGW          = '@WITH_MINGWIN@'; # use MinGW for Windows build
147$USE_MINGW      = '@USE_MINGW@';     # use MinGW in cygwin or pure-mingw
148if ( $MINGW eq "yes" )
149{ $CC             = '@CC@';           # C compiler
150  $CXX            = '@CXX@'; }        # C++ compiler
151else
152{ $CC             = PathFormat('@CC@');           # C compiler
153  $CXX            = PathFormat('@CXX@'); }        # C++ compiler
154$FLIPCMD        = "";               # Flip '/' to '\' wrapper (only for winnt)
155$GLIBC          = "";               # Whether the platform uses glibc
156$PROEXT         = "@PROEXT@";
157$EPM_FLAGS	= "";
158
159# Required for OS/2 macro expansion
160my @unixroot='@unixroot';
161
162#
163#--------------------------------------------------------------------
164# IV. Initialise the warning container and print a note to the user.
165#--------------------------------------------------------------------
166#
167# Add the configure (pre-requisite) warnings to the warning container
168# , $Warning.
169AddWarning( "configure", "" );
170#
171print ("Setting up the environment for building Apache OpenOffice $newline");
172#
173#--------------------------------------------------
174# V. Setting the environment variables/values.
175#--------------------------------------------------
176#
177# A. Checking the platform first.
178#
179# get perls idea for OS
180# needed to differentiate cygwin/native perl on windows
181$perl_os = $^O;
182
183#
184# B. Gathering information from the system.
185#
186# 1. Path
187$oldPATH = $ENV{"PATH"};
188chomp( $oldPATH );                  # cut off new line
189#
190# C. Setting the constant values.
191#
192# Setting platform independent constant values.
193print "Setting platform independent values... ";
194# NB: Language options now set at 'ToFile' stage.
195$BMP_WRITES_FLAG      = "TRUE";
196$BUILD_SOSL_RELEASE   = "TRUE";
197$RSC_ONCE             = "TRUE";
198$CALL_CDECL           = "TRUE";
199$COMMON_OUTDIR        = "";
200$common_build         = "";
201$NO_REC_RES           = "TRUE";
202$SO3                  = "TRUE";
203$SOLAR_JAVA           = "@SOLAR_JAVA@";
204$SOLAR_PLUGIN         = "TRUE";
205$UPDATER              = "YES";
206$BUILD_DELIVER        = "true";
207$VCL                  = "TRUE";
208$BUILD_SOSL           = "true";
209$ENABLEUNICODE        = "TRUE";
210$NEW_JAR_PACK         = "TRUE";
211$NO_BSYMBOLIC         = "TRUE";
212$comment              = "#";           # UNIX script comment character
213$TARFILE_LOCATION = "@TARFILE_LOCATION@"; # where to find tarballs with external sources
214
215# Setting platform dependent constant values.
216if ( $platform =~ m/solaris/ )
217{     print "Setting Solaris specific values... ";
218   if ($platform =~ m/^i[3456]86/)
219   {
220      if ( $CC =~ "gcc") {
221         $outfile        = "SolarisX86GccEnv.Set";
222         $OUTPATH        = "unxsogi";
223      } else {
224         $outfile        = "SolarisX86Env.Set";
225         $OUTPATH        = "unxsoli4";
226      }
227      $CPU            = "I";
228      $CPUNAME        = "INTEL";
229	  $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
230	  $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."xawt";
231	  $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
232
233   }
234   else
235   {
236      if ( $CC =~ "gcc") {
237         $outfile        = "SolarisSparcGccEnv.Set";
238         $OUTPATH        = "unxsogs";
239      } else {
240         $outfile        = "SolarisSparcEnv.Set";
241         $OUTPATH        = "unxsols4";
242      }
243      $CPU            = "S";
244      $CPUNAME        = "SPARC";
245	  $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc";
246	  $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."xawt";
247	  $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."native_threads";
248   }
249
250   if ( $CC =~ "gcc") {
251       $COM            = "GCC";
252       $CVER           = "C300";
253   } else {
254       $COM            = "C52";
255       $CVER           = "C52";
256       $COMEX          = 4;
257   }
258   $BIG_SVX        = "TRUE";
259   $COMPATH        = '@COMPATH@';
260   $GUI            = "UNX";
261   $GUIBASE        = "unx";
262   $GVER           = "VCL";
263   $INPATH         = $OUTPATH.$PROEXT;
264   $OS             = "SOLARIS";
265   $PATH_SEPERATOR = $ps;
266}
267elsif ( $platform =~ m/netbsd/ )
268{
269#Set platform specific values:
270   if ($platform =~ m/^i[3456]86/)
271   {  print "Setting NetBSD x86 specific values... ";
272      $outfile        = "NetBSDX86Env.Set";
273      $CPU            = "I";
274      $CPUNAME        = "INTEL";
275      $OUTPATH        = "unxbsdi";
276      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
277      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."client";
278      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
279   }
280   elsif ($platform =~ m/^sparc/)
281   {  print "Setting NetBSD Sparc specific values... ";
282      $outfile        = "NetBSDSparcEnv.Set";
283      $CPU            = "S";
284      $CPUNAME        = "SPARC";
285      $OUTPATH        = "unxbsds";
286      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc";
287      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."client";
288      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."native_threads";
289   }
290   elsif ($platform =~ m/powerpc/)
291   {  print "Setting NetBSD PPC specific values... ";
292      $outfile        = "NetBSDPPCEnv.Set";
293      $CPU            = "P";
294      $CPUNAME        = "POWERPC";
295      $OUTPATH        = "unxbsdppc";
296      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
297      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."classic";
298      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads";
299   }
300   else
301   { print "Unsupported NetBSD architecture: $platform \n";
302     exit 1;
303   }
304   #Conditional setting depending on gcc3:
305      $CVER           = "C300";
306      $OUTPATH        = $OUTPATH."2";
307   # General NetBSD settings:
308      $BIG_SVX        = "TRUE";
309      $COM            = "GCC";
310      $COMPATH        = '@COMPATH@';
311      $GUI            = "UNX";
312      $GUIBASE        = "unx";
313      $GVER           = "VCL";
314      $INPATH         = $OUTPATH.$PROEXT;
315      $OS             = "NETBSD";
316      $PATH_SEPERATOR = $ps;
317}
318elsif ( $platform =~ m/kfreebsd/ )
319{
320# General GNU/kFreeBSD settings:
321      $CVER           = "C341";
322      $BIG_SVX        = "TRUE";
323      $COM            = "GCC";
324      $COMPATH        = '@COMPATH@';
325      $GLIBC          = "2REDHAT60";
326      $GUI            = "UNX";
327      $GUIBASE        = "unx";
328      $GVER           = "VCL";
329      $OS             = "LINUX";
330      $PATH_SEPERATOR = $ps;
331
332#Set platform specific values:
333   if ($platform =~ m/^i[3456]86/)
334   {  print "Setting GNU/kFreeBSD x86 specific values... ";
335      $outfile        = "GNUkFreeBSDX86Env.Set";
336      $CPU            = "I";
337      $CPUNAME        = "INTEL";
338      $OUTPATH        = "unxkfgi6";
339
340      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
341      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."client";
342      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
343
344   }
345   elsif ($platform =~ m/^x86_64/)
346   {  print "Setting GNU/kFreeBSD x86-64 specific values... ";
347      $outfile        = "GNUkFreeBSDX86-64Env.Set";
348      $CPU            = "X";
349      $CPUNAME        = "X86_64";
350      $OUTPATH        = "unxkfgx6";
351
352      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64";
353      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64".$ds."server";
354      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64".$ds."native_threads";
355   }
356
357   $INPATH         = $OUTPATH.$PROEXT;
358}
359elsif ( $platform =~ m/freebsd/ )
360{     $BIG_SVX        = "TRUE";
361      $COM            = "@COM_IS@";
362      $COMPATH        = '@COMPATH@' . '/bin';
363      $CVER           = "C300";
364      $GUI            = "UNX";
365      $GUIBASE        = "unx";
366      $GVER           = "VCL";
367      $OS             = "FREEBSD";
368      $PATH_SEPERATOR = $ps;
369      $OSVERSION      = '@OSVERSION@';
370   if (($platform =~ m/^amd64/) || ($platform =~ m/^x86_64/))
371   {  my ( $JAVA_OS );
372      print "Setting FreeBSD AMD64 specific values... ";
373      $outfile        = "FreeBSDAMDEnv.Set";
374      $CPU            = "X";
375      $CPUNAME        = "X86_64";
376      $OUTPATH        = "unxfbsdx";
377      $JAVA_OS        = '@JAVA_HOME@';
378      $JAVA_OS        =~ s/.*\///;
379      if ($JAVA_OS =~ m/^linux/)
380      {  $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
381         $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."client";
382         $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
383      }
384      else
385      {  $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64";
386         $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64".$ds."server";
387         $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64".$ds."native_threads";
388      }
389   }
390   elsif ($platform =~ m/^i386/)
391   {  print "Setting FreeBSD x86 specific values... ";
392      $outfile        = "FreeBSDX86Env.Set";
393      $CPU            = "I";
394      $CPUNAME        = "INTEL";
395      $OUTPATH        = "unxfbsdi";
396      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
397      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."client";
398      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
399   }
400   elsif ($platform =~ m/^arm.*?l-/)
401   {  print "Setting FreeBSD ARM specific values... ";
402      $outfile        = "FreeBSDARMEnv.Set";
403      $CPU            = "R";
404      $CPUNAME        = "ARM";
405      $OUTPATH        = "unxfbsdr";
406      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."arm";
407      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."arm".$ds."server";
408      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."arm".$ds."native_threads";
409      $EPM_FLAGS      = "-a arm";
410   }
411   elsif ($platform =~ m/^powerpc/)
412   {
413      if (($platform =~ m/^powerpc64/) && ('@SIZEOF_LONG@' eq '8')) {
414         print "Setting FreeBSD PPC64 specific values... ";
415         $outfile = "FreeBSDPPC64Env.Set";
416         $OUTPATH = "unxfbsdppc64";
417         $CPUNAME = "POWERPC64";
418
419         if ( $JDK eq "gcj" ) {
420            $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64";
421            $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64".$ds."client";
422            $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64".$ds."native_threads";
423         }
424      }
425      else {
426         print "Setting FreeBSD PPC specific values... ";
427         $outfile = "FreeBSDPPCEnv.Set";
428         $OUTPATH = "unxlngppc";
429         $CPUNAME = "POWERPC";
430
431         if ( $JDK eq "gcj" ) {
432            $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
433            $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."client";
434            $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads"; }
435         elsif ($JDK =~ m/^[Ii][Bb][Mm]/)
436         {  $JRELIBDIR     = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
437            $JRETOOLKITDIR = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."classic";
438            $JRETHREADDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
439         }
440	 # OpenJDK
441	 elsif ($JDK =~ m/sun/) {
442	    $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
443	    $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."server";
444	    $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads";
445	 }
446      }
447
448      $CPU            = "P";
449
450   }
451   else
452   {  print "Unsupported FreeBSD architecture: $platform \n";
453         exit 1;
454   }
455   if( @GCCVER@ >= 30401 ) {
456      $CVER        = "C341";
457   }
458      $INPATH         = $OUTPATH.$PROEXT;
459}
460elsif ( $platform =~ m/linux/ )
461{
462# General Linux settings:
463      $CVER           = "C341";
464      $BIG_SVX        = "TRUE";
465      $COM            = "GCC";
466      $COMPATH        = '@COMPATH@';
467      $GLIBC          = "2REDHAT60";
468      $GUI            = "UNX";
469      $GUIBASE        = "unx";
470      $GVER           = "VCL";
471      $OS             = "LINUX";
472      $PATH_SEPERATOR = $ps;
473
474#Set platform specific values:
475   if ($platform =~ m/^i[3456]86/)
476   {  print "Setting Linux x86 specific values... ";
477      $outfile        = "LinuxX86Env.Set";
478      $CPU            = "I";
479      $CPUNAME        = "INTEL";
480
481      if ($JDK =~ m/^[Ii][Bb][Mm]/)
482      { $JRELIBDIR     = '$JAVA_HOME'.$ds."jre".$ds."bin";
483        $JRETOOLKITDIR = '$JAVA_HOME'.$ds."jre".$ds."bin".$ds."classic";
484        $JRETHREADDIR  = '$JAVA_HOME'.$ds."jre".$ds."bin"; }
485
486      elsif ($JDK =~ m/^[Bb][Ee][Aa]/)
487      { $JRELIBDIR     = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
488        $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."jrockit";
489        $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads"; }
490
491      else {
492      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
493      # has both server and client
494      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."client";
495      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
496      }
497
498      $OUTPATH     = "unxlngi6";
499   }
500   elsif ($platform =~ m/^x86_64/)
501   {  print "Setting Linux x86-64 specific values... ";
502      $outfile        = "LinuxX86-64Env.Set";
503      $CPU            = "X";
504      $CPUNAME        = "X86_64";
505      $OUTPATH        = "unxlngx6";
506      # Blackdown.org JDK porting project uses `amd64' and `server' in JDK 1.4.2 RC1
507      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64";
508      # has both server and client
509      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64".$ds."server";
510      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64".$ds."native_threads";
511   }
512   elsif ($platform =~ m/^ia64/)
513   {  print "Setting Linux ia64 specific values... ";
514      $outfile        = "LinuxIA64Env.Set";
515      $CPU            = "A";
516      $CPUNAME        = "IA64";
517      $OUTPATH        = "unxlnga";
518      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ia64";
519      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ia64".$ds."server";
520      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ia64".$ds."native_threads";
521   }
522   elsif ($platform =~ m/^sparc/)
523
524   {  print "Setting Linux Sparc specific values... ";
525      $outfile        = "LinuxSparcEnv.Set";
526      $CPU            = "S";
527      $CPUNAME        = "SPARC";
528      $OUTPATH        = "unxlngs";
529      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc";
530      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."server";
531      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."native_threads";
532   }
533   elsif ($platform =~ m/^powerpc/)
534   {
535      if (($platform =~ m/^powerpc64/) && ('@SIZEOF_LONG@' eq '8')) {
536         print "Setting Linux PPC64 specific values... ";
537         $outfile = "LinuxPPC64Env.Set";
538         $OUTPATH = "unxlngppc64";
539         $CPUNAME = "POWERPC64";
540
541         if ( $JDK eq "gcj" ) {
542            $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64";
543            $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64".$ds."client";
544            $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64".$ds."native_threads";
545         }
546      }
547      else {
548         print "Setting Linux PPC specific values... ";
549         $outfile = "LinuxPPCEnv.Set";
550         $OUTPATH = "unxlngppc";
551         $CPUNAME = "POWERPC";
552
553         if ( $JDK eq "gcj" ) {
554            $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
555            $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."client";
556            $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads"; }
557         elsif ($JDK =~ m/^[Ii][Bb][Mm]/)
558         {  $JRELIBDIR     = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
559            $JRETOOLKITDIR = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."classic";
560            $JRETHREADDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
561         }
562	 # OpenJDK
563	 elsif ($JDK =~ m/sun/) {
564	    $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
565	    $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."server";
566	    $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads";
567	 }
568      }
569
570      $CPU            = "P";
571
572   }
573   elsif ($platform =~ m/^s390/)
574   {
575      if (($platform =~ m/^s390x/) && ('@SIZEOF_LONG@' eq '8')) {
576         print "Setting Linux zSeries specific values... ";
577         $outfile        = "LinuxS390XEnv.Set";
578         $CPUNAME        = "S390X";
579	 $ARCH           = "s390x";
580         $OUTPATH        = "unxlngs390x";
581      }
582      else {
583         print "Setting Linux S/390 specific values... ";
584         $outfile        = "LinuxS390Env.Set";
585         $CPUNAME        = "S390";
586	 $ARCH           = "s390";
587         $OUTPATH        = "unxlngs390";
588      }
589      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds.$ARCH;
590      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds.$ARCH.$ds."server";
591      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds.$ARCH.$ds."native_threads";
592      $CPU            = "3";
593   }
594   elsif ($platform =~ m/^m68k/)
595   {  print "Setting Linux m68k specific values... ";
596      $outfile        = "LinuxM68KEnv.Set";
597      $CPU            = "6";
598      $CPUNAME        = "M68K";
599      $OUTPATH        = "unxlngm68k";
600      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."m68k";
601      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."m68k".$ds."server";
602      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."m68k".$ds."native_threads";
603   }
604   elsif ($platform =~ m/^hppa/)
605   {  print "Setting Linux hppa specific values... ";
606      $outfile        = "LinuxHPPAEnv.Set";
607      $CPU            = "H";
608      $CPUNAME        = "HPPA";
609      $OUTPATH        = "unxlnghppa";
610      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."hppa";
611      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."hppa".$ds."server";
612      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."hppa".$ds."native_threads";
613      $EPM_FLAGS      = "-a hppa";
614   }
615   elsif ($platform =~ m/^alpha/)
616   {  print "Setting Linux Alpha specific values... ";
617      $outfile        = "LinuxAlphaEnv.Set";
618      $CPU            = "L";
619      $CPUNAME        = "AXP";
620      $OUTPATH        = "unxlngaxp";
621      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha";
622      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha".$ds."server";
623      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha".$ds."native_threads";
624   }
625   elsif ($platform =~ m/^arm.*?l-/)
626   {  print "Setting Linux ARM specific values... ";
627      $outfile        = "LinuxARMEnv.Set";
628      $CPU            = "R";
629      $CPUNAME        = "ARM";
630      $OUTPATH        = "unxlngr";
631      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."arm";
632      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."arm".$ds."server";
633      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."arm".$ds."native_threads";
634      $EPM_FLAGS      = "-a arm";
635   }
636   elsif ($platform =~ m/^mips/)
637   {  print "Setting Linux MIPS specific values... ";
638      $outfile        = "LinuxMIPSEnv.Set";
639      $CPU            = "M";
640      $CPUNAME        = "GODSON";
641      $OUTPATH        = "unxlngmips";
642
643      if ('@SIZEOF_LONG@' eq '8') {
644        if ('@WORDS_BIGENDIAN@' ne 'yes') {
645          $EPM_FLAGS = "-a mips64el";
646          if ( $JDK eq "gcj" ) {
647	    $ARCH = "mips64el";
648          }
649        }
650        else {
651          $ARCH = "mips64";
652        }
653      }
654      else {
655        if ('@WORDS_BIGENDIAN@' ne 'yes') {
656          $EPM_FLAGS = "-a mipsel";
657	  if ( $JDK =~ m/sun/ && -d "@JAVA_HOME@".$ds."jre".$ds."lib".$ds."mips32" ) {
658	   $ARCH = "mips32"; # Lemote
659	  } else {
660	   $ARCH = "mipsel";
661 	  }
662        }
663        else {
664          $ARCH = "mips";
665        }
666      }
667
668      $JRELIBDIR      = '$JAVA_HOME'.$ds."lib".$ds.$ARCH;
669      if ( $JDK =~ m/sun/ && -d "@JAVA_HOME@".$ds."jre".$ds."lib".$ds."mips32" ) {
670      	$JRETOOLKITDIR  = '$JAVA_HOME'.$ds."lib".$ds.$ARCH.$ds."client"; # Lemote
671      } else {
672      	$JRETOOLKITDIR  = '$JAVA_HOME'.$ds."lib".$ds.$ARCH.$ds."server";
673      }
674      $JRETHREADDIR   = '$JAVA_HOME'.$ds."lib".$ds.$ARCH.$ds."native_threads";
675   }
676
677
678   $INPATH         = $OUTPATH.$PROEXT;
679}
680elsif ( $platform =~ m/osf1/ )
681{     print "Setting Tru64 specific values... ";
682      $outfile        = "Tru64AlphaEnv.Set";
683      $BIG_SVX        = "TRUE";
684      $COM            = "CXX";
685      $COMPATH        = '@COMPATH@';
686      $CPU            = "A";
687      $CPUNAME        = "ALPHA_";
688      $CVER           = "C62";
689      $GUI            = "UNX";
690      $GUIBASE        = "unx";
691      $GVER           = "VCL";
692      $OUTPATH        = "unxt64";
693      $INPATH         = $OUTPATH.$PROEXT;
694      $OS             = "TRU64";
695      $PATH_SEPERATOR = $ps;
696      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha";
697      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha".$ds."client";
698      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha".$ds."native_threads";
699}
700elsif ( $platform =~ m/cygwin/ )
701{
702      $MSPDB_PATH     = PathFormat('@MSPDB_PATH@');
703      $MIDL_PATH      = PathFormat('@MIDL_PATH@');
704      $CSC_PATH       = PathFormat('@CSC_PATH@');
705      $PSDK_HOME      = PathFormat('@PSDK_HOME@');
706      $DIRECTXSDK_LIB = PathFormat('@DIRECTXSDK_LIB@');
707      $USE_DIRECTX5   = "";
708      $FRAME_HOME     = PathFormat('@FRAME_HOME@');
709      $USE_NEW_SDK    = "TRUE";
710      $CPUNAME        = "INTEL";
711      $CPU            = "I";
712      $GUI            = "WNT";
713      $GUIBASE        = "WIN";
714      $GVER           = "NT351";
715      $OS             = "WNT";
716      $DYNAMIC_CRT    = "TRUE";
717      $SET_EXCEPTIONS = "TRUE";
718      $use_shl_versions = "TRUE";
719      $wps = ';'; # Windows style path seperator
720  if ( $MINGW eq "yes" )
721  {   # At the moment this implies the use of tcsh
722      print "Setting Windows NT cygwin MinGW specific values... ";
723      $FLIPCMD        = "slfl.pl";
724      $PATH_SEPERATOR = ';';
725      $outfile        = "winmingw.set";
726      $COMPATH        = PathFormat('@COMPATH@/bin');
727      $COMPATH        =~ s/\/bin$//i;
728      $COM            = "GCC";
729      $CVER           = "C341";
730      $OUTPATH        = "wntgcci";
731      $INPATH         = $OUTPATH.$PROEXT;
732      $ATL_INCLUDE = '$SOLARVER'.$ds.'$INPATH'.$ds."inc".$ds."external".$ds."mingw".$ds."include".$ds."atl". " ".'$PSDK_HOME'.$ds."include".$ds."atl";
733  }
734  else # The MSVC section starts here
735  {   $outfile        = "winenv.set";
736      $COMPATH        = PathFormat('@COMPATH@');
737      $CXX_X64_BINARY = PathFormat('@COMPATH@/bin/amd64/cl.exe');
738      $LINK_X64_BINARY = PathFormat('@COMPATH@/bin/amd64/link.exe');
739      $LIBMGR_X64_BINARY = PathFormat('@COMPATH@/bin/amd64/lib.exe');
740      $COM            = "MSC";
741      $OUTPATH        = "wntmsci@COMEX@";
742      $INPATH         = $OUTPATH.$PROEXT;
743      $COMEX          = '@COMEX@';
744      if ( "@COMEX@" eq "10" ) { # .NET 2003 needs M1310
745          $CVER        = "M1310";
746      } elsif ( "@COMEX@" ge "11" ) { # .NET 2005 needs M1400
747	  if ( "@COMEX@" eq "11" ) {
748	      $CVER        = "M1400";
749	  } elsif ( "@COMEX@" eq "12" ) {
750	      $CVER        = "M1500";
751	  } else {                   # Unsupported
752	      die "Unsupported value for COMEX variable.\n";
753	  }
754      }
755	  print "Setting W32 build with bash shell specific values... ";
756	  # No speacial treatment for CC an CXX anymore.
757	  $FLIPCMD        = "slfl.pl";
758	  $PATH_SEPERATOR = ';';
759  }
760}
761elsif ( $platform =~ m/os2/ )
762{
763      $COMPATH        = PathFormat('@COMPATH@');
764      $MSPDB_PATH     = PathFormat('@MSPDB_PATH@');
765      $MIDL_PATH      = PathFormat('@MIDL_PATH@');
766      $CSC_PATH       = PathFormat('@CSC_PATH@');
767      $PSDK_HOME      = PathFormat('@PSDK_HOME@');
768      $FRAME_HOME     = PathFormat('@FRAME_HOME@');
769      $USE_NEW_SDK    = "TRUE";
770      $CPUNAME        = "INTEL";
771      $CPU            = "I";
772      $GUI            = "OS2";
773      $GUIBASE        = "os2";
774      $GVER           = "VCL";
775      $OS             = "OS2";
776      $DYNAMIC_CRT    = "TRUE";
777      $SET_EXCEPTIONS = "TRUE";
778      $use_shl_versions = "TRUE";
779  {
780      print "Setting OS/2 gcc 3.3.5 specific values... \n";
781      $outfile        = "os2env.set";
782      $COM            = "GCC";
783      $CVER           = "C300";
784      $OUTPATH        = "os2gcci";
785      $INPATH         = $OUTPATH.$PROEXT;
786      $COMEX          = '@COMEX@';
787
788  {   print "Setting OS/2 with 4OS2 specific values... ";
789      # Change path to lower case.
790      $COMPATH        = lc $COMPATH;
791      $PATH_SEPERATOR = ';';
792      $ps = ';';
793      $wps = ';'; # Windows style path seperator
794  }
795
796  }
797}
798elsif ( $platform =~ m/darwin/ )
799{     print "Setting Mac OS X/Darwin specific values... ";
800      $BIG_SVX        = "TRUE";
801      $COMPATH        = '@COMPATH@';
802      print "Darwin platform = " . $platform ." ";
803      if( $CC =~ "gcc" )
804      {
805          print "Setting values for MacOSX/Darwin for Xcode<=3";
806          $COM            = "GCC";
807          $outfile        = "MacOSXX86Env.Set";
808          $CPU            = "I";
809          $CPUNAME        = "INTEL";
810          $OUTPATH        = "unxmacxi";
811      }
812      elsif ($platform =~ m/^i[3456]86/)
813      {
814          print "Setting values for MacOSX/Darwin on x86_32... ";
815          $COM            = "CLANG";
816          $outfile        = "MacOSXX32Env.Set";
817          $CPU            = "I";
818          $CPUNAME        = "INTEL";
819          $OUTPATH        = "unxmacci";
820      }
821      elsif ($platform =~ m/^x86_64/)
822      {
823          print "Setting values for MacOSX/Darwin on x86_64... ";
824          $COM            = "CLANG";
825          $outfile        = "MacOSXX64Env.Set";
826          $CPU            = "X";
827          $CPUNAME        = "X86_64";
828          $OUTPATH        = "unxmaccx";
829      }
830      else
831      {
832	  print "\nset_soenv: Unknown MacOSX/Darwin platform: $platform\n";
833	  exit 1;
834      }
835      $CVER           = "DUMMY_CVER";
836      $GUI            = "UNX";
837      $GVER           = "VCL";
838      $INPATH         = $OUTPATH.$PROEXT;
839      $OS             = "MACOSX";
840      $PATH_SEPERATOR = $ps;
841      # GUIBASE is set below; may be "aqua" or "unx".
842}
843elsif ( $platform =~ m/aix/ )
844{
845   if( $platform !~ m/^powerpc/ )
846   {
847	print "\nAIX has only been ported and tested on powerpc\n";
848	AddWarning( "set_soenv", "Platform $platform has not been tested");
849   }
850   print "Setting AIX PPC specific values... ";
851   $outfile        = "aixPPCEnv.Set";
852   $CPU            = "P";
853   $CPUNAME        = "POWERPC";
854   $OUTPATH        = "unxlngppc";
855   $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
856   $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."classic";
857   $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads";
858   $BIG_SVX        = "TRUE";
859   $COM            = "GCC";
860   $CVER           = "C300";
861   $COMPATH        = '@COMPATH@';
862   $GUI            = "UNX";
863   $GUIBASE        = "unx";
864   $GVER           = "VCL";
865   $INPATH         = $OUTPATH.$PROEXT;
866   $OS             = "AIX";
867   $PATH_SEPERATOR = $ps;
868}
869else {
870	print "\nset_soenv:  Cannot figure out what platform you are running\n";
871	print "For $platform.\n";
872	exit 1;
873}
874print "done\n";
875
876#
877# D. Gathering directory information from the user.
878#
879# If the directory does not exist something is strange.
880# 1. Apache OpenOffice build home directory.
881chomp($SRC_ROOT  = `pwd`);
882$SRC_ROOT =~ s/\/config_office//;
883$SRC_ROOT = PathFormat($SRC_ROOT);
884CheckPathExist( $SRC_ROOT );
885
886
887#-----------------------------------------------------------------------------------------------------
888# Copy top level makefile from config_office/ to $SRC_ROOT
889#-----------------------------------------------------------------------------------------------------
890if (! -e "makefile.rc")
891{  AddWarning( "set_soenv", "makefile.rc not found in config_office/. Could not copy to SRC_ROOT." );
892}
893else
894{  `cp -f makefile.rc $SRC_ROOT/makefile.mk`;
895}
896
897# 2. Java home directory.
898# JAVA_HOME as argument from autoconf.
899$JAVA_HOME = PathFormat('@JAVA_HOME@') ;
900
901if ( $platform =~ m/cygwin|os2/ ) {
902   $JAVA_HOME =~ s/[\s\/]+$//;	# remove trailing \n or \/ if there is any.
903}
904# 3. shell path.
905if ( $platform =~ m/os2/ )
906{
907$OOO_SHELL = 'sh';
908}
909else
910{
911$OOO_SHELL = '@SHELLPATH@'."\/bash";
912}
913
914# ml.exe assembler path for Windows users.
915if ($platform =~ m/cygwin/)
916{  $ASM_PATH = PathFormat('@ASM_HOME@');
917}
918
919# nasm.exe assembler path for Windows users.
920if ($platform =~ m/cygwin/)
921{  $NASM_PATH = PathFormat('@NASM_HOME@');
922}
923
924#
925# E. Determining the envionment values based on the information
926#    that was gathered earlier on.
927#
928print "Setting the environment variables... ";
929$USR                  = $ds."usr";
930$ETC                  = $ds."etc";
931$BIN                  = $ds."bin";
932$LIB                  = $ds."lib";
933$LIB64                = $ds."lib";
934$LIB64               .= "64"
935if ($platform =~ m/x86_64-.*-linux/);
936$LIB64               .= "64"
937if (($platform =~ m/powerpc64-.*-linux/) && ('@SIZEOF_LONG@' eq '8'));
938$LIB64               .= "64"
939if (($platform =~ m/s390x-.*-linux/) && ('@SIZEOF_LONG@' eq '8'));
940$INC                  = $ds."inc";
941$INCLUDE              = $ds."include";
942$DEV                  = $ds."dev";
943$OPT                  = $ds."opt";
944$LOCAL                = $ds."local";
945$SOLENV               = $ds."solenv";
946$SOLVER               = $ds."solver";
947$CONFIG               = $ds."config";
948$USR_BIN              = $USR.$BIN;
949$USR_LIB              = $USR.$LIB64;
950$USR_LOCAL            = $USR.$ds."local";
951$USR_CCS              = $USR.$ds."ccs";
952$USR_OPENWIN          = $USR.$ds."openwin";
953$USR_DT               = $USR.$ds."dt";
954$COMMON_BUILD_TOOLS   = '$SRC_ROOT'.$ds."external".$ds."common";
955
956# Generate alternate output file for sh?
957$outfile_sh = $outfile.".sh";
958
959if ($GUI eq "OS2")
960{
961   # Generate output file for 4os2?
962   $outfile_bat = $outfile;
963   $outfile_bat =~ s/set$/cmd/i;
964}
965
966# Windows NT only variables
967if ($platform =~ m/cygwin/)
968{
969   if ( $JAVA_HOME ne "" )
970   {
971      $JAVA_LIB             = $JAVA_HOME.$LIB;
972   }
973   # Import SystemDrive enviroment variable
974   use Env qw(SYSTEMDRIVE);
975   # Change $SYSTEMDRIVE to lower case.
976   $SYSTEMDRIVE          = lc $SYSTEMDRIVE;
977   use Env qw(SYSTEMROOT);
978   $CYGWIN_PATH          = PathFormat('@CYGWIN_PATH@'); # Windows bash path
979   $WIN_GREP             = '$CYGWIN_PATH'.$ds."grep.exe";
980   $WIN_FIND             = '$CYGWIN_PATH'.$ds."find.exe";
981   $WIN_LS               = '$CYGWIN_PATH'.$ds."ls.exe";
982   $WIN_GNUCOPY          = '$CYGWIN_PATH'.$ds."cp.exe";
983   $WIN_TOUCH            = '$CYGWIN_PATH'.$ds."touch.exe";
984}
985
986if ( $JAVA_HOME ne "" )
987{
988   $JAVA_BIN             = $JAVA_HOME.$BIN;
989   $JAVA_INCLUDE         = $JAVA_HOME.$ds."include";
990}
991
992
993$PERL                 = PathFormat('@PERL@'); # Perl program
994$PERL_PATH            = dirname('@PERL@'); # Perl Path
995$XLIB                 = PathFormat('@XLIB@'); # X11 libraries
996$XINC                 = PathFormat('@XINC@'); # X11 includes
997
998# YD disable autodetection, use PATH
999if ( $platform =~ m/os2/ )
1000{
1001   $PERL = 'perl';
1002   $PERL_PATH = '';
1003}
1004
1005# The project's workstamp.
1006$WORK_STAMP            = "@SOURCEVERSION@";
1007# Location of the source.
1008$SOLARSRC             = '$SRC_ROOT';
1009# Location of the repository.
1010my @splitlist = split( /\//, $SRC_ROOT );
1011pop @splitlist;
1012$SOURCE_ROOT_DIR      = join("/", @splitlist);
1013
1014# default TARFILE_LOCATION
1015if ('@TARFILE_LOCATION@' eq "DEFAULT")
1016{	$TARFILE_LOCATION="$SOURCE_ROOT_DIR/ext_sources";
1017}
1018
1019#
1020$DEVROOT              = '$SRC_ROOT';
1021# Set solenv and solver to given or default values.
1022# Location of the solenv tree.
1023if ('@LOCAL_SOLENV@' eq "DEFAULT")
1024{  $SOLARENV          = $SRC_ROOT.$SOLENV;
1025}
1026else
1027{  $SOLARENV          =  PathFormat('@LOCAL_SOLENV@');
1028}
1029# Location of the solver tree.
1030if ('@LOCAL_SOLVER@' eq "DEFAULT")
1031{  $SOLARVER          = $SRC_ROOT.$SOLVER.$ds.$UPD;
1032}
1033else
1034{  $SOLARVER          = PathFormat('@LOCAL_SOLVER@').$ds.$UPD;
1035}
1036#Location of Solar version.
1037$SOLARVERSION         = '$SOLARVER';
1038
1039#Location of gnu make directories.
1040$WORKDIR              = '$SOLARVER/$INPATH/workdir';
1041$OUTDIR              = '$SOLARVER/$INPATH';
1042
1043$SOLARENVINC          = '$SOLARENV'.$INC;
1044# Location of
1045$LOCALINI             = '$SOLARENV'.$CONFIG;
1046# Location of
1047$STAR_INIROOT         = '$SOLARENV'.$CONFIG;
1048# Location of
1049$STAR_INIROOTOLD      = '$SOLARENV'.$CONFIG;
1050# Location of
1051$STAR_STANDLST        = '$SOLARENV'.$CONFIG.$ds."stand.lst";
1052# Location of
1053$STAR_SSCOMMON        = '$SOLARENV'.$CONFIG.$ds."ssolar.cmn";
1054# Location of
1055$STAR_SSOLARINI       = '$SOLARENV'.$CONFIG.$ds."ssolar.ini";
1056# Location of dmake resource.
1057$DMAKEROOT            = '$SOLARENVINC'.$ds."startup";
1058# Location of JDK classes .zip file.
1059# but in jdk 1.2 it is called rt.jar and it lives in jre/lib
1060$CLASSPATH            = '$JAVA_HOME'.$ds.'jre'.$LIB.$ds."rt.jar".$wps.'.';
1061# Location of the JDK supported standard classes.zip file.
1062# see above for why the change
1063$XCLASSPATH           = '$JAVA_HOME'.$ds.'jre'.$LIB.$ds."rt.jar".$wps.'.';
1064
1065# Location used by the linker to create libraries.
1066if ($platform =~ m/solaris/)
1067{  $SOLAREXTRALIB     = $L.$par_dir.$LIB.
1068                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$ds."lib.solaris.2.6".
1069                        $L.$LIB.
1070                        $L.$USR.$LIB.
1071                        $L.$USR.$LOCAL.$LIB.
1072                        $L.$USR_DT.$LIB.
1073                        $L.$USR_OPENWIN.$LIB;
1074}
1075elsif ($platform =~ m/linux|netbsd|osf1|freebsd|aix/)
1076{
1077   $SOLAREXTRALIB     = $L.$par_dir.$LIB64;
1078}
1079elsif ($platform =~ m/darwin/)
1080{  $SOLAREXTRALIB     = $L.$LIB.
1081                        $L.$USR.$LIB;
1082}
1083elsif ($platform !~ m/cygwin|os2/ )
1084{  AddWarning( "set_soenv", "$platform not configured for linkage create libraries" );
1085}
1086
1087# Windows NT only variables
1088if ($platform =~ m/cygwin|os2/)
1089{  $COMP_ENV          = $OUTPATH;
1090
1091   $JAVAHOME          = '$JAVA_HOME';
1092
1093   $ILIB             = $cur_dir;
1094
1095   # Mingw is different
1096   if ( $COM eq "MSC" )
1097   {  $ILIB       .=    $wps.$SOLARVER.$ds.$INPATH.$LIB.
1098                        $wps.$JAVA_HOME.$LIB.
1099                        $wps.$PSDK_HOME.$LIB.
1100                        $wps.$FRAME_HOME.$LIB.
1101                        $wps.$COMPATH.$LIB;
1102      if ( '@ENABLE_DIRECTX@' ne "" ) {
1103          # We may have DirectX but not DirectDraw
1104          if ( '@ENABLE_DIRECT_DRAW@' ne "") {
1105              $ILIB   .= $wps.$DIRECTXSDK_LIB;
1106              if ( '@COMEX@' eq "10" ) {
1107                  # .NET2003 provides and compiles against DirectX 5 libraries and is
1108                  # hereby still Win9x compatible.
1109                  $ILIB .= $wps.'$COMPATH'.$ds.'PlatformSDK'.$LIB;
1110                  $USE_DIRECTX5 = "YES";
1111              }
1112          }
1113      }
1114      # ILIB needs to use '\' directory seperators;
1115      $ILIB = WinPath( $ILIB, ";" );
1116   }
1117   elsif ( $COM eq "GCC" )
1118   {  $ILIB       .=    $wps.$SOLARVER.$ds.$INPATH.$LIB.
1119                        $wps.$SOLARVER.$ds.$INPATH.$BIN.
1120                        $wps.$JAVA_HOME.$LIB;
1121      if ( $USE_MINGW eq "cygwin" )
1122      {  $ILIB    .= $wps.PathFormat($USR.$LIB.$ds."mingw").
1123                     $wps.PathFormat($USR.$LIB.$ds."w32api");
1124      }
1125      else
1126      {  $ILIB       .= $wps.$COMPATH.$LIB;
1127      }
1128      $ILIB       .= $wps.PathFormat("@MINGW_CLIB_DIR@").
1129                     $wps.$PSDK_HOME.$LIB;
1130      if ( '@ENABLE_DIRECTX@' )
1131      {   $ILIB   .= $wps.PathFormat("@DIRECTXSDK_LIB@");
1132      }
1133   }
1134
1135   $JAVAHOME          = '$JAVA_HOME';
1136
1137}
1138
1139# The general environment path.
1140if ($platform =~ m/linux|netbsd|odf1|freebsd|aix|solaris/)
1141{  $PATH              = $cur_dir.
1142                        $ps.'$SOLARENV'.$ds.'$INPATH'.$BIN.
1143                        $ps.'$SOLARENV'.$BIN;
1144
1145   if ($platform =~ m/solaris/) {
1146	$PATH .= $ps.$USR_CCS.$BIN;
1147   }
1148
1149   $PATH             .= $ps.$oldPATH;
1150
1151   my @javaBits;
1152   if (( $JAVA_HOME ne "" ) && ( $JDK ne "gcj" )) {
1153      @javaBits = ( '$JAVA_HOME'.$BIN, 'javac' );
1154   } else {
1155      @javaBits = ();
1156   }
1157   $PATH              = GetCorrectPath ($PATH,
1158                                        $COMPATH, $CC,
1159                                        $PERL_PATH, 'perl',
1160                                        @javaBits);
1161}
1162
1163elsif ($platform =~ m/cygwin/)
1164{  # The PATH variable is completely created from scratch. Elements
1165   # from oldPATH that are not yet included are appended to PATH at
1166   # the end.
1167
1168   my ( $tmppath );
1169
1170   $PATH              = $cur_dir.
1171                        $ps.CygFormat($SOLARENV).$ds."bin".
1172                        $ps.CygFormat($SOLARENV).$ds.$INPATH.$BIN;
1173
1174   if ( $JAVA_HOME ne "" )
1175   {
1176      # hack either "hotspot" or "client" should be used, depending on the jdk version:
1177      # 1.2.x   -   no such directory, unsupported
1178      # 1.3.x   -   hotspot, client missing
1179      # 1.4.x   -   client, hotspot missing
1180
1181      $PATH .= $ps.CygFormat($JAVA_HOME).$BIN;
1182	  if ( -d $JAVA_HOME.$ds."jre".$ds."bin".$ds."hotspot" ) {
1183		  $PATH .= $ps.CygFormat($JAVA_HOME).$ds."jre".$ds."bin".$ds."hotspot";
1184	  }
1185	  if ( -d $JAVA_HOME.$ds."jre".$ds."bin".$ds."client" ) {
1186		  $PATH .= $ps.CygFormat($JAVA_HOME).$ds."jre".$ds."bin".$ds."client";
1187	  }
1188   }
1189
1190   # Add path to compiler
1191   $tmppath = CygFormat($COMPATH).$BIN;
1192   $tmppath =~ s/^\/\//\//;
1193   $PATH .= $ps.$tmppath;
1194
1195   if ( $COM eq "MSC" ) {
1196       $tmppath = CygFormat($MSPDB_PATH);
1197	   # for .NET to find mspdb71.dll (needed by CL.EXE C/C++ Compiler)
1198	   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
1199		   $PATH .= $ps.$tmppath;
1200	   }
1201	   if ( ( $COMEX ge "10" ) ) {
1202		   # .NET needs midl.exe
1203               $tmppath = CygFormat($MIDL_PATH);
1204		   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
1205			   $PATH .= $ps.$tmppath;
1206		   }
1207		   # .NET needs csc.exe
1208               $tmppath = CygFormat($CSC_PATH);
1209		   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
1210			   $PATH .= $ps.$tmppath;
1211		   }
1212		   # Native installer needs some files if the Windows Installer SDK
1213               $tmppath = CygFormat($PSDK_HOME);
1214		   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath\/bin)(?:[:]|\Z)/i ) {
1215			   $PATH .= $ps.$tmppath.$BIN;
1216		   }
1217	   }
1218   } else { # Mingw is different
1219	   # Native installer needs some files if the Windows Installer SDK
1220               $tmppath = CygFormat($PSDK_HOME);
1221	   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath\/bin)(?:[:]|\Z)/i ) {
1222		   $PATH .= $ps.$tmppath.$BIN;
1223	   }
1224   }
1225
1226   if ( $ASM_PATH ne "ASM_IN_PATH" )
1227   {   $PATH          .= $ps.CygFormat($ASM_PATH);
1228   }
1229   if ( $NASM_PATH ne "NASM_IN_PATH" && $NASM_PATH ne "NO_NASM_HOME" && $NASM_PATH ne "" )
1230   {   $PATH          .= $ps.CygFormat($NASM_PATH);
1231   }
1232   # zip.exe / unzip.exe path for Windows users.
1233   my $zip_home_path = PathFormat('@ZIP_HOME@');
1234   $tmppath = CygFormat($zip_home_path);
1235   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
1236       $PATH          .= $ps.$tmppath;
1237   }
1238
1239   # Possible cygwin paths must follow behind the OOo and MS paths
1240
1241   # Check if $PERL_PATH is already set in PATH
1242   $tmppath = CygFormat($PERL_PATH);
1243   if ( ! ( $PATH =~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) )
1244   {
1245      $PATH          .= $ps.$tmppath;
1246   }
1247   # Check if $CYGWIN_PATH is already set in PATH
1248   $tmppath = CygFormat($CYGWIN_PATH);
1249   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
1250      $PATH           .= $ps.$tmppath;
1251   }
1252   # nsis path for Windows users.
1253   $NSIS_PATH = PathFormat('@NSIS_PATH@');
1254   $tmppath = CygFormat($NSIS_PATH);
1255   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
1256       $PATH          .= $ps.$tmppath;
1257   }
1258   # path to sn.exe (signing) for Windows users.
1259   my $sn_path = PathFormat('@FRAME_HOME@/bin');
1260   $tmppath = CygFormat($sn_path);
1261   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
1262       $PATH          .= $ps.$tmppath;
1263   }
1264
1265
1266   # Add the rest of the original path if it is still missing.
1267   if (($^O eq "cygwin")) { # Not for ActiveState perl
1268       my $expandedPATH = $PATH;
1269       $expandedPATH =~ s/(\$\w+)/$1/eeg;
1270
1271       # fix situations where PATH may look like /bin:"C:\blah\bleh":/ugh
1272       my $fixedPATH = $oldPATH;
1273       if ( $oldPATH =~ /"/ ) {
1274	   $fixedPATH = "";
1275	   foreach my $pathentry ( split( '"',$oldPATH ) ) {
1276	       if ( ( $pathentry =~ /^$ps/ ) || ( $pathentry =~ /$ps$/ ) ) {
1277		   $fixedPATH .= $pathentry;
1278	       } else {
1279		   chomp( $pathentry = qx{cygpath -d "$pathentry"} ) ;
1280		   chomp( $pathentry = qx{cygpath -u "$pathentry"} ) ;
1281		   $fixedPATH .= $pathentry;
1282	       }
1283	   }
1284       }
1285
1286       foreach my $pathentry (split($ps,$fixedPATH)) {
1287           if ( ! ( $expandedPATH =~ /(?:$ps|\A)(?:$pathentry)(?:$ps|\Z)/ ) ) {
1288               $PATH .= $ps.$pathentry;
1289               $expandedPATH .= $ps.$pathentry;
1290           }
1291       }
1292   } else {
1293       $PATH          .= $ps.$oldPATH;
1294   }
1295
1296   # The path now is in cygwin posix format
1297
1298}
1299
1300elsif ($platform =~ m/os2/)
1301{  # The PATH variable is completely created from scratch. Everything that is not
1302   # needed is appended to the end.
1303
1304   $PATH              = $cur_dir.
1305                        $ps.'$SOLARENV'.$ds."bin".
1306                        $ps.'$SOLARENV'.$ds.'$INPATH'.$BIN;
1307
1308   if ( $JAVA_HOME ne "" )
1309   {
1310      # hack either "hotspot" or "client" should be used, depending on the jdk version:
1311      # 1.2.x   -   no such directory, unsupported
1312      # 1.3.x   -   hotspot, client missing
1313      # 1.4.x   -   client, hotspot missing
1314
1315      $PATH .= $ps.$JAVA_HOME.$BIN;
1316	  if ( -d $JAVA_HOME.$ds."jre".$ds."bin".$ds."hotspot" ) {
1317		  $PATH .= $ps.$JAVA_HOME.$ds."jre".$ds."bin".$ds."hotspot";
1318	  }
1319	  if ( -d $JAVA_HOME.$ds."jre".$ds."bin".$ds."client" ) {
1320		  $PATH .= $ps.$JAVA_HOME.$ds."jre".$ds."bin".$ds."client";
1321	  }
1322   }
1323
1324  if ( '@ANT_HOME@' ne '' )
1325  {
1326     $PATH .= $ps.'@ANT_HOME@/bin';
1327  }
1328
1329  # Append old PATH
1330  my $temp = $oldPATH;
1331  $temp =~ s/\\/\//g ;
1332  $PATH             .= $ps.$temp;
1333}
1334
1335elsif ($platform =~ m/darwin/)
1336{  $PATH              = $cur_dir.
1337                        $ps.'$SOLARENV'.$ds.'$INPATH'.$BIN.
1338                        $ps.'$SOLARENV'.$BIN;
1339
1340  # Append old PATH
1341  $PATH             .= $ps.$oldPATH;
1342}
1343else
1344{  AddWarning( "set_soenv", "$platform not configured for general environment paths" );
1345}
1346
1347# Linker library search directory paths.
1348if ($platform =~ m/solaris/)
1349{  $SOLARLIB          = $L.$par_dir.$LIB.
1350                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB.
1351                        $L.'$SOLARVER'.$ds.'$INPATH'.$LIB.
1352                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB.
1353                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB."solaris.2.6".
1354                        $L.$LIB.
1355                        $L.$USR_LIB;
1356   if ( $CC =~ "gcc" ) {
1357      $SOLARLIB      .= $L.$COMPATH.$LIB;
1358   }
1359   $SOLARLIB         .= $L.$USR_LOCAL.$LIB.
1360                        $L.$USR_DT.$LIB.
1361                        $L.$USR_OPENWIN.$LIB.
1362                        $L.'$JAVA_HOME'.$LIB.
1363                        $L.$JRELIBDIR.
1364                        $L.$JRETOOLKITDIR.
1365                        $L.$JRETHREADDIR.
1366                        $L.$XLIB;
1367}
1368elsif ($platform =~ m/linux|netbasd|osf1|aix|freebsd/)
1369{  $SOLARLIB          = $L.$par_dir.$LIB.
1370                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB.
1371                        $L.'$SOLARVER'.$ds.'$INPATH'.$LIB.
1372                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB.
1373                        $L.'$JAVA_HOME'.$LIB64.
1374                        $L.$JRELIBDIR.
1375                        $L.$JRETOOLKITDIR.
1376                        $L.$JRETHREADDIR.
1377                        $L.$XLIB;
1378}
1379elsif ($platform =~ m/cygwin|os2/)
1380{  $SOLARLIB          = $L.'$SOLARVER'.$ds.'$INPATH'.$LIB.
1381                        $L.$par_dir.$LIB.
1382                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB;
1383}
1384elsif ($platform =~ m/darwin/)
1385{  $SOLARLIB          = $L.'$SOLARVER'.$ds.'$INPATH'.$LIB.
1386                        $L.$USR_LIB;
1387    # [ed] 6/15/02 Add in X11 libraries onto the library path
1388    if ($GUIBASE eq "unx") {
1389       $SOLARLIB      .= $L.$XLIB;
1390    }
1391
1392}
1393
1394
1395# Location of the compiler include search directory paths.
1396$SOLARINC             = $I.$cur_dir.
1397                        $I.'$SOLARVER'.$ds.'$INPATH'.$INC.$ds."stl".
1398                        $I.'$SOLARVER'.$ds.'$INPATH'.$INC.$ds."external".
1399                        $I.'$SOLARVER'.$ds.'$INPATH'.$INC.
1400                        $I.'$SOLARENV'.$ds.'$OUTPATH'.$INC.
1401                        $I.'$SOLARENV'.$INC.
1402                        $I.'$SRC_ROOT'.$ds."res";
1403
1404if ($platform =~ m/solaris|linux|osf1|freebsd|netbsd/)
1405{
1406if ($platform =~ m/linux|freebsd|netbsd/)
1407{
1408# This simply adds an include path, so even cases that break the FHS work
1409}
1410if ($platform =~ m/solaris/ && ! $CC =~ "gcc")
1411{
1412$SOLARINC            .= '/SC5 ';
1413}
1414# Platform dependent include path at the top of this list of include paths
1415if ($platform =~ m/solaris/)
1416{
1417    $SOLARINC         .= $I.$COMPATH.$ds."include";
1418}
1419if ($platform =~ m/linux/)
1420{
1421# This simply adds an include path, so even cases that break the FHS work
1422}
1423
1424
1425   	$SOLARINC      .= $I.'$SOLARENV'.$INC.$ds."Xp31".
1426                     $I.'$JAVA_HOME'.$INCLUDE;
1427
1428	#include system dependent Java include directory
1429	if (!($JDK eq "gcj"))
1430	{
1431   		if ($platform =~ m/solaris/)
1432   		{  $SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."solaris";
1433   		}
1434   		elsif  ($platform =~ m/linux|osf1/)
1435   		{  $SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."linux";
1436   		}
1437   		elsif ($platform =~ m/freebsd/)
1438   		{
1439      		$SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."freebsd";
1440      		$SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."bsd";
1441      		$SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."linux";
1442   		}
1443   		elsif ($platform =~ m/netbsd/)
1444   		{  $SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."netbsd";
1445   		}
1446
1447   		#java threads include path
1448
1449   		$SOLARINC .=$I.'$JAVA_HOME'.$INCLUDE.$ds."native_threads".$ds."include";
1450	}
1451    #The tail, if needed
1452    if ($platform =~ m/linux|freebsd|netbsd/)
1453    {  $SOLARINC  .= $I.$XINC;
1454    }
1455    elsif ($platform =~ m/osf1/)
1456    {  $SOLARINC  .= $I.$XINC.
1457                     $I.$USR.$INCLUDE;
1458    }
1459}
1460elsif ($platform =~ m/cygwin/)
1461{  $SOLARINC         .= $I.'$JAVA_HOME'.$ds."include".$ds."win32".
1462                        $I.'$JAVA_HOME'.$ds."include";
1463   # Mingw is different
1464   if ( $COM eq "MSC" )
1465   {  $SOLARINC       .= $I.'$PSDK_HOME'.$INCLUDE.
1466                         $I.'$COMPATH'.$ds."include";
1467      if ( '@ENABLE_DIRECTX@' ne "" ) {
1468          $SOLARINC   .= $I.PathFormat('@DIRECTXSDK_HOME@').$INCLUDE;
1469          if ( '@COMEX@' eq "10" ) {
1470              # .NET2003 provides and compiles against DirectX 5 libraries and is
1471              # hereby still Win9x compatible.
1472              $SOLARINC .= $I.'$COMPATH'.$ds.'PlatformSDK'.$ds."include";
1473          }
1474      }
1475   }
1476   elsif ( $COM eq "GCC" )
1477   {  $SOLARINC       .= $I.'$SOLARVER'.$ds.'$INPATH'.$INC.$ds."external".$ds."mingw".$ds."include";
1478     if ( $USE_MINGW eq "cygwin" )
1479     {  $SOLARINC    .= $I.PathFormat($USR.$ds."include".$ds."mingw").
1480                        $I.PathFormat($USR.$ds."include".$ds."w32api").
1481                        $I.PathFormat($USR.$ds."include"); }
1482     else
1483     {  $SOLARINC    .= $I.'$COMPATH'.$ds."include"; }
1484     @mingw_lib_include_paths = split( / /, "@MINGW_LIB_INCLUDE_PATH@" );
1485     $SOLARINC .= $I.PathFormat("@MINGW_BACKWARD_INCLUDE_PATH@");
1486     foreach $mingw_lib_include_path (@mingw_lib_include_paths)
1487       {   chomp $mingw_lib_include_path;
1488           if ( $mingw_lib_include_path ne $COMPATH.$ds."include" && $mingw_lib_include_path ne "" )
1489           {
1490              $SOLARINC   .= $I.PathFormat($mingw_lib_include_path);
1491           }
1492       }
1493     $SOLARINC .= $I.PathFormat("@GXX_INCLUDE_PATH@").$I.PathFormat("@GXX_INCLUDE_PATH@".$ds."mingw32").
1494                  $I.'$PSDK_HOME'.$INCLUDE;
1495   }
1496   if ( '@ENABLE_DIRECTX@' ne "" ) {
1497       $SOLARINC   .= $I.PathFormat('@DIRECTXSDK_HOME@').$INCLUDE;
1498   }
1499}
1500elsif ($platform =~ m/darwin/)
1501{
1502    $FRAMEWORKSHOME = "@MACOSX_SDK_PATH@/System/Library/Frameworks";
1503    chomp( my $TOOLSPATH = `xcode-select --print-path` );
1504    my $STLINC = "$TOOLSPATH/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/";
1505	if ( !(-e $STLINC) && !(-d $STLINC) ) {
1506	   # Xcode 5
1507	   $STLINC = "$TOOLSPATH/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/";
1508	}
1509    $SOLARINC .= $I.$STLINC . $I.$FRAMEWORKSHOME.$ds."JavaVM.framework".$ds."Headers";
1510    $GUIBASE  = "aqua";
1511}
1512else
1513{  AddWarning( "set_soenv", "$platform not configured for system dependant include dir" );
1514}
1515
1516#
1517print "done\n";
1518
1519$gb_REPOS = $SRC_ROOT;
1520for my $repo (split(/ /,"@ADDITIONAL_REPOSITORIES@"))
1521{
1522    my $abs_repo = `cd $SRC_ROOT/$repo;pwd`;
1523    chomp($abs_repo);
1524    $gb_REPOS .= " " . $abs_repo;
1525}
1526
1527
1528#
1529# F. Setting the different aliases.
1530#
1531print "Setting the aliases... ";
1532# 1. alias for a full product make.
1533	$mkout           = '"$PERL $SOLARENV/bin/mkout.pl"';
1534	$deliver         = '"$PERL $SOLARENV/bin/deliver.pl"';
1535	$build           = '"$PERL $SOLARENV/bin/build.pl"';
1536	$build_client    = '"$PERL $SOLARENV/bin/build_client.pl"';
1537	$zipdep          = '"$PERL $SOLARENV/bin/zipdep.pl"';
1538# 3. alias for a full product make
1539$nmake           = '"dmake"';
1540print "done\n";
1541#
1542#--------------------------
1543# VI. Open the output file.
1544#--------------------------
1545#
1546open( OUT, ">$outfile" ) ||
1547   die "Cannot open $outfile: $!\n";
1548
1549# Create sh environment file
1550open( OUT_SH, ">$outfile_sh" ) ||
1551  die "Cannot open $outfile_sh: $!\n";
1552
1553if(defined($outfile_bat))
1554{  # Create bat environment file
1555   open( OUT_BAT, ">$outfile_bat" ) ||
1556   die "Cannot open $outfile_bat: $!\n";
1557}
1558
1559#
1560#------------------------------------------
1561# VII. Writing the data to the output file.
1562#------------------------------------------
1563#
1564# Write file header.
1565CreateFileHeader( *OUT, $UPD, $platform, "(t)csh", "#" );
1566CreateFileHeader( *OUT_SH, $UPD, $platform, "sh/bash/ksh", "#" );
1567CreateFileHeader( *OUT_BAT, $UPD, $platform, "4nt", "rem" ) if defined($outfile_bat);
1568
1569ToFile( "SRC_ROOT",	     $SRC_ROOT,          "e" );
1570ToFile( "OOO_SHELL",         $OOO_SHELL,         "e" );
1571ToFile( "JAVA_HOME",         $JAVA_HOME,         "e" );
1572ToFile( "ANT_HOME",          PathFormat("@ANT_HOME@"), "e" );
1573ToFile( "ANT_LIB",           PathFormat("@ANT_LIB@"), "e" );
1574ToFile( "ANT",               PathFormat("@ANT@"), "e" );
1575ToFile( "JDKLIB",            $JAVA_LIB,          "e" );
1576ToFile( "ASM_PATH",          $ASM_PATH,          "e" );
1577ToFile( "NASM_PATH",         $NASM_PATH,         "e" );
1578ToFile( "BUILD_SOSL",        $BUILD_SOSL,        "e" );
1579ToFile( "FRAMEWORKSHOME",    $FRAMEWORKSHOME,    "e" );
1580ToFile( "Empty",             $empty,             "n" );
1581
1582#
1583# Writing the platform independent constant values to file.
1584# (c = comment, e = environment variable, a = alias )
1585ToFile( "Platform independent constant values.", $empty, "c" );
1586# dictionaries
1587if ('@WITH_DICT@' =~ m/ALL,/s)
1588{
1589   foreach $dict (@DICTIONARIES)
1590   {
1591      ToFile( "DIC_$dict",     "TRUE",          "e" );
1592   }
1593   ToFile( "DIC_ALL",          "TRUE",          "e" );
1594}
1595else
1596{
1597   foreach $dict (@DICTIONARIES)
1598   {   if ('@WITH_DICT@' =~ m/$dict,/s)
1599       {   my $val="TRUE";
1600           ToFile( "DIC_$dict",     $val,          "e" );
1601       }
1602       else
1603       {   my $val;
1604           undef $val;
1605           ToFile( "DIC_$dict",     $val,          "e" );
1606       }
1607   }
1608}
1609# Languages
1610ToFile( "WITH_LANG",         "@WITH_LANG@",      "e" );
1611ToFile( "INTRO_BITMAPS",     "@INTRO_BITMAPS@",  "e" );
1612ToFile( "ABOUT_BITMAPS",     "@ABOUT_BITMAPS@",  "e" );
1613ToFile( "OOO_VENDOR",        "@OOO_VENDOR@",     "e" );
1614ToFile( "OOODMAKEMODE",      "YES",              "e" );
1615ToFile( "WITH_POOR_HELP_LOCALIZATIONS", "@WITH_POOR_HELP_LOCALIZATIONS@", "e" );
1616
1617ToFile( "CALL_CDECL",        $CALL_CDECL,        "e" );
1618ToFile( "COMMON_OUTDIR",     $COMMON_OUTDIR,     "e" );
1619ToFile( "common_build",      $common_build,      "e" );
1620ToFile( "BMP_WRITES_FLAG",   $BMP_WRITES_FLAG,   "e" );
1621ToFile( "BUILD_SOSL_RELEASE", $BUILD_SOSL_RELEASE, "e" );
1622ToFile( "NO_REC_RES",        $NO_REC_RES,        "e" );
1623ToFile( "SO3",               $SO3,               "e" );
1624ToFile( "SOLAR_PLUGIN",      $SOLAR_PLUGIN,      "e" );
1625ToFile( "UPDATER",           $UPDATER,           "e" );
1626ToFile( "build_deliver",     $BUILD_DELIVER,     "e" );
1627ToFile( "VCL",               $VCL,               "e" );
1628ToFile( "ENABLEUNICODE",     $ENABLEUNICODE,     "e" );
1629ToFile( "NEW_JAR_PACK",      $NEW_JAR_PACK,      "e" );
1630ToFile( "NO_BSYMBOLIC",      $NO_BSYMBOLIC,      "e" );
1631ToFile( "TF_FILTER",         "TRUE",             "e" );
1632if ("@ENABLE_DEBUG@" eq "TRUE") {
1633ToFile( "debug",             "true",             "e" );
1634}
1635if ("@ENABLE_WERROR@" eq "FALSE") {
1636ToFile( "EXTERNAL_WARNINGS_NOT_ERRORS", "TRUE",  "e" );
1637}
1638ToFile( "PRODUCT",           "@PRODUCT@",        "e" );
1639ToFile( "PROFULLSWITCH",     "@PROFULLSWITCH@",  "e" );
1640ToFile( "PROEXT",            $PROEXT,            "e" );
1641ToFile( "VALGRIND_CFLAGS",   "@VALGRIND_CFLAGS@",  "e" );
1642ToFile( "UNIXWRAPPERNAME",   "@UNIXWRAPPERNAME@","e" );
1643ToFile( "ENABLE_NSS_MODULE",  "@ENABLE_NSS_MODULE@", "e" );
1644ToFile( "MOZILLABUILD",  "@MOZILLABUILD@", "e" );
1645ToFile( "BUILD_VER_STRING",  "@BUILD_VER_STRING@", "e" );
1646if ($platform =~ m/linux/ && $platform =~ m/powerpc/) {
1647ToFile( "JITC_PROCESSOR_TYPE","6",                 "e" );
1648}
1649ToFile( "DEFAULT_TO_ENGLISH_FOR_PACKING",  "yes", "e" );
1650ToFile( "ENABLE_GTK",        "@ENABLE_GTK@",       "e" );
1651ToFile( "GTK_CFLAGS",        "@GTK_CFLAGS@",       "e" );
1652ToFile( "GTK_LIBS",          "@GTK_LIBS@",         "e" );
1653ToFile( "GTHREAD_CFLAGS",        "@GTHREAD_CFLAGS@",       "e" );
1654ToFile( "GTHREAD_LIBS",          "@GTHREAD_LIBS@",         "e" );
1655ToFile( "ENABLE_SYSTRAY_GTK", "@ENABLE_SYSTRAY_GTK@", "e" );
1656ToFile( "ENABLE_STATIC_GTK", "@ENABLE_STATIC_GTK@", "e" );
1657ToFile( "ENABLE_GSTREAMER",  "@ENABLE_GSTREAMER@", "e" );
1658ToFile( "ENABLE_CAIRO",      "@ENABLE_CAIRO@",     "e" );
1659ToFile( "ENABLE_CAIRO_CANVAS", "@ENABLE_CAIRO_CANVAS@",     "e" );
1660ToFile( "ENABLE_OPENGL",     "@ENABLE_OPENGL@",    "e" );
1661ToFile( "ENABLE_PDFIMPORT",  "@ENABLE_PDFIMPORT@", "e" );
1662ToFile( "ENABLE_REPORTBUILDER","@ENABLE_REPORTBUILDER@","e" );
1663ToFile( "SYSTEM_JFREEREPORT","@SYSTEM_JFREEREPORT@","e" );
1664ToFile( "OOO_JUNIT_JAR",     "@OOO_JUNIT_JAR@",    "e" );
1665ToFile( "SAC_JAR",           "@SAC_JAR@",          "e" );
1666ToFile( "LIBXML_JAR",        "@LIBXML_JAR@",       "e" );
1667ToFile( "FLUTE_JAR",         "@FLUTE_JAR@",        "e" );
1668ToFile( "JFREEREPORT_JAR",   "@JFREEREPORT_JAR@",  "e" );
1669ToFile( "LIBLAYOUT_JAR",     "@LIBLAYOUT_JAR@",    "e" );
1670ToFile( "LIBLOADER_JAR",     "@LIBLOADER_JAR@",    "e" );
1671ToFile( "LIBFORMULA_JAR",    "@LIBFORMULA_JAR@",   "e" );
1672ToFile( "LIBREPOSITORY_JAR", "@LIBREPOSITORY_JAR@","e" );
1673ToFile( "LIBBASE_JAR",       "@LIBBASE_JAR@",      "e" );
1674ToFile( "LIBFONTS_JAR",      "@LIBFONTS_JAR@",     "e" );
1675ToFile( "LIBSERIALIZER_JAR", "@LIBSERIALIZER_JAR@","e" );
1676ToFile( "ENABLE_MEDIAWIKI",  "@ENABLE_MEDIAWIKI@", "e" );
1677ToFile( "SYSTEM_APACHE_COMMONS","@SYSTEM_APACHE_COMMONS@","e" );
1678ToFile( "COMMONS_CODEC_JAR", "@COMMONS_CODEC_JAR@","e" );
1679ToFile( "COMMONS_LANG_JAR",  "@COMMONS_LANG_JAR@", "e" );
1680ToFile( "COMMONS_HTTPCLIENT_JAR","@COMMONS_HTTPCLIENT_JAR@","e" );
1681ToFile( "COMMONS_LOGGING_JAR","@COMMONS_LOGGING_JAR@","e" );
1682ToFile( "SYSTEM_SERVLETAPI", "@SYSTEM_SERVLETAPI@", "e" );
1683ToFile( "SERVLETAPI_JAR",    "@SERVLETAPI_JAR@",   "e" );
1684ToFile( "ENABLE_DBUS",       "@ENABLE_DBUS@",      "e" );
1685ToFile( "ENABLE_GCONF",      "@ENABLE_GCONF@",     "e" );
1686ToFile( "ENABLE_GNOMEVFS",   "@ENABLE_GNOMEVFS@",  "e" );
1687ToFile( "ENABLE_GIO",        "@ENABLE_GIO@",       "e" );
1688ToFile( "ENABLE_KDE",        "@ENABLE_KDE@",       "e" );
1689ToFile( "KDE_CFLAGS",        "@KDE_CFLAGS@",       "e" );
1690ToFile( "KDE_LIBS",          "@KDE_LIBS@",         "e" );
1691ToFile( "MOC",               "@MOC@",              "e" );
1692ToFile( "ENABLE_KDE4",       "@ENABLE_KDE4@",      "e" );
1693ToFile( "KDE4_CFLAGS",       "@KDE4_CFLAGS@",      "e" );
1694ToFile( "KDE4_LIBS",         "@KDE4_LIBS@",        "e" );
1695ToFile( "MOC4",              "@MOC4@",             "e" );
1696ToFile( "ENABLE_KAB",        "@ENABLE_KAB@",       "e" );
1697ToFile( "PSPRINT",           "TRUE",             "e" );
1698ToFile( "MKDEPENDSOLVER",    "TRUE",             "e" );
1699ToFile( "nodep",             "@nodep@",          "e" );
1700ToFile( "TARFILE_LOCATION",  $TARFILE_LOCATION,  "e" );
1701ToFile( "DO_FETCH_TARBALLS", "@DO_FETCH_TARBALLS@",  "e" );
1702ToFile( "CUSTOM_PACK_LIST",  "@CUSTOM_PACK_LIST@",  "e" );
1703ToFile( "USE_PACKAGER",      "@USE_PACKAGER@",      "e" );
1704ToFile( "ENABLE_ONLINE_UPDATE", "@ENABLE_ONLINE_UPDATE@", "e" );
1705#
1706# Writing the platform dependent constant values to file.
1707# (c = comment, e = environment variable, a = alias )
1708ToFile( "Platform dependent constant values.", $empty, "c" );
1709ToFile( "SOLAR_JAVA",        $SOLAR_JAVA,        "e" );
1710ToFile( "BIG_SVX",           $BIG_SVX,           "e" );
1711ToFile( "COM",               $COM,               "e" );
1712ToFile( "COMPATH",           $COMPATH,           "e" );
1713ToFile( "CC_PATH",           "@CC_PATH@",        "e" );
1714ToFile( "CXX_X64_BINARY",    $CXX_X64_BINARY,    "e" );
1715ToFile( "LINK_X64_BINARY",   $LINK_X64_BINARY,   "e" );
1716ToFile( "LIBMGR_X64_BINARY", $LIBMGR_X64_BINARY, "e" );
1717ToFile( "CPU",               $CPU,               "e" );
1718ToFile( "CPUNAME",           $CPUNAME,           "e" );
1719ToFile( "CVER",              $CVER,              "e" );
1720ToFile( "GUI",               $GUI,               "e" );
1721ToFile( "GLIBC",             $GLIBC,             "e" );
1722ToFile( "GUIBASE",           $GUIBASE,           "e" );
1723ToFile( "GVER",              $GVER,              "e" );
1724ToFile( "OS",                $OS,                "e" );
1725ToFile( "OSVERSION",         $OSVERSION,         "e" );
1726ToFile( "PTHREAD_CFLAGS",    "@PTHREAD_CFLAGS@", "e" );
1727ToFile( "PTHREAD_LIBS",      "@PTHREAD_LIBS@",   "e" );
1728ToFile( "OUTPATH",           $OUTPATH,           "e" );
1729ToFile( "INPATH",            $INPATH,            "e" );
1730ToFile( "PATH_SEPERATOR",    $PATH_SEPERATOR,    "e" );
1731ToFile( "COMEX",             $COMEX,             "e" );
1732ToFile( "CDPATHx",           $CDPATHx,           "e" );
1733ToFile( "DYNAMIC_CRT",       $DYNAMIC_CRT,       "e" );
1734ToFile( "SET_EXCEPTIONS",    $SET_EXCEPTIONS,    "e" );
1735ToFile( "use_shl_versions",  $use_shl_versions,  "e" );
1736ToFile( "FLIPCMD",           $FLIPCMD,           "e" );
1737ToFile( "ARM_TARGET",        "@ARM_TARGET@",     "e" );
1738if ( $platform =~ m/darwin/ )
1739{
1740# MAXOSX_DEPLOYMENT_TARGET : The minimum version required to run the build,
1741# build can assume functions/libraries of that version to be available
1742# (safer/easier than dealing with the MAC_OS_X_VERSION_MAX_ALLOWED macro)
1743# http://developer.apple.com/technotes/tn2002/tn2064.html
1744    ToFile( "MACOSX_DEPLOYMENT_TARGET",       "@MACOSX_DEPLOYMENT_TARGET@",       "e" );
1745    ToFile( "MACOSX_SDK_PATH",       "@MACOSX_SDK_PATH@",       "e" );
1746}
1747if ( $platform =~ m/freebsd/ )
1748{
1749    ToFile( "FBSD_GCC_RPATH",       "@FBSD_GCC_RPATH@", "e" );
1750    ToFile( "LIBINTL_PREFIX",       "@LIBINTL_PREFIX@", "e" );
1751}
1752
1753#
1754# Writing the variables to file.
1755# (c = comment, e = environment variable, a = alias, n = newline )
1756ToFile( "Variable values.",  $empty,             "c" );
1757if ( $platform =~ m/cygwin/ )
1758{  ToFile( "CYGWIN_PATH",       $CYGWIN_PATH,       "e" );
1759   ToFile( "PSDK_HOME",         $PSDK_HOME,         "e" );
1760   ToFile( "WINDOWS_VISTA_PSDK","@WINDOWS_VISTA_PSDK@","e" );
1761   ToFile( "DIRECTXSDK_LIB",    $DIRECTXSDK_LIB,    "e" );
1762   ToFile( "USE_DIRECTX5",      $USE_DIRECTX5,      "e" );
1763   ToFile( "ATL_LIB",           "@ATL_LIB@",        "e" );
1764   ToFile( "ATL_LIB_X64",       "@ATL_LIB_X64@",    "e" );
1765   ToFile( "ATL_INCLUDE",       "@ATL_INCLUDE@",    "e" );
1766   ToFile( "HAVE_ATLTHUNK",     "@HAVE_ATLTHUNK@",  "e" );
1767   ToFile( "MFC_LIB",           "@MFC_LIB@",        "e" );
1768   ToFile( "MFC_INCLUDE",       "@MFC_INCLUDE@",    "e" );
1769   ToFile( "NSIS_PATH",         $NSIS_PATH,         "e" );
1770   ToFile( "DISABLE_ACTIVEX",   "@DISABLE_ACTIVEX@","e" );
1771   ToFile( "DISABLE_ATL",       "@DISABLE_ATL@",    "e" );
1772   ToFile( "USE_NEW_SDK",       $USE_NEW_SDK,       "e" );
1773
1774   # Hack around dmake's mktmp not generating DOS paths.
1775#   my $tmpdir = qx{cygpath -m "/tmp"};
1776#   chomp($tmpdir);
1777#   ToFile( "TMPDIR",     $tmpdir,            "e" );
1778    ToFile( "TMPDIR",     "/tmp",            "e" );
1779}
1780ToFile( "ENABLE_HUNSPELL",	"@ENABLE_HUNSPELL@", "e" );
1781ToFile( "ENABLE_HYPHEN",	"@ENABLE_HYPHEN@", "e" );
1782
1783ToFile( "PERL",              $PERL,              "e" );
1784ToFile( "RPM",               "@RPM@",            "e" );
1785ToFile( "DPKG",              "@DPKG@",           "e" );
1786ToFile( "FAKEROOT",          "@FAKEROOT@",       "e" );
1787ToFile( "PKGMK",             "@PKGMK@",          "e" );
1788ToFile( "GNUMAKE",           "@GNUMAKE@",        "e" );
1789ToFile( "GNUTAR",            "@GNUTAR@",         "e" );
1790ToFile( "UPD",               $UPD,               "e" );
1791ToFile( "WORK_STAMP",        $WORK_STAMP,        "e" );
1792ToFile( "SOLARVER",          $SOLARVER,          "e" );
1793ToFile( "SOLARVERSION",      $SOLARVERSION,      "e" );
1794ToFile( "WORKDIR",           $WORKDIR,           "e" );
1795ToFile( "OUTDIR",            $OUTDIR,            "e" );
1796ToFile( "SOLARENV",          $SOLARENV,          "e" );
1797ToFile( "SOLARENVINC",       $SOLARENVINC,       "e" );
1798ToFile( "LOCALINI",          $LOCALINI,          "e" );
1799ToFile( "STAR_INIROOT",      $STAR_INIROOT,      "e" );
1800ToFile( "STAR_INIROOTOLD",   $STAR_INIROOTOLD,   "e" );
1801ToFile( "STAR_STANDLST",     $STAR_STANDLST,     "e" );
1802ToFile( "STAR_SSCOMMON",     $STAR_SSCOMMON,     "e" );
1803ToFile( "STAR_SSOLARINI",    $STAR_SSOLARINI,    "e" );
1804ToFile( "DMAKEROOT",         $DMAKEROOT,         "e" );
1805if ( $JDK ne "gcj" ) {
1806   ToFile( "CLASSPATH",         $CLASSPATH,         "e" );
1807   ToFile( "XCLASSPATH",        $XCLASSPATH,        "e" );
1808}
1809else {
1810   ToFile( "JAVACISGCJ",       '@JAVACISGCJ@',      "e" );
1811}
1812if ( $GUI eq "UNX" ) {
1813   ToFile( "AWTLIB",           '@AWTLIB@',          "e" );
1814}
1815if ( '@JDK@' ne '' )
1816{
1817   ToFile( "JDK",             "@JDK@",           "e" );
1818   ToFile( "JAVAFLAGS",             "@JAVAFLAGS@",           "e" );
1819   ToFile( "JAVAINTERPRETER", PathFormat("@JAVAINTERPRETER@"), "e" );
1820   ToFile( "JAVAIFLAGS",      "@JAVAIFLAGS@",    "e" );
1821   ToFile( "JAVACOMPILER",    PathFormat("@JAVACOMPILER@"), "e" );
1822   ToFile( "JAVAAOTCOMPILER", PathFormat("@JAVAAOTCOMPILER@"), "e" );
1823   ToFile( "JAVADOC",         PathFormat("@JAVADOC@"), "e" );
1824}
1825ToFile( "SCPDEFS",           '@SCPDEFS@',        "e" );
1826ToFile( "SOLAREXTRAINC",     $SOLAREXTRAINC,     "e" );
1827ToFile( "SOLAREXTRALIB",     $SOLAREXTRALIB,     "e" );
1828ToFile( "PATH",              $PATH,              "e" );
1829ToFile( "SOLARLIB",          $SOLARLIB,          "e" );
1830ToFile( "SOLARINC",          $SOLARINC,          "e" );
1831ToFile( "COMP_ENV",          $COMP_ENV,          "e" );
1832ToFile( "JAVAHOME",          $JAVAHOME,          "e" );
1833ToFile( "CC",                $CC,                "e" );
1834ToFile( "HAVE_GCC_VISIBILITY_FEATURE",
1835		"@HAVE_GCC_VISIBILITY_FEATURE@", "e" );
1836ToFile( "HAVE_LD_HASH_STYLE","@HAVE_LD_HASH_STYLE@","e" );
1837ToFile( "HAVE_LD_BSYMBOLIC_FUNCTIONS",
1838		"@HAVE_LD_BSYMBOLIC_FUNCTIONS@","e" );
1839ToFile( "CXX",               $CXX,               "e" );
1840ToFile( "USE_CCACHE",        "@USE_CCACHE@",     "e" );
1841ToFile( "MINGWCXX",          "@MINGWCXX@",       "e" );
1842ToFile( "MINGWSTRIP",        "@MINGWSTRIP@",     "e" );
1843ToFile( "USE_SYSTEM_STL",    "@USE_SYSTEM_STL@", "e" );
1844ToFile( "ALLOC",             "@ALLOC@",          "e" );
1845ToFile( "ENABLE_SYMBOLS",    "@ENABLE_SYMBOLS@",    "e" );
1846ToFile( "DISABLE_STRIP",     "@DISABLE_STRIP@",     "e" );
1847ToFile( "LFS_CFLAGS",        "@LFS_CFLAGS@",     "e" );
1848ToFile( "ENABLE_CRASHDUMP",  "@ENABLE_CRASHDUMP@",  "e" );
1849ToFile( "ENABLE_CUPS",       "@ENABLE_CUPS@",       "e" );
1850ToFile( "ENABLE_RANDR",      "@ENABLE_RANDR@",      "e" );
1851ToFile( "ENABLE_FONTCONFIG", "@ENABLE_FONTCONFIG@", "e" );
1852ToFile( "ENABLE_DIRECTX",    "@ENABLE_DIRECTX@",    "e" );
1853ToFile( "ENABLE_DIRECT_DRAW","@ENABLE_DIRECT_DRAW@","e" );
1854ToFile( "ENABLE_LAYOUT",     "@ENABLE_LAYOUT@",     "e" );
1855ToFile( "ENABLE_PCH",        "@ENABLE_PCH@",       "e" );
1856ToFile( "ENABLE_GRAPHITE",   "@ENABLE_GRAPHITE@",   "e");
1857ToFile( "SYSTEM_GRAPHITE",   "@SYSTEM_GRAPHITE@",   "e");
1858ToFile( "GRAPHITE_LIBS",     "@GRAPHITE_LIBS@",     "e");
1859ToFile( "GRAPHITE_CFLAGS",   "@GRAPHITE_CFLAGS@",   "e");
1860ToFile( "VC_STANDARD",       "@VC_STANDARD@",      "e" );
1861ToFile( "BUILD_X64",         "@BUILD_X64@",      "e" );
1862ToFile( "ENABLE_CATEGORY_B", "@ENABLE_CATEGORY_B@", "e");
1863ToFile( "BUNDLED_EXTENSION_BLOBS", "@BUNDLED_EXTENSION_BLOBS@", "e");
1864ToFile( "BUNDLED_PREREG_EXTENSIONS", "@BUNDLED_PREREG_EXTENSIONS@", "e");
1865ToFile( "ENABLE_BUNDLED_DICTIONARIES", "@ENABLE_BUNDLED_DICTIONARIES@", "e");
1866ToFile( "SYSTEM_DICTS",      "@SYSTEM_DICTS@",     "e");
1867ToFile( "DICT_SYSTEM_DIR",   "@DICT_SYSTEM_DIR@",  "e");
1868ToFile( "HYPH_SYSTEM_DIR",   "@HYPH_SYSTEM_DIR@",  "e");
1869ToFile( "THES_SYSTEM_DIR",   "@THES_SYSTEM_DIR@",  "e");
1870ToFile( "ENABLE_LOCKDOWN",   "@ENABLE_LOCKDOWN@",  "e" );
1871ToFile( "WITH_LDAP",         "@WITH_LDAP@",        "e" );
1872ToFile( "WITH_OPENLDAP",     "@WITH_OPENLDAP@",    "e" );
1873ToFile( "MOZ_INC",           "@MOZ_INC@",          "e" );
1874ToFile( "WITH_CATA_FONTS",   "@WITH_CATA_FONTS@",  "e" );
1875ToFile( "WITH_CATB_FONTS",   "@WITH_CATB_FONTS@",  "e" );
1876ToFile( "WITH_FONTS",        "@WITH_FONTS@",       "e" );
1877ToFile( "WITHOUT_AFMS",      "@WITHOUT_AFMS@",     "e" );
1878ToFile( "WITHOUT_PPDS",      "@WITHOUT_PPDS@",     "e" );
1879ToFile( "BUILD_TYPE",        "@BUILD_TYPE@",       "e" );
1880ToFile( "ADDITIONAL_REPOSITORIES", "@ADDITIONAL_REPOSITORIES@", "e" );
1881ToFile( "VERBOSE",           "@VERBOSE@",          "e" );
1882ToFile( "ENABLE_EVOAB2",     "@ENABLE_EVOAB2@",    "e" );
1883ToFile( "GOBJECT_CFLAGS",    "@GOBJECT_CFLAGS@",   "e" );
1884ToFile( "GOBJECT_LIBS",      "@GOBJECT_LIBS@",     "e" );
1885if ( '@ENABLE_RPATH@' eq "no" ) {
1886  ToFile( "LINKFLAGSRUNPATH",'',                   "e" );
1887}
1888ToFile( "EPM",               "@EPM@",              "e" );
1889ToFile( "EPM_URL",           "@EPM_URL@",	   "e" );
1890ToFile( "EPM_FLAGS",         $EPM_FLAGS,           "e" );
1891ToFile( "BUILD_EPM",         "@BUILD_EPM@",        "e" );
1892ToFile( "PKGFORMAT",         "@PKGFORMAT@",        "e" );
1893ToFile( "SYSTEM_STDLIBS",    "@SYSTEM_STDLIBS@",   "e" );
1894ToFile( "SYSTEM_ZLIB",       "@SYSTEM_ZLIB@",      "e" );
1895ToFile( "SYSTEM_NSS",        "@SYSTEM_NSS@",       "e" );
1896ToFile( "NSS_CFLAGS",        "@NSS_CFLAGS@",       "e" );
1897ToFile( "NSS_LIBS",          "@NSS_LIBS@",         "e" );
1898ToFile( "SYSTEM_OPENSSL",    "@SYSTEM_OPENSSL@",   "e" );
1899ToFile( "OPENSSL_CFLAGS",    "@OPENSSL_CFLAGS@",   "e" );
1900ToFile( "OPENSSL_LIBS",      "@OPENSSL_LIBS@",     "e" );
1901ToFile( "SYSTEM_PYTHON",     "@SYSTEM_PYTHON@",    "e" );
1902ToFile( "PYTHON_CFLAGS",     "@PYTHON_CFLAGS@",    "e" );
1903ToFile( "PYTHON_LIBS",       "@PYTHON_LIBS@",      "e" );
1904if ($SYSTEM_PYTHON eq "NO") {
1905ToFile( "HOME",              "@HOME@",             "e" );
1906}
1907ToFile( "SYSTEM_ICU",        "@SYSTEM_ICU@",       "e" );
1908ToFile( "ICU_MAJOR",         "@ICU_MAJOR@",        "e" );
1909ToFile( "ICU_MINOR",         "@ICU_MINOR@",        "e" );
1910ToFile( "ICU_MICRO",         "@ICU_MICRO@",        "e" );
1911ToFile( "SYSTEM_GENBRK",     "@SYSTEM_GENBRK@",    "e" );
1912ToFile( "SYSTEM_GENCCODE",   "@SYSTEM_GENCCODE@",  "e" );
1913ToFile( "SYSTEM_GENCMN",     "@SYSTEM_GENCMN@",    "e" );
1914ToFile( "SYSTEM_JPEG",       "@SYSTEM_JPEG@",      "e" );
1915ToFile( "FREETYPE_CFLAGS",   "@FREETYPE_CFLAGS@",  "e" );
1916ToFile( "FREETYPE_LIBS",     "@FREETYPE_LIBS@",    "e" );
1917ToFile( "SYSTEM_POPPLER",    "@SYSTEM_POPPLER@",   "e" );
1918ToFile( "POPPLER_CFLAGS",    "@POPPLER_CFLAGS@",   "e" );
1919ToFile( "POPPLER_LIBS",      "@POPPLER_LIBS@",     "e" );
1920ToFile( "GSTREAMER_CFLAGS",  "@GSTREAMER_CFLAGS@", "e" );
1921ToFile( "GSTREAMER_LIBS",    "@GSTREAMER_LIBS@",   "e" );
1922ToFile( "SYSTEM_CAIRO",      "@SYSTEM_CAIRO@",     "e" );
1923ToFile( "BUILD_PIXMAN",      "@BUILD_PIXMAN@",     "e" );
1924ToFile( "CAIRO_CFLAGS",      "@CAIRO_CFLAGS@",     "e" );
1925ToFile( "CAIRO_LIBS",        "@CAIRO_LIBS@",       "e" );
1926ToFile( "XRANDR_CFLAGS",     "@XRANDR_CFLAGS@",    "e" );
1927ToFile( "XRANDR_LIBS",       "@XRANDR_LIBS@",      "e" );
1928ToFile( "XRANDR_DLOPEN",     "@XRANDR_DLOPEN@",    "e" );
1929ToFile( "SYSTEM_CPPUNIT",    "@SYSTEM_CPPUNIT@",   "e" );
1930ToFile( "CPPUNIT_CFLAGS",    "@CPPUNIT_CFLAGS@",   "e" );
1931ToFile( "CPPUNIT_LIBS",      "@CPPUNIT_LIBS@",     "e" );
1932ToFile( "WITH_CPPUNIT",      "@WITH_CPPUNIT@",     "e" );
1933ToFile( "SYSTEM_LIBXML",     "@SYSTEM_LIBXML@",    "e" );
1934ToFile( "USE_FT_EMBOLDEN",   "@USE_FT_EMBOLDEN@",  "e" );
1935ToFile( "LIBXML_CFLAGS",     "@LIBXML_CFLAGS@",    "e" );
1936ToFile( "LIBXML_LIBS",       "@LIBXML_LIBS@",      "e" );
1937ToFile( "SYSTEM_EXPAT",      "@SYSTEM_EXPAT@",     "e" );
1938ToFile( "ENABLE_MYSQLC",     "@ENABLE_MYSQLC@",    "e" );
1939ToFile( "SYSTEM_MYSQL",      "@SYSTEM_MYSQL@",     "e" );
1940ToFile( "SYSTEM_MYSQL_CPPCONN","@SYSTEM_MYSQL_CPPCONN@","e" );
1941ToFile( "MYSQL_INC",         "@MYSQL_INC@",        "e" );
1942ToFile( "MYSQL_LIB",         "@MYSQL_LIB@",        "e" );
1943ToFile( "MYSQL_DEFINES",     "@MYSQL_DEFINES@",    "e" );
1944ToFile( "LIBMYSQL_PATH",     "@LIBMYSQL_PATH@",    "e" );
1945ToFile( "SYSTEM_HSQLDB",     "@SYSTEM_HSQLDB@",    "e" );
1946ToFile( "HSQLDB_JAR",        "@HSQLDB_JAR@",       "e" );
1947ToFile( "SYSTEM_LUCENE",     "@SYSTEM_LUCENE@",    "e" );
1948ToFile( "LUCENE_CORE_JAR",   "@LUCENE_CORE_JAR@",  "e" );
1949ToFile( "LUCENE_ANALYZERS_JAR",   "@LUCENE_ANALYZERS_JAR@",  "e" );
1950ToFile( "SYSTEM_BSH",        "@SYSTEM_BSH@",       "e" );
1951ToFile( "BSH_JAR",           "@BSH_JAR@",          "e" );
1952ToFile( "ENABLE_BEANSHELL", "@ENABLE_BEANSHELL@",  "e" );
1953ToFile( "SYSTEM_SAXON",      "@SYSTEM_SAXON@",     "e" );
1954ToFile( "SAXON_JAR",         "@SAXON_JAR@",        "e" );
1955ToFile( "DISABLE_SAXON",     "@DISABLE_SAXON@",    "e" );
1956ToFile( "ENABLE_JAVASCRIPT", "@ENABLE_JAVASCRIPT@","e" );
1957ToFile( "SYSTEM_APR",        "@SYSTEM_APR@",       "e" );
1958ToFile( "APR_CFLAGS",        "@APR_CFLAGS@",       "e" );
1959ToFile( "APR_LIBS",          "@APR_LIBS@",         "e" );
1960ToFile( "SYSTEM_APR_UTIL",   "@SYSTEM_APR_UTIL@",  "e" );
1961ToFile( "APR_UTIL_CFLAGS",   "@APR_UTIL_CFLAGS@",  "e" );
1962ToFile( "APR_UTIL_LIBS",     "@APR_UTIL_LIBS@",    "e" );
1963ToFile( "SYSTEM_SERF",       "@SYSTEM_SERF@",      "e" );
1964ToFile( "SERF_CFLAGS",       "@SERF_CFLAGS@",      "e" );
1965ToFile( "SERF_LIBS",         "@SERF_LIBS@",        "e" );
1966ToFile( "SYSTEM_COINMP",     "@SYSTEM_COINMP@",    "e" );
1967ToFile( "ENABLE_COINMP",     "@ENABLE_COINMP@",    "e" );
1968ToFile( "COINMP_CFLAGS",     "@COINMP_CFLAGS@",    "e" );
1969ToFile( "COINMP_LIBS",       "@COINMP_LIBS@",      "e" );
1970ToFile( "SYSTEM_ODBC_HEADERS","@SYSTEM_ODBC_HEADERS@","e" );
1971ToFile( "SYSTEM_LIBXSLT",    "@SYSTEM_LIBXSLT@",   "e" );
1972ToFile( "LIBXSLT_CFLAGS",    "@LIBXSLT_CFLAGS@",   "e" );
1973ToFile( "LIBXSLT_LIBS",      "@LIBXSLT_LIBS@",     "e" );
1974ToFile( "SYSTEM_SANE_HEADER","@SYSTEM_SANE_HEADER@","e" );
1975ToFile( "SYSTEM_XRENDER_HEADERS","@SYSTEM_XRENDER_HEADERS@","e" );
1976ToFile( "SYSTEM_CURL",       "@SYSTEM_CURL@",      "e" );
1977ToFile( "CURL_CFLAGS",       "@CURL_CFLAGS@",      "e" );
1978ToFile( "CURL_LIBS",         "@CURL_LIBS@",        "e" );
1979ToFile( "SYSTEM_BOOST",      "@SYSTEM_BOOST@",     "e" );
1980ToFile( "SYSTEM_MDDS",       "@SYSTEM_MDDS@",      "e" );
1981ToFile( "SYSTEM_VIGRA",      "@SYSTEM_VIGRA@",     "e" );
1982ToFile( "SYSTEM_GDKPIXBUF",  "@SYSTEM_GDKPIXBUF@",   "e" );
1983ToFile( "SYSTEM_GLIB",       "@SYSTEM_GLIB@",   "e" );
1984ToFile( "SYSTEM_GETTEXT",    "@SYSTEM_GETTEXT@",   "e" );
1985ToFile( "SYSTEM_PANGO",      "@SYSTEM_PANGO@",   "e" );
1986ToFile( "SYSTEM_LIBPNG",     "@SYSTEM_LIBPNG@",   "e" );
1987ToFile( "SYSTEM_LIBJPEG",    "@SYSTEM_LIBJPEG@",   "e" );
1988ToFile( "RAT_JAR_HOME",      "@RAT_JAR_HOME@",     "e" );
1989ToFile( "DMAKE_URL",         "@DMAKE_URL@",        "e" );
1990ToFile( "DMAKE_PATH",        "@DMAKE_PATH@",       "e" );
1991ToFile( "IS_SYSTEM_DMAKE",   "@IS_SYSTEM_DMAKE@",  "e" );
1992ToFile( "BUILD_STAX",        "@BUILD_STAX@",       "e" );
1993ToFile( "BUILD_UNOWINREG",   "@BUILD_UNOWINREG@",  "e" );
1994ToFile( "USE_XINERAMA",      "@USE_XINERAMA@",     "e" );
1995ToFile( "XINERAMA_LINK",     "@XINERAMA_LINK@",    "e" );
1996ToFile( "SYSTEM_REDLAND",    "@SYSTEM_REDLAND@",   "e" );
1997ToFile( "REDLAND_CFLAGS",    "@REDLAND_CFLAGS@",   "e" );
1998ToFile( "REDLAND_LIBS",      "@REDLAND_LIBS@",     "e" );
1999ToFile( "SYSTEM_HUNSPELL",   "@SYSTEM_HUNSPELL@",  "e" );
2000ToFile( "HUNSPELL_CFLAGS",   "@HUNSPELL_CFLAGS@",  "e" );
2001ToFile( "HUNSPELL_LIBS",     "@HUNSPELL_LIBS@",    "e" );
2002ToFile( "HAVE_GETOPT",       "@HAVE_GETOPT@",      "e" );
2003ToFile( "HAVE_READDIR_R",    "@HAVE_READDIR_R@",   "e" );
2004ToFile( "SYSTEM_LIBC",       "@SYSTEM_LIBC@",      "e" );
2005ToFile( "SYSTEM_HYPH",       "@SYSTEM_HYPH@",      "e" );
2006ToFile( "HYPHEN_LIB",        "@HYPHEN_LIB@",       "e" );
2007ToFile( "SYSTEM_MYTHES",     "@SYSTEM_MYTHES@",    "e" );
2008ToFile( "MYTHES_CFLAGS",     "@MYTHES_CFLAGS@",    "e" );
2009ToFile( "MYTHES_LIBS",       "@MYTHES_LIBS@",      "e" );
2010ToFile( "SYSTEM_LIBTEXTCAT", "@SYSTEM_LIBTEXTCAT@","e" );
2011ToFile( "SYSTEM_LIBTEXTCAT_DATA","@SYSTEM_LIBTEXTCAT_DATA@","e" );
2012ToFile( "PAM",               "@PAM@",              "e" );
2013ToFile( "NEW_SHADOW_API",    "@NEW_SHADOW_API@",   "e" );
2014ToFile( "PAM_LINK",          "@PAM_LINK@",         "e" );
2015ToFile( "CRYPT_LINK",        "@CRYPT_LINK@",       "e" );
2016ToFile( "XAU_LIBS",          "@XAU_LIBS@",         "e" );
2017ToFile( "GXX_INCLUDE_PATH",  PathFormat("@GXX_INCLUDE_PATH@"), "e" );
2018ToFile( "COMMON_BUILD_TOOLS",$COMMON_BUILD_TOOLS,  "e" );
2019if ($platform !~ m/cygwin|os2/) {
2020   if ( !defined $ENV{"TMPDIR"} || $ENV{"TMPDIR"} eq "" ) {
2021      ToFile( "TMPDIR",      "/tmp",               "e" );
2022   } else {
2023      ToFile( "TMPDIR",      "$ENV{'TMPDIR'}",     "e" );
2024   }
2025}
2026ToFile( "SOLARSRC",           $SOLARSRC,           "e" );
2027ToFile( "SOURCE_ROOT_DIR",    $SOURCE_ROOT_DIR,    "e" );
2028ToFile( "gb_REPOS",           $gb_REPOS,           "e" );
2029
2030if ( $platform =~ m/cygwin/ )
2031{
2032   ToFile( "ILIB",              $ILIB,              "e" );
2033   if ( $MINGW eq "yes" )
2034   {  ToFile( "ATL_INCLUDE",       $ATL_INCLUDE,       "e" );
2035      ToFile( "EXCEPTIONS",        "@EXCEPTIONS@",        "e" );
2036      ToFile( "DIRECTXSDK_HOME",    PathFormat("@DIRECTXSDK_HOME@"),    "e" );
2037      ToFile( "USE_MINGW",         $USE_MINGW,              "e" );
2038      ToFile( "MINGW_CLIB_DIR",         PathFormat("@MINGW_CLIB_DIR@"),              "e" );
2039      ToFile( "MINGW_SHARED_GCCLIB",         "@MINGW_SHARED_GCCLIB@",              "e" );
2040      ToFile( "MINGW_GCCLIB_EH",      "@MINGW_GCCLIB_EH@",              "e" );
2041      ToFile( "MINGW_SHARED_GXXLIB",         "@MINGW_SHARED_GXXLIB@",              "e" );
2042      ToFile( "MINGW_SHARED_LIBSTDCPP",         "@MINGW_SHARED_LIBSTDCPP@",              "e" );
2043      ToFile( "MINGW_GCCDLL",         "@MINGW_GCCDLL@",              "e" );
2044      ToFile( "MINGW_GXXDLL",         "@MINGW_GXXDLL@",              "e" );
2045   }
2046   ToFile( "GREP",              $WIN_GREP,          "e" );
2047   ToFile( "FIND",              $WIN_FIND,          "e" );
2048   ToFile( "LS",                $WIN_LS,            "e" );
2049   ToFile( "GNUCOPY",           $WIN_GNUCOPY,       "e" );
2050   ToFile( "TOUCH",             $WIN_TOUCH,         "e" );
2051   ToFile( "WITH_VC_REDIST",    "@WITH_VC_REDIST@", "e" );
2052}
2053if ( $platform =~ m/os2/ )
2054{
2055   #ToFile( "ILIB",              $ILIB,              "e" );
2056
2057   ToFile( "GREP",              "grep.exe",         "e" );
2058   ToFile( "FIND",              "find.exe",         "e" );
2059   ToFile( "LS",                "ls.exe",           "e" );
2060   ToFile( "GNUCOPY",           "cp.exe",           "e" );
2061   ToFile( "TOUCH",             "touch",            "e" );
2062   ToFile( "CONFIG_SITE",       "/@unixroot/usr/share/config.legacy", "e" );
2063}
2064
2065# $perlpre is only used for the following three variables
2066# and only set for OS2.
2067my $perlpre = "";
2068if (( $platform =~ m/os2/ )) {
2069   $perlpre = "perl ".${SOLARENV}.${BIN}.${ds};
2070}
2071ToFile( "DELIVER",       $perlpre."deliver.pl",     "e" );
2072ToFile( "MKOUT",         $perlpre."mkout.pl",       "e" );
2073ToFile( "ZIPDEP",        $perlpre."zipdep.pl",      "e" );
2074
2075#
2076# Writing the aliases to file.
2077ToFile( "Aliases.",          $empty,             "c" );
2078ToFile( "Don't set aliases when bootstrapping", $empty, "c" );
2079ToFile( 'if ( ! ${?_ISBOOTSTRAP_} ) then', $empty, "y");
2080ToFile( "if test -z \"\$_ISBOOTSTRAP_\"; then", $empty, "z");
2081
2082ToFile( "alias mkout",       $mkout,             "a" );
2083ToFile( "alias deliver",     $deliver,           "a" );
2084ToFile( "alias build",       $build,             "a" );
2085ToFile( "alias build_client",$build_client,      "a" );
2086ToFile( "alias zipdep",      $zipdep,            "a" );
2087if ( $platform !~ m/cygwin/ )
2088{  ToFile( "alias nmake",       $nmake,             "a" );
2089}
2090if ( $platform =~ m/os2/ )
2091{  ToFile( "alias gunzip",       "gzip -d",         "a" );
2092}
2093
2094ToFile( "endif",             $empty, "y");
2095ToFile( "fi",                $empty, "z");
2096
2097# Check if the right dmake version is used. (W32 only)
2098if ( $platform =~ m/cygwin/ ) {
2099    ToFile( "Check if the right dmake version is used.", $empty, "c" );
2100    # Invalidate build environment.
2101    ToFile( "WORK_STAMP", "_invalid_", "e" );
2102    # Don't test the dmake version if this file is sourced by bootstrap
2103    ToFile( "bash -c 'if test -n \"\$_ISBOOTSTRAP_\" || (dmake.exe -V | grep -e \"-cygwin\\|OS := cygwin\" > /dev/null ); then true; else echo -e \"\\n\\nERROR: Not a cygwin build dmake or dmake missing, please check!\\n\\n\" ; sleep 5; false ; fi' || exit 1", $empty, "y");
2104    # Restore valid environment if test was successful.
2105    ToFile( "WORK_STAMP",        $WORK_STAMP,        "e" );
2106    ToFile( "", $empty, "n");
2107}
2108
2109# on Solaris, MacOSX and FreeBSD (and Windows) set GNUPATCH and GPERF
2110if ($platform =~ m/solaris|darwin|freebsd|cygwin/)
2111{
2112  ToFile( "GNUPATCH",   "@GNUPATCH@",	"e");
2113  ToFile( "GPERF", "@GPERF@",	"e");
2114}
2115ToFile( "GNUCOPY",	"@GNUCP@",	"e");
2116# OS/2 define .pl as executable for 4os2
2117# use - as switch char for dmake (os2/switchar.c)
2118if ($platform =~ m/os2/)
2119{
2120  ToFile( ".pl",   	"perl",	"e");
2121  ToFile( "SWITCHAR",   "-",	"e");
2122}
2123ToFile( "SAL_ENABLE_FILE_LOCKING",	"1",	"e");
2124#
2125# Writing unset variables you might not need to file.
2126#
2127print OUT $unsetvars;
2128
2129print OUT_SH "export $exportvars$newline";
2130print OUT_SH "unset $unsetvarssh$newline";
2131
2132if(defined($outfile_bat))
2133{  print OUT_BAT $unsetvarsbat;
2134}
2135
2136#
2137#---------------------------
2138# VIII. Closing output file.
2139#---------------------------
2140#
2141close( OUT ) || print "Can't close $outfile: $!";
2142
2143close( OUT_SH ) || print "Can't close $outfile_sh: $!";
2144
2145if( defined($outfile_bat))
2146{  close( OUT_BAT ) || print "Can't close $outfile_bat: $!";
2147}
2148
2149#
2150#------------------------------
2151# IX. Sourcing the output file.
2152#------------------------------
2153#
2154#---------------------------------
2155# X. Set up the build environment.
2156#---------------------------------
2157#
2158#--------------------------------------------------------
2159# XI. Moving the output file to the build home directory.
2160#--------------------------------------------------------
2161#
2162$tmp = $SRC_ROOT.$ds.$outfile;
2163if (rename( $outfile, $tmp ) ne 1)
2164{  `mv -f $outfile $tmp`;
2165}
2166
2167$tmp = $SRC_ROOT.$ds.$outfile_sh;
2168if (rename( $outfile_sh, $tmp ) ne 1)
2169{  `mv -f $outfile_sh $tmp`;
2170}
2171
2172if(defined($outfile_bat))
2173{
2174    $tmp = $SRC_ROOT.$ds.$outfile_bat;
2175    if (rename( $outfile_bat, $tmp ) ne 1)
2176    {  `mv -f $outfile_bat $tmp`;
2177    }
2178}
2179
2180#
2181#--------------------------------------------------------
2182# XII. Message at the end.
2183#--------------------------------------------------------
2184#
2185#
2186print "*********************************************************".
2187      "******************* $newline"."*"."$newline";
2188print "* Apache OpenOffice $UPD configuration. $newline";
2189for ( $tmp = 0; $tmp < 2; $tmp++ )
2190{  print "* $newline";
2191}
2192print "* Configuration part of Apache OpenOffice $UPD build is finished. $newline* $newline";
2193print "* Note: Be aware that you might not be able to build Apache OpenOffice if $newline".
2194      "* you ignore any warnings that were generated during this configuration $newline".
2195      "* process. $newline* $newline";
2196
2197if ( $Warning ne "" )
2198{  print "$Warning*";
2199   print "$newline";
2200}
2201
2202print "*$newline* USAGE: $newline";
2203print "* Source $outfile (in tcsh)";
2204print " or $outfile.sh (in sh)";
2205print "$newline";
2206print "* in order to set up the build-environment variables.$newline";
2207for ( $tmp = 0; $tmp < 2; $tmp++ )
2208{  print "* $newline";
2209}
2210print "*********************************************************".
2211      "******************* $newline";
2212
2213$bootfile = "bootstrap";
2214open( OUT, ">$bootfile" ) ||
2215die "Cannot open $bootfile: $!\n";
2216print OUT "#!/bin/sh\n";
2217print OUT "_ISBOOTSTRAP_=TRUE ; export _ISBOOTSTRAP_ ; . $SRC_ROOT/$outfile.sh\n";
2218print OUT "unset _ISBOOTSTRAP_; export _ISBOOTSTRAP_\n";
2219if ( $MINGW eq "yes" )
2220{  print OUT 'PATH="/usr/bin:$PATH" : export PATH'."\n"; }
2221close( OUT ) || print "Can't close $bootfile: $!";
2222system(`cat bootstrap.1 >> bootstrap`);
2223system(`chmod +x bootstrap`);
2224#
2225#--------------------------------------------------------
2226# Moving the bootstrap file to the build home directory.
2227#--------------------------------------------------------
2228#
2229$tmp = $SRC_ROOT.$ds.$bootfile;
2230if (rename( $bootfile, $tmp ) ne 1)
2231{  `mv -f $bootfile $tmp`;
2232}
2233
2234print "Configure completed";
2235if ( $Warning ne "" ) {
2236	print ", but\n***** WARNINGS WERE ISSUED *****";
2237}
2238print "\n\nRun ./bootstrap in $SRC_ROOT to provide build tools and get third-party packages\n";
2239
2240#
2241#-----------------
2242# XII. Functions.
2243#-----------------
2244#
2245#-------------------------------------------------------------
2246# Function name: CheckPathName
2247# Description:   chops off the '/' character if it's the last
2248#                character in a pathname. also adds the '/'
2249#                character if it's not the first character
2250#                in a path.
2251# Arguments:     1. Path (string)
2252# Return value:  Path (string)
2253#-------------------------------------------------------------
2254sub CheckPathName
2255{  my $retrn = $_[ 0 ];
2256   if ($platform =~ m/cygwin/)
2257   {  # Check if the first character is not a '/'.
2258      if ( !( $_[ 0 ] =~ /^\// ) )
2259      {  $retrn = $ds.$_[ 0 ];
2260      }
2261   }
2262   # kill the last '/','\','\n' if they exists.
2263   $retrn =~ s![\s/\\]+$!!;
2264   # Done!
2265   return( $retrn );
2266}
2267#-------------------------------------------------------------
2268# Function name: CheckPathExist
2269# Description:   Checks whether the directory that is given
2270#                as an argument exists. If not abort.
2271# Arguments:     1. Path (string)
2272# Return value:  void
2273#-------------------------------------------------------------
2274sub CheckPathExist
2275{  my $dir = $_[ 0 ];
2276   if ( !( -d $dir ) and $^O ne 'MSWin32' )
2277   {  print ( "The directory $_[ 0 ] does not exist. Please create first.\n" );
2278      exit 1;
2279   }
2280   else
2281   {  # Don't check under ActiveState Perl (Windows). The path is possibly
2282      # posix and it cannot handle it.
2283      return "true";
2284   }
2285}
2286#------------------------------------------------------------
2287# Function name: CreateFileHeader
2288# Description:   Creates a header for the outfile.
2289# Arguments:     1. File to write to
2290#                2. UPD (string)
2291#                3. Platform (string)
2292#                4. name of shell for this file
2293#                5. comment to use for this file
2294# Return value:  void
2295#------------------------------------------------------------
2296sub CreateFileHeader
2297{  my $timestamp = `date`;
2298   chomp( $timestamp );
2299   my $filehandle = $_[0];
2300   my $comment = $_[4];
2301   print { $filehandle } "$comment #################################################################";
2302   print { $filehandle } $newline;
2303   print { $filehandle } "$comment Apache OpenOffice $_[ 1 ] build environment file for: $_[ 2 ]. $newline";
2304   print { $filehandle } "$comment Generated on: $timestamp $newline";
2305   print { $filehandle } "$comment Source this file to set up the build environment. $newline";
2306   print { $filehandle } "$comment 1. exec $_[3] $newline";
2307   print { $filehandle } "$comment 2. source $outfile $newline";
2308   print { $filehandle } "$comment #################################################################";
2309   print { $filehandle } $newline;
2310}
2311#---------------------------------------------------------
2312# Function name: ToFile
2313# Description:   Writes the environment variable in the
2314#                output file.
2315# Arguments:     1. Name of environment variable (string)
2316#                2. Value of environment variable (string)
2317#                3. e - env. var
2318#                   a - alias
2319#                   c - comment
2320#                   n - newline
2321#                   x - raw, write as is to OUT_BAT
2322#                   y - raw, write as is to OUT
2323#                   z - raw, write as is to OUT_SH
2324# Return value:  void
2325#---------------------------------------------------------
2326sub ToFile {
2327   if ( $_[ 2 ] eq "e" ) {
2328      # Write an environment variable to file.
2329      if (defined $_[ 1 ] && $_[ 1 ] ne "" ) {
2330         my $envvar = $_[ 1 ];
2331         my $envvarbash = $envvar;
2332
2333         if ($platform =~ m/os2/) {
2334             # expand the variables
2335             $envvar =~ s/(\$\{?\w+\}?)/$1/eeg ;
2336             # Some variables need to be translated
2337             #if ( ($_[ 0 ] =~ /^PATH$/) and ($platform !~ m/os2/) ) {
2338             #    # PATH is in cygwin format, but for 4nt it needs to be DOS.
2339             #    $win_format_var = WinPath( $envvar, ":" );
2340             #} else {
2341             #    $win_format_var = WinFormat( $envvar );
2342             #}
2343             ## The excluded variables are translated by cygwin
2344             #if ( $_[ 0 ] !~ /^PATH$|^TMP$|^TEMP$|^TMPDIR$|^HOME$/i ) {
2345             #    $envvar = $win_format_var;
2346             #}
2347         }
2348
2349         # Tcsh/bash needs backslashes quoted
2350         $envvar =~ s/\\/\\\\/g;
2351         $envvarbash = $envvar;
2352
2353         if ($platform =~ m/os2/) {
2354             # expand the variables
2355             $envvar =~ s/(\$\{?\w+\}?)/$1/eeg ;
2356             if ($_[ 0 ] =~ /^PATH$|^BEGINLIBPATH$/) {
2357                # always use \ for them
2358                $envvar =~ s/\//\\/g ;
2359             }
2360             $win_format_var = $envvar;
2361         }
2362
2363         printf("%-12s %-17s %-10s %s\n", "The variable", $_[ 0 ], "is set to:", $envvar);
2364         print OUT "$setenv $_[ 0 ] \"$envvar\"$newline";  # to tcsh file
2365         print OUT_SH "$_[ 0 ]=\"$envvarbash\"$newline";   # to sh file
2366         $exportvars .= " $_[ 0 ]";                        # add to export list for sh file
2367
2368         if(defined($outfile_bat)) {
2369             print OUT_BAT "IF DEFINED $_[ 0 ] $unset $_[ 0 ]$newline";
2370             print OUT_BAT "$set $_[ 0 ]=$win_format_var$newline";
2371         }
2372
2373      } else {
2374         printf("%-12s %-17s %-10s %s\n", "The variable", $_[ 0 ], "is set to:", "unset") ; # to stdout
2375         $unsetvars .= "$unsetenv $_[ 0 ] >& /dev/null$newline"; # for tcsh file
2376         $unsetvarssh .= " $_[ 0 ]";                             # for sh file
2377         if(defined($outfile_bat)) {
2378             $unsetvarsbat .= "$unset $_[ 0 ] >& NUL$newline";
2379         }
2380      }
2381   }
2382   elsif ( $_[ 2 ] eq "a" )
2383   {  # Write an alias to file.
2384      print "The $_[ 0 ] is set to: $_[ 1 ]\n";    # to stdout
2385      print OUT "$_[ 0 ] $_[ 1 ]$newline";         # to tcsh file
2386      print OUT_SH "$_[ 0 ]=$_[ 1 ]$newline";      # to sh file
2387      if(defined($outfile_bat)) # create the correct 4nt alias format
2388      {  my $aliastmp = $_[ 1 ];
2389         $aliastmp =~ s/\$/\%/g;
2390         $aliastmp =~ s!/!\\!g;
2391         $aliastmp =~ s!"!!g;
2392         print OUT_BAT "$_[ 0 ]=".'`'.$aliastmp.'`'.$newline;
2393      }
2394   }
2395   elsif ( $_[ 2 ] eq "c" )
2396   {  # Write a comment to file.
2397      print "$newline";
2398      print "$comment$newline";
2399      print "$comment $_[ 0 ]$newline";
2400      print "$comment$newline";
2401      print OUT "$newline";
2402      print OUT "$comment$newline";
2403      print OUT "$comment $_[ 0 ]$newline";
2404      print OUT "$comment$newline";
2405      print OUT_SH "$newline";
2406      print OUT_SH "$comment$newline";
2407      print OUT_SH "$comment $_[ 0 ]$newline";
2408      print OUT_SH "$comment$newline";
2409      if(defined($outfile_bat)) {
2410          print OUT_BAT "$newline";
2411          print OUT_BAT "rem $newline";
2412          print OUT_BAT "rem $_[ 0 ]$newline";
2413          print OUT_BAT "rem $newline";
2414      }
2415   }
2416   elsif ( $_[ 2 ] eq "n" )
2417   {  #Write a newline to a file
2418      print OUT "$newline";
2419      print OUT_SH "$newline";
2420      print OUT_BAT "$newline" if defined($outfile_bat);
2421   }
2422   elsif ( $_[ 2 ] eq "y" )
2423   {
2424      #Write first argument as is, and nothing else
2425      print OUT "$_[ 0 ]$newline";
2426   }
2427   elsif ( $_[ 2 ] eq "z" )
2428   {
2429      #Write first argument as is, and nothing else
2430      print OUT_SH "$_[ 0 ]$newline";
2431   }
2432   else
2433   {  print "Unknown type!$newline";
2434   }
2435}
2436#----------------------------------------------------------
2437# Function name: PathFormat
2438# Description:   Reformat path to either POSIX or mixed mode style.
2439# Arguments:     1. Variable (string)
2440# Return value:  Reformatted String
2441#----------------------------------------------------------
2442sub PathFormat
2443{  my ( $variable, $d1, $d2 );
2444   $variable = $_[ 0 ];
2445
2446   if ( $platform =~ m/cygwin/ )
2447   {   $variable =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables
2448       $variable =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables twice!
2449
2450       # Complain if PosixPath is used on a PATH-like string
2451       if ( $variable =~ m/;/ ) {
2452           die( "Do not use on PATH lists (i.e., 'c:\\foo;d:\\bar')");
2453       }
2454
2455       # Replace path with space with short dos path
2456       if ( $variable =~ / / ) {
2457           chomp( $variable = qx{cygpath -d "$variable"} ) ;
2458       }
2459
2460       # Replace absolute paths or DOS paths with ...
2461       if ( ( $variable =~ m/^\// ) or ( $variable =~ m/:/ ) ) {
2462           # mixed mode paths
2463           chomp( $variable = qx{cygpath -m "$variable"} );
2464       }
2465   }
2466   return $variable;
2467}
2468#----------------------------------------------------------
2469# Function name: CygFormat
2470# Description:   Format variables to cygwin posix style path
2471#                unless .
2472# Arguments:     1. Variable (string)
2473# Return value:  Reformatted String
2474#----------------------------------------------------------
2475sub CygFormat
2476{  my ( $variable, $d1, $d2 );
2477   $variable = $_[ 0 ];
2478   # ToDo: Do the replacement only if Windows and var contains "\" and ":"
2479   if ( $platform =~ m/cygwin|os2/ )
2480   {
2481       # Complain if PosixPath is used on a PATH-like string
2482       if ( $variable =~ m/;/ ) {
2483           die( "Do not use on PATH lists (i.e., 'c:\\foo;d:\\bar')");
2484       }
2485
2486       # Replace DOS paths with posix paths
2487       if ( ( $variable =~ m/\\/ ) or ( $variable =~ m/:/ ) ) {
2488           chomp( $variable = qx{cygpath -u "$variable"} );
2489       }
2490   }
2491   return $variable;
2492}
2493#----------------------------------------------------------
2494# Function name: WinFormat
2495# Description:   Format variables to Windows Format.
2496# Arguments:     1. Variable (string)
2497# Return value:  Reformatted String
2498#----------------------------------------------------------
2499sub WinFormat
2500{  my ( $variable, $d1 );
2501   $variable = $_[ 0 ];
2502   $variable =~ s/^\s+//g ; #remove leading spaces
2503   $variable =~ s/\s+$//g ; #remove trailing spaces
2504   $variable =~ s/(\$\{?\w+\}?)/$1/eeg ;   # expand the variables
2505   $variable =~ s/(\$\{?\w+\}?)/$1/eeg ;   # expand the variables twice!
2506   $variable =~ s/:+/:/g ;                 # remove multiple ;
2507
2508   # Some variables are already in DOS path format, return early.
2509   if ( $variable =~ /\\/ ) {
2510       return $variable;
2511   }
2512   if ( $variable eq ";" ) {
2513       # Ignore single ';'
2514       return $variable;
2515   }
2516   if ( $variable =~ /;/ and $variable =~ /\// ) {
2517       # Mixed mode path-style entry, separated with ;, like CLASSPATH
2518       return $variable;
2519   }
2520
2521   # Search for posix path entry and replace with cygpath -w entry
2522   # ( -d if filename contains space )
2523
2524   # Normal paths
2525
2526   # One special case is if "perl " is prepended.
2527   $variable =~ /^(perl\s+)?(.*)$/;
2528   my $perlpre = $1;
2529   if ( !defined($perlpre) ) {
2530       $perlpre = "";
2531   }
2532   $variable = $2;
2533
2534   if ( $variable =~ /^\/[\w\.~ ]+/ ) {
2535       if ( $variable =~ / / ) {
2536           # Use DOS 8.3 style to avoid quoting
2537           chomp( $variable = qx{cygpath -d "$variable"} );
2538       } else {
2539           # Use "normal" filenames
2540           chomp( $variable = qx{cygpath -w "$variable"} );
2541       }
2542   } else {
2543       # relative or absolute DOS paths here
2544       $variable =~ s#/#\\#g;
2545   }
2546
2547   $variable = $perlpre.$variable;
2548   if ( ($perlpre ne "") && ($^O eq "cygwin")) {
2549       # Cygwin's perl needs quoted backslashes
2550       $variable =~ s#\\#\\\\#g;
2551   }
2552
2553   return $variable;
2554}
2555
2556#----------------------------------------------------------
2557# Function name: WinPath
2558# Description:   Reformat a $sep seperated path using DOS paths.
2559# Arguments:     1. Variable (string)
2560#                2. Separaror (string)
2561# Return value:  Reformatted String
2562#----------------------------------------------------------
2563sub WinPath
2564{
2565    my ( $variable, $d1, $sep, @split_var );
2566
2567    if ( $platform =~ m/cygwin/ ) {
2568        $variable = $_[ 0 ];
2569        $sep = $_[ 1 ];
2570        $variable =~ s/^\s+//g ; #remove leading spaces
2571        $variable =~ s/\s+$//g ; #remove trailing spaces
2572        $variable =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables
2573        $variable =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables twice!
2574
2575        @split_var = split(/$sep/,$variable);
2576        foreach $d1 ( @split_var ) {
2577            if ( $d1 =~ /(?:^\/[\w\.~ ]+)+/ ) {
2578                if ( $d1 =~ / / ) {
2579                    # Use DOS 8.3 style to avoid quoting
2580                    chomp( $d1 = qx{cygpath -d "$d1"} );
2581                } else {
2582                    # Use "normal" filenames
2583                    chomp( $d1 = qx{cygpath -w "$d1"} );
2584                }
2585            }
2586        }
2587        $variable = join(';',@split_var);
2588
2589        $variable =~ s/\//\\/g; # Remaining \ come from e.g.: ../foo/baa
2590    }
2591
2592    return $variable;
2593}
2594
2595#--------------------------------------------------------
2596# Function name: GetCorrectPath
2597# Description:   Creates the build environment.
2598# Arguments:     1.   existing / original path
2599#                2... pairs of <path, executable>
2600# Return value:  String - Correct Path
2601#--------------------------------------------------------
2602sub GetCorrectPath
2603{
2604	sub PathLookup
2605	{
2606	    my $cmd = shift;
2607	    while (@_) {
2608		my $elem = shift;
2609
2610		-x "$elem/$cmd" && return $elem;
2611	    }
2612	    return '';
2613	}
2614
2615	sub SaneGrep
2616	{
2617	    # Perl grep is unbelievably strange.
2618	    my $needle = shift;
2619	    while (@_) {
2620		my $haystack = shift;
2621		if ($needle eq $haystack) {
2622		    return 1;
2623		}
2624	    }
2625	    return 0;
2626	}
2627
2628	sub CleanupPath
2629	{
2630	    my @elements = @_;
2631	    my @cleanName = ();
2632
2633	    while (@elements) {
2634		my $elem = shift @elements;
2635		if (!SaneGrep ($elem, @cleanName)) {
2636			push @cleanName, $elem;
2637		}
2638	    }
2639
2640	    return @cleanName;
2641	}
2642
2643	my $oldPath = shift;
2644	my @originalPairs = @_;
2645	my @pairs = @originalPairs;
2646	my @Path = split /$ps/, $oldPath;
2647	my @buildPath;
2648	my @sysPath;
2649	my $elem;
2650
2651	for $elem (@Path) {
2652	    if ($elem eq '.' || $elem =~ m'^$SOLARENV/' ||
2653		$elem =~ m'/solenv/') {
2654		    push @buildPath, $elem;
2655	    } else {
2656		    push @sysPath, $elem;
2657	    }
2658	}
2659
2660	while (@pairs) {
2661	    my $path = shift @pairs;
2662	    my $cmd = shift @pairs;
2663	    my $to_append = 1;
2664
2665	    if (! -x "$path/$cmd") {
2666		AddWarning ("Missing executable $path/$cmd\n");
2667	    }
2668
2669	    for $elem (@sysPath) {
2670		if ($elem eq $path) {
2671#		    print "Hit duplicate path in path; break\n";
2672		    $to_append = 0;
2673		    last;
2674		}
2675		if (-f "$elem/$cmd" && ! -l "$elem/$cmd") {
2676#		    print "Element already in path ...\n";
2677		    unshift @sysPath, $path;
2678		    $to_append = 0;
2679		    last;
2680		} else {
2681#		    print "No file $elem/$cmd\n";
2682		}
2683	    }
2684	    if ($to_append) {
2685		push @sysPath, $path;
2686	    }
2687	}
2688
2689	@pairs = @originalPairs;
2690	while (@pairs) {
2691	    my $path = shift @pairs;
2692	    my $cmd = shift @pairs;
2693	    my $realpath;
2694
2695	    $realpath = PathLookup ($cmd, @sysPath);
2696	    if (!($realpath eq $path)) {
2697		AddWarning ("Path conflict for executables " .
2698                            "$path/$cmd against $realpath");
2699	    }
2700	}
2701
2702	return join $ps, @buildPath, CleanupPath (@sysPath);
2703}
2704
2705#------------------------------------------------------------
2706# Function name: AddWarning
2707# Description:   Adds any kind of warning for the user.
2708#                The warning will be shown at the end
2709#                of this script.
2710# Arguments:     1. Add the configure warnings or the set_soenv
2711#                   warning (string).
2712#                2. Warning (string).
2713# Return value:  void
2714#------------------------------------------------------------
2715sub AddWarning
2716{  if ( $_[ 0 ] eq "configure" )
2717   {  open( IN, $warnfile );
2718      while ( <IN> )
2719      {  $Warning = $Warning."* - ".$_;
2720      }
2721      close( IN );
2722      # Remove the temporary warning file.
2723      # unlink ( $warnfile );
2724   }
2725   elsif ( $_[ 0 ] eq "set_soenv" )
2726   {  my ( $arg1 );
2727      $arg1 = $_[ 1 ];
2728      chomp( $arg1 );                            # cut off new line
2729      $Warning = $Warning."* - set_soenv: warning: $arg1 $newline";  # add the warning
2730   }
2731}
2732#-------------------
2733# That's all folks!
2734#-------------------
2735