From b5c7a1ea72da52cb11f54212dda984e0507aab92 Mon Sep 17 00:00:00 2001
From: Norbert Thiebaud <nthiebaud@gmail.com>
Date: Fri, 20 Jan 2012 20:15:51 -0600
Subject: remove everything possible but PATH from set_soenv

only PATH and SOLARENV which is used as a trigger to call Env.Host.sh
are left...
---
 config_host.mk.in |  14 +++++++
 configure.in      |  49 ++++++++++++++++++++---
 set_soenv.in      | 116 ++++++------------------------------------------------
 3 files changed, 71 insertions(+), 108 deletions(-)

diff --git a/config_host.mk.in b/config_host.mk.in
index 4bb228863cb2..fcd22b90cccf 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -17,6 +17,7 @@ export ANCIENT_BISON="@ANCIENT_BISON@"
 export ANDROID_NDK_HOME="@ANDROID_NDK_HOME@"
 export ANDROID_SDK_HOME="@ANDROID_SDK_HOME@"
 export AR="@AR@"
+export ASM_PATH="@ASM_PATH@"
 export ATL_INCLUDE="@ATL_INCLUDE@"
 export ATL_LIB="@ATL_LIB@"
 export AWTLIB='@AWTLIB@'
@@ -39,6 +40,7 @@ export CC="@CC@"
 export CC_FOR_BUILD="@CC_FOR_BUILD@"
 export CDR_CFLAGS="@CDR_CFLAGS@"
 export CDR_LIBS="@CDR_LIBS@"
+export CLASSPATH="@CLASSPATH@"
 export CL_X64="@CL_X64@"
 export COM="@COM@"
 export COMEX="@COMEX@"
@@ -56,6 +58,7 @@ export CPUNAME="@CPUNAME@"
 export CPUNAME_FOR_BUILD="@CPUNAME_FOR_BUILD@"
 export CPU_FOR_BUILD="@CPU_FOR_BUILD@"
 export CROSS_COMPILING="@CROSS_COMPILING@"
+export CSC_PATH="@CSC_PATH@"
 export CT2N_EXTENSION_PACK="@CT2N_EXTENSION_PACK@"
 export CURL_CFLAGS="@CURL_CFLAGS@"
 export CURL_LIBS="@CURL_LIBS@"
@@ -84,6 +87,7 @@ export DISABLE_STRIP="@DISABLE_STRIP@"
 export DLLTOOL="@DLLTOOL@"
 export DMAKEROOT="@SRC_ROOT@/solenv/inc/startup"
 export DOCDIR="@DOCDIR@"
+export DOTNET_FRAMEWORK_HOME="@DOTNET_FRAMEWORK_HOME@"
 export DOXYGEN="@DOXYGEN@"
 export DO_FETCH_TARBALLS="@DO_FETCH_TARBALLS@"
 export DPKG="@DPKG@"
@@ -209,9 +213,12 @@ export INTRO_BIPMAP="@INTRO_BITMAP@"
 export JAVAFLAGS="@JAVAFLAGS@"
 export JAVAIFLAGS="@JAVAIFLAGS@"
 export JAVAINTERPRETER="@JAVAINTERPRETER@"
+export JAVACISGCJ="@JAVACISGCJ@"
+export JAVACISKAFFE="@JAVACISKAFFE@"
 export JAVACOMPILER="@JAVACOMPILER@"
 export JAVADOC="@JAVADOC@"
 @x_JAVALIB@ export JAVALIB="@JAVALIB@"
+export JAVA_HOME="@JAVA_HOME@"
 export JAVA_SOURCE_VER="@JAVA_SOURCE_VER@"
 export JAVA_TARGET_VER="@JAVA_TARGET_VER@"
 export JDK="@JDK@"
@@ -263,6 +270,7 @@ export MDDS_CPPFLAGS="@MDDS_CPPFLAGS@"
 export MERGELIBS="@MERGELIBS@"
 export MFC_INCLUDE="@MFC_INCLUDE@"
 export MFC_LIB="@MFC_LIB@"
+export MIDL_PATH="@MIDL_PATH@"
 export MINGWCXX="@MINGWCXX@"
 export MINGWSTRIP="@MINGWSTRIP@"
 export MINGW_CLIB_DIR="@MINGW_CLIB_DIR@"
@@ -284,6 +292,7 @@ export MOZ_INC="@MOZ_INC@"
 export MOZ_LDAP_CFLAGS="@MOZ_LDAP_CFLAGS@"
 export MOZ_LIB="@MOZ_LIB@"
 export MOZ_LIB_XPCOM="@MOZ_LIB_XPCOM@"
