configure.vbs revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
0N/A'
2362N/A' The purpose of this script is to check for all external tools, headers, and
0N/A' libraries VBox OSE depends on.
0N/A'
0N/A' The script generates the build configuration file 'AutoConfig.kmk' and the
0N/A' environment setup script 'env.bat'. A log of what has been done is
2362N/A' written to 'configure.log'.
0N/A'
2362N/A
0N/A'
0N/A' Copyright (C) 2006 InnoTek Systemberatung GmbH
0N/A'
0N/A' This file is part of VirtualBox Open Source Edition (OSE), as
0N/A' available from http://www.virtualbox.org. This file is free software;
0N/A' you can redistribute it and/or modify it under the terms of the GNU
0N/A' General Public License as published by the Free Software Foundation,
0N/A' in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
0N/A' distribution. VirtualBox OSE is distributed in the hope that it will
0N/A' be useful, but WITHOUT ANY WARRANTY of any kind.
0N/A'
2362N/A' If you received this file as part of a commercial VirtualBox
2362N/A' distribution, then only the terms of your commercial VirtualBox
2362N/A' license agreement apply instead of the previous paragraph.
0N/A'
0N/A
0N/A
0N/A'*****************************************************************************
0N/A'* Global Variables *
1652N/A'*****************************************************************************
0N/Adim g_strPath, g_strEnvFile, g_strLogFile, g_strCfgFile, g_strShellOutput
0N/Ag_strPath = Left(Wscript.ScriptFullName, Len(Wscript.ScriptFullName) - Len("\configure.vbs"))
0N/Ag_strEnvFile = g_strPath & "\env.bat"
0N/Ag_strCfgFile = g_strPath & "\AutoConfig.kmk"
0N/Ag_strLogFile = g_strPath & "\configure.log"
0N/A'g_strTmpFile = g_strPath & "\configure.tmp"
1652N/A
0N/Adim g_objShell, g_objFileSys
0N/ASet g_objShell = WScript.CreateObject("WScript.Shell")
0N/ASet g_objFileSys = WScript.CreateObject("Scripting.FileSystemObject")
0N/A
0N/Adim g_strPathkBuild, g_strPathkBuildBin, g_strPathDev, g_strPathVCC, g_strPathPSDK, g_strSubOutput
0N/Ag_strPathkBuild = ""
0N/Ag_strPathDev = ""
0N/Ag_strPathVCC = ""
0N/Ag_strPathPSDK = ""
0N/A
0N/Adim g_blnDisableCOM, g_strDisableCOM
0N/Ag_blnDisableCOM = False
0N/Ag_strDisableCOM = ""
0N/A
0N/A' The internal mode is primarily for skipping the xerces and xalan monsters.
0N/Adim g_blnInternalMode
0N/Ag_blnInternalMode = False
0N/A
0N/A
0N/A
0N/A''
0N/A' Converts to unix slashes
0N/Afunction UnixSlashes(str)
0N/A UnixSlashes = replace(str, "\", "/")
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Converts to dos slashes
0N/Afunction DosSlashes(str)
0N/A DosSlashes = replace(str, "/", "\")
0N/Aend function
1652N/A
1652N/A
0N/A''
0N/A' Read a file (typically the tmp file) into a string.
0N/Afunction FileToString(strFilename)
0N/A const ForReading = 1, TristateFalse = 0
0N/A dim objLogFile, str
0N/A
0N/A set objFile = g_objFileSys.OpenTextFile(DosSlashes(strFilename), ForReading, False, TristateFalse)
0N/A str = objFile.ReadAll()
0N/A objFile.Close()
0N/A
0N/A FileToString = str
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Deletes a file
0N/Asub FileDelete(strFilename)
0N/A if g_objFileSys.FileExists(DosSlashes(strFilename)) then
0N/A g_objFileSys.DeleteFile(DosSlashes(strFilename))
0N/A end if
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Appends a line to an ascii file.
0N/Asub FileAppendLine(strFilename, str)
0N/A const ForAppending = 8, TristateFalse = 0
0N/A dim objFile
0N/A
0N/A set objFile = g_objFileSys.OpenTextFile(DosSlashes(strFilename), ForAppending, True, TristateFalse)
0N/A objFile.WriteLine(str)
0N/A objFile.Close()
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Checks if the file exists.
0N/Afunction FileExists(strFilename)
0N/A FileExists = g_objFileSys.FileExists(DosSlashes(strFilename))
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Checks if the directory exists.
0N/Afunction DirExists(strDirectory)
0N/A DirExists = g_objFileSys.FolderExists(DosSlashes(strDirectory))
0N/Aend function
0N/A
0N/A''
0N/A' Gets a value from the registry. Returns "" if string wasn't found / valid.
0N/Afunction RegGetString(strName)
0N/A RegGetString = ""
0N/A On Error Resume Next
0N/A RegGetString = g_objShell.RegRead(strName)
0N/Aend function
0N/A
0N/A''
0N/A' Returns an array of subkey strings.
0N/Afunction RegEnumSubKeys(strRoot, strKeyPath)
0N/A const HKEY_LOCAL_MACHINE = &H80000002
0N/A const HKEY_CURRENT_USER = &H80000001
0N/A dim objReg, iRoot
0N/A set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
0N/A
0N/A select case strRoot
0N/A case "HKLM"
0N/A iRoot = HKEY_LOCAL_MACHINE
0N/A case "HKCU"
0N/A iRoot = HKEY_CURRENT_USER
0N/A case else
0N/A MsgFatal "RegEnumSubKeys: Unknown root: " & strRoot
0N/A end select
0N/A
0N/A On Error Resume Next
0N/A rc = objReg.EnumKey(iRoot, strKeyPath, arrSubKeys)
0N/A if rc = 0 then
0N/A RegEnumSubKeys = arrSubKeys
0N/A else
0N/A RegEnumSubKeys = Array()
0N/A end if
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Gets the commandline used to invoke the script.
0N/Afunction GetCommandline()
0N/A dim str, i
0N/A
0N/A '' @todo find an api for querying it instead of reconstructing it like this...
0N/A GetCommandline = "cscript configure.vbs"
0N/A for i = 1 to WScript.Arguments.Count
0N/A str = WScript.Arguments.Item(i - 1)
0N/A if str = "" then
0N/A str = """"""
0N/A elseif (InStr(1, str, " ")) then
0N/A str = """" & str & """"
0N/A end if
0N/A GetCommandline = GetCommandline & " " & str
0N/A next
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Gets an environment variable.
0N/Afunction EnvGet(strName)
0N/A EnvGet = g_objShell.Environment("PROCESS")(strName)
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Sets an environment variable.
0N/Asub EnvSet(strName, strValue)
0N/A g_objShell.Environment("PROCESS")(strName) = strValue
0N/A LogPrint "EnvSet: " & strName & "=" & strValue
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Appends a string to an environment variable
0N/Asub EnvAppend(strName, strValue)
0N/A dim str
0N/A str = g_objShell.Environment("PROCESS")(strName)
0N/A g_objShell.Environment("PROCESS")(strName) = str & strValue
0N/A LogPrint "EnvAppend: " & strName & "=" & str & strValue
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Prepends a string to an environment variable
0N/Asub EnvPrepend(strName, strValue)
0N/A dim str
0N/A str = g_objShell.Environment("PROCESS")(strName)
0N/A g_objShell.Environment("PROCESS")(strName) = strValue & str
0N/A LogPrint "EnvPrepend: " & strName & "=" & strValue & str
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Get the path of the parent directory. Returns root if root was specified.
0N/A' Expects abs path.
0N/Afunction PathParent(str)
0N/A PathParent = g_objFileSys.GetParentFolderName(DosSlashes(str))
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Strips the filename from at path.
0N/Afunction PathStripFilename(str)
0N/A PathStripFilename = g_objFileSys.GetParentFolderName(DosSlashes(str))
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Get the abs path, use the short version if necessary.
0N/Afunction PathAbs(str)
0N/A PathAbs = g_objFileSys.GetAbsolutePathName(DosSlashes(str))
0N/A if (InStr(1, PathAbs, " ") > 0) _
0N/A Or (InStr(1, PathAbs, "&") > 0) _
0N/A Or (InStr(1, PathAbs, "$") > 0) _
0N/A then
0N/A if FileExists(PathAbs) then
0N/A dim objFile
0N/A set objFile = g_objFileSys.GetFile(PathAbs)
0N/A PathAbs = objFile.ShortPath
0N/A elseif DirExists(PathAbs) then
0N/A dim objFolder
0N/A set objFolder = g_objFileSys.GetFolder(PathAbs)
0N/A PathAbs = objFolder.ShortPath
0N/A else
0N/A ' ignore non-existing paths.
0N/A end if
0N/A end if
0N/A
0N/A
0N/A if (FileExists(PathAbs) Or DirExists(PathAbs)) _
0N/A And ( (InStr(1, PathAbs, " ") > 0) _
0N/A Or (InStr(1, PathAbs, "&") > 0) _
0N/A Or (InStr(1, PathAbs, "$") > 0)) _
0N/A then
0N/A MsgFatal "PathAbs(" & str & ") attempted to return filename with problematic " _
0N/A & "characters in it (" & PathAbs & "). The tool/sdk referenced will probably " _
0N/A & "need to be copied or reinstalled to a location without 'spaces', '$', ';' " _
0N/A & "or '&' in the path name. (Unless it's a problem with this script of course...)"
0N/A end if
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Executes a command in the shell catching output in g_strShellOutput
0N/Afunction Shell(strCommand, blnBoth)
0N/A dim strShell, strCmdline, objExec, str
0N/A
0N/A strShell = g_objShell.ExpandEnvironmentStrings("%ComSpec%")
0N/A if blnBoth = true then
0N/A strCmdline = strShell & " /c " & strCommand & " 2>&1"
0N/A else
0N/A strCmdline = strShell & " /c " & strCommand & " 2>nul"
0N/A end if
0N/A
0N/A LogPrint "# Shell: " & strCmdline
0N/A Set objExec = g_objShell.Exec(strCmdLine)
0N/A g_strShellOutput = objExec.StdOut.ReadAll()
0N/A objExec.StdErr.ReadAll()
0N/A do while objExec.Status = 0
0N/A Wscript.Sleep 20
0N/A g_strShellOutput = g_strShellOutput & objExec.StdOut.ReadAll()
0N/A objExec.StdErr.ReadAll()
0N/A loop
0N/A
0N/A LogPrint "# Status: " & objExec.ExitCode
0N/A LogPrint "# Start of Output"
0N/A LogPrint g_strShellOutput
0N/A LogPrint "# End of Output"
0N/A
0N/A Shell = objExec.ExitCode
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Try find the specified file in the path.
0N/Afunction Which(strFile)
0N/A dim strPath, iStart, iEnd, str
0N/A
0N/A ' the path
0N/A strPath = EnvGet("Path")
0N/A iStart = 1
0N/A do while iStart <= Len(strPath)
0N/A iEnd = InStr(iStart, strPath, ";")
0N/A if iEnd <= 0 then iEnd = Len(strPath) + 1
0N/A if iEnd > iStart then
0N/A str = Mid(strPath, iStart, iEnd - iStart) & "/" & strFile
0N/A if FileExists(str) then
0N/A Which = str
0N/A exit function
0N/A end if
0N/A end if
0N/A iStart = iEnd + 1
0N/A loop
0N/A
0N/A ' registry or somewhere?
0N/A
0N/A Which = ""
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Append text to the log file and echo it to stdout
0N/Asub Print(str)
0N/A LogPrint str
0N/A Wscript.Echo str
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Prints a test header
0N/Asub PrintHdr(strTest)
0N/A LogPrint "***** Checking for " & strTest & " *****"
0N/A Wscript.Echo "Checking for " & StrTest & "..."
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Prints a success message
0N/Asub PrintResult(strTest, strResult)
0N/A LogPrint "** " & strTest & ": " & strResult
0N/A Wscript.Echo " Found "& strTest & ": " & strResult
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Warning message.
0N/Asub MsgWarning(strMsg)
0N/A Print "warning: " & strMsg
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Fatal error.
0N/Asub MsgFatal(strMsg)
0N/A Print "fatal error: " & strMsg
0N/A Wscript.Quit
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Error message, fatal unless flag to ignore errors is given.
0N/Asub MsgError(strMsg)
0N/A Print "error: " & strMsg
0N/A if g_blnInternalMode = False then
0N/A Wscript.Quit
0N/A end if
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Write a log header with some basic info.
0N/Asub LogInit
0N/A FileDelete g_strLogFile
0N/A LogPrint "# Log file generated by " & Wscript.ScriptFullName
0N/A for i = 1 to WScript.Arguments.Count
0N/A LogPrint "# Arg #" & i & ": " & WScript.Arguments.Item(i - 1)
0N/A next
0N/A if Wscript.Arguments.Count = 0 then
0N/A LogPrint "# No arguments given"
0N/A end if
0N/A LogPrint "# Reconstructed command line: " & GetCommandline()
0N/A
0N/A ' some Wscript stuff
0N/A LogPrint "# Wscript properties:"
0N/A LogPrint "# ScriptName: " & Wscript.ScriptName
0N/A LogPrint "# Version: " & Wscript.Version
0N/A LogPrint "# Build: " & Wscript.BuildVersion
0N/A LogPrint "# Name: " & Wscript.Name
0N/A LogPrint "# Full Name: " & Wscript.FullName
0N/A LogPrint "# Path: " & Wscript.Path
0N/A LogPrint "#"
0N/A
0N/A
0N/A ' the environment
0N/A LogPrint "# Environment:"
0N/A dim objEnv
0N/A for each strVar in g_objShell.Environment("PROCESS")
0N/A LogPrint "# " & strVar
0N/A next
0N/A LogPrint "#"
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Append text to the log file.
0N/Asub LogPrint(str)
0N/A FileAppendLine g_strLogFile, str
0N/A 'Wscript.Echo "dbg: " & str
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Checks if the file exists and logs failures.
0N/Afunction LogFileExists(strPath, strFilename)
0N/A LogFileExists = FileExists(strPath & "/" & strFilename)
0N/A if LogFileExists = False then
0N/A LogPrint "Testing '" & strPath & "': " & strFilename & " not found"
0N/A end if
0N/A
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Finds the first file matching the pattern.
0N/A' If no file is found, log the failure.
0N/Afunction LogFindFile(strPath, strPattern)
0N/A dim str
0N/A
0N/A '
0N/A ' Yes, there are some facy database kinda interface to the filesystem
0N/A ' however, breaking down the path and constructing a usable query is
0N/A ' too much hassle. So, we'll do it the unix way...
0N/A '
0N/A if Shell("dir /B """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True) = 0 _
0N/A And InStr(1, g_strShellOutput, Chr(13)) > 1 _
0N/A then
0N/A ' return the first word.
0N/A LogFindFile = Left(g_strShellOutput, InStr(1, g_strShellOutput, Chr(13)) - 1)
0N/A else
0N/A LogPrint "Testing '" & strPath & "': " & strPattern & " not found"
0N/A LogFindFile = ""
0N/A end if
0N/Aend function
0N/A
0N/A
0N/A''
0N/A' Initializes the config file.
0N/Asub CfgInit
0N/A FileDelete g_strCfgFile
0N/A CfgPrint "# -*- Makefile -*-"
0N/A CfgPrint "#"
0N/A CfgPrint "# Build configuration generated by " & GetCommandline()
0N/A CfgPrint "#"
0N/A if g_blnInternalMode = False then
0N/A CfgPrint "VBOX_OSE := 1"
0N/A end if
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Prints a string to the config file.
0N/Asub CfgPrint(str)
0N/A FileAppendLine g_strCfgFile, str
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Initializes the environment batch script.
0N/Asub EnvInit
0N/A FileDelete g_strEnvFile
0N/A EnvPrint "@echo off"
0N/A EnvPrint "rem"
0N/A EnvPrint "rem Environment setup script generated by " & GetCommandline()
0N/A EnvPrint "rem"
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' Prints a string to the environment batch script.
0N/Asub EnvPrint(str)
0N/A FileAppendLine g_strEnvFile, str
0N/Aend sub
0N/A
0N/A
0N/A''
0N/A' No COM
0N/Asub DisableCOM(strReason)
0N/A if g_blnDisableCOM = False then
0N/A LogPrint "Disabled COM components: " & strReason
0N/A g_blnDisableCOM = True
g_strDisableCOM = strReason
CfgPrint "VBOX_WITH_MAIN="
CfgPrint "VBOX_WITH_QTGUI="
CfgPrint "VBOX_WITH_VBOXSDL="
CfgPrint "VBOX_WITH_DEBUGGER_GUI="
CfgPrint "VBOX_WITHOUT_COM=1"
end if
end sub
''
' Checks for kBuild - very simple :)
sub CheckForkBuild(strOptkBuild)
PrintHdr "kBuild"
'
' Check if there is a 'kmk' in the path somewhere without
' any PATH_KBUILD* stuff around.
'
blnNeedEnvVars = True
g_strPathkBuild = strOptkBuild
g_strPathkBuildBin = ""
if (g_strPathkBuild = "") _
And (EnvGet("PATH_KBUILD") = "") _
And (EnvGet("PATH_KBUILD_BIN") = "") _
And (Shell("kmk.exe --version", True) = 0) _
And (InStr(1,g_strShellOutput, "kBuild Make 0.1") > 0) _
And (InStr(1,g_strShellOutput, "PATH_KBUILD") > 0) _
And (InStr(1,g_strShellOutput, "PATH_KBUILD_BIN") > 0) then
'' @todo Need to parse out the PATH_KBUILD and PATH_KBUILD_BIN values to complete the other tests.
'blnNeedEnvVars = False
MsgWarning "You've installed kBuild it seems. configure.vbs hasn't been updated to " _
& "deal with that yet and will use the one it ships with. Sorry."
end if
'
' Check for the PATH_KBUILD env.var. and fall back on root/kBuild otherwise.
'
if g_strPathkBuild = "" then
g_strPathkBuild = EnvGet("PATH_KBUILD")
if (g_strPathkBuild <> "") and (FileExists(g_strPathkBuild & "/footer.kmk") = False) then
MsgWarning "Ignoring incorrect kBuild path (PATH_KBUILD=" & g_strPathkBuild & ")"
g_strPathkBuild = ""
end if
if g_strPathkBuild = "" then
g_strPathkBuild = g_strPath & "/kBuild"
end if
end if
g_strPathkBuild = UnixSlashes(PathAbs(g_strPathkBuild))
'
' Determin the location of the kBuild binaries.
'
if g_strPathkBuildBin = "" then
dim str2
if EnvGet("PROCESSOR_ARCHITECTURE") = "x86" then
g_strPathkBuildBin = g_strPathkBuild & "/bin/win.x86"
else ' boldly assumes there is only x86 and amd64.
g_strPathkBuildBin = g_strPathkBuild & "/bin/win.amd64"
if FileExists(g_strPathkBuild & "/kmk.exe") = False then
g_strPathkBuildBin = g_strPathkBuild & "/bin/win.x86"
end if
end if
if FileExists(g_strPathkBuild & "/kmk.exe") = False then
g_strPathkBuildBin = g_strPathkBuild & "/bin/win.x86"
end if
end if
'
' Perform basic validations of the kBuild installation.
'
if (FileExists(g_strPathkBuild & "/footer.kmk") = False) _
Or (FileExists(g_strPathkBuild & "/header.kmk") = False) _
Or (FileExists(g_strPathkBuild & "/rules.kmk") = False) then
MsgFatal "Can't find valid kBuild at '" & g_strPathkBuild & "'. Either there is an " _
& "incorrect PATH_KBUILD in the environment or the checkout didn't succeed."
exit sub
end if
if (FileExists(g_strPathkBuildBin & "/kmk.exe") = False) _
Or (FileExists(g_strPathkBuildBin & "/kmk_ash.exe") = False) then
MsgFatal "Can't find valid kBuild binaries at '" & g_strPathkBuildBin & "'. Either there is an " _
& "incorrect PATH_KBUILD in the environment or the checkout didn't succeed."
exit sub
end if
if (Shell(DosSlashes(g_strPathkBuildBin & "/kmk.exe") & " --version", True) <> 0) Then
MsgFatal "Can't execute '" & g_strPathkBuildBin & "/kmk.exe --version'. check configure.log for the out."
exit sub
end if
'
' Check for env.vars that kBuild uses.
'
str = EnvGet("BUILD_TYPE")
if (str <> "") _
And (InStr(1, "|release|debug|profile|kprofile", str) <= 0) then
EnvPrint "set BUILD_TYPE=release"
EnvSet "BUILD_TYPE", "release"
MsgWarning "Found unknown BUILD_TYPE value '" & str &"' in your environment. Setting it to 'release'."
end if
str = EnvGet("BUILD_TARGET")
if (str <> "") _
And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
EnvPrint "set BUILD_TARGET=win"
EnvSet "BUILD_TARGET", "win"
MsgWarning "Found unknown BUILD_TARGET value '" & str &"' in your environment. Setting it to 'win32'."
end if
str = EnvGet("BUILD_TARGET_ARCH")
if (str <> "") _
And (InStr(1, "x86|amd64", str) <= 0) then
EnvPrint "set BUILD_TARGET_ARCH=x86"
EnvSet "BUILD_TARGET_ARCH", "x86"
MsgWarning "Found unknown BUILD_TARGET_ARCH value '" & str &"' in your environment. Setting it to 'x86'."
end if
str = EnvGet("BUILD_TARGET_CPU")
' perhaps a bit pedantic this since this isn't clearly define nor used much...
if (str <> "") _
And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then
EnvPrint "set BUILD_TARGET_CPU=i386"
EnvSet "BUILD_TARGET_CPU", "i386"
MsgWarning "Found unknown BUILD_TARGET_CPU value '" & str &"' in your environment. Setting it to 'i386'."
end if
str = EnvGet("BUILD_PLATFORM")
if (str <> "") _
And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
EnvPrint "set BUILD_PLATFORM=win"
EnvSet "BUILD_PLATFORM", "win"
MsgWarning "Found unknown BUILD_PLATFORM value '" & str &"' in your environment. Setting it to 'win32'."
end if
str = EnvGet("BUILD_PLATFORM_ARCH")
if (str <> "") _
And (InStr(1, "x86|amd64", str) <= 0) then
EnvPrint "set BUILD_PLATFORM_ARCH=x86"
EnvSet "BUILD_PLATFORM_ARCH", "x86"
MsgWarning "Found unknown BUILD_PLATFORM_ARCH value '" & str &"' in your environment. Setting it to 'x86'."
end if
str = EnvGet("BUILD_PLATFORM_CPU")
' perhaps a bit pedantic this since this isn't clearly define nor used much...
if (str <> "") _
And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then
EnvPrint "set BUILD_PLATFORM_CPU=i386"
EnvSet "BUILD_PLATFORM_CPU", "i386"
MsgWarning "Found unknown BUILD_PLATFORM_CPU value '" & str &"' in your environment. Setting it to 'i386'."
end if
'
' If PATH_DEV is set, check that it's pointing to something useful.
'
str = EnvGet("PATH_DEV")
g_strPathDev = str
if (str <> "") _
And False then '' @todo add some proper tests here.
strNew = UnixSlashes(g_strPath & "/tools")
EnvPrint "set PATH_DEV=" & strNew
EnvSet "PATH_DEV", strNew
MsgWarning "Found PATH_DEV='" & str &"' in your environment. Setting it to '" & strNew & "'."
g_strPathDev = strNew
end if
if g_strPathDev = "" then g_strPathDev = UnixSlashes(g_strPath & "/tools")
'
' Write PATH_KBUILD to the environment script if necessary.
'
if blnNeedEnvVars = True then
EnvPrint "set PATH_KBUILD=" & g_strPathkBuild
EnvSet "PATH_KBUILD", g_strPathkBuild
EnvPrint "set PATH=" & g_strPathkBuildBin & ";%PATH%"
EnvPrepend "PATH", g_strPathkBuildBin & ";"
end if
PrintResult "kBuild", g_strPathkBuild
PrintResult "kBuild binaries", g_strPathkBuildBin
end sub
''
' Checks for Visual C++ version 7 or 8.
sub CheckForVisualCPP(strOptVC, strOptVCCommon, blnOptVCExpressEdition)
dim strPathVC, strPathVCCommon, str, str2, blnNeedMsPDB
PrintHdr "Visual C++"
'
' Try find it...
'
strPathVC = ""
strPathVCCommon = ""
if (strPathVC = "") And (strOptVC <> "") then
if CheckForVisualCPPSub(strOptVC, strOptVCCommon, blnOptVCExpressEdition) then
strPathVC = strOptVC
strPathVCCommon = strOptVCCommon
end if
end if
if strPathVC = "" Then
strPathVC = g_strPathDev & "/win.x86/vcc/v8"
if CheckForVisualCPPSub(strPathVC, "", blnOptVCExpressEdition) = False then
strPathVC = g_strPathDev & "/win.x86/vcc/v7"
if CheckForVisualCPPSub(strPathVC, "", blnOptVCExpressEdition) = False then
strPathVC = ""
end if
end if
end if
if (strPathVC = "") _
And (Shell("cl.exe", True) = 0) then
str = Which("cl.exe")
if FileExists(PathStripFilename(strClExe) & "/build.exe") then
' don't know how to deal with this cl.
Warning "Ignoring DDK cl.exe (" & str & ")."
else
strPathVC = PathParent(PathStripFilename(str))
strPathVCCommon = PathParent(strPathVC) & "/Common7"
end if
end if
if strPathVC = "" then
str = RegGetString("HKLM\SOFTWARE\Microsoft\VisualStudio\8.0\Setup\VS\ProductDir")
str2 = RegGetString("HKLM\SOFTWARE\Microsoft\VisualStudio\8.0\Setup\VS\EnvironmentDirectory")
if str <> "" And str2 <> "" Then
str = str & "VC"
str2 = PathParent(str2)
if CheckForVisualCPPSub(str, str2, blnOptVCExpressEdition) then
strPathVC = str
strPathVCCommon = str2
end if
end if
end if
if strPathVC = "" then
'' @todo check what this really looks like on 7.1
str = RegGetString("HKLM\SOFTWARE\Microsoft\VisualStudio\7.1\Setup\VS\ProductDir")
str2 = RegGetString("HKLM\SOFTWARE\Microsoft\VisualStudio\7.1\Setup\VS\EnvironmentDirectory")
if str <> "" And str2 <> "" Then
str = str & "VC7"
str2 = PathParent(str2)
if CheckForVisualCPPSub(str, str2, blnOptVCExpressEdition) then
strPathVC = str
strPathVCCommon = str2
end if
end if
end if
if strPathVC = "" then
str = RegGetString("HKLM\SOFTWARE\Microsoft\VisualStudio\7.0\Setup\VS\ProductDir")
str2 = RegGetString("HKLM\SOFTWARE\Microsoft\VisualStudio\7.0\Setup\VS\EnvironmentDirectory")
if str <> "" And str2 <> "" Then
str = str & "VC7"
str2 = PathParent(str2)
if CheckForVisualCPPSub(str, str2, blnOptVCExpressEdition) then
strPathVC = str
strPathVCCommon = str2
end if
end if
end if
if strPathVC = "" then
str = RegGetString("HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VC7\8.0")
if str <> "" then
str2 = PathParent(str) & "/Common7"
if CheckForVisualCPPSub(str, str2, blnOptVCExpressEdition) then
strPathVC = str
strPathVCCommon = str2
end if
end if
end if
' finally check for the express edition.
if strPathVC = "" then
str = RegGetString("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Visual C++ 2005 Express Edition - ENU\InstallLocation")
if str <> "" then
str2 = str & "Common7"
str = str & "VC/"
if CheckForVisualCPPSub(str, str2, blnOptVCExpressEdition) then
strPathVC = str
strPathVCCommon = str2
end if
end if
end if
if strPathVC = "" then
MsgError "Cannot find cl.exe (Visual C++) anywhere on your system. Check the build requirements."
exit sub
end if
'
' Clean up the path and determin the VC directory.
'
strPathVC = UnixSlashes(PathAbs(strPathVC))
g_strPathVCC = strPathVC
'
' Check the version.
' We'll have to make sure mspdbXX.dll is somewhere in the PATH.
'
if (strPathVCCommon <> "") Then
EnvAppend "PATH", ";" & strPathVCCommon & "/IDE"
end if
if Shell(DosSlashes(strPathVC & "/bin/cl.exe"), True) <> 0 then
MsgError "Executing '" & strClExe & "' (which we believe to be the Visual C++ compiler driver) failed."
exit sub
end if
if (InStr(1, g_strShellOutput, "Version 13.10") <= 0) _
And (InStr(1, g_strShellOutput, "Version 14.") <= 0) then
MsgError "The Visual C++ compiler we found ('" & strPathVC & "') isn't 7.1 or 8.0. Check the build requirements."
exit sub
end if
'
' Ok, emit build config variables.
'
if InStr(1, g_strShellOutput, "Version 14.") > 0 then
CfgPrint "VBOX_USE_VCC80 := 1"
CfgPrint "PATH_TOOL_VCC80 := " & g_strPathVCC
CfgPrint "PATH_TOOL_VCC80X86 = $(PATH_TOOL_VCC80)"
CfgPrint "PATH_TOOL_VCC80AMD64 = $(PATH_TOOL_VCC80)"
if blnOptVCExpressEdition _
And LogFileExists(strPathVC, "atlmfc/include/atlbase.h") = False _
then
CfgPrint "TOOL_VCC80X86_MT = $(PATH_SDK_WINPSDK)/Bin/mt.exe"
CfgPrint "TOOL_VCC80AMD64_MT = $(TOOL_VCC80X86_MT)"
CfgPrint "VBOX_WITHOUT_COMPILER_REDIST=1"
DisableCOM "No ATL"
PrintResult "Visual C++ v8 (or later) without ATL", g_strPathVCC
else
PrintResult "Visual C++ v8 (or later)", g_strPathVCC
end if
else
CfgPrint "PATH_TOOL_VCC70 := " & g_strPathVCC
if blnOptVCExpressEdition _
And LogFileExists(strPathVC, "atlmfc/include/atlbase.h") = False _
then
CfgPrint "VBOX_WITHOUT_COMPILER_REDIST=1"
DisableCOM "No ATL"
PrintResult "Visual C++ v7.1 without ATL", g_strPathVCC
else
PrintResult "Visual C++ v7.1", g_strPathVCC
end if
end if
' and the env.bat path fix.
if strPathVCCommon <> "" then
EnvPrint "set PATH=%PATH%;" & strPathVCCommon & "/IDE;"
end if
end sub
''
' Checks if the specified path points to a usable PSDK.
function CheckForVisualCPPSub(strPathVC, strPathVCCommon, blnOptVCExpressEdition)
strPathVC = UnixSlashes(PathAbs(strPathVC))
CheckForVisualCPPSub = False
LogPrint "trying: strPathVC=" & strPathVC & " strPathVCCommon=" & strPathVCCommon & " blnOptVCExpressEdition=" & blnOptVCExpressEdition
if LogFileExists(strPathVC, "bin/cl.exe") _
And LogFileExists(strPathVC, "bin/link.exe") _
And LogFileExists(strPathVC, "include/string.h") _
And LogFileExists(strPathVC, "lib/libcmt.lib") _
And LogFileExists(strPathVC, "lib/msvcrt.lib") _
then
if blnOptVCExpressEdition _
Or ( LogFileExists(strPathVC, "atlmfc/include/atlbase.h") _
And LogFileExists(strPathVC, "atlmfc/lib/atls.lib")) _
Then
'' @todo figure out a way we can verify the version/build!
CheckForVisualCPPSub = True
end if
end if
end function
''
' Checks for a platform SDK that works with the compiler
sub CheckForPlatformSDK(strOptSDK)
dim strPathPSDK, str
PrintHdr "Windows Platform SDK (recent)"
strPathPSDK = ""
' Check the supplied argument first.
str = strOptSDK
if str <> "" then
if CheckForPlatformSDKSub(str) then strPathPSDK = str
end if
' The tools location.
if strPathPSDK = "" then
str = g_strPathDev & "/win.x86/sdk/200604"
if CheckForPlatformSDKSub(str) then strPathPSDK = str
end if
if strPathPSDK = "" then
str = g_strPathDev & "/win.x86/sdk/200504"
if CheckForPlatformSDKSub(str) then strPathPSDK = str
end if
if strPathPSDK = "" then
str = g_strPathDev & "/win.x86/sdk/200209"
if CheckForPlatformSDKSub(str) then strPathPSDK = str
end if
' Look for it in the environment
str = EnvGet("MSSdk")
if (strPathPSDK = "") And (str <> "") then
if CheckForPlatformSDKSub(str) then strPathPSDK = str
end if
str = EnvGet("Mstools")
if (strPathPSDK = "") And (str <> "") then
if CheckForPlatformSDKSub(str) then strPathPSDK = str
end if
' Check if there is one installed with the compiler.
if (strPathPSDK = "") And (str <> "") then
str = g_strPathVCC & "/PlatformSDK"
if CheckForPlatformSDKSub(str) then strPathPSDK = str
end if
' Check the registry next.
arrSubKeys = RegEnumSubKeys("HKLM", "SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs")
for Each strSubKey In arrSubKeys
str = RegGetString("HKLM\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\" & strSubKey & "\Install Dir")
if (strPathPSDK = "") And (str <> "") then
if CheckForPlatformSDKSub(str) then strPathPSDK = str
end if
Next
arrSubKeys = RegEnumSubKeys("HKCU", "SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs")
for Each strSubKey In arrSubKeys
str = RegGetString("HKCU\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\" & strSubKey & "\Install Dir")
if (strPathPSDK = "") And (str <> "") then
if CheckForPlatformSDKSub(str) then strPathPSDK = str
end if
Next
' Give up.
if strPathPSDK = "" then
MsgError "Cannot find a suitable Platform SDK. Check configure.log and the build requirements."
exit sub
end if
'
' Emit the config.
'
strPathPSDK = UnixSlashes(PathAbs(strPathPSDK))
CfgPrint "PATH_SDK_WINPSDK := " & strPathPSDK
CfgPrint "PATH_SDK_WINPSDKINCS = $(PATH_SDK_WINPSDK)"
CfgPrint "PATH_SDK_WIN32SDK = $(PATH_SDK_WINPSDK)"
CfgPrint "PATH_SDK_WIN64SDK = $(PATH_SDK_WINPSDK)"
PrintResult "Windows Platform SDK", strPathPSDK
g_strPathPSDK = strPathPSDK
end sub
''
' Checks if the specified path points to a usable PSDK.
function CheckForPlatformSDKSub(strPathPSDK)
CheckForPlatformSDKSub = False
LogPrint "trying: strPathPSDK=" & strPathPSDK
if LogFileExists(strPathPSDK, "include/Windows.h") _
And LogFileExists(strPathPSDK, "lib/Kernel32.Lib") _
And LogFileExists(strPathPSDK, "lib/User32.Lib") _
then
CheckForPlatformSDKSub = True
end if
end function
''
' Checks for a Windows 2003 DDK that works with the compiler intrinsics.
sub CheckForWin2k3DDK(strOptDDK)
dim strPathDDK, str, strSubKeys
PrintHdr "Windows 2003 DDK, build 3790 or later"
'
' Find the DDK.
'
strPathDDK = ""
' The specified path.
if (strPathDDK = "") And (strOptDDK <> "") then
if CheckForWin2k3DDKSub(strOptDDK, True) then strPathDDK = strOptDDK
end if
' The tools location.
if strPathDDK = "" then
str = g_strPathDev & "/win.x86/ddkwin2k3/200503"
if CheckForWin2k3DDKSub(str, False) then strPathDDK = str
end if
if strPathDDK = "" then
str = g_strPathDev & "/win.x86/ddkwin2k3/2004"
if CheckForWin2k3DDKSub(str, False) then strPathDDK = str
end if
if strPathDDK = "" then
MsgError "Cannot find a suitable Windows 2003 DDK. Check configure.log and the build requirements."
exit sub
end if
' Check the environment
str = EnvGet("DDK_INC_PATH")
if (strPathDDK = "") And (str <> "") then
str = PathParent(PathParent(str))
if CheckForWin2k3DDKSub(str, True) then strPathDDK = str
end if
str = EnvGet("BASEDIR")
if (strPathDDK = "") And (str <> "") then
if CheckForWin2k3DDKSub(str, True) then strPathDDK = str
end if
' Check the registry next.
arrSubKeys = RegEnumSubKeys("HKLM", "SOFTWARE\Microsoft\WINDDK") '' @todo Need some sorting stuff here.
for Each strSubKey In arrSubKeys
str = RegGetString("HKLM\SOFTWARE\Microsoft\WINDDK\" & strSubKey & "\SFNDirectory")
if (strPathDDK = "") And (str <> "") then
if CheckForWin2k3DDKSub(str, False) then strPathDDK = str
end if
Next
arrSubKeys = RegEnumSubKeys("HKCU", "SOFTWARE\Microsoft\WINDDK") '' @todo Need some sorting stuff here.
for Each strSubKey In arrSubKeys
str = RegGetString("HKCU\SOFTWARE\Microsoft\WINDDK\" & strSubKey & "\SFNDirectory")
if (strPathDDK = "") And (str <> "") then
if CheckForWin2k3DDKSub(str, False) then strPathDDK = str
end if
Next
'
' Emit the config.
'
strPathDDK = UnixSlashes(PathAbs(strPathDDK))
CfgPrint "PATH_SDK_W2K3DDK := " & strPathDDK
CfgPrint "PATH_SDK_W2K3DDKX86 = $(PATH_SDK_W2K3DDK)"
CfgPrint "PATH_SDK_W2K3DDKAMD64 = $(PATH_SDK_W2K3DDK)"
PrintResult "Windows 2003 DDK", strPathDDK
end sub
'' Quick check if the DDK is in the specified directory or not.
function CheckForWin2k3DDKSub(strPathDDK, blnCheckBuild)
CheckForWin2k3DDKSub = False
LogPrint "trying: strPathDDK=" & strPathDDK & " blnCheckBuild=" & blnCheckBuild
if LogFileExists(strPathDDK, "inc/ddk/wnet/ntdef.h") _
And LogFileExists(strPathDDK, "lib/wnet/i386/int64.lib") _
then
'' @todo figure out a way we can verify the version/build!
CheckForWin2k3DDKSub = True
end if
end function
''
' Checks for a recent DirectX SDK.
sub CheckForDirectXSDK(strOptDXSDK)
dim strPathDXSDK, str, arrSubKeys, arrSubKeys2, strKey, strKey2
PrintHdr "Direct X SDK"
'
' Find the DX SDK.
'
strPathDXSDK = ""
' The specified path.
if (strPathDXSDK = "") And (strOptDXSDK <> "") then
if CheckForDirectXSDKSub(strOptDXSDK) then strPathDXSDK = strOptDXSDK
end if
' The tools location.
if strPathDXSDK = "" then
str = g_strPathDev & "/win.x86/dxsdk/200610"
if CheckForDirectXSDKSub(str) then strPathDXSDK = str
end if
' Check the installer registry (sucks a bit).
arrSubKeys = RegEnumSubKeys("HKLM", "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData")
for Each strSubKey In arrSubKeys
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\" & strSubKey & "\Products"
arrSubKeys2 = RegEnumSubKeys("HKLM", strKey)
for Each strSubKey2 In arrSubKeys2
strKey2 = "HKLM\" & strKey & "\" & strSubKey2 & "\InstallProperties"
str = RegGetString(strKey2 & "\DisplayName")
if InStr(1, str, "Microsoft DirectX SDK") > 0 then
str = RegGetString(strKey2 & "\InstallLocation")
if (str <> "") And (strPathDXSDK = "") then
if CheckForDirectXSDKSub(str) then
strPathDXSDK = str
Exit For
end if
end if
end if
Next
Next
if strPathDXSDK = "" then
MsgError "Cannot find a suitable Direct X SDK. Check configure.log and the build requirements."
exit sub
end if
'
' Emit the config.
'
strPathDXSDK = UnixSlashes(PathAbs(strPathDXSDK))
CfgPrint "PATH_SDK_DXSDK := " & strPathDXSDK
CfgPrint "PATH_SDK_DXSDKX86 = $(PATH_SDK_DXSDK)"
CfgPrint "PATH_SDK_DXSDKAMD64 = $(PATH_SDK_DXSDK)"
PrintResult "Direct X SDK", strPathDXSDK
end sub
'' Quick check if the DXSDK is in the specified directory or not.
function CheckForDirectXSDKSub(strPathDXSDK)
CheckForDirectXSDKSub = False
LogPrint "trying: strPathDXSDK=" & strPathDXSDK
if LogFileExists(strPathDXSDK, "Lib/x86/dxguid.lib") _
then
'' @todo figure out a way we can verify the version/build!
CheckForDirectXSDKSub = True
end if
end function
''
' Checks for a MingW32 suitable for building the recompiler.
'
' strOptW32API is currently ignored.
'
sub CheckForMingW(strOptMingw, strOptW32API)
dim strPathMingW, strPathW32API, str
PrintHdr "MinGW GCC v3.3.x + Binutils + Runtime + W32API"
'
' Find the MinGW and W32API tools.
'
strPathMingW = ""
strPathW32API = ""
' The specified path.
if (strPathMingW = "") And (strOptMingW <> "") then
if CheckForMingWSub(strOptMingW, strOptW32API) then
strPathMingW = strOptMingW
strPathW32API = strOptW32API
end if
end if
' The tools location.
if strPathMingW = "" then
str = g_strPathDev & "/win.x86/mingw32/v3.3.3"
str2 = g_strPathDev & "/win.x86/w32api/v2.5"
if CheckForMingWSub(str, str2) then
strPathMingW = str
strPathW32API = str2
end if
end if
' See if there is any gcc around.
if strPathMingW = "" then
str = Which("mingw32-gcc.exe")
if (str <> "") then
str = PathParent(PathStripFilename(str))
if CheckForMingWSub(str, str) then strPathMingW = str
end if
end if
if strPathMingW = "" then
str = Which("gcc.exe")
if (str <> "") then
str = PathParent(PathStripFilename(str))
if CheckForMingWSub(str, str) then strPathMingW = str
end if
end if
' Success?
if strPathMingW = "" then
if strOptMingw = "" then
MsgError "Can't locate a suitable MinGW installation. Try specify the path with " _
& "the --with-MinGW=<path> argument. If still no luck, consult the configure.log and the build requirements."
else
MsgError "Can't locate a suitable MinGW installation. Please consult the configure.log and the build requirements."
end if
exit sub
end if
'
' Emit the config.
'
strPathMingW = UnixSlashes(PathAbs(strPathMingW))
CfgPrint "PATH_TOOL_MINGW32 := " & strPathMingW
PrintResult "MinGW (GCC v" & g_strSubOutput & ")", strPathMingW
if (strPathMingW = strPathW32API) Or strPathW32API = "" then
CfgPrint "PATH_SDK_W32API = $(PATH_TOOL_MINGW32)"
else
CfgPrint "PATH_SDK_W32API = " & strPathW32API
PrintResult "W32API", strPathW32API
end if
end sub
''
' Checks if the specified path points to an usable MinGW or not.
function CheckForMingWSub(strPathMingW, strPathW32API)
g_strSubOutput = ""
if strPathW32API = "" then strPathW32API = strPathMingW
LogPrint "trying: strPathMingW=" &strPathMingW & " strPathW32API=" & strPathW32API
if LogFileExists(strPathMingW, "bin/mingw32-gcc.exe") _
And LogFileExists(strPathMingW, "bin/ld.exe") _
And LogFileExists(strPathMingW, "bin/objdump.exe") _
And LogFileExists(strPathMingW, "bin/dllwrap.exe") _
And LogFileExists(strPathMingW, "bin/as.exe") _
And LogFileExists(strPathMingW, "include/string.h") _
And LogFileExists(strPathMingW, "include/_mingw.h") _
And LogFileExists(strPathMingW, "lib/dllcrt1.o") _
And LogFileExists(strPathMingW, "lib/dllcrt2.o") _
And LogFileExists(strPathMingW, "lib/libmsvcrt.a") _
_
And LogFileExists(strPathW32API, "lib/libkernel32.a") _
And LogFileExists(strPathW32API, "include/windows.h") _
then
if Shell(DosSlashes(strPathMingW & "/bin/gcc.exe") & " --version", True) = 0 then
dim offVer, iMajor, iMinor, iPatch, strVer
' extract the version.
strVer = ""
offVer = InStr(1, g_strShellOutput, "(GCC) ")
if offVer > 0 then
strVer = LTrim(Mid(g_strShellOutput, offVer + Len("(GCC) ")))
strVer = RTrim(Left(strVer, InStr(1, strVer, " ")))
if (Mid(strVer, 2, 1) = ".") _
And (Mid(strVer, 4, 1) = ".") then
iMajor = Int(Left(strVer, 1)) ' Is Int() the right thing here? I want atoi()!!!
iMinor = Int(Mid(strVer, 3, 1))
iPatch = Int(Mid(strVer, 5))
else
LogPrint "Malformed version: '" & strVer & "'"
strVer = ""
end if
end if
if strVer <> "" then
if (iMajor = 3) And (iMinor = 3) then
CheckForMingWSub = True
g_strSubOutput = strVer
else
LogPrint "MinGW version '" & iMajor & "." & iMinor & "." & iPatch & "' is not supported (or configure.vbs failed to parse it correctly)."
end if
else
LogPrint "Couldn't locate the GCC version in the output!"
end if
else
LogPrint "Failed to run gcc.exe!"
end if
end if
end function
''
' Checks for any libSDL binaries.
sub CheckForlibSDL(strOptlibSDL)
dim strPathlibSDL, str
PrintHdr "libSDL"
'
' Try find some SDL library.
'
' First, the specific location.
strPathlibSDL = ""
if (strPathlibSDL = "") And (strOptlibSDL <> "") then
if CheckForlibSDLSub(strOptlibSDL) then strPathlibSDL = strOptlibSDL
end if
' The tools location.
if strPathlibSDL = "" Then
str = g_strPathDev & "/win.x86/libsdl/v1.2.11"
if CheckForlibSDLSub(str) then strPathlibSDL = str
end if
if strPathlibSDL = "" Then
str = g_strPathDev & "/win.x86/libsdl/v1.2.7-InnoTek"
if CheckForlibSDLSub(str) then strPathlibSDL = str
end if
' Poke about in the path.
str = Which("SDLmain.lib")
if (strPathlibSDL = "") And (str <> "") Then
str = PathParent(PathStripFilename(str))
if CheckForlibSDLSub(str) then strPathlibSDL = str
end if
str = Which("SDL.dll")
if (strPathlibSDL = "") And (str <> "") Then
str = PathParent(PathStripFilename(str))
if CheckForlibSDLSub(str) then strPathlibSDL = str
end if
' Success?
if strPathlibSDL = "" then
if strOptlibSDL = "" then
MsgError "Can't locate libSDL. Try specify the path with the --with-libSDL=<path> argument. " _
& "If still no luck, consult the configure.log and the build requirements."
else
MsgError "Can't locate libSDL. Please consult the configure.log and the build requirements."
end if
exit sub
end if
strPathLibSDL = UnixSlashes(PathAbs(strPathLibSDL))
CfgPrint "PATH_SDK_LIBSDL := " & strPathlibSDL
PrintResult "libSDL", strPathlibSDL
end sub
''
' Checks if the specified path points to an usable libSDL or not.
function CheckForlibSDLSub(strPathlibSDL)
CheckForlibSDLSub = False
LogPrint "trying: strPathlibSDL=" & strPathlibSDL
if LogFileExists(strPathlibSDL, "lib/SDL.lib") _
And LogFileExists(strPathlibSDL, "lib/SDLmain.lib") _
And LogFileExists(strPathlibSDL, "lib/SDL.dll") _
And LogFileExists(strPathlibSDL, "include/SDL.h") _
And LogFileExists(strPathlibSDL, "include/SDL_syswm.h") _
And LogFileExists(strPathlibSDL, "include/SDL_version.h") _
then
CheckForlibSDLSub = True
end if
end function
dim g_strXercesVer
g_strXercesVer = ""
''
' Checks for xerces.
sub CheckForXerces(strOptXerces)
dim strPathXerces, str
PrintHdr "Xerces"
' Skip if no COM/ATL.
if g_blnDisableCOM then
PrintResult "Xerces", "Skipped (" & g_strDisableCOM & ")"
exit sub
end if
'
' Try find some xerces dll/lib.
'
strPathXerces = ""
if (strPathXerces = "") And (strOptXerces <> "") then
if CheckForXercesSub(strOptXerces) then strPathXerces = strOptXerces
end if
if strPathXerces = "" Then
str = Which("xerces-c_2_9.lib")
if str = "" then str = Which("xerces-c_2_8.lib")
if str = "" then str = Which("xerces-c_2_7.lib")
if str = "" then str = Which("xerces-c_2_6.lib")
if str <> "" Then
str = PathParent(PathStripFilename(str))
if CheckForXercesSub(str) then strPathXerces = str
end if
end if
if strPathXerces = "" Then
str = Which("xerces-c_2_9.dll")
if str = "" then str = Which("xerces-c_2_8.dll")
if str = "" then str = Which("xerces-c_2_7.dll")
if str = "" then str = Which("xerces-c_2_6.dll")
if str <> "" Then
str = PathParent(PathStripFilename(str))
if CheckForXercesSub(str) then strPathXerces = str
end if
end if
' Ignore failure if we're in 'internal' mode.
if (strPathXerces = "") and g_blnInternalMode then
PrintResult "Xerces", "ignored (internal mode)"
exit sub
end if
' Success?
if strPathXerces = "" then
if strOptXerces = "" then
MsgError "Can't locate Xerces. Try specify the path with the --with-xerces=<path> argument. " _
& "If still no luck, consult the configure.log and the build requirements."
else
MsgError "Can't locate Xerces. Please consult the configure.log and the build requirements."
end if
exit sub
end if
strPathXerces = UnixSlashes(PathAbs(strPathXerces))
CfgPrint "SDK_VBOX_XERCES_INCS := " & strPathXerces & "/include"
CfgPrint "SDK_VBOX_XERCES_LIBS := " & strPathXerces & "/lib/xerces-c_" & Left(g_strXercesVer, 1) & ".lib"
CfgPrint "DLL_SDK_VBOX_XERCES_XERCES := " & strPathXerces & "/bin/xerces-c_" & g_strXercesVer & ".dll"
PrintResult "Xerces", strPathXerces
end sub
''
' Checks if the specified path points to an usable libSDL or not.
function CheckForXercesSub(strPathXerces)
dim str
CheckForXercersSub = False
LogPrint "trying: strPathXerces=" & strPathXerces
if LogFileExists(strPathXerces, "include/xercesc/dom/DOM.hpp") _
And LogFileExists(strPathXerces, "include/xercesc/validators/datatype/DatatypeValidator.hpp") _
then
' The version is encoded in the dll/lib name, so try first
' to find the dll and then a matching lib.
str = LogFindFile(strPathXerces, "bin/xerces-c_*.dll")
if str <> "" then
g_strXercesVer = Mid(str, Len("xerces-c_") + 1, Len(str) - Len("xerces-c_.dll"))
' the library omits the minor version (in the current distro).
if LogFileExists(strPathXerces, "lib/xerces-c_" & Left(g_strXercesVer, 1) & ".lib") then
CheckForXercesSub = True
end if
end if
end if
end function
dim g_strXalanVer
g_strXalanVer = ""
''
' Checks for Xalan.
sub CheckForXalan(strOptXalan)
dim strPathXalan, str
PrintHdr "Xalan"
' Skip if no COM/ATL.
if g_blnDisableCOM then
PrintResult "Xalan", "Skipped (" & g_strDisableCOM & ")"
exit sub
end if
'
' Try find some Xalan dll/lib.
'
strPathXalan = ""
if (strPathXalan = "") And (strOptXalan <> "") then
if CheckForXalanSub(strOptXalan) then strPathXalan = strOptXalan
end if
if strPathXalan = "" Then
str = Which("Xalan-c_1_12.lib")
if str = "" then str = Which("Xalan-c_1_11.lib")
if str = "" then str = Which("Xalan-c_1_10.lib")
if str = "" then str = Which("Xalan-c_1_9.lib")
if str <> "" Then
str = PathParent(PathStripFilename(str))
if CheckForXalanSub(str) then strPathXalan = str
end if
end if
if strPathXalan = "" Then
str = Which("Xalan-c_1_12.dll")
if str = "" then str = Which("Xalan-c_1_11.dll")
if str = "" then str = Which("Xalan-c_1_10.dll")
if str = "" then str = Which("Xalan-c_1_9.dll")
if str <> "" Then
str = PathParent(PathStripFilename(str))
if CheckForXalanSub(str) then strPathXalan = str
end if
end if
' Ignore failure if we're in 'internal' mode.
if (strPathXalan = "") and g_blnInternalMode then
PrintResult "Xalan", "ignored (internal mode)"
exit sub
end if
' Success?
if strPathXalan = "" then
if strOptXalan = "" then
MsgError "Can't locate Xalan. Try specify the path with the --with-Xalan=<path> argument. " _
& "If still no luck, consult the configure.log and the build requirements."
else
MsgError "Can't locate Xalan. Please consult the configure.log and the build requirements."
end if
exit sub
end if
strPathXalan = UnixSlashes(PathAbs(strPathXalan))
CfgPrint "SDK_VBOX_XALAN_INCS := " & strPathXalan & "/include"
CfgPrint "SDK_VBOX_XALAN_LIBS := " & strPathXalan & "/lib/Xalan-C_" & Left(g_strXalanVer, 1) & ".lib"
CfgPrint "DLL_SDK_VBOX_XALAN_XALAN := " & strPathXalan & "/bin/Xalan-C_" & g_strXalanVer & ".dll"
CfgPrint "DLL_SDK_VBOX_XALAN_XALAN-MESSAGES := " & strPathXalan & "/bin/XalanMessages_" & g_strXalanVer & ".dll"
PrintResult "Xalan", strPathXalan
end sub
''
' Checks if the specified path points to an usable Xalan or not.
function CheckForXalanSub(strPathXalan)
dim str
CheckForXercersSub = False
LogPrint "trying: strPathXalan=" & strPathXalan
if LogFileExists(strPathXalan, "include/xalanc/DOMSupport/DOMSupport.hpp") _
And LogFileExists(strPathXalan, "include/xalanc/XalanDOM/XalanText.hpp") _
then
' The version is encoded in the dll/lib name, so try first
' to find the dll and then a matching lib.
str = LogFindFile(strPathXalan, "bin/Xalan-C_*.dll")
if str <> "" then
g_strXalanVer = Mid(str, Len("Xalan-C_") + 1, Len(str) - Len("Xalan-C_.dll"))
' the library omits the minor version (in the current distro).
if LogFileExists(strPathXalan, "bin/XalanMessages_" & g_strXalanVer & ".dll") _
And LogFileExists(strPathXalan, "lib/Xalan-C_" & Left(g_strXalanVer, 1) & ".lib") _
then
CheckForXalanSub = True
end if
end if
end if
end function
dim g_strQtVer
g_strQtVer = ""
''
' Checks for any Qt binaries. Failure here isn't fatal.
sub CheckForQt(strOptQt)
dim strPathQt, str
PrintHdr "Qt"
'
' Try find the Qt installation.
'
strPathQt = ""
if (strPathQt = "") And (strOptQt <> "") then
if CheckForQtSub(strOptQt) then strPathQt = strOptQt
end if
if strPathQt = "" then
str = g_strPathDev & "/win.x86/qt/v3.3.3"
if CheckForQtSub(str) then strPathQt = str
end if
'' @todo check for Qt installations and stuff later.
' Found anything?
if strPathQt = "" then
CfgPrint "VBOX_WITH_QTGUI="
PrintResult "Qt", "not found"
else
CfgPrint "VBOX_PATH_QT := " & strPathQt
CfgPrint "QTDIR = $(VBOX_PATH_QT)"
CfgPrint "LIB_QT = $(VBOX_PATH_QT)/lib/dynamic/qt-mt" & g_strQtVer & ".lib"
CfgPrint "VBOX_DLL_QT = $(VBOX_PATH_QT)/bin/qt-mt" & g_strQtVer & ".dll"
PrintResult "Qt (" & g_strQtVer & ")", strPathQt
end if
end sub
''
' Checks if the specified path points to an usable Qt install or not.
function CheckForQtSub(strPathQt)
CheckForQtSub = False
LogPrint "trying: strPathQt=" & strPathQt
if LogFileExists(strPathQt, "bin/moc.exe") _
And LogFileExists(strPathQt, "bin/uic.exe") _
And LogFileExists(strPathQt, "include/qvbox.h") _
And LogFileExists(strPathQt, "include/qt_windows.h") _
And LogFileExists(strPathQt, "include/qapplication.h") _
And LogFileExists(strPathQt, "include/qtextedit.h") _
And LogFileExists(strPathQt, "lib/dynamic/qtmain.lib") _
then
dim str
' This check might need improving.
str = LogFindFile(strPathQt, "lib/dynamic/qt-mt33*.lib")
if str <> "" then
g_strQtVer = Mid(str, Len("qt-mt") + 1, Len(str) - Len("qt-mt.lib"))
if LogFileExists(strPathQt, "bin/qt-mt" & g_strQtVer & ".dll") then
CheckForQtSub = True
end if
end if
end if
end function
''
' Show usage.
sub usage
Print "Usage: cscript configure.vbs [options]"
Print ""
Print "Configuration:"
Print " -h, --help"
Print " --internal"
Print ""
Print "Components:"
Print " --disable-COM"
Print ""
Print "Locations:"
Print " --with-DDK=PATH "
Print " --with-DXSDK=PATH "
Print " --with-kBuild=PATH "
Print " --with-libSDL=PATH "
Print " --with-MinGW=PATH "
Print " --with-Qt3=PATH "
Print " --with-SDK=PATH "
Print " --with-VC=PATH "
Print " --with-VC-Common=PATH "
Print " --with-VC-Express-Edition"
Print " --with-W32API=PATH "
Print " --with-Xalan=PATH "
Print " --with-Xerces=PATH "
end sub
''
' The main() like function.
'
Sub Main
'
' Write the log header and check that we're not using wscript.
'
LogInit
If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then
Wscript.Echo "This script must be run under CScript."
Wscript.Quit(1)
End If
'
' Parse arguments.
'
strOptDDK = ""
strOptDXDDK = ""
strOptkBuild = ""
strOptlibSDL = ""
strOptMingW = ""
strOptQt = ""
strOptSDK = ""
strOptVC = ""
strOptVCCommon = ""
blnOptVCExpressEdition = False
strOptW32API = ""
blnOptXalan = ""
blnOptXerces = ""
blnOptDisableCOM = False
for i = 1 to Wscript.Arguments.Count
dim str, strArg, strPath
' Separate argument and path value
str = Wscript.Arguments.item(i - 1)
if InStr(1, str, "=") > 0 then
strArg = Mid(str, 1, InStr(1, str, "=") - 1)
strPath = Mid(str, InStr(1, str, "=") + 1)
if strPath = "" then MsgFatal "Syntax error! Argument #" & i & " is missing the path."
else
strArg = str
strPath = ""
end if
' Process the argument
select case LCase(strArg)
case "--with-ddk"
strOptDDK = strPath
case "--with-dxsdk"
strOptDXSDK = strPath
case "--with-kbuild"
strOptkBuild = strPath
case "--with-libsdl"
strOptlibSDL = strPath
case "--with-mingw"
strOptMingW = strPath
case "--with-qt"
strOptQt = strPath
case "--with-sdk"
strOptSDK = strPath
case "--with-vc"
strOptVC = strPath
case "--with-vc-common"
strOptVCCommon = strPath
case "--with-vc-express-edition"
blnOptVCExpressEdition = True
case "--with-w32api"
strOptW32API = strPath
case "--with-xalan"
strOptXalan = strPath
case "--with-xerces"
strOptXerces = strPath
case "--disable-com"
blnOptDisableCOM = True
case "--enable-com"
blnOptDisableCOM = False
case "--internal"
g_blnInternalMode = True
case "-h", "--help", "-?"
usage
Wscript.Quit(0)
case else
Wscript.echo "syntax error: Unknown option '" & str &"'."
usage
Wscript.Quit(1)
end select
next
'
' Initialize output files.
'
CfgInit
EnvInit
'
' Check that the Shell function is sane.
'
g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = "This works"
if Shell("set TESTING_ENVIRONMENT_INHERITANC", False) <> 0 then ' The 'E' is missing on purpose (4nt).
MsgFatal "shell execution test failed!"
end if
if g_strShellOutput <> "TESTING_ENVIRONMENT_INHERITANCE=This works" & CHR(13) & CHR(10) then
MsgFatal "shell inheritance or shell execution isn't working right."
end if
g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = ""
Print "Shell inheritance test: OK"
'
' Do the checks.
'
if blnOptDisableCOM = True then
DisableCOM "--disable-com"
end if
CheckForkBuild strOptkBuild
CheckForVisualCPP strOptVC, strOptVCCommon, blnOptVCExpressEdition
CheckForPlatformSDK strOptSDK
CheckForWin2k3DDK strOptDDK
CheckForDirectXSDK strOptDXSDK
CheckForMingW strOptMingw, strOptW32API
CheckForlibSDL strOptlibSDL
CheckForXerces strOptXerces
CheckForXalan strOptXalan
CheckForQt strOptQt
if g_blnInternalMode then
EnvPrint "call " & g_strPathDev & "/env.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9"
end if
End Sub
Main