make/scripts/vsvars.sh
changeset 21759 e24e22311718
parent 21510 0b432ae58dd5
child 21760 9f542d8601a8
equal deleted inserted replaced
21510:0b432ae58dd5 21759:e24e22311718
     1 #!/bin/sh
       
     2 
       
     3 #
       
     4 # Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
       
     5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     6 #
       
     7 # This code is free software; you can redistribute it and/or modify it
       
     8 # under the terms of the GNU General Public License version 2 only, as
       
     9 # published by the Free Software Foundation.
       
    10 #
       
    11 # This code is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14 # version 2 for more details (a copy is included in the LICENSE file that
       
    15 # accompanied this code).
       
    16 #
       
    17 # You should have received a copy of the GNU General Public License version
       
    18 # 2 along with this work; if not, write to the Free Software Foundation,
       
    19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20 #
       
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22 # or visit www.oracle.com if you need additional information or have any
       
    23 # questions.
       
    24 #
       
    25 
       
    26 # This file should be used to set the Visual Studio environment
       
    27 #   variables normally set by the vcvars32.bat or vcvars64.bat file or
       
    28 #   SetEnv.cmd for older SDKs.
       
    29 
       
    30 ########################################################################
       
    31 # Error functions
       
    32 msg() # message
       
    33 {
       
    34   echo "$1" 1>&2
       
    35 }
       
    36 error() # message
       
    37 {
       
    38   msg "ERROR: $1"
       
    39   exit 1
       
    40 }
       
    41 warning() # message
       
    42 {
       
    43   msg "WARNING: $1"
       
    44 }
       
    45 envpath() # path
       
    46 {
       
    47   if [ "${fixpath}" != "" -a -d "$1" ] ; then
       
    48     ${fixpath} "$1"
       
    49   else
       
    50     echo "$1"
       
    51   fi
       
    52 }
       
    53 ########################################################################
       
    54 
       
    55 
       
    56 # Defaults settings
       
    57 debug="false"
       
    58 verbose="false"
       
    59 
       
    60 set -e
       
    61 
       
    62 CYGWIN="nodosfilewarning ntsec"
       
    63 export CYGWIN
       
    64 
       
    65 # pathsepIn is always ; because the input strings are coming from
       
    66 # vcvarsxx.bat.  This is true under all of MKS, Cygwin, MINGW/msys
       
    67 pathsepIn=';'
       
    68 
       
    69 OS="`uname -s`"
       
    70 case "${OS}" in
       
    71   CYGWIN*)
       
    72     pathflag='-c'
       
    73     devnull=/dev/null
       
    74     pathsepOut=':'
       
    75   ;;
       
    76 
       
    77   MINGW*)
       
    78     pathflag='-m'
       
    79     devnull=/dev/null
       
    80     pathsepOut=':'
       
    81   ;;
       
    82 
       
    83   *)
       
    84     # MKS?
       
    85     # Continue using dosname -s
       
    86     pathflag='-s'
       
    87     fixpath="dosname ${pathflag}"
       
    88     fixpath_windows="${fixpath}"
       
    89     fixpath_path="echo"
       
    90     devnull=NUL
       
    91     pathsepOut=';'
       
    92   ;;
       
    93 esac
       
    94 
       
    95 case "${OS}" in
       
    96   CYGWIN*|MINGW*)
       
    97     t=`dirname ${0}`
       
    98     wd=`cd ${t} 2> ${devnull} && pwd`
       
    99     fixpath_script="${wd}/fixpath.pl"
       
   100     if [ ! -f "${fixpath_script}" ] ; then
       
   101         error "Does not exist: ${fixpath_script}"
       
   102     fi
       
   103     fixpath="perl ${fixpath_script} ${pathflag}"
       
   104     fixpath_windows="perl ${fixpath_script} -d"
       
   105     fixpath_path="${fixpath_windows}"
       
   106   ;;
       
   107 esac
       
   108 
       
   109 shellStyle="sh"
       
   110 ## As far as I can tell from hg history, this has not worked
       
   111 ## for a long time because PPID is unset.  When run under Cygwin
       
   112 ## the script quits due to the 1 return from grep.
       
   113 ##parentCsh="` ps -p ${PPID} 2> ${devnull} | grep csh `"
       
   114 ##if [ "${parentCsh}" != "" ] ; then
       
   115 ##  shellStyle="csh"
       
   116 ##fi
       
   117 
       
   118 # Check environment first
       
   119 if [ "${PROGRAMFILES}" != "" ] ; then
       
   120   progfiles=`envpath "${PROGRAMFILES}"`
       
   121 elif [ "${ProgramFiles}" != "" ] ; then
       
   122   progfiles=`envpath "${ProgramFiles}"`
       
   123 elif [ "${SYSTEMDRIVE}" != "" ] ; then
       
   124   progfiles=`envpath "${SYSTEMDRIVE}/Program Files"`
       
   125 elif [ "${SystemDrive}" != "" ] ; then
       
   126   progfiles=`envpath "${SystemDrive}/Program Files"`
       
   127 else
       
   128   error "No PROGRAMFILES or SYSTEMDRIVE defined in environment"
       
   129 fi
       
   130 
       
   131 # Arch data model
       
   132 if [ "${PROCESSOR_IDENTIFIER}" != "" ] ; then
       
   133   arch=`echo "${PROCESSOR_IDENTIFIER}" | cut -d' ' -f1`
       
   134 else
       
   135   if [ "${MACHTYPE}" != "" ] ; then
       
   136     if [ "`echo ${MACHTYPE} | grep 64`" != "" ] ; then
       
   137       # Assume this is X64, not IA64
       
   138       arch="x64"
       
   139     else
       
   140       arch="x86"
       
   141     fi
       
   142   else
       
   143    arch="`uname -m`"
       
   144   fi
       
   145   PROCESSOR_IDENTIFIER="${arch}"
       
   146   export PROCESSOR_IDENTIFIER
       
   147 fi
       
   148 if [ "${arch}" = "X86" -o \
       
   149      "${arch}" = "386" -o "${arch}" = "i386" -o \
       
   150      "${arch}" = "486" -o "${arch}" = "i486" -o \
       
   151      "${arch}" = "586" -o "${arch}" = "i586" -o \
       
   152      "${arch}" = "686" -o "${arch}" = "i686" -o \
       
   153      "${arch}" = "86" ] ; then
       
   154   arch="x86"
       
   155 fi
       
   156 if [ "${arch}" = "X64"     -o \
       
   157      "${arch}" = "8664"    -o "${arch}" = "i8664"   -o \
       
   158      "${arch}" = "amd64"   -o "${arch}" = "AMD64"   -o \
       
   159      "${arch}" = "EM64T"   -o "${arch}" = "emt64t"  -o \
       
   160      "${arch}" = "intel64" -o "${arch}" = "Intel64" -o \
       
   161      "${arch}" = "64" ] ; then
       
   162   arch="x64"
       
   163   binarch64="\\amd64"
       
   164 fi
       
   165 if [ "${arch}" = "IA64" ] ; then
       
   166   arch="ia64"
       
   167   binarch64="\\ia64"
       
   168 fi
       
   169 if [ "${arch}" != "x86" -a "${arch}" != "x64" -a "${arch}" != "ia64" ] ; then
       
   170  error "No PROCESSOR_IDENTIFIER or MACHTYPE environment variables and uname -m is not helping"
       
   171 fi
       
   172 if [ "${arch}" = "x86" ] ; then
       
   173   arch_data_model=32
       
   174   progfiles32="${progfiles}"
       
   175   progfiles64="${progfiles}"
       
   176 else
       
   177   arch_data_model=64
       
   178   progfiles32="${progfiles}"
       
   179   if [ "${PROGRAMW6432}" != "" ] ; then
       
   180     progfiles64=`envpath "${PROGRAMW6432}"`
       
   181   else
       
   182     progfiles64=`envpath "C:/Program Files"`
       
   183   fi
       
   184 fi
       
   185 
       
   186 # VS2012 (VC11)
       
   187 if [ "${VS110COMNTOOLS}" = "" ] ; then
       
   188   VS110COMNTOOLS="${progfiles32}/Microsoft Visual Studio 11.0/Common7/Tools/"
       
   189   export VS110COMNTOOLS
       
   190 fi
       
   191 vc11Bin32Dir=`envpath "${VS110COMNTOOLS}"`/../../VC/Bin
       
   192 vc11Bin64Dir="${vc11Bin32Dir}"
       
   193 vc11vars32Bat="vcvars32.bat"
       
   194 vc11vars64Bat="vcvars64.bat"
       
   195 
       
   196 # VS2010 (VC10)
       
   197 if [ "${VS100COMNTOOLS}" = "" ] ; then
       
   198   VS100COMNTOOLS="${progfiles32}/Microsoft Visual Studio 10.0/Common7/Tools/"
       
   199   export VS100COMNTOOLS
       
   200 fi
       
   201 vc10Bin32Dir=`envpath "${VS100COMNTOOLS}"`/../../VC/Bin
       
   202 vc10Bin64Dir="${vc10Bin32Dir}${binarch64}"
       
   203 vc10vars32Bat="vcvars32.bat"
       
   204 vc10vars64Bat="vcvars64.bat"
       
   205 
       
   206 # VS2008 (VC9)
       
   207 if [ "${VS90COMNTOOLS}" = "" ] ; then
       
   208   VS90COMNTOOLS="${progfiles32}/Microsoft Visual Studio 9.0/Common7/Tools/"
       
   209   export VS90COMNTOOLS
       
   210 fi
       
   211 vc9Bin32Dir=`envpath "${VS90COMNTOOLS}"`/../../VC/Bin
       
   212 vc9Bin64Dir="${vc9Bin32Dir}"
       
   213 vc9vars32Bat="vcvars32.bat"
       
   214 vc9vars64Bat="vcvars64.bat"
       
   215 
       
   216 # VS2005 (VC8)
       
   217 if [ "${VS80COMNTOOLS}" = "" ] ; then
       
   218   VS80COMNTOOLS="${progfiles32}/Microsoft Visual Studio 8.0/Common7/Tools/"
       
   219   export VS80COMNTOOLS
       
   220 fi
       
   221 vc8Bin32Dir=`envpath "${VS80COMNTOOLS}"`/../../VC/Bin
       
   222 vc8Bin64Dir="${progfiles64}/Microsoft Platform SDK"
       
   223 vc8vars32Bat="vcvars32.bat"
       
   224 vc8vars64Bat="SetEnv.cmd /X64"
       
   225 
       
   226 # VS2003 (VC7)
       
   227 if [ "${VS71COMNTOOLS}" = "" ] ; then
       
   228   VS71COMNTOOLS="${progfiles32}/Microsoft Visual Studio .NET 2003/Common7/Tools/"
       
   229   export VS71COMNTOOLS
       
   230 fi
       
   231 vc7Bin32Dir=`envpath "${VS71COMNTOOLS}"`/../../VC7/Bin
       
   232 vc7Bin64Dir="${progfiles64}/Microsoft Platform SDK"
       
   233 vc7vars32Bat="vcvars32.bat"
       
   234 vc7vars64Bat="SetEnv.cmd /X64"
       
   235 
       
   236 # Force user to select
       
   237 vcSelection=""
       
   238 
       
   239 # Parse options
       
   240 usage="Usage: $0 [-help] [-debug] [-v] [-c] [-s] [-p] [-v11] [-v10] [-v9] [-v8] [-v7] [-32] [-64]"
       
   241 while [ $# -gt 0 ] ; do
       
   242   if [ "$1" = "-help" ] ; then
       
   243     msg "${usage}"
       
   244     msg "  -help    Print out this help message"
       
   245     msg "  -debug   Print out extra env variables to help debug this script"
       
   246     msg "  -v       Verbose output warns about missing directories"
       
   247     msg "  -c       Print out csh style output"
       
   248     msg "  -s       Print out sh style output"
       
   249     msg "  -p       Print out properties style output"
       
   250     msg "  -v11     Use Visual Studio 11 VS2012"
       
   251     msg "  -v10     Use Visual Studio 10 VS2010"
       
   252     msg "  -v9      Use Visual Studio 9 VS2008"
       
   253     msg "  -v8      Use Visual Studio 8 VS2005"
       
   254     msg "  -v7      Use Visual Studio 7 VS2003"
       
   255     msg "  -32      Force 32bit"
       
   256     msg "  -64      Force 64bit"
       
   257     exit 0
       
   258   elif [ "$1" = "-debug" ] ; then
       
   259     debug="true"
       
   260     shift
       
   261   elif [ "$1" = "-v" ] ; then
       
   262     verbose="true"
       
   263     shift
       
   264   elif [ "$1" = "-c" ] ; then
       
   265     shellStyle="csh"
       
   266     shift
       
   267   elif [ "$1" = "-s" ] ; then
       
   268     shellStyle="sh"
       
   269     shift
       
   270   elif [ "$1" = "-p" ] ; then
       
   271     shellStyle="props"
       
   272     shift
       
   273   elif [ "$1" = "-v11" ] ; then
       
   274     vcBin32Dir="${vc11Bin32Dir}"
       
   275     vcBin64Dir="${vc11Bin64Dir}"
       
   276     vcvars32Bat="${vc11vars32Bat}"
       
   277     vcvars64Bat="${vc11vars64Bat}"
       
   278     vcSelection="11"
       
   279     shift
       
   280   elif [ "$1" = "-v10" ] ; then
       
   281     vcBin32Dir="${vc10Bin32Dir}"
       
   282     vcBin64Dir="${vc10Bin64Dir}"
       
   283     vcvars32Bat="${vc10vars32Bat}"
       
   284     vcvars64Bat="${vc10vars64Bat}"
       
   285     vcSelection="10"
       
   286     shift
       
   287   elif [ "$1" = "-v9" ] ; then
       
   288     vcBin32Dir="${vc9Bin32Dir}"
       
   289     vcBin64Dir="${vc9Bin64Dir}"
       
   290     vcvars32Bat="${vc9vars32Bat}"
       
   291     vcvars64Bat="${vc9vars64Bat}"
       
   292     vcSelection="9"
       
   293     shift
       
   294   elif [ "$1" = "-v8" ] ; then
       
   295     vcBin32Dir="${vc8Bin32Dir}"
       
   296     vcBin64Dir="${vc8Bin64Dir}"
       
   297     vcvars32Bat="${vc8vars32Bat}"
       
   298     vcvars64Bat="${vc8vars64Bat}"
       
   299     vcSelection="8"
       
   300     shift
       
   301   elif [ "$1" = "-v7" ] ; then
       
   302     vcBin32Dir="${vc7Bin32Dir}"
       
   303     vcBin64Dir="${vc7Bin64Dir}"
       
   304     vcvars32Bat="${vc7vars32Bat}"
       
   305     vcvars64Bat="${vc7vars64Bat}"
       
   306     vcSelection="7"
       
   307     shift
       
   308   elif [ "$1" = "-32" ] ; then
       
   309     arch_data_model=32
       
   310     shift
       
   311   elif [ "$1" = "-64" ] ; then
       
   312     arch_data_model=64
       
   313     shift
       
   314   else
       
   315     msg "${usage}"
       
   316     error "Unknown option: $1"
       
   317   fi
       
   318 done
       
   319 
       
   320 # Need to pick
       
   321 if [ "${vcSelection}" = "" ] ; then
       
   322   msg "${usage}"
       
   323   error "You must pick the version"
       
   324 fi
       
   325 
       
   326 # Which vcvars bat file to run
       
   327 if [ "${arch_data_model}" = "32" ] ; then
       
   328   vcBinDir="${vcBin32Dir}"
       
   329   vcvarsBat="${vcvars32Bat}"
       
   330 fi
       
   331 if [ "${arch_data_model}" = "64" ] ; then
       
   332   vcBinDir="${vcBin64Dir}"
       
   333   vcvarsBat="${vcvars64Bat}"
       
   334 fi
       
   335 
       
   336 # Do not allow any error returns
       
   337 set -e
       
   338 
       
   339 # Different systems have different awk's
       
   340 if [ -f /usr/bin/nawk ] ; then
       
   341   awk="nawk"
       
   342 elif [ -f /usr/bin/gawk ] ; then
       
   343   awk="gawk"
       
   344 else
       
   345   awk="awk"
       
   346 fi
       
   347 
       
   348 if [ "${verbose}" = "true" ] ; then
       
   349   echo "# Welcome to verbose mode"
       
   350   set -x
       
   351 fi
       
   352 
       
   353 if [ "${debug}" = "true" ] ; then
       
   354   echo "# Welcome to debug mode"
       
   355   set -x
       
   356 fi
       
   357 
       
   358 # Temp file area
       
   359 tmp="/tmp/vsvars.$$"
       
   360 rm -f -r ${tmp}
       
   361 mkdir -p ${tmp}
       
   362 
       
   363 # Check paths
       
   364 checkPaths() # var path sep
       
   365 {
       
   366   set -e
       
   367   sep="$3"
       
   368   checklist="${tmp}/checklist"
       
   369   printf "%s\n" "$2" | \
       
   370     sed -e 's@\\@/@g' | \
       
   371     sed -e 's@//@/@g' | \
       
   372     ${awk} -F"${sep}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}'  \
       
   373       > ${checklist}
       
   374   cat ${checklist} | while read orig; do
       
   375     if [ "${orig}" != "" ] ; then
       
   376       if [ ! -d "${orig}" ] ; then
       
   377         warning "Directory in $1 does not exist: ${orig}"
       
   378       fi
       
   379     fi
       
   380   done
       
   381 }
       
   382 
       
   383 # Remove all duplicate entries
       
   384 removeDeadDups() # string sepIn sepOut
       
   385 {
       
   386   set -e
       
   387   sepIn="$2"
       
   388   sepOut="$3"
       
   389   pathlist="${tmp}/pathlist"
       
   390   printf "%s\n" "$1" | \
       
   391     sed -e 's@\\@/@g' | \
       
   392     sed -e 's@//@/@g' | \
       
   393     ${awk} -F"${sepIn}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}'  \
       
   394       > ${pathlist}
       
   395   upaths="${tmp}/upaths"
       
   396   cat ${pathlist} | while read orig; do
       
   397     p="${orig}"
       
   398     if [ "${fixpath}" != "" ] ; then
       
   399       if [ "${p}" != "" ] ; then
       
   400         if [ -d "${p}" ] ; then
       
   401           short=`${fixpath} "${p}"`
       
   402           if [ "${short}" != "" -a -d "${short}" ] ; then
       
   403             p="${short}"
       
   404           fi
       
   405           echo "${p}" >> ${upaths}
       
   406         fi
       
   407       fi
       
   408     fi
       
   409   done
       
   410   newpaths=""
       
   411   for i in  `cat ${upaths}` ; do
       
   412     # For some reason, \r characters can get into this
       
   413     i=`echo "${i}" | tr -d '\r' | sed -e 's@/$@@'`
       
   414     if [ "${newpaths}" = "" ] ; then
       
   415       newpaths="${i}"
       
   416     else
       
   417       newpaths="${newpaths}${sepOut}${i}"
       
   418     fi
       
   419   done
       
   420   printf "%s\n" "${newpaths}" | \
       
   421     ${awk} -F"${sepOut}" \
       
   422        '{a[$1];printf "%s",$1;for(i=2;i<=NF;i++){if(!($i in a)){a[$i];printf "%s%s",FS,$i;}};printf "\n";}'
       
   423 }
       
   424 
       
   425 # Create bat file to process Visual Studio vcvars*.bat files
       
   426 createBat() # batfile bindir command
       
   427 {
       
   428   bat="$1"
       
   429   bindir="$2"
       
   430   command="$3"
       
   431   stdout="${bat}.stdout"
       
   432   rm -f ${bat} ${stdout}
       
   433   echo "Output from: ${command}" > ${stdout}
       
   434   bdir=`envpath "${bindir}"`
       
   435   cat > ${bat} << EOF  
       
   436 REM Pick the right vcvars bat file
       
   437 REM Empty these out so we only get the additions we want
       
   438 set INCLUDE=
       
   439 set LIB=
       
   440 set LIBPATH=
       
   441 set MSVCDIR=
       
   442 set MSSdk=
       
   443 set Mstools=
       
   444 set DevEnvDir=
       
   445 set VCINSTALLDIR=
       
   446 set VSINSTALLDIR=
       
   447 set WindowsSdkDir=
       
   448 REM Run the vcvars bat file, send all output to stderr
       
   449 call `${fixpath_windows} ${bdir}`\\${command} > `${fixpath_windows} "${stdout}"`
       
   450 REM Echo out env var settings
       
   451 echo VS_VS71COMNTOOLS="%VS71COMNTOOLS%"
       
   452 echo export VS_VS71COMNTOOLS
       
   453 echo VS_VS80COMNTOOLS="%VS80COMNTOOLS%"
       
   454 echo export VS_VS80COMNTOOLS
       
   455 echo VS_VS90COMNTOOLS="%VS90COMNTOOLS%"
       
   456 echo export VS_VS90COMNTOOLS
       
   457 echo VS_VS100COMNTOOLS="%VS100COMNTOOLS%"
       
   458 echo export VS_VS100COMNTOOLS
       
   459 echo VS_VS110COMNTOOLS="%VS110COMNTOOLS%"
       
   460 echo export VS_VS110COMNTOOLS
       
   461 echo VS_VCINSTALLDIR="%VCINSTALLDIR%"
       
   462 echo export VS_VCINSTALLDIR
       
   463 echo VS_VSINSTALLDIR="%VSINSTALLDIR%"
       
   464 echo export VS_VSINSTALLDIR
       
   465 echo VS_DEVENVDIR="%DevEnvDir%"
       
   466 echo export VS_DEVENVDIR
       
   467 echo VS_MSVCDIR="%MSVCDIR%"
       
   468 echo export VS_MSVCDIR
       
   469 echo VS_MSSDK="%MSSdk%"
       
   470 echo export VS_MSSDK
       
   471 echo VS_MSTOOLS="%Mstools%"
       
   472 echo export VS_MSTOOLS
       
   473 echo VS_WINDOWSSDKDIR="%WindowsSdkDir%"
       
   474 echo export VS_WINDOWSSDKDIR
       
   475 echo VS_INCLUDE="%INCLUDE%"
       
   476 echo export VS_INCLUDE
       
   477 echo VS_LIB="%LIB%"
       
   478 echo export VS_LIB
       
   479 echo VS_LIBPATH="%LIBPATH%"
       
   480 echo export VS_LIBPATH
       
   481 echo VS_WPATH="%PATH%"
       
   482 echo export VS_WPATH
       
   483 EOF
       
   484   chmod a+x ${bat}
       
   485 }
       
   486 
       
   487 # Create env file
       
   488 createEnv() # batfile envfile
       
   489 {
       
   490   rm -f ${1}.stdout ${1}.temp1 ${1}.temp2
       
   491   batfile=`${fixpath} ${1}`
       
   492   cmd.exe -Q -C < "$batfile" 1> ${1}.temp1 2> ${1}.temp2
       
   493   cat ${1}.temp1 | \
       
   494     sed -e 's@^Microsoft.*@@' \
       
   495         -e 's@^.*Copyright.*@@' \
       
   496         -e 's@^.*>REM.*@@' \
       
   497         -e 's@^.*>set.*@@' \
       
   498         -e 's@^.*>echo.*@@' \
       
   499         -e 's@^.*>call.*@@' \
       
   500         -e 's@^.*>$@@' \
       
   501         -e 's@\\@/@g' | \
       
   502     sed -e 's@//@/@g' > $2
       
   503   if [ -f "${1}.stdout" ] ; then
       
   504     cat ${1}.stdout 1>&2
       
   505   fi
       
   506   chmod a+x $2
       
   507 }
       
   508 
       
   509 printEnv() # name pname vsname val
       
   510 {
       
   511   name="$1"
       
   512   pname="$2"
       
   513   vsname="$3"
       
   514   val="$4"
       
   515   if [ "${val}" != "" ] ; then
       
   516     if [ "${shellStyle}" = "csh" ] ; then
       
   517       if [ "${debug}" = "true" ] ; then
       
   518         echo "setenv ${vsname} \"${val}\";"
       
   519       fi
       
   520       echo "setenv ${name} \"${val}\";"
       
   521     elif [ "${shellStyle}" = "sh" ] ; then
       
   522       if [ "${debug}" = "true" ] ; then
       
   523         echo "${vsname}=\"${val}\";"
       
   524         echo "export ${vsname};"
       
   525       fi
       
   526       echo "${name}=\"${val}\";"
       
   527       echo "export ${name};"
       
   528     elif [ "${shellStyle}" = "props" ] ; then
       
   529       echo "vs.${pname}=${val}"
       
   530     fi
       
   531   fi
       
   532 }
       
   533 
       
   534 #############################################################################
       
   535 
       
   536 # Get Visual Studio settings
       
   537 if [ "${fixpath}" != "" ] ; then
       
   538 
       
   539   # Create bat file to run
       
   540   batfile="${tmp}/vs-to-env.bat"
       
   541   if [ ! -d "${vcBinDir}" ] ; then
       
   542     error "Does not exist: ${vcBinDir}"
       
   543   elif [ "${vcvarsBat}" = "" ] ; then
       
   544     error "No vcvars script: ${vcvarsBat}"
       
   545   else
       
   546     createBat "${batfile}" "${vcBinDir}" "${vcvarsBat}"
       
   547   fi
       
   548 
       
   549   # Run bat file to create environment variable settings
       
   550   envfile="${tmp}/env.sh"
       
   551   createEnv "${batfile}" "${envfile}"
       
   552 
       
   553   # Read in the VS_* settings
       
   554   . ${envfile}
       
   555 
       
   556   # Derive unix style path, save old, and define new (remove dups)
       
   557   VS_UPATH=`${fixpath_path} "${VS_WPATH}"`
       
   558   export VS_UPATH
       
   559   VS_OPATH=`printf "%s" "${PATH}" | sed -e 's@\\\\@/@g'`
       
   560   export VS_OPATH
       
   561   VS_PATH=`removeDeadDups "${VS_UPATH}${pathsepIn}${VS_OPATH}" "${pathsepIn}" "${pathsepOut}"`
       
   562   export VS_PATH
       
   563 
       
   564 fi
       
   565 
       
   566 # Adjustments due to differences in vcvars*bat files
       
   567 if [ "${VS_MSVCDIR}" = "" ] ; then
       
   568   VS_MSVCDIR="${VS_VCINSTALLDIR}"
       
   569 fi
       
   570 if [ "${VS_DEVENVDIR}" = "" ] ; then
       
   571   VS_DEVENVDIR="${VS_VSINSTALLDIR}"
       
   572 fi
       
   573 
       
   574 # Print env settings
       
   575 #        env           vs.prop       vs env           value
       
   576 #        -------       -------       ----------       -----
       
   577 printEnv INCLUDE       include       VS_INCLUDE       "${VS_INCLUDE}"
       
   578 printEnv LIB           lib           VS_LIB           "${VS_LIB}"
       
   579 printEnv LIBPATH       libpath       VS_LIBPATH       "${VS_LIBPATH}"
       
   580 if [ "${debug}" = "true" ] ; then
       
   581   printEnv UPATH         upath         VS_UPATH         "${VS_UPATH}"
       
   582   printEnv WPATH         wpath         VS_WPATH         "${VS_WPATH}"
       
   583   printEnv OPATH         opath         VS_OPATH         "${VS_OPATH}"
       
   584 fi
       
   585 printEnv PATH          path          VS_PATH          "${VS_PATH}"
       
   586 printEnv VCINSTALLDIR  vcinstalldir  VS_VCINSTALLDIR  "${VS_VCINSTALLDIR}"
       
   587 printEnv VSINSTALLDIR  vsinstalldir  VS_VSINSTALLDIR  "${VS_VSINSTALLDIR}"
       
   588 printEnv MSVCDIR       msvcdir       VS_MSVCDIR       "${VS_MSVCDIR}"
       
   589 printEnv MSSDK         mssdk         VS_MSSDK         "${VS_MSSDK}"
       
   590 printEnv MSTOOLS       mstools       VS_MSTOOLS       "${VS_MSTOOLS}"
       
   591 printEnv DEVENVDIR     devenvdir     VS_DEVENVDIR     "${VS_DEVENVDIR}"
       
   592 printEnv WINDOWSSDKDIR windowssdkdir VS_WINDOWSSDKDIR "${VS_WINDOWSSDKDIR}"
       
   593 if [ "${vcSelection}" = "11" ] ; then
       
   594   printEnv VS110COMNTOOLS vs110comntools VS_VS110COMNTOOLS "${VS_VS110COMNTOOLS}"
       
   595 elif [ "${vcSelection}" = "10" ] ; then
       
   596   printEnv VS100COMNTOOLS vs100comntools VS_VS100COMNTOOLS "${VS_VS100COMNTOOLS}"
       
   597 elif [ "${vcSelection}" = "9" ] ; then
       
   598   printEnv VS90COMNTOOLS vs90comntools VS_VS90COMNTOOLS "${VS_VS90COMNTOOLS}"
       
   599 elif [ "${vcSelection}" = "7" ] ; then
       
   600   printEnv VS71COMNTOOLS vs71comntools VS_VS71COMNTOOLS "${VS_VS71COMNTOOLS}"
       
   601 elif [ "${vcSelection}" = "8" ] ; then
       
   602   printEnv VS80COMNTOOLS vs80comntools VS_VS80COMNTOOLS "${VS_VS80COMNTOOLS}"
       
   603 fi
       
   604 
       
   605 # Check final settings
       
   606 if [ "${verbose}" = "true" ] ; then
       
   607   checkPaths "Windows PATH" "${VS_WPATH}" ";"
       
   608   checkPaths LIB "${VS_LIB}" ";"
       
   609   checkPaths INCLUDE "${VS_INCLUDE}" ";"
       
   610   checkPaths PATH "${VS_PATH}" "${pathsepIn}"
       
   611 fi
       
   612 
       
   613 # Remove all temp files
       
   614 if [ "${debug}" != "true" ] ; then
       
   615   rm -f -r ${tmp}
       
   616 fi
       
   617 
       
   618 exit 0
       
   619