+export MSPDB_PATH="@MSPDB_PATH@"
 export MYSQL_DEFINES="@MYSQL_DEFINES@"
 export MYSQL_INC="@MYSQL_INC@"
 export MYSQL_LIB="@MYSQL_LIB@"
@@ -318,6 +327,7 @@ export OUTPATH="@OUTPATH@"
 export OUTPATH_FOR_BUILD="@OUTPATH_FOR_BUILD@"
 export OXYGENOFFICE_PACK="@OXYGENOFFICE_PACK@"
 export PATH_SEPERATOR="@P_SEP@"
+export PERL="@PERL@"
 export PKGFORMAT="@PKGFORMAT@"
 export PKGMK="@PKGMK@"
 export PKG_CONFIG="@PKG_CONFIG@"
@@ -352,6 +362,7 @@ export SAMPLEICC_LIBS="@SAMPLEICC_LIBS@"
 export SAXON_JAR="@SAXON_JAR@"
 export SCPDEFS='@SCPDEFS@'
 export SERVLETAPI_JAR="@SERVLETAPI_JAR@"
+export SHOWINCLUDES_PREFIX="@SHOWINCLUDES_PREFIX@"
 export SIZEOF_DOUBLE="@SIZEOF_DOUBLE@"
 export SIZEOF_INT="@SIZEOF_INT@"
 export SIZEOF_LONG="@SIZEOF_LONG@"
@@ -449,6 +460,8 @@ export SYSTEM_VIGRA="@SYSTEM_VIGRA@"
 export SYSTEM_ZLIB="@SYSTEM_ZLIB@"
 export TARFILE_LOCATION="@TARFILE_LOCATION@"
 export THES_SYSTEM_DIR="@THES_SYSTEM_DIR@"
+@x_Cygwin@ export TMP="@TMP_DIRECTORY@"
+export TMPDIR="@TEMP_DIRECTORY@"
 export TYPO_EXTENSION_PACK="@TYPO_EXTENSION_PACK@"
 export UNIXWRAPPERNAME="@UNIXWRAPPERNAME@"
 export UPD="@UPD@"
@@ -497,6 +510,7 @@ export WPG_CFLAGS="@WPG_CFLAGS@"
 export WPG_LIBS="@WPG_LIBS@"
 export WPS_CFLAGS="@WPS_CFLAGS@"
 export WPS_LIBS="@WPS_LIBS@"
+export XCLASSPATH="@XCLASSPATH@"
 export XINERAMA_LINK="@XINERAMA_LINK@"
 export XRANDR_CFLAGS="@XRANDR_CFLAGS@"
 export XRANDR_DLOPEN="@XRANDR_DLOPEN@"
diff --git a/configure.in b/configure.in
index 55c062f8c8a1..9b2c287381a9 100644
--- a/configure.in
+++ b/configure.in
@@ -2649,6 +2649,8 @@ if test "$_os" = "WINNT"; then
     fi
 fi
 AC_SUBST(COMEX)
+PathFormat "$MSPDB_PATH"
+MSPDB_PATH="$formatted_path"
 AC_SUBST(MSPDB_PATH)
 AC_SUBST(SHOWINCLUDES_PREFIX)
 
@@ -3571,7 +3573,6 @@ if test "$PERL"; then
 else
     AC_MSG_ERROR([Perl not found, install version 5 of Perl])
 fi
-AC_SUBST(PERL)
 
 dnl ===================================================================
 dnl Testing for required Perl modules
@@ -3723,9 +3724,16 @@ if test "$build_os" = "cygwin"; then
         AC_MSG_ERROR([mscoree.lib (.NET Framework) not found. Make sure you use --with-dotnet-framework-home])
     fi
     AC_MSG_RESULT(found)
-    # Convert to posix path with 8.3 filename restrictions ( No spaces )
-    DOTNET_FRAMEWORK_HOME=`cygpath -d "$DOTNET_FRAMEWORK_HOME"`
-    DOTNET_FRAMEWORK_HOME=`cygpath -u "$DOTNET_FRAMEWORK_HOME"`
+
+    PathFormat "$MIDL_PATH"
+    MIDL_PATH="$formatted_path"
+
+    PathFormat "$DOTNET_FRAMEWORK_HOME"
+    DOTNET_FRAMEWORK_HOME="$formatted_path"
+
+    PathFormat "$CSC_PATH"
+    CSC_PATH="$formatted_path"
+
     AC_SUBST(MIDL_PATH)
     AC_SUBST(CSC_PATH)
     AC_SUBST(DOTNET_FRAMEWORK_HOME)
@@ -5150,11 +5158,20 @@ if test "$SOLAR_JAVA" != "" ; then
         test -d "$JRE_BASE_DIR/$JAVA_TOOLKIT" && JAVALIB="$JAVALIB -L$JRE_BASE_DIR/$JAVA_TOOLKIT"
         test -d "$JRE_BASE_DIR/native_thread" && JAVALIB="$JAVALIB -L$JRE_BASE_DIR/native_thread"
     fi
+
+    CLASSPATH=
+    if test "$JDK"!="gcj" ; then
+        if test -f "$JAVA_HOME/jre/lib/rt.jar" ; then
+            CLASSPATH="${JAVA_HOME}/jre/lib/rt.jar${P_SEP}."
+        fi
+    fi
+    XCLASSPATH="$CLASSPATH"
 else
     x_JAVALIB=[\#]
     x_JDKLIB=[\#]
 fi
 
+AC_SUBST(CLASSPATH)
 AC_SUBST(JAVALIB)
 AC_SUBST(JAVACOMPILER)
 AC_SUBST(JAVADOC)
@@ -5166,6 +5183,7 @@ AC_SUBST(JAVA_SOURCE_VER)
 AC_SUBST(JAVA_TARGET_VER)
 AC_SUBST(JDK)
 AC_SUBST(JDKLIB)
+AC_SUBST(XCLASSPATH)
 AC_SUBST(x_JAVALIB)
 AC_SUBST(x_JDKLIB)
 
@@ -7930,7 +7948,9 @@ if test "$_os" = "WINNT" -a "$WITH_MINGW" != "yes"; then
 else
     with_asm_home="NO_ASM_HOME"
 fi
-ASM_HOME="$with_asm_home"
+
+FormatPath "$with_asm_home"
+ASM_HOME="$formatted_path"
 AC_SUBST(ASM_HOME)
 AC_SUBST(ML_EXE)
 
@@ -10765,6 +10785,25 @@ if test -z "$SOLARLIB_FOR_BUILD" ; then
 fi
 AC_SUBST(SOLARLIB_FOR_BUILD)
 
+PathFormat "$PERL"
+PERL="$formatted_path"
+AC_SUBST(PERL)
+
+if test "$build_os" = "cygwin" ; then
+    TEMP_DIRECTORY=`cygpath -m "/tmp"`
+    if test -n "$TMP" ; then
+        TMP_DIRECTORY="$TMP"
+    else
+        TMP_DIRECTORY="$TEMP_DIRECTORY"
+    fi
+else
+    if test -n "$TMPDIR" ; then
+        TEMP_DIRECTORY="$TMPDIR"
+    else
+        TEMP_DIRECTORY="/tmp"
+    fi
+fi
+
 # make sure config.guess is +x; we execute config.guess, so it has to be so;
 chmod +x ./config.guess
 
diff --git a/set_soenv.in b/set_soenv.in
index 162b2ac63e15..e5be260d34d1 100755
--- a/set_soenv.in
+++ b/set_soenv.in
@@ -49,7 +49,7 @@ my ( $CC );
 #
 # Platform dependent constant values.
 my (
-      $OUTPATH, $INPATH,
+      $OUTPATH,
       );
 #
 #-------------------------------------------
@@ -64,12 +64,10 @@ my ( $BIN, $LIB,
 my ( $oldPATH, $SRC_ROOT, $JAVA_HOME, $JDK,
      $UPD,
      $SOLARENV,
-     $CLASSPATH, $XCLASSPATH, $COMPATH,
-     $MSPDB_PATH, $MIDL_PATH, $CSC_PATH, $SHOWINCLUDES_PREFIX,
+     $COMPATH,
      $PATH,
      $PERL,
-     $COMP_ENV, $JAVAHOME, $WINDOWS_SDK_HOME, $DIRECTXSDK_LIB, $DOTNET_FRAMEWORK_HOME,
-     $TMPDIR,
+     $WINDOWS_SDK_HOME, $DOTNET_FRAMEWORK_HOME,
      $GNUMAKE,
      );
 #
@@ -80,15 +78,12 @@ my ( $oldPATH, $SRC_ROOT, $JAVA_HOME, $JDK,
 my ( $dmake, $build, $mkout, $deliver, $zipdep );
 #
 
-$INPATH="@INPATH@";
 $OUTPATH="@OUTPATH@";
 $COMPATH="@COMPATH@";
 #-------------------------------------------------------------
 # IIIa. Initialising constants.
 #-------------------------------------------------------------
 #
-# $platform is needed for PathFormat()
-#
 $platform       = '@host@';
 
 $UPD            = '@UPD@';          # the project's UPD
@@ -107,7 +102,7 @@ $CL_X64 = '@CL_X64@';
 $GNUMAKE        = "@GNUMAKE@";
 
 # JAVA_HOME as argument from autoconf.
-$JAVA_HOME = PathFormat('@JAVA_HOME@') ;
+$JAVA_HOME = "@JAVA_HOME@" ;
 
 if ( $platform =~ m/cygwin/ ) {
    $JAVA_HOME =~ s/[\s\/]+$//;	# remove trailing \n or \/ if there is any.
@@ -143,12 +138,6 @@ $comment              = "#";           # UNIX script comment character
 # Setting platform dependent constant values.
 if ( $platform =~ m/cygwin|mingw32/ )
 {
-    $MSPDB_PATH     = PathFormat('@MSPDB_PATH@');
-    $MIDL_PATH      = PathFormat('@MIDL_PATH@');
-    $CSC_PATH       = PathFormat('@CSC_PATH@');
-    $SHOWINCLUDES_PREFIX = '@SHOWINCLUDES_PREFIX@';
-    $WINDOWS_SDK_HOME      = "@WINDOWS_SDK_HOME@";
-    $DOTNET_FRAMEWORK_HOME = PathFormat('@DOTNET_FRAMEWORK_HOME@');
     $wps = ';' if '@build_os@' eq 'cygwin'; # Windows style path seperator
 }
 
@@ -165,12 +154,6 @@ $SRC_ROOT = $ENV{"SRC_ROOT"};
 CheckPathExist( $SRC_ROOT );
 
 
-# ml.exe assembler path for Windows users.
-if ($platform =~ m/cygwin/)
-{
-    $ASM_PATH = PathFormat('@ASM_HOME@');
-}
-
 #
 # E. Determining the envionment values based on the information
 #    that was gathered earlier on.
@@ -178,20 +161,11 @@ if ($platform =~ m/cygwin/)
 $BIN                  = $ds."bin";
 $LIB                  = $ds."lib";
 
-$PERL                 = PathFormat('@PERL@'); # Perl program
+$PERL                 = '@PERL@';
 $PERL_PATH            = dirname('@PERL@'); # Perl Path
 
 #
-$SOLARENV             = PathFormat("$SRC_ROOT/solenv");
-
-# Location of JDK classes .zip file.
-# but in jdk 1.2 it is called rt.jar and it lives in jre/lib
-$CLASSPATH            = '';
-$CLASSPATH           .= $JAVA_HOME.$ds.'jre'.$LIB.$ds."rt.jar" if (-f $JAVA_HOME.$ds.'jre'.$LIB.$ds."rt.jar");
-$CLASSPATH           .= $wps.'.' if ($CLASSPATH ne '');
-
-# Why do we need XCLASSPATH when it has the exact same value as CLASSPATH?
-$XCLASSPATH           = $CLASSPATH;
+$SOLARENV             = "$SRC_ROOT/solenv";
 
 
 # The general environment path.
@@ -253,29 +227,29 @@ elsif ($platform =~ m/cygwin/)
        $PATH .= $ps.$tmppath;
    }
 
-    $tmppath = CygFormat($MSPDB_PATH);
+    $tmppath = CygFormat("@MSPDB_PATH@");
     # for MSVC to find mspdb*.dll
     if ( "$PATH:$oldPATH" !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
         $PATH .= $ps.$tmppath;
     }
     # need midl.exe
-    $tmppath = CygFormat($MIDL_PATH);
+    $tmppath = CygFormat("@MIDL_PATH@");
     if ( "$PATH:$oldPATH" !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
         $PATH .= $ps.$tmppath;
     }
     # needs csc.exe
-    $tmppath = CygFormat($CSC_PATH);
+    $tmppath = CygFormat("@CSC_PATH@");
     if ( "$PATH:$oldPATH" !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
         $PATH .= $ps.$tmppath;
     }
     # Installer needs some files if the Windows Installer SDK
-    $tmppath = CygFormat($WINDOWS_SDK_HOME);
+    $tmppath = CygFormat("@WINDOWS_SDK_HOME@");
     if ( "$PATH:$oldPATH" !~ /(?:[:]|\A)(?:$tmppath\/bin)(?:[:]|\Z)/i ) {
         $PATH .= $ps.$tmppath.$BIN;
     }
 
-   if ( $ASM_PATH ne "ASM_IN_PATH" )
-   {   $PATH          .= $ps.CygFormat($ASM_PATH);
+   if ( "@ASM_HOME@" ne "ASM_IN_PATH" )
+   {   $PATH          .= $ps.CygFormat("@ASM_HOME@");
    }
 
    # Possible cygwin paths must follow behind the OOo and MS paths.
@@ -287,7 +261,7 @@ elsif ($platform =~ m/cygwin/)
       $PATH          .= $ps.$tmppath;
    }
    # path to sn.exe (signing) for Windows users.
-   my $sn_path = PathFormat('@DOTNET_FRAMEWORK_HOME@/bin');
+   my $sn_path = "@DOTNET_FRAMEWORK_HOME@/bin";
    $tmppath = CygFormat($sn_path);
    if ( "$PATH:$oldPATH" !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
        $PATH          .= $ps.$tmppath;
@@ -372,40 +346,8 @@ open( OUT, ">$SRC_ROOT/$outfile" ) ||
 # Write file header.
 CreateFileHeader( *OUT, $UPD, $platform, "sh/bash/ksh", "#" );
 
-ToFile( "JAVA_HOME",         $JAVA_HOME,         "e" );
-
-if ( $platform =~ m/cygwin/ )
-{
 
-   # Hack around dmake's mktmp not generating DOS paths.
-   my $tmpdir = qx{cygpath -m "/tmp"};
-   chomp($tmpdir);
-   ToFile( "TMPDIR",     $tmpdir,            "e" );
-   if ( !defined $ENV{"TMP"} || $ENV{"TMP"} eq "" ) {
-      ToFile( "TMP", $tmpdir, "e" );
-   } else {
-      ToFile( "TMP", "$ENV{'TMP'}", "e" );
-   }
-}
-else
-{
-   if ( !defined $ENV{"TMPDIR"} || $ENV{"TMPDIR"} eq "" ) {
-      ToFile( "TMPDIR",      "/tmp",               "e" );
-   } else {
-      ToFile( "TMPDIR",      "$ENV{'TMPDIR'}",     "e" );
-   }
-}
-
-ToFile( "PERL",              $PERL,              "e" );
 ToFile( "SOLARENV",          $SOLARENV,          "e" );
-if ( $JDK ne "gcj" ) {
-   ToFile( "CLASSPATH",         $CLASSPATH,         "e" );
-   ToFile( "XCLASSPATH",        $XCLASSPATH,        "e" );
-   ToFile( "JAVACISKAFFE",     '@JAVACISKAFFE@',    "e" );
-}
-else {
-   ToFile( "JAVACISGCJ",       '@JAVACISGCJ@',      "e" );
-}
 
 if ( '@CROSS_COMPILING@' eq 'YES' )
 {
@@ -642,39 +584,7 @@ sub ToFile {
    {  print "Unknown type!$newline";
    }
 }
-#----------------------------------------------------------
-# Function name: PathFormat
-# Description:   Reformat path to either POSIX or mixed mode style.
-# Arguments:     1. Variable (string)
-# Return value:  Reformatted String
-#----------------------------------------------------------
-sub PathFormat
-{  my ( $variable, $d1, $d2 );
-   $variable = $_[ 0 ];
-
-   if ( $platform =~ m/cygwin/ )
-   {   $variable =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables
-       $variable =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables twice!
 
-       # Complain if PosixPath is used on a PATH-like string
-       if ( $variable =~ m/;/ ) {
-           die( "Do not use on PATH lists (i.e., 'c:\\foo;d:\\bar')");
-       }
-
-       # Replace path with space with short dos path
-       if ( $variable =~ / / ) {
-           chomp( $variable = qx{cygpath -d "$variable"} ) ;
-       }
-
-       # Replace absolute paths or DOS paths with ...
-       if ( ( $variable =~ m/^\// ) or ( $variable =~ m/:/ ) ) {
-           # mixed mode paths
-           chomp( $variable = qx{realpath "$variable"} ) unless ($variable =~ m/:/);
-           chomp( $variable = qx{cygpath -m "$variable"} );
-       }
-   }
-   return $variable;
-}
 #----------------------------------------------------------
 # Function name: CygFormat
 # Description:   Format variables to cygwin posix style path
-- 
cgit