VirtualBox

source: vbox/trunk/configure.vbs@ 73410

Last change on this file since 73410 was 71902, checked in by vboxsync, 7 years ago

configure.vbs: Pick the 64-bit kBuild binaries on 64-bit hosts. Buggy test forced 32-bit regardless of any other considerations.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Id
File size: 74.6 KB
Line 
1' $Id: configure.vbs 71902 2018-04-18 15:19:39Z vboxsync $
2'' @file
3' The purpose of this script is to check for all external tools, headers, and
4' libraries VBox OSE depends on.
5'
6' The script generates the build configuration file 'AutoConfig.kmk' and the
7' environment setup script 'env.bat'. A log of what has been done is
8' written to 'configure.log'.
9'
10
11'
12' Copyright (C) 2006-2017 Oracle Corporation
13'
14' This file is part of VirtualBox Open Source Edition (OSE), as
15' available from http://www.virtualbox.org. This file is free software;
16' you can redistribute it and/or modify it under the terms of the GNU
17' General Public License (GPL) as published by the Free Software
18' Foundation, in version 2 as it comes in the "COPYING" file of the
19' VirtualBox OSE distribution. VirtualBox OSE is distributed in the
20' hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
21'
22
23
24'*****************************************************************************
25'* Global Variables *
26'*****************************************************************************
27dim g_strPath, g_strEnvFile, g_strLogFile, g_strCfgFile, g_strShellOutput
28g_strPath = Left(Wscript.ScriptFullName, Len(Wscript.ScriptFullName) - Len("\configure.vbs"))
29g_strEnvFile = g_strPath & "\env.bat"
30g_strCfgFile = g_strPath & "\AutoConfig.kmk"
31g_strLogFile = g_strPath & "\configure.log"
32'g_strTmpFile = g_strPath & "\configure.tmp"
33
34dim g_objShell, g_objFileSys
35Set g_objShell = WScript.CreateObject("WScript.Shell")
36Set g_objFileSys = WScript.CreateObject("Scripting.FileSystemObject")
37
38dim g_strPathkBuild, g_strPathkBuildBin, g_strPathDev, g_strPathVCC, g_strPathPSDK, g_strVerPSDK, g_strPathDDK, g_strSubOutput
39g_strPathkBuild = ""
40g_strPathDev = ""
41g_strPathVCC = ""
42g_strPathPSDK = ""
43g_strPathDDK = ""
44
45dim g_strTargetArch
46g_strTargetArch = ""
47
48dim g_strHostArch
49g_strHostArch = ""
50
51dim g_blnDisableCOM, g_strDisableCOM
52g_blnDisableCOM = False
53g_strDisableCOM = ""
54
55' The internal mode is primarily for skipping some large libraries.
56dim g_blnInternalMode
57g_blnInternalMode = False
58
59' Whether to try the internal stuff first or last.
60dim g_blnInternalFirst
61g_blnInternalFirst = True
62
63
64
65''
66' Converts to unix slashes
67function UnixSlashes(str)
68 UnixSlashes = replace(str, "\", "/")
69end function
70
71
72''
73' Converts to dos slashes
74function DosSlashes(str)
75 DosSlashes = replace(str, "/", "\")
76end function
77
78
79''
80' Read a file (typically the tmp file) into a string.
81function FileToString(strFilename)
82 const ForReading = 1, TristateFalse = 0
83 dim objLogFile, str
84
85 set objFile = g_objFileSys.OpenTextFile(DosSlashes(strFilename), ForReading, False, TristateFalse)
86 str = objFile.ReadAll()
87 objFile.Close()
88
89 FileToString = str
90end function
91
92
93''
94' Deletes a file
95sub FileDelete(strFilename)
96 if g_objFileSys.FileExists(DosSlashes(strFilename)) then
97 g_objFileSys.DeleteFile(DosSlashes(strFilename))
98 end if
99end sub
100
101
102''
103' Appends a line to an ascii file.
104sub FileAppendLine(strFilename, str)
105 const ForAppending = 8, TristateFalse = 0
106 dim objFile
107
108 set objFile = g_objFileSys.OpenTextFile(DosSlashes(strFilename), ForAppending, True, TristateFalse)
109 objFile.WriteLine(str)
110 objFile.Close()
111end sub
112
113
114''
115' Checks if the file exists.
116function FileExists(strFilename)
117 FileExists = g_objFileSys.FileExists(DosSlashes(strFilename))
118end function
119
120
121''
122' Checks if the directory exists.
123function DirExists(strDirectory)
124 DirExists = g_objFileSys.FolderExists(DosSlashes(strDirectory))
125end function
126
127
128''
129' Checks if this is a WOW64 process.
130function IsWow64()
131 if g_objShell.Environment("PROCESS")("PROCESSOR_ARCHITEW6432") <> "" then
132 IsWow64 = 1
133 else
134 IsWow64 = 0
135 end if
136end function
137
138
139''
140' Returns a reverse sorted array (strings).
141function ArraySortStrings(arrStrings)
142 for i = LBound(arrStrings) to UBound(arrStrings)
143 str1 = arrStrings(i)
144 for j = i + 1 to UBound(arrStrings)
145 str2 = arrStrings(j)
146 if StrComp(str2, str1) < 0 then
147 arrStrings(j) = str1
148 str1 = str2
149 end if
150 next
151 arrStrings(i) = str1
152 next
153 ArraySortStrings = arrStrings
154end function
155
156
157''
158' Prints a string array.
159sub ArrayPrintStrings(arrStrings, strPrefix)
160 for i = LBound(arrStrings) to UBound(arrStrings)
161 Print strPrefix & "arrStrings(" & i & ") = '" & arrStrings(i) & "'"
162 next
163end sub
164
165
166''
167' Returns a reverse sorted array (strings).
168function ArrayRSortStrings(arrStrings)
169 ' Sort it.
170 arrStrings = ArraySortStrings(arrStrings)
171
172 ' Reverse the array.
173 cnt = UBound(arrStrings) - LBound(arrStrings) + 1
174 if cnt > 0 then
175 j = UBound(arrStrings)
176 iHalf = Fix(LBound(arrStrings) + cnt / 2)
177 for i = LBound(arrStrings) to iHalf - 1
178 strTmp = arrStrings(i)
179 arrStrings(i) = arrStrings(j)
180 arrStrings(j) = strTmp
181 j = j - 1
182 next
183 end if
184 ArrayRSortStrings = arrStrings
185end function
186
187
188''
189' Returns the input array with the string appended.
190' Note! There must be some better way of doing this...
191function ArrayAppend(arr, str)
192 dim i, cnt
193 cnt = UBound(arr) - LBound(arr) + 1
194 redim arrRet(cnt)
195 for i = LBound(arr) to UBound(arr)
196 arrRet(i) = arr(i)
197 next
198 arrRet(UBound(arr) + 1) = str
199 ArrayAppend = arrRet
200end function
201
202
203
204''
205' Translates a register root name to a value
206function RegTransRoot(strRoot)
207 const HKEY_LOCAL_MACHINE = &H80000002
208 const HKEY_CURRENT_USER = &H80000001
209 select case strRoot
210 case "HKLM"
211 RegTransRoot = HKEY_LOCAL_MACHINE
212 case "HKCU"
213 RegTransRoot = HKEY_CURRENT_USER
214 case else
215 MsgFatal "RegTransRoot: Unknown root: '" & strRoot & "'"
216 RegTransRoot = 0
217 end select
218end function
219
220
221'' The registry globals
222dim g_objReg, g_objRegCtx
223dim g_blnRegistry
224g_blnRegistry = false
225
226
227''
228' Init the register provider globals.
229function RegInit()
230 RegInit = false
231 On Error Resume Next
232 if g_blnRegistry = false then
233 set g_objRegCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
234 ' Comment out the following for lines if the cause trouble on your windows version.
235 if IsWow64() then
236 g_objRegCtx.Add "__ProviderArchitecture", 64
237 g_objRegCtx.Add "__RequiredArchitecture", true
238 end if
239 set objLocator = CreateObject("Wbemscripting.SWbemLocator")
240 set objServices = objLocator.ConnectServer("", "root\default", "", "", , , , g_objRegCtx)
241 set g_objReg = objServices.Get("StdRegProv")
242 g_blnRegistry = true
243 end if
244 RegInit = true
245end function
246
247
248''
249' Gets a value from the registry. Returns "" if string wasn't found / valid.
250function RegGetString(strName)
251 RegGetString = ""
252 if RegInit() then
253 dim strRoot, strKey, strValue
254 dim iRoot
255
256 ' split up into root, key and value parts.
257 strRoot = left(strName, instr(strName, "\") - 1)
258 strKey = mid(strName, instr(strName, "\") + 1, instrrev(strName, "\") - instr(strName, "\"))
259 strValue = mid(strName, instrrev(strName, "\") + 1)
260
261 ' Must use ExecMethod to call the GetStringValue method because of the context.
262 Set InParms = g_objReg.Methods_("GetStringValue").Inparameters
263 InParms.hDefKey = RegTransRoot(strRoot)
264 InParms.sSubKeyName = strKey
265 InParms.sValueName = strValue
266 On Error Resume Next
267 set OutParms = g_objReg.ExecMethod_("GetStringValue", InParms, , g_objRegCtx)
268 if OutParms.ReturnValue = 0 then
269 RegGetString = OutParms.sValue
270 end if
271 else
272 ' fallback mode
273 On Error Resume Next
274 RegGetString = g_objShell.RegRead(strName)
275 end if
276end function
277
278
279''
280' Returns an array of subkey strings.
281function RegEnumSubKeys(strRoot, strKeyPath)
282 dim iRoot
283 iRoot = RegTransRoot(strRoot)
284 RegEnumSubKeys = Array()
285
286 if RegInit() then
287 ' Must use ExecMethod to call the EnumKey method because of the context.
288 Set InParms = g_objReg.Methods_("EnumKey").Inparameters
289 InParms.hDefKey = RegTransRoot(strRoot)
290 InParms.sSubKeyName = strKeyPath
291 On Error Resume Next
292 set OutParms = g_objReg.ExecMethod_("EnumKey", InParms, , g_objRegCtx)
293 if OutParms.ReturnValue = 0 then
294 RegEnumSubKeys = OutParms.sNames
295 end if
296 else
297 ' fallback mode
298 dim objReg, rc, arrSubKeys
299 set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
300 On Error Resume Next
301 rc = objReg.EnumKey(iRoot, strKeyPath, arrSubKeys)
302 if rc = 0 then
303 RegEnumSubKeys = arrSubKeys
304 end if
305 end if
306end function
307
308
309''
310' Returns an array of full path subkey strings.
311function RegEnumSubKeysFull(strRoot, strKeyPath)
312 dim arrTmp
313 arrTmp = RegEnumSubKeys(strRoot, strKeyPath)
314 for i = LBound(arrTmp) to UBound(arrTmp)
315 arrTmp(i) = strKeyPath & "\" & arrTmp(i)
316 next
317 RegEnumSubKeysFull = arrTmp
318end function
319
320
321''
322' Returns an rsorted array of subkey strings.
323function RegEnumSubKeysRSort(strRoot, strKeyPath)
324 RegEnumSubKeysRSort = ArrayRSortStrings(RegEnumSubKeys(strRoot, strKeyPath))
325end function
326
327
328''
329' Returns an rsorted array of subkey strings.
330function RegEnumSubKeysFullRSort(strRoot, strKeyPath)
331 RegEnumSubKeysFullRSort = ArrayRSortStrings(RegEnumSubKeysFull(strRoot, strKeyPath))
332end function
333
334
335''
336' Gets the commandline used to invoke the script.
337function GetCommandline()
338 dim str, i
339
340 '' @todo find an api for querying it instead of reconstructing it like this...
341 GetCommandline = "cscript configure.vbs"
342 for i = 1 to WScript.Arguments.Count
343 str = WScript.Arguments.Item(i - 1)
344 if str = "" then
345 str = """"""
346 elseif (InStr(1, str, " ")) then
347 str = """" & str & """"
348 end if
349 GetCommandline = GetCommandline & " " & str
350 next
351end function
352
353
354''
355' Gets an environment variable.
356function EnvGet(strName)
357 EnvGet = g_objShell.Environment("PROCESS")(strName)
358end function
359
360
361''
362' Sets an environment variable.
363sub EnvSet(strName, strValue)
364 g_objShell.Environment("PROCESS")(strName) = strValue
365 LogPrint "EnvSet: " & strName & "=" & strValue
366end sub
367
368
369''
370' Appends a string to an environment variable
371sub EnvAppend(strName, strValue)
372 dim str
373 str = g_objShell.Environment("PROCESS")(strName)
374 g_objShell.Environment("PROCESS")(strName) = str & strValue
375 LogPrint "EnvAppend: " & strName & "=" & str & strValue
376end sub
377
378
379''
380' Prepends a string to an environment variable
381sub EnvPrepend(strName, strValue)
382 dim str
383 str = g_objShell.Environment("PROCESS")(strName)
384 g_objShell.Environment("PROCESS")(strName) = strValue & str
385 LogPrint "EnvPrepend: " & strName & "=" & strValue & str
386end sub
387
388''
389' Gets the first non-empty environment variable of the given two.
390function EnvGetFirst(strName1, strName2)
391 EnvGetFirst = g_objShell.Environment("PROCESS")(strName1)
392 if EnvGetFirst = "" then
393 EnvGetFirst = g_objShell.Environment("PROCESS")(strName2)
394 end if
395end function
396
397
398''
399' Get the path of the parent directory. Returns root if root was specified.
400' Expects abs path.
401function PathParent(str)
402 PathParent = g_objFileSys.GetParentFolderName(DosSlashes(str))
403end function
404
405
406''
407' Strips the filename from at path.
408function PathStripFilename(str)
409 PathStripFilename = g_objFileSys.GetParentFolderName(DosSlashes(str))
410end function
411
412
413''
414' Get the abs path, use the short version if necessary.
415function PathAbs(str)
416 strAbs = g_objFileSys.GetAbsolutePathName(DosSlashes(str))
417 strParent = g_objFileSys.GetParentFolderName(strAbs)
418 if strParent = "" then
419 PathAbs = strAbs
420 else
421 strParent = PathAbs(strParent) ' Recurse to resolve parent paths.
422 PathAbs = g_objFileSys.BuildPath(strParent, g_objFileSys.GetFileName(strAbs))
423
424 dim obj
425 set obj = Nothing
426 if FileExists(PathAbs) then
427 set obj = g_objFileSys.GetFile(PathAbs)
428 elseif DirExists(PathAbs) then
429 set obj = g_objFileSys.GetFolder(PathAbs)
430 end if
431
432 if not (obj is nothing) then
433 for each objSub in obj.ParentFolder.SubFolders
434 if obj.Name = objSub.Name or obj.ShortName = objSub.ShortName then
435 if InStr(1, objSub.Name, " ") > 0 _
436 Or InStr(1, objSub.Name, "&") > 0 _
437 Or InStr(1, objSub.Name, "$") > 0 _
438 then
439 PathAbs = g_objFileSys.BuildPath(strParent, objSub.ShortName)
440 if InStr(1, PathAbs, " ") > 0 _
441 Or InStr(1, PathAbs, "&") > 0 _
442 Or InStr(1, PathAbs, "$") > 0 _
443 then
444 MsgFatal "PathAbs(" & str & ") attempted to return filename with problematic " _
445 & "characters in it (" & PathAbs & "). The tool/sdk referenced will probably " _
446 & "need to be copied or reinstalled to a location without 'spaces', '$', ';' " _
447 & "or '&' in the path name. (Unless it's a problem with this script of course...)"
448 end if
449 else
450 PathAbs = g_objFileSys.BuildPath(strParent, objSub.Name)
451 end if
452 exit for
453 end if
454 next
455 end if
456 end if
457end function
458
459
460''
461' Get the abs path, use the long version.
462function PathAbsLong(str)
463 strAbs = g_objFileSys.GetAbsolutePathName(DosSlashes(str))
464 strParent = g_objFileSys.GetParentFolderName(strAbs)
465 if strParent = "" then
466 PathAbsLong = strAbs
467 else
468 strParent = PathAbsLong(strParent) ' Recurse to resolve parent paths.
469 PathAbsLong = g_objFileSys.BuildPath(strParent, g_objFileSys.GetFileName(strAbs))
470
471 dim obj
472 set obj = Nothing
473 if FileExists(PathAbsLong) then
474 set obj = g_objFileSys.GetFile(PathAbsLong)
475 elseif DirExists(PathAbsLong) then
476 set obj = g_objFileSys.GetFolder(PathAbsLong)
477 end if
478
479 if not (obj is nothing) then
480 for each objSub in obj.ParentFolder.SubFolders
481 if obj.Name = objSub.Name or obj.ShortName = objSub.ShortName then
482 PathAbsLong = g_objFileSys.BuildPath(strParent, objSub.Name)
483 exit for
484 end if
485 next
486 end if
487 end if
488end function
489
490
491''
492' Executes a command in the shell catching output in g_strShellOutput
493function Shell(strCommand, blnBoth)
494 dim strShell, strCmdline, objExec, str
495
496 strShell = g_objShell.ExpandEnvironmentStrings("%ComSpec%")
497 if blnBoth = true then
498 strCmdline = strShell & " /c " & strCommand & " 2>&1"
499 else
500 strCmdline = strShell & " /c " & strCommand & " 2>nul"
501 end if
502
503 LogPrint "# Shell: " & strCmdline
504 Set objExec = g_objShell.Exec(strCmdLine)
505 g_strShellOutput = objExec.StdOut.ReadAll()
506 objExec.StdErr.ReadAll()
507 do while objExec.Status = 0
508 Wscript.Sleep 20
509 g_strShellOutput = g_strShellOutput & objExec.StdOut.ReadAll()
510 objExec.StdErr.ReadAll()
511 loop
512
513 LogPrint "# Status: " & objExec.ExitCode
514 LogPrint "# Start of Output"
515 LogPrint g_strShellOutput
516 LogPrint "# End of Output"
517
518 Shell = objExec.ExitCode
519end function
520
521
522''
523' Try find the specified file in the path.
524function Which(strFile)
525 dim strPath, iStart, iEnd, str
526
527 ' the path
528 strPath = EnvGet("Path")
529 iStart = 1
530 do while iStart <= Len(strPath)
531 iEnd = InStr(iStart, strPath, ";")
532 if iEnd <= 0 then iEnd = Len(strPath) + 1
533 if iEnd > iStart then
534 str = Mid(strPath, iStart, iEnd - iStart) & "/" & strFile
535 if FileExists(str) then
536 Which = str
537 exit function
538 end if
539 end if
540 iStart = iEnd + 1
541 loop
542
543 ' registry or somewhere?
544
545 Which = ""
546end function
547
548
549''
550' Append text to the log file and echo it to stdout
551sub Print(str)
552 LogPrint str
553 Wscript.Echo str
554end sub
555
556
557''
558' Prints a test header
559sub PrintHdr(strTest)
560 LogPrint "***** Checking for " & strTest & " *****"
561 Wscript.Echo "Checking for " & StrTest & "..."
562end sub
563
564
565''
566' Prints a success message
567sub PrintResultMsg(strTest, strResult)
568 LogPrint "** " & strTest & ": " & strResult
569 Wscript.Echo " Found "& strTest & ": " & strResult
570end sub
571
572
573''
574' Prints a successfully detected path
575sub PrintResult(strTest, strPath)
576 strLongPath = PathAbsLong(strPath)
577 if PathAbs(strPath) <> strLongPath then
578 LogPrint "** " & strTest & ": " & strPath & " (" & UnixSlashes(strLongPath) & ")"
579 Wscript.Echo " Found " & strTest & ": " & strPath & " (" & UnixSlashes(strLongPath) & ")"
580 else
581 LogPrint "** " & strTest & ": " & strPath
582 Wscript.Echo " Found " & strTest & ": " & strPath
583 end if
584end sub
585
586
587''
588' Warning message.
589sub MsgWarning(strMsg)
590 Print "warning: " & strMsg
591end sub
592
593
594''
595' Fatal error.
596sub MsgFatal(strMsg)
597 Print "fatal error: " & strMsg
598 Wscript.Quit
599end sub
600
601
602''
603' Error message, fatal unless flag to ignore errors is given.
604sub MsgError(strMsg)
605 Print "error: " & strMsg
606 if g_blnInternalMode = False then
607 Wscript.Quit
608 end if
609end sub
610
611
612''
613' Write a log header with some basic info.
614sub LogInit
615 FileDelete g_strLogFile
616 LogPrint "# Log file generated by " & Wscript.ScriptFullName
617 for i = 1 to WScript.Arguments.Count
618 LogPrint "# Arg #" & i & ": " & WScript.Arguments.Item(i - 1)
619 next
620 if Wscript.Arguments.Count = 0 then
621 LogPrint "# No arguments given"
622 end if
623 LogPrint "# Reconstructed command line: " & GetCommandline()
624
625 ' some Wscript stuff
626 LogPrint "# Wscript properties:"
627 LogPrint "# ScriptName: " & Wscript.ScriptName
628 LogPrint "# Version: " & Wscript.Version
629 LogPrint "# Build: " & Wscript.BuildVersion
630 LogPrint "# Name: " & Wscript.Name
631 LogPrint "# Full Name: " & Wscript.FullName
632 LogPrint "# Path: " & Wscript.Path
633 LogPrint "#"
634
635
636 ' the environment
637 LogPrint "# Environment:"
638 dim objEnv
639 for each strVar in g_objShell.Environment("PROCESS")
640 LogPrint "# " & strVar
641 next
642 LogPrint "#"
643end sub
644
645
646''
647' Append text to the log file.
648sub LogPrint(str)
649 FileAppendLine g_strLogFile, str
650 'Wscript.Echo "dbg: " & str
651end sub
652
653
654''
655' Checks if the file exists and logs failures.
656function LogFileExists(strPath, strFilename)
657 LogFileExists = FileExists(strPath & "/" & strFilename)
658 if LogFileExists = False then
659 LogPrint "Testing '" & strPath & "': " & strFilename & " not found"
660 end if
661
662end function
663
664
665''
666' Finds the first file matching the pattern.
667' If no file is found, log the failure.
668function LogFindFile(strPath, strPattern)
669 dim str
670
671 '
672 ' Yes, there are some facy database kinda interface to the filesystem
673 ' however, breaking down the path and constructing a usable query is
674 ' too much hassle. So, we'll do it the unix way...
675 '
676 if Shell("dir /B """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True) = 0 _
677 And InStr(1, g_strShellOutput, Chr(13)) > 1 _
678 then
679 ' return the first word.
680 LogFindFile = Left(g_strShellOutput, InStr(1, g_strShellOutput, Chr(13)) - 1)
681 else
682 LogPrint "Testing '" & strPath & "': " & strPattern & " not found"
683 LogFindFile = ""
684 end if
685end function
686
687
688''
689' Finds the first directory matching the pattern.
690' If no directory is found, log the failure,
691' else return the complete path to the found directory.
692function LogFindDir(strPath, strPattern)
693 dim str
694
695 '
696 ' Yes, there are some facy database kinda interface to the filesystem
697 ' however, breaking down the path and constructing a usable query is
698 ' too much hassle. So, we'll do it the unix way...
699 '
700
701 ' List the alphabetically last names as first entries (with /O-N).
702 if Shell("dir /B /AD /O-N """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True) = 0 _
703 And InStr(1, g_strShellOutput, Chr(13)) > 1 _
704 then
705 ' return the first word.
706 LogFindDir = strPath & "/" & Left(g_strShellOutput, InStr(1, g_strShellOutput, Chr(13)) - 1)
707 else
708 LogPrint "Testing '" & strPath & "': " & strPattern & " not found"
709 LogFindDir = ""
710 end if
711end function
712
713
714''
715' Initializes the config file.
716sub CfgInit
717 FileDelete g_strCfgFile
718 CfgPrint "# -*- Makefile -*-"
719 CfgPrint "#"
720 CfgPrint "# Build configuration generated by " & GetCommandline()
721 CfgPrint "#"
722 if g_blnInternalMode = False then
723 CfgPrint "VBOX_OSE := 1"
724 CfgPrint "VBOX_VCC_WERR = $(NO_SUCH_VARIABLE)"
725 end if
726end sub
727
728
729''
730' Prints a string to the config file.
731sub CfgPrint(str)
732 FileAppendLine g_strCfgFile, str
733end sub
734
735
736''
737' Initializes the environment batch script.
738sub EnvInit
739 FileDelete g_strEnvFile
740 EnvPrint "@echo off"
741 EnvPrint "rem"
742 EnvPrint "rem Environment setup script generated by " & GetCommandline()
743 EnvPrint "rem"
744end sub
745
746
747''
748' Prints a string to the environment batch script.
749sub EnvPrint(str)
750 FileAppendLine g_strEnvFile, str
751end sub
752
753
754''
755' No COM
756sub DisableCOM(strReason)
757 if g_blnDisableCOM = False then
758 LogPrint "Disabled COM components: " & strReason
759 g_blnDisableCOM = True
760 g_strDisableCOM = strReason
761 CfgPrint "VBOX_WITH_MAIN="
762 CfgPrint "VBOX_WITH_QTGUI="
763 CfgPrint "VBOX_WITH_VBOXSDL="
764 CfgPrint "VBOX_WITH_DEBUGGER_GUI="
765 end if
766end sub
767
768
769''
770' No UDPTunnel
771sub DisableUDPTunnel(strReason)
772 if g_blnDisableUDPTunnel = False then
773 LogPrint "Disabled UDPTunnel network transport: " & strReason
774 g_blnDisableUDPTunnel = True
775 g_strDisableUDPTunnel = strReason
776 CfgPrint "VBOX_WITH_UDPTUNNEL="
777 end if
778end sub
779
780
781''
782' No SDL
783sub DisableSDL(strReason)
784 if g_blnDisableSDL = False then
785 LogPrint "Disabled SDL frontend: " & strReason
786 g_blnDisableSDL = True
787 g_strDisableSDL = strReason
788 CfgPrint "VBOX_WITH_VBOXSDL="
789 end if
790end sub
791
792
793''
794' Checks the the path doesn't contain characters the tools cannot deal with.
795sub CheckSourcePath
796 dim sPwd
797
798 sPwd = PathAbs(g_strPath)
799 if InStr(1, sPwd, " ") > 0 then
800 MsgError "Source path contains spaces! Please move it. (" & sPwd & ")"
801 end if
802 if InStr(1, sPwd, "$") > 0 then
803 MsgError "Source path contains the '$' char! Please move it. (" & sPwd & ")"
804 end if
805 if InStr(1, sPwd, "%") > 0 then
806 MsgError "Source path contains the '%' char! Please move it. (" & sPwd & ")"
807 end if
808 if InStr(1, sPwd, Chr(10)) > 0 _
809 Or InStr(1, sPwd, Chr(13)) > 0 _
810 Or InStr(1, sPwd, Chr(9)) > 0 _
811 then
812 MsgError "Source path contains control characters! Please move it. (" & sPwd & ")"
813 end if
814 Print "Source path: OK"
815end sub
816
817
818''
819' Checks for kBuild - very simple :)
820sub CheckForkBuild(strOptkBuild)
821 PrintHdr "kBuild"
822
823 '
824 ' Check if there is a 'kmk' in the path somewhere without
825 ' any KBUILD_*PATH stuff around.
826 '
827 blnNeedEnvVars = True
828 g_strPathkBuild = strOptkBuild
829 g_strPathkBuildBin = ""
830 if (g_strPathkBuild = "") _
831 And (EnvGetFirst("KBUILD_PATH", "PATH_KBUILD") = "") _
832 And (EnvGetFirst("KBUILD_BIN_PATH", "PATH_KBUILD_BIN") = "") _
833 And (Shell("kmk.exe --version", True) = 0) _
834 And (InStr(1,g_strShellOutput, "kBuild Make 0.1") > 0) _
835 And (InStr(1,g_strShellOutput, "KBUILD_PATH") > 0) _
836 And (InStr(1,g_strShellOutput, "KBUILD_BIN_PATH") > 0) then
837 '' @todo Need to parse out the KBUILD_PATH and KBUILD_BIN_PATH values to complete the other tests.
838 'blnNeedEnvVars = False
839 MsgWarning "You've installed kBuild it seems. configure.vbs hasn't been updated to " _
840 & "deal with that yet and will use the one it ships with. Sorry."
841 end if
842
843 '
844 ' Check for the KBUILD_PATH env.var. and fall back on root/kBuild otherwise.
845 '
846 if g_strPathkBuild = "" then
847 g_strPathkBuild = EnvGetFirst("KBUILD_PATH", "PATH_KBUILD")
848 if (g_strPathkBuild <> "") and (FileExists(g_strPathkBuild & "/footer.kmk") = False) then
849 MsgWarning "Ignoring incorrect kBuild path (KBUILD_PATH=" & g_strPathkBuild & ")"
850 g_strPathkBuild = ""
851 end if
852
853 if g_strPathkBuild = "" then
854 g_strPathkBuild = g_strPath & "/kBuild"
855 end if
856 end if
857
858 g_strPathkBuild = UnixSlashes(PathAbs(g_strPathkBuild))
859
860 '
861 ' Check for env.vars that kBuild uses (do this early to set g_strTargetArch).
862 '
863 str = EnvGetFirst("KBUILD_TYPE", "BUILD_TYPE")
864 if (str <> "") _
865 And (InStr(1, "|release|debug|profile|kprofile", str) <= 0) then
866 EnvPrint "set KBUILD_TYPE=release"
867 EnvSet "KBUILD_TYPE", "release"
868 MsgWarning "Found unknown KBUILD_TYPE value '" & str &"' in your environment. Setting it to 'release'."
869 end if
870
871 str = EnvGetFirst("KBUILD_TARGET", "BUILD_TARGET")
872 if (str <> "") _
873 And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
874 EnvPrint "set KBUILD_TARGET=win"
875 EnvSet "KBUILD_TARGET", "win"
876 MsgWarning "Found unknown KBUILD_TARGET value '" & str &"' in your environment. Setting it to 'win32'."
877 end if
878
879 str = EnvGetFirst("KBUILD_TARGET_ARCH", "BUILD_TARGET_ARCH")
880 if (str <> "") _
881 And (InStr(1, "x86|amd64", str) <= 0) then
882 EnvPrint "set KBUILD_TARGET_ARCH=x86"
883 EnvSet "KBUILD_TARGET_ARCH", "x86"
884 MsgWarning "Found unknown KBUILD_TARGET_ARCH value '" & str &"' in your environment. Setting it to 'x86'."
885 str = "x86"
886 end if
887 if g_strTargetArch = "" then '' command line parameter --target-arch=x86|amd64 has priority
888 if str <> "" then
889 g_strTargetArch = str
890 elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _
891 Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then
892 g_strTargetArch = "amd64"
893 else
894 g_strTargetArch = "x86"
895 end if
896 else
897 if InStr(1, "x86|amd64", g_strTargetArch) <= 0 then
898 EnvPrint "set KBUILD_TARGET_ARCH=x86"
899 EnvSet "KBUILD_TARGET_ARCH", "x86"
900 MsgWarning "Unknown --target-arch=" & str &". Setting it to 'x86'."
901 end if
902 end if
903 LogPrint " Target architecture: " & g_strTargetArch & "."
904 Wscript.Echo " Target architecture: " & g_strTargetArch & "."
905 EnvPrint "set KBUILD_TARGET_ARCH=" & g_strTargetArch
906
907 str = EnvGetFirst("KBUILD_TARGET_CPU", "BUILD_TARGET_CPU")
908 ' perhaps a bit pedantic this since this isn't clearly define nor used much...
909 if (str <> "") _
910 And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then
911 EnvPrint "set BUILD_TARGET_CPU=i386"
912 EnvSet "KBUILD_TARGET_CPU", "i386"
913 MsgWarning "Found unknown KBUILD_TARGET_CPU value '" & str &"' in your environment. Setting it to 'i386'."
914 end if
915
916 str = EnvGetFirst("KBUILD_HOST", "BUILD_PLATFORM")
917 if (str <> "") _
918 And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
919 EnvPrint "set KBUILD_HOST=win"
920 EnvSet "KBUILD_HOST", "win"
921 MsgWarning "Found unknown KBUILD_HOST value '" & str &"' in your environment. Setting it to 'win32'."
922 end if
923
924 str = EnvGetFirst("KBUILD_HOST_ARCH", "BUILD_PLATFORM_ARCH")
925 if str <> "" then
926 if InStr(1, "x86|amd64", str) <= 0 then
927 str = "x86"
928 MsgWarning "Found unknown KBUILD_HOST_ARCH value '" & str &"' in your environment. Setting it to 'x86'."
929 end if
930 elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _
931 Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then
932 str = "amd64"
933 else
934 str = "x86"
935 end if
936 LogPrint " Host architecture: " & str & "."
937 Wscript.Echo " Host architecture: " & str & "."
938 EnvPrint "set KBUILD_HOST_ARCH=" & str
939 g_strHostArch = str
940
941 str = EnvGetFirst("KBUILD_HOST_CPU", "BUILD_PLATFORM_CPU")
942 ' perhaps a bit pedantic this since this isn't clearly define nor used much...
943 if (str <> "") _
944 And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then
945 EnvPrint "set KBUILD_HOST_CPU=i386"
946 EnvSet "KBUILD_HOST_CPU", "i386"
947 MsgWarning "Found unknown KBUILD_HOST_CPU value '" & str &"' in your environment. Setting it to 'i386'."
948 end if
949
950 '
951 ' Determin the location of the kBuild binaries.
952 '
953 if g_strPathkBuildBin = "" then
954 g_strPathkBuildBin = g_strPathkBuild & "/bin/win." & g_strHostArch
955 if FileExists(g_strPathkBuildBin & "/kmk.exe") = False then
956 g_strPathkBuildBin = g_strPathkBuild & "/bin/win.x86"
957 end if
958 end if
959
960 '
961 ' Perform basic validations of the kBuild installation.
962 '
963 if (FileExists(g_strPathkBuild & "/footer.kmk") = False) _
964 Or (FileExists(g_strPathkBuild & "/header.kmk") = False) _
965 Or (FileExists(g_strPathkBuild & "/rules.kmk") = False) then
966 MsgFatal "Can't find valid kBuild at '" & g_strPathkBuild & "'. Either there is an " _
967 & "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."
968 exit sub
969 end if
970 if (FileExists(g_strPathkBuildBin & "/kmk.exe") = False) _
971 Or (FileExists(g_strPathkBuildBin & "/kmk_ash.exe") = False) then
972 MsgFatal "Can't find valid kBuild binaries at '" & g_strPathkBuildBin & "'. Either there is an " _
973 & "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."
974 exit sub
975 end if
976
977 if (Shell(DosSlashes(g_strPathkBuildBin & "/kmk.exe") & " --version", True) <> 0) Then
978 MsgFatal "Can't execute '" & g_strPathkBuildBin & "/kmk.exe --version'. check configure.log for the out."
979 exit sub
980 end if
981
982 '
983 ' If PATH_DEV is set, check that it's pointing to something useful.
984 '
985 str = EnvGet("PATH_DEV")
986 g_strPathDev = str
987 if (str <> "") _
988 And False then '' @todo add some proper tests here.
989 strNew = UnixSlashes(g_strPath & "/tools")
990 EnvPrint "set PATH_DEV=" & strNew
991 EnvSet "PATH_DEV", strNew
992 MsgWarning "Found PATH_DEV='" & str &"' in your environment. Setting it to '" & strNew & "'."
993 g_strPathDev = strNew
994 end if
995 if g_strPathDev = "" then g_strPathDev = UnixSlashes(g_strPath & "/tools")
996
997 '
998 ' Write KBUILD_PATH to the environment script if necessary.
999 '
1000 if blnNeedEnvVars = True then
1001 EnvPrint "set KBUILD_PATH=" & g_strPathkBuild
1002 EnvSet "KBUILD_PATH", g_strPathkBuild
1003 EnvPrint "set PATH=" & g_strPathkBuildBin & ";%PATH%"
1004 EnvPrepend "PATH", g_strPathkBuildBin & ";"
1005 end if
1006
1007 PrintResult "kBuild", g_strPathkBuild
1008 PrintResult "kBuild binaries", g_strPathkBuildBin
1009end sub
1010
1011
1012''
1013' Checks for Visual C++ version 10 (2010).
1014sub CheckForVisualCPP(strOptVC, strOptVCCommon, blnOptVCExpressEdition)
1015 dim strPathVC, strPathVCCommon, str, str2, blnNeedMsPDB
1016 PrintHdr "Visual C++"
1017
1018 '
1019 ' Try find it...
1020 '
1021 strPathVC = ""
1022 strPathVCCommon = ""
1023 if (strPathVC = "") And (strOptVC <> "") then
1024 if CheckForVisualCPPSub(strOptVC, strOptVCCommon, blnOptVCExpressEdition) then
1025 strPathVC = strOptVC
1026 strPathVCCommon = strOptVCCommon
1027 end if
1028 end if
1029
1030 if (strPathVC = "") And (g_blnInternalFirst = True) Then
1031 strPathVC = g_strPathDev & "/win.x86/vcc/v10sp1"
1032 if CheckForVisualCPPSub(strPathVC, "", blnOptVCExpressEdition) = False then
1033 strPathVC = ""
1034 end if
1035 end if
1036
1037 if (strPathVC = "") _
1038 And (Shell("cl.exe", True) = 0) then
1039 str = Which("cl.exe")
1040 if FileExists(PathStripFilename(strClExe) & "/build.exe") then
1041 ' don't know how to deal with this cl.
1042 Warning "Ignoring DDK cl.exe (" & str & ")."
1043 else
1044 strPathVC = PathParent(PathStripFilename(str))
1045 strPathVCCommon = PathParent(strPathVC) & "/Common7"
1046 end if
1047 end if
1048
1049 if (strPathVC = "") then
1050 str = RegGetString("HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Setup\VS\ProductDir")
1051 if str <> "" Then
1052 str2 = str & "Common7"
1053 str = str & "VC"
1054 if CheckForVisualCPPSub(str, str2, blnOptVCExpressEdition) then
1055 strPathVC = str
1056 strPathVCCommon = str2
1057 end if
1058 end if
1059 end if
1060
1061 if (strPathVC = "") then
1062 str = RegGetString("HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\Setup\VS\ProductDir")
1063 if str <> "" Then
1064 str2 = str & "Common7"
1065 str = str & "VC"
1066 if CheckForVisualCPPSub(str, str2, blnOptVCExpressEdition) then
1067 strPathVC = str
1068 strPathVCCommon = str2
1069 end if
1070 end if
1071 end if
1072
1073 if (strPathVC = "") And (g_blnInternalFirst = False) Then
1074 strPathVC = g_strPathDev & "/win.x86/vcc/v10sp1"
1075 if CheckForVisualCPPSub(strPathVC, "", blnOptVCExpressEdition) = False then
1076 strPathVC = ""
1077 end if
1078 end if
1079
1080 if strPathVC = "" then
1081 MsgError "Cannot find cl.exe (Visual C++) anywhere on your system. Check the build requirements."
1082 exit sub
1083 end if
1084
1085 '
1086 ' Clean up the path and determin the VC directory.
1087 '
1088 strPathVC = UnixSlashes(PathAbs(strPathVC))
1089 g_strPathVCC = strPathVC
1090
1091 '
1092 ' Check the version.
1093 ' We'll have to make sure mspdbXX.dll is somewhere in the PATH.
1094 '
1095 if (strPathVCCommon <> "") Then
1096 EnvAppend "PATH", ";" & strPathVCCommon & "/IDE"
1097 end if
1098 if Shell(DosSlashes(strPathVC & "/bin/cl.exe"), True) <> 0 then
1099 MsgError "Executing '" & strClExe & "' (which we believe to be the Visual C++ compiler driver) failed."
1100 exit sub
1101 end if
1102
1103 if (InStr(1, g_strShellOutput, "Version 16.") <= 0) _
1104 And (InStr(1, g_strShellOutput, "Version 17.") <= 0) then
1105 MsgError "The Visual C++ compiler we found ('" & strPathVC & "') isn't 10.0 or 11.0. Check the build requirements."
1106 exit sub
1107 end if
1108
1109 '
1110 ' Ok, emit build config variables.
1111 '
1112 if InStr(1, g_strShellOutput, "Version 16.") > 0 then
1113 CfgPrint "PATH_TOOL_VCC100 := " & g_strPathVCC
1114 CfgPrint "PATH_TOOL_VCC100X86 := $(PATH_TOOL_VCC100)"
1115 CfgPrint "PATH_TOOL_VCC100AMD64 := $(PATH_TOOL_VCC100)"
1116 if LogFileExists(strPathVC, "atlmfc/include/atlbase.h") then
1117 PrintResult "Visual C++ v10 with ATL", g_strPathVCC
1118 elseif LogFileExists(g_strPathDDK, "inc/atl71/atlbase.h") _
1119 And LogFileExists(g_strPathDDK, "lib/ATL/i386/atls.lib") then
1120 CfgPrint "VBOX_WITHOUT_COMPILER_REDIST=1"
1121 CfgPrint "PATH_TOOL_VCC100_ATLMFC_INC = " & g_strPathDDK & "/inc/atl71"
1122 CfgPrint "PATH_TOOL_VCC100_ATLMFC_LIB.amd64 = " & g_strPathDDK & "/lib/ATL/amd64"
1123 CfgPrint "PATH_TOOL_VCC100_ATLMFC_LIB.x86 = " & g_strPathDDK & "/lib/ATL/i386"
1124 CfgPrint "PATH_TOOL_VCC100AMD64_ATLMFC_INC = " & g_strPathDDK & "/inc/atl71"
1125 CfgPrint "PATH_TOOL_VCC100AMD64_ATLMFC_LIB = " & g_strPathDDK & "/lib/ATL/amd64"
1126 CfgPrint "PATH_TOOL_VCC100X86_ATLMFC_INC = " & g_strPathDDK & "/inc/atl71"
1127 CfgPrint "PATH_TOOL_VCC100X86_ATLMFC_LIB = " & g_strPathDDK & "/lib/ATL/i386"
1128 PrintResult "Visual C++ v10 with DDK ATL", g_strPathVCC
1129 else
1130 CfgPrint "VBOX_WITHOUT_COMPILER_REDIST=1"
1131 DisableCOM "No ATL"
1132 PrintResult "Visual C++ v10 (or later) without ATL", g_strPathVCC
1133 end if
1134
1135 elseif InStr(1, g_strShellOutput, "Version 17.") > 0 then
1136 CfgPrint "PATH_TOOL_VCC110 := " & g_strPathVCC
1137 CfgPrint "PATH_TOOL_VCC110X86 := $(PATH_TOOL_VCC110)"
1138 CfgPrint "PATH_TOOL_VCC110AMD64 := $(PATH_TOOL_VCC110)"
1139 PrintResult "Visual C++ v11", g_strPathVCC
1140 MsgWarning "The support for Visual C++ v11 (aka 2012) is experimental"
1141
1142 else
1143 MsgError "The Visual C++ compiler we found ('" & strPathVC & "') isn't 10.0 or 11.0. Check the build requirements."
1144 exit sub
1145 end if
1146
1147 ' and the env.bat path fix.
1148 if strPathVCCommon <> "" then
1149 EnvPrint "set PATH=%PATH%;" & strPathVCCommon & "/IDE;"
1150 end if
1151end sub
1152
1153''
1154' Checks if the specified path points to a usable PSDK.
1155function CheckForVisualCPPSub(strPathVC, strPathVCCommon, blnOptVCExpressEdition)
1156 strPathVC = UnixSlashes(PathAbs(strPathVC))
1157 CheckForVisualCPPSub = False
1158 LogPrint "trying: strPathVC=" & strPathVC & " strPathVCCommon=" & strPathVCCommon & " blnOptVCExpressEdition=" & blnOptVCExpressEdition
1159 if LogFileExists(strPathVC, "bin/cl.exe") _
1160 And LogFileExists(strPathVC, "bin/link.exe") _
1161 And LogFileExists(strPathVC, "include/string.h") _
1162 And LogFileExists(strPathVC, "lib/libcmt.lib") _
1163 And LogFileExists(strPathVC, "lib/msvcrt.lib") _
1164 then
1165 if blnOptVCExpressEdition _
1166 Or ( LogFileExists(strPathVC, "atlmfc/include/atlbase.h") _
1167 And LogFileExists(strPathVC, "atlmfc/lib/atls.lib")) _
1168 Or ( LogFileExists(g_strPathDDK, "inc/atl71/atlbase.h") _
1169 And LogFileExists(g_strPathDDK, "lib/ATL/i386/atls.lib")) _
1170 Then
1171 '' @todo figure out a way we can verify the version/build!
1172 CheckForVisualCPPSub = True
1173 end if
1174 end if
1175end function
1176
1177
1178''
1179' Checks for a platform SDK that works with the compiler
1180sub CheckForPlatformSDK(strOptSDK)
1181 dim strPathPSDK, str
1182 PrintHdr "Windows Platform SDK (recent)"
1183
1184 strPathPSDK = ""
1185
1186 ' Check the supplied argument first.
1187 str = strOptSDK
1188 if str <> "" then
1189 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1190 end if
1191
1192 ' The tools location (first).
1193 if strPathPSDK = "" And g_blnInternalFirst then
1194 str = g_strPathDev & "/win.x86/sdk/v7.1"
1195 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1196 end if
1197
1198 if strPathPSDK = "" And g_blnInternalFirst then
1199 str = g_strPathDev & "/win.x86/sdk/v8.0"
1200 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1201 end if
1202
1203 ' Look for it in the environment
1204 str = EnvGet("MSSdk")
1205 if strPathPSDK = "" And str <> "" then
1206 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1207 end if
1208
1209 str = EnvGet("Mstools")
1210 if strPathPSDK = "" And str <> "" then
1211 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1212 end if
1213
1214 ' Check if there is one installed with the compiler.
1215 if strPathPSDK = "" And str <> "" then
1216 str = g_strPathVCC & "/PlatformSDK"
1217 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1218 end if
1219
1220 ' Check the registry next (ASSUMES sorting).
1221 arrSubKeys = RegEnumSubKeysRSort("HKLM", "SOFTWARE\Microsoft\Microsoft SDKs\Windows")
1222 for each strSubKey in arrSubKeys
1223 str = RegGetString("HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")
1224 if strPathPSDK = "" And str <> "" then
1225 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1226 end if
1227 Next
1228 arrSubKeys = RegEnumSubKeysRSort("HKCU", "SOFTWARE\Microsoft\Microsoft SDKs\Windows")
1229 for each strSubKey in arrSubKeys
1230 str = RegGetString("HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")
1231 if strPathPSDK = "" And str <> "" then
1232 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1233 end if
1234 Next
1235
1236 ' The tools location (post).
1237 if (strPathPSDK = "") And (g_blnInternalFirst = False) then
1238 str = g_strPathDev & "/win.x86/sdk/v7.1"
1239 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1240 end if
1241
1242 if (strPathPSDK = "") And (g_blnInternalFirst = False) then
1243 str = g_strPathDev & "/win.x86/sdk/v8.0"
1244 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1245 end if
1246
1247 ' Give up.
1248 if strPathPSDK = "" then
1249 MsgError "Cannot find a suitable Platform SDK. Check configure.log and the build requirements."
1250 exit sub
1251 end if
1252
1253 '
1254 ' Emit the config.
1255 '
1256 strPathPSDK = UnixSlashes(PathAbs(strPathPSDK))
1257 CfgPrint "PATH_SDK_WINPSDK" & g_strVerPSDK & " := " & strPathPSDK
1258 CfgPrint "VBOX_WINPSDK := WINPSDK" & g_strVerPSDK
1259
1260 PrintResult "Windows Platform SDK (v" & g_strVerPSDK & ")", strPathPSDK
1261 g_strPathPSDK = strPathPSDK
1262end sub
1263
1264''
1265' Checks if the specified path points to a usable PSDK.
1266function CheckForPlatformSDKSub(strPathPSDK)
1267 CheckForPlatformSDKSub = False
1268 LogPrint "trying: strPathPSDK=" & strPathPSDK
1269 if LogFileExists(strPathPSDK, "include/Windows.h") _
1270 And LogFileExists(strPathPSDK, "lib/Kernel32.Lib") _
1271 And LogFileExists(strPathPSDK, "lib/User32.Lib") _
1272 And LogFileExists(strPathPSDK, "bin/rc.exe") _
1273 And Shell("""" & DosSlashes(strPathPSDK & "/bin/rc.exe") & """" , True) <> 0 _
1274 then
1275 if InStr(1, g_strShellOutput, "Resource Compiler Version 6.2.") > 0 then
1276 g_strVerPSDK = "80"
1277 CheckForPlatformSDKSub = True
1278 elseif InStr(1, g_strShellOutput, "Resource Compiler Version 6.1.") > 0 then
1279 g_strVerPSDK = "71"
1280 CheckForPlatformSDKSub = True
1281 end if
1282 end if
1283end function
1284
1285
1286''
1287' Checks for a Windows 7 Driver Kit.
1288sub CheckForWinDDK(strOptDDK)
1289 dim strPathDDK, str, strSubKeys
1290 PrintHdr "Windows DDK v7.1"
1291
1292 '
1293 ' Find the DDK.
1294 '
1295 strPathDDK = ""
1296 ' The specified path.
1297 if strPathDDK = "" And strOptDDK <> "" then
1298 if CheckForWinDDKSub(strOptDDK, True) then strPathDDK = strOptDDK
1299 end if
1300
1301 ' The tools location (first).
1302 if strPathDDK = "" And g_blnInternalFirst then
1303 str = g_strPathDev & "/win.x86/ddk/7600.16385.1"
1304 if CheckForWinDDKSub(str, False) then strPathDDK = str
1305 end if
1306
1307 ' Check the environment
1308 str = EnvGet("DDK_INC_PATH")
1309 if strPathDDK = "" And str <> "" then
1310 str = PathParent(PathParent(str))
1311 if CheckForWinDDKSub(str, True) then strPathDDK = str
1312 end if
1313
1314 str = EnvGet("BASEDIR")
1315 if strPathDDK = "" And str <> "" then
1316 if CheckForWinDDKSub(str, True) then strPathDDK = str
1317 end if
1318
1319 ' Some array constants to ease the work.
1320 arrSoftwareKeys = array("SOFTWARE", "SOFTWARE\Wow6432Node")
1321 arrRoots = array("HKLM", "HKCU")
1322
1323 ' Windows 7 WDK.
1324 arrLocations = array()
1325 for each strSoftwareKey in arrSoftwareKeys
1326 for each strSubKey in RegEnumSubKeysFull("HKLM", strSoftwareKey & "\Microsoft\KitSetup\configured-kits")
1327 for each strSubKey2 in RegEnumSubKeysFull("HKLM", strSubKey)
1328 str = RegGetString("HKLM\" & strSubKey2 & "\setup-install-location")
1329 if str <> "" then
1330 arrLocations = ArrayAppend(arrLocations, PathAbsLong(str))
1331 end if
1332 next
1333 next
1334 next
1335 arrLocations = ArrayRSortStrings(arrLocations)
1336
1337 ' Check the locations we've gathered.
1338 for each str in arrLocations
1339 if strPathDDK = "" then
1340 if CheckForWinDDKSub(str, True) then strPathDDK = str
1341 end if
1342 next
1343
1344 ' The tools location (post).
1345 if (strPathDDK = "") And (g_blnInternalFirst = False) then
1346 str = g_strPathDev & "/win.x86/ddk/7600.16385.1"
1347 if CheckForWinDDKSub(str, False) then strPathDDK = str
1348 end if
1349
1350 ' Give up.
1351 if strPathDDK = "" then
1352 MsgError "Cannot find the Windows DDK v7.1. Check configure.log and the build requirements."
1353 exit sub
1354 end if
1355
1356 '
1357 ' Emit the config.
1358 '
1359 strPathDDK = UnixSlashes(PathAbs(strPathDDK))
1360 CfgPrint "PATH_SDK_WINDDK71 := " & strPathDDK
1361
1362 PrintResult "Windows DDK v7.1", strPathDDK
1363 g_strPathDDK = strPathDDK
1364end sub
1365
1366'' Quick check if the DDK is in the specified directory or not.
1367function CheckForWinDDKSub(strPathDDK, blnCheckBuild)
1368 CheckForWinDDKSub = False
1369 LogPrint "trying: strPathDDK=" & strPathDDK & " blnCheckBuild=" & blnCheckBuild
1370 if LogFileExists(strPathDDK, "inc/api/ntdef.h") _
1371 And LogFileExists(strPathDDK, "lib/win7/i386/int64.lib") _
1372 And LogFileExists(strPathDDK, "lib/wlh/i386/int64.lib") _
1373 And LogFileExists(strPathDDK, "lib/wnet/i386/int64.lib") _
1374 And LogFileExists(strPathDDK, "lib/wxp/i386/int64.lib") _
1375 And Not LogFileExists(strPathDDK, "lib/win8/i386/int64.lib") _
1376 And LogFileExists(strPathDDK, "bin/x86/rc.exe") _
1377 then
1378 if Not blnCheckBuild then
1379 CheckForWinDDKSub = True
1380 '' @todo Find better build check.
1381 elseif Shell("""" & DosSlashes(strPathDDK & "/bin/x86/rc.exe") & """" , True) <> 0 _
1382 And InStr(1, g_strShellOutput, "Resource Compiler Version 6.1.") > 0 then
1383 CheckForWinDDKSub = True
1384 end if
1385 end if
1386end function
1387
1388
1389''
1390' Finds midl.exe
1391sub CheckForMidl()
1392 dim strMidl
1393 PrintHdr "Midl.exe"
1394
1395 ' Skip if no COM/ATL.
1396 if g_blnDisableCOM then
1397 PrintResultMsg "Midl", "Skipped (" & g_strDisableCOM & ")"
1398 exit sub
1399 end if
1400
1401 if LogFileExists(g_strPathPSDK, "bin/Midl.exe") then
1402 strMidl = g_strPathPSDK & "/bin/Midl.exe"
1403 elseif LogFileExists(g_strPathVCC, "Common7/Tools/Bin/Midl.exe") then
1404 strMidl = g_strPathVCC & "/Common7/Tools/Bin/Midl.exe"
1405 elseif LogFileExists(g_strPathDDK, "bin/x86/Midl.exe") then
1406 strMidl = g_strPathDDK & "/bin/x86/Midl.exe"
1407 elseif LogFileExists(g_strPathDDK, "bin/Midl.exe") then
1408 strMidl = g_strPathDDK & "/bin/Midl.exe"
1409 elseif LogFileExists(g_strPathDev, "win.x86/bin/Midl.exe") then
1410 strMidl = g_strPathDev & "/win.x86/bin/Midl.exe"
1411 else
1412 MsgWarning "Midl.exe not found!"
1413 exit sub
1414 end if
1415
1416 CfgPrint "VBOX_MAIN_IDL := " & strMidl
1417 PrintResult "Midl.exe", strMidl
1418end sub
1419
1420
1421''
1422' Checks for a MinGW32 suitable for building the recompiler.
1423'
1424' strOptW32API is currently ignored.
1425'
1426sub CheckForMinGW32(strOptMinGW32, strOptW32API)
1427 dim strPathMingW32, strPathW32API, str
1428 PrintHdr "MinGW32 GCC v3.3.x + Binutils + Runtime + W32API"
1429
1430 '
1431 ' Find the MinGW and W32API tools.
1432 '
1433 strPathMingW32 = ""
1434 strPathW32API = ""
1435
1436 ' The specified path.
1437 if (strPathMingW32 = "") And (strOptMinGW32 <> "") then
1438 if CheckForMinGW32Sub(strOptMinGW32, strOptW32API) then
1439 strPathMingW32 = strOptMinGW32
1440 strPathW32API = strOptW32API
1441 end if
1442 end if
1443
1444 ' The tools location (first).
1445 if (strPathMingW32 = "") And (g_blnInternalFirst = True) then
1446 str = g_strPathDev & "/win.x86/mingw32/v3.3.3"
1447 str2 = g_strPathDev & "/win.x86/w32api/v2.5"
1448 if CheckForMinGW32Sub(str, str2) then
1449 strPathMingW32 = str
1450 strPathW32API = str2
1451 end if
1452 end if
1453
1454 ' See if there is any gcc around.
1455 if strPathMingW32 = "" then
1456 str = Which("mingw32-gcc.exe")
1457 if (str <> "") then
1458 str = PathParent(PathStripFilename(str))
1459 if CheckForMinGW32Sub(str, str) then strPathMingW32 = str
1460 end if
1461 end if
1462
1463 if strPathMingW32 = "" then
1464 str = Which("gcc.exe")
1465 if (str <> "") then
1466 str = PathParent(PathStripFilename(str))
1467 if CheckForMinGW32Sub(str, str) then strPathMingW32 = str
1468 end if
1469 end if
1470
1471 ' The tools location (post).
1472 if (strPathMingW32 = "") And (g_blnInternalFirst = False) then
1473 str = g_strPathDev & "/win.x86/mingw32/v3.3.3"
1474 str2 = g_strPathDev & "/win.x86/w32api/v2.5"
1475 if CheckForMinGW32Sub(str, str2) then
1476 strPathMingW32 = str
1477 strPathW32API = str2
1478 end if
1479 end if
1480
1481 ' Success?
1482 if strPathMingW32 = "" then
1483 if g_strTargetArch = "amd64" then
1484 MsgWarning "Can't locate a suitable MinGW32 installation, ignoring since we're targeting AMD64 and won't need it."
1485 elseif strOptMinGW32 = "" then
1486 MsgError "Can't locate a suitable MinGW32 installation. Try specify the path with " _
1487 & "the --with-MinGW32=<path> argument. If still no luck, consult the configure.log and the build requirements."
1488 else
1489 MsgError "Can't locate a suitable MinGW32 installation. Please consult the configure.log and the build requirements."
1490 end if
1491 exit sub
1492 end if
1493
1494 '
1495 ' Emit the config.
1496 '
1497 strPathMingW32 = UnixSlashes(PathAbs(strPathMingW32))
1498 CfgPrint "PATH_TOOL_MINGW32 := " & strPathMingW32
1499 PrintResult "MinGW32 (GCC v" & g_strSubOutput & ")", strPathMingW32
1500 if (strPathMingW32 = strPathW32API) Or strPathW32API = "" then
1501 CfgPrint "PATH_SDK_W32API := $(PATH_TOOL_MINGW32)"
1502 else
1503 CfgPrint "PATH_SDK_W32API := " & strPathW32API
1504 PrintResult "W32API", strPathW32API
1505 end if
1506end sub
1507
1508''
1509' Checks if the specified path points to an usable MinGW or not.
1510function CheckForMinGW32Sub(strPathMingW32, strPathW32API)
1511 g_strSubOutput = ""
1512 if strPathW32API = "" then strPathW32API = strPathMingW32
1513 LogPrint "trying: strPathMingW32=" &strPathMingW32 & " strPathW32API=" & strPathW32API
1514
1515 if LogFileExists(strPathMingW32, "bin/mingw32-gcc.exe") _
1516 And LogFileExists(strPathMingW32, "bin/ld.exe") _
1517 And LogFileExists(strPathMingW32, "bin/objdump.exe") _
1518 And LogFileExists(strPathMingW32, "bin/dllwrap.exe") _
1519 And LogFileExists(strPathMingW32, "bin/as.exe") _
1520 And LogFileExists(strPathMingW32, "include/string.h") _
1521 And LogFileExists(strPathMingW32, "include/_mingw.h") _
1522 And LogFileExists(strPathMingW32, "lib/dllcrt1.o") _
1523 And LogFileExists(strPathMingW32, "lib/dllcrt2.o") _
1524 And LogFileExists(strPathMingW32, "lib/libmsvcrt.a") _
1525 _
1526 And LogFileExists(strPathW32API, "lib/libkernel32.a") _
1527 And LogFileExists(strPathW32API, "include/windows.h") _
1528 then
1529 if Shell(DosSlashes(strPathMingW32 & "/bin/gcc.exe") & " --version", True) = 0 then
1530 dim offVer, iMajor, iMinor, iPatch, strVer
1531
1532 ' extract the version.
1533 strVer = ""
1534 offVer = InStr(1, g_strShellOutput, "(GCC) ")
1535 if offVer > 0 then
1536 strVer = LTrim(Mid(g_strShellOutput, offVer + Len("(GCC) ")))
1537 strVer = RTrim(Left(strVer, InStr(1, strVer, " ")))
1538 if (Mid(strVer, 2, 1) = ".") _
1539 And (Mid(strVer, 4, 1) = ".") then
1540 iMajor = Int(Left(strVer, 1)) ' Is Int() the right thing here? I want atoi()!!!
1541 iMinor = Int(Mid(strVer, 3, 1))
1542 iPatch = Int(Mid(strVer, 5))
1543 else
1544 LogPrint "Malformed version: '" & strVer & "'"
1545 strVer = ""
1546 end if
1547 end if
1548 if strVer <> "" then
1549 if (iMajor = 3) And (iMinor = 3) then
1550 CheckForMinGW32Sub = True
1551 g_strSubOutput = strVer
1552 else
1553 LogPrint "MinGW32 version '" & iMajor & "." & iMinor & "." & iPatch & "' is not supported (or configure.vbs failed to parse it correctly)."
1554 end if
1555 else
1556 LogPrint "Couldn't locate the GCC version in the output!"
1557 end if
1558
1559 else
1560 LogPrint "Failed to run gcc.exe!"
1561 end if
1562 end if
1563end function
1564
1565
1566''
1567' Checks for a MinGW-w64 suitable for building the recompiler.
1568sub CheckForMinGWw64(strOptMinGWw64)
1569 dim strPathMingWw64, str
1570 PrintHdr "MinGW-w64 GCC (unprefixed)"
1571
1572 '
1573 ' Find the MinGW-w64 tools.
1574 '
1575 strPathMingWw64 = ""
1576
1577 ' The specified path.
1578 if (strPathMingWw64 = "") And (strOptMinGWw64 <> "") then
1579 if CheckForMinGWw64Sub(strOptMinGWw64) then
1580 strPathMingWw64 = strOptMinGWw64
1581 end if
1582 end if
1583
1584 ' The tools location (first).
1585 if (strPathMinGWw64 = "") And (g_blnInternalFirst = True) then
1586 str = g_strPathDev & "/win.amd64/mingw-w64/r1"
1587 if CheckForMinGWw64Sub(str) then
1588 strPathMinGWw64 = str
1589 end if
1590 end if
1591
1592 ' See if there is any gcc around.
1593 if strPathMinGWw64 = "" then
1594 str = Which("x86_64-w64-mingw32-gcc.exe")
1595 if (str <> "") then
1596 str = PathParent(PathStripFilename(str))
1597 if CheckForMinGWw64Sub(str) then strPathMinGWw64 = str
1598 end if
1599 end if
1600
1601 if strPathMinGWw64 = "" then
1602 str = Which("gcc.exe")
1603 if (str <> "") then
1604 str = PathParent(PathStripFilename(str))
1605 if CheckForMinGWw64Sub(str) then strPathMinGWw64 = str
1606 end if
1607 end if
1608
1609 ' The tools location (post).
1610 if (strPathMinGWw64 = "") And (g_blnInternalFirst = False) then
1611 str = g_strPathDev & "/win.amd64/mingw-w64/r1"
1612 if CheckForMinGWw64Sub(str) then
1613 strPathMinGWw64 = str
1614 end if
1615 end if
1616
1617 ' Success?
1618 if strPathMinGWw64 = "" then
1619 if g_strTargetArch = "x86" then
1620 MsgWarning "Can't locate a suitable MinGW-w64 installation, ignoring since we're targeting x86 and won't need it."
1621 elseif strOptMinGWw64 = "" then
1622 MsgError "Can't locate a suitable MinGW-w64 installation. Try specify the path with " _
1623 & "the --with-MinGW-w64=<path> argument. If still no luck, consult the configure.log and the build requirements."
1624 else
1625 MsgError "Can't locate a suitable MinGW-w64 installation. Please consult the configure.log and the build requirements."
1626 end if
1627 exit sub
1628 end if
1629
1630 '
1631 ' Emit the config.
1632 '
1633 strPathMinGWw64 = UnixSlashes(PathAbs(strPathMinGWw64))
1634 CfgPrint "PATH_TOOL_MINGWW64 := " & strPathMinGWw64
1635 PrintResult "MinGW-w64 (GCC v" & g_strSubOutput & ")", strPathMinGWw64
1636end sub
1637
1638''
1639' Checks if the specified path points to an usable MinGW-w64 or not.
1640function CheckForMinGWw64Sub(strPathMinGWw64)
1641 g_strSubOutput = ""
1642 LogPrint "trying: strPathMinGWw64=" &strPathMinGWw64
1643
1644 if LogFileExists(strPathMinGWw64, "bin/gcc.exe") _
1645 And LogFileExists(strPathMinGWw64, "bin/ld.exe") _
1646 And LogFileExists(strPathMinGWw64, "bin/objdump.exe") _
1647 And LogFileExists(strPathMinGWw64, "bin/dllwrap.exe") _
1648 And LogFileExists(strPathMinGWw64, "bin/dlltool.exe") _
1649 And LogFileExists(strPathMinGWw64, "bin/as.exe") _
1650 And LogFileExists(strPathMinGWw64, "include/bfd.h") _
1651 And LogFileExists(strPathMinGWw64, "lib64/libgcc_s.a") _
1652 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/dllcrt1.o") _
1653 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/dllcrt2.o") _
1654 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/libmsvcrt.a") _
1655 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/libmsvcr100.a") _
1656 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/include/_mingw.h") _
1657 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/include/stdint.h") _
1658 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/include/windows.h") _
1659 then
1660 if Shell(DosSlashes(strPathMinGWw64 & "/bin/gcc.exe") & " -dumpversion", True) = 0 then
1661 dim offVer, iMajor, iMinor, iPatch, strVer
1662
1663 ' extract the version.
1664 strVer = Trim(Replace(Replace(g_strShellOutput, vbCr, ""), vbLf, ""))
1665 if (Mid(strVer, 2, 1) = ".") _
1666 And (Mid(strVer, 4, 1) = ".") then
1667 iMajor = Int(Left(strVer, 1)) ' Is Int() the right thing here? I want atoi()!!!
1668 iMinor = Int(Mid(strVer, 3, 1))
1669 iPatch = Int(Mid(strVer, 5))
1670 else
1671 LogPrint "Malformed version: '" & strVer & "'"
1672 strVer = ""
1673 end if
1674 if strVer <> "" then
1675 if (iMajor = 4) And (iMinor >= 4) then
1676 CheckForMinGWw64Sub = True
1677 g_strSubOutput = strVer
1678 else
1679 LogPrint "MinGW-w64 version '" & iMajor & "." & iMinor & "." & iPatch & "' is not supported (or configure.vbs failed to parse it correctly)."
1680 end if
1681 else
1682 LogPrint "Couldn't locate the GCC version in the output!"
1683 end if
1684
1685 else
1686 LogPrint "Failed to run gcc.exe!"
1687 end if
1688 end if
1689end function
1690
1691
1692''
1693' Checks for any libSDL binaries.
1694sub CheckForlibSDL(strOptlibSDL)
1695 dim strPathlibSDL, str
1696 PrintHdr "libSDL"
1697
1698 '
1699 ' Try find some SDL library.
1700 '
1701
1702 ' First, the specific location.
1703 strPathlibSDL = ""
1704 if (strPathlibSDL = "") And (strOptlibSDL <> "") then
1705 if CheckForlibSDLSub(strOptlibSDL) then strPathlibSDL = strOptlibSDL
1706 end if
1707
1708 ' The tools location (first).
1709 if (strPathlibSDL = "") And (g_blnInternalFirst = True) Then
1710 str = g_strPathDev & "/win.x86/libsdl/v1.2.11"
1711 if CheckForlibSDLSub(str) then strPathlibSDL = str
1712 end if
1713
1714 if (strPathlibSDL = "") And (g_blnInternalFirst = True) Then
1715 str = g_strPathDev & "/win.x86/libsdl/v1.2.7-InnoTek"
1716 if CheckForlibSDLSub(str) then strPathlibSDL = str
1717 end if
1718
1719 ' Poke about in the path.
1720 str = Which("SDLmain.lib")
1721 if (strPathlibSDL = "") And (str <> "") Then
1722 str = PathParent(PathStripFilename(str))
1723 if CheckForlibSDLSub(str) then strPathlibSDL = str
1724 end if
1725
1726 str = Which("SDL.dll")
1727 if (strPathlibSDL = "") And (str <> "") Then
1728 str = PathParent(PathStripFilename(str))
1729 if CheckForlibSDLSub(str) then strPathlibSDL = str
1730 end if
1731
1732 ' The tools location (post).
1733 if (strPathlibSDL = "") And (g_blnInternalFirst = False) Then
1734 str = g_strPathDev & "/win.x86/libsdl/v1.2.11"
1735 if CheckForlibSDLSub(str) then strPathlibSDL = str
1736 end if
1737
1738 if (strPathlibSDL = "") And (g_blnInternalFirst = False) Then
1739 str = g_strPathDev & "/win.x86/libsdl/v1.2.7-InnoTek"
1740 if CheckForlibSDLSub(str) then strPathlibSDL = str
1741 end if
1742
1743 ' Success?
1744 if strPathlibSDL = "" then
1745 if strOptlibSDL = "" then
1746 MsgError "Can't locate libSDL. Try specify the path with the --with-libSDL=<path> argument. " _
1747 & "If still no luck, consult the configure.log and the build requirements."
1748 else
1749 MsgError "Can't locate libSDL. Please consult the configure.log and the build requirements."
1750 end if
1751 exit sub
1752 end if
1753
1754 strPathLibSDL = UnixSlashes(PathAbs(strPathLibSDL))
1755 CfgPrint "PATH_SDK_LIBSDL := " & strPathlibSDL
1756
1757 PrintResult "libSDL", strPathlibSDL
1758end sub
1759
1760''
1761' Checks if the specified path points to an usable libSDL or not.
1762function CheckForlibSDLSub(strPathlibSDL)
1763 CheckForlibSDLSub = False
1764 LogPrint "trying: strPathlibSDL=" & strPathlibSDL
1765 if LogFileExists(strPathlibSDL, "lib/SDL.lib") _
1766 And LogFileExists(strPathlibSDL, "lib/SDLmain.lib") _
1767 And LogFileExists(strPathlibSDL, "lib/SDL.dll") _
1768 And LogFileExists(strPathlibSDL, "include/SDL.h") _
1769 And LogFileExists(strPathlibSDL, "include/SDL_syswm.h") _
1770 And LogFileExists(strPathlibSDL, "include/SDL_version.h") _
1771 then
1772 CheckForlibSDLSub = True
1773 end if
1774end function
1775
1776
1777''
1778' Checks for libxml2.
1779sub CheckForXml2(strOptXml2)
1780 dim strPathXml2, str
1781 PrintHdr "libxml2"
1782
1783 ' Skip if no COM/ATL.
1784 if g_blnDisableCOM then
1785 PrintResultMsg "libxml2", "Skipped (" & g_strDisableCOM & ")"
1786 exit sub
1787 end if
1788
1789 '
1790 ' Try find some xml2 dll/lib.
1791 '
1792 strPathXml2 = ""
1793 if (strPathXml2 = "") And (strOptXml2 <> "") then
1794 if CheckForXml2Sub(strOptXml2) then strPathXml2 = strOptXml2
1795 end if
1796
1797 if strPathXml2 = "" Then
1798 str = Which("libxml2.lib")
1799 if str <> "" Then
1800 str = PathParent(PathStripFilename(str))
1801 if CheckForXml2Sub(str) then strPathXml2 = str
1802 end if
1803 end if
1804
1805 ' Ignore failure if we're in 'internal' mode.
1806 if (strPathXml2 = "") and g_blnInternalMode then
1807 PrintResultMsg "libxml2", "ignored (internal mode)"
1808 exit sub
1809 end if
1810
1811 ' Success?
1812 if strPathXml2 = "" then
1813 if strOptXml2 = "" then
1814 MsgError "Can't locate libxml2. Try specify the path with the --with-libxml2=<path> argument. " _
1815 & "If still no luck, consult the configure.log and the build requirements."
1816 else
1817 MsgError "Can't locate libxml2. Please consult the configure.log and the build requirements."
1818 end if
1819 exit sub
1820 end if
1821
1822 strPathXml2 = UnixSlashes(PathAbs(strPathXml2))
1823 CfgPrint "SDK_VBOX_LIBXML2_INCS := " & strPathXml2 & "/include"
1824 CfgPrint "SDK_VBOX_LIBXML2_LIBS := " & strPathXml2 & "/lib/libxml2.lib"
1825
1826 PrintResult "libxml2", strPathXml2
1827end sub
1828
1829''
1830' Checks if the specified path points to an usable libxml2 or not.
1831function CheckForXml2Sub(strPathXml2)
1832 dim str
1833
1834 CheckForXml2Sub = False
1835 LogPrint "trying: strPathXml2=" & strPathXml2
1836 if LogFileExists(strPathXml2, "include/libxml/xmlexports.h") _
1837 And LogFileExists(strPathXml2, "include/libxml/xmlreader.h") _
1838 then
1839 str = LogFindFile(strPathXml2, "bin/libxml2.dll")
1840 if str <> "" then
1841 if LogFindFile(strPathXml2, "lib/libxml2.lib") <> "" then
1842 CheckForXml2Sub = True
1843 end if
1844 end if
1845 end if
1846end function
1847
1848
1849''
1850' Checks for openssl
1851sub CheckForSsl(strOptSsl, bln32Bit)
1852 dim strPathSsl, str
1853 PrintHdr "openssl"
1854
1855 strOpenssl = "openssl"
1856 if bln32Bit = True then
1857 strOpenssl = "openssl32"
1858 end if
1859
1860 '
1861 ' Try find some openssl dll/lib.
1862 '
1863 strPathSsl = ""
1864 if (strPathSsl = "") And (strOptSsl <> "") then
1865 if CheckForSslSub(strOptSsl) then strPathSsl = strOptSsl
1866 end if
1867
1868 if strPathSsl = "" Then
1869 str = Which("libssl.lib")
1870 if str <> "" Then
1871 str = PathParent(PathStripFilename(str))
1872 if CheckForSslSub(str) then strPathSsl = str
1873 end if
1874 end if
1875
1876 ' Ignore failure if we're in 'internal' mode.
1877 if (strPathSsl = "") and g_blnInternalMode then
1878 PrintResultMsg strOpenssl, "ignored (internal mode)"
1879 exit sub
1880 end if
1881
1882 ' Success?
1883 if strPathSsl = "" then
1884 if strOptSsl = "" then
1885 MsgError "Can't locate " & strOpenssl & ". " _
1886 & "Try specify the path with the --with-" & strOpenssl & "=<path> argument. " _
1887 & "If still no luck, consult the configure.log and the build requirements."
1888 else
1889 MsgError "Can't locate " & strOpenssl & ". " _
1890 & "Please consult the configure.log and the build requirements."
1891 end if
1892 exit sub
1893 end if
1894
1895 strPathSsl = UnixSlashes(PathAbs(strPathSsl))
1896 if bln32Bit = True then
1897 CfgPrint "SDK_VBOX_OPENSSL-x86_INCS := " & strPathSsl & "/include"
1898 CfgPrint "SDK_VBOX_OPENSSL-x86_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1899 CfgPrint "SDK_VBOX_BLD_OPENSSL-x86_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1900 else
1901 CfgPrint "SDK_VBOX_OPENSSL_INCS := " & strPathSsl & "/include"
1902 CfgPrint "SDK_VBOX_OPENSSL_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1903 CfgPrint "SDK_VBOX_BLD_OPENSSL_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1904 end if
1905
1906 PrintResult strOpenssl, strPathSsl
1907end sub
1908
1909''
1910' Checks if the specified path points to an usable openssl or not.
1911function CheckForSslSub(strPathSsl)
1912
1913 CheckForSslSub = False
1914 LogPrint "trying: strPathSsl=" & strPathSsl
1915 if LogFileExists(strPathSsl, "include/openssl/md5.h") _
1916 And LogFindFile(strPathSsl, "lib/libssl.lib") <> "" _
1917 then
1918 CheckForSslSub = True
1919 end if
1920end function
1921
1922
1923''
1924' Checks for libcurl
1925sub CheckForCurl(strOptCurl, bln32Bit)
1926 dim strPathCurl, str
1927 PrintHdr "libcurl"
1928
1929 strCurl = "libcurl"
1930 if bln32Bit = True then
1931 strCurl = "libcurl32"
1932 end if
1933
1934 '
1935 ' Try find some cURL dll/lib.
1936 '
1937 strPathCurl = ""
1938 if (strPathCurl = "") And (strOptCurl <> "") then
1939 if CheckForCurlSub(strOptCurl) then strPathCurl = strOptCurl
1940 end if
1941
1942 if strPathCurl = "" Then
1943 str = Which("libcurl.lib")
1944 if str <> "" Then
1945 str = PathParent(PathStripFilename(str))
1946 if CheckForCurlSub(str) then strPathCurl = str
1947 end if
1948 end if
1949
1950 ' Ignore failure if we're in 'internal' mode.
1951 if (strPathCurl = "") and g_blnInternalMode then
1952 PrintResultMsg strCurl, "ignored (internal mode)"
1953 exit sub
1954 end if
1955
1956 ' Success?
1957 if strPathCurl = "" then
1958 if strOptCurl = "" then
1959 MsgError "Can't locate " & strCurl & ". " _
1960 & "Try specify the path with the --with-" & strCurl & "=<path> argument. " _
1961 & "If still no luck, consult the configure.log and the build requirements."
1962 else
1963 MsgError "Can't locate " & strCurl & ". " _
1964 & "Please consult the configure.log and the build requirements."
1965 end if
1966 exit sub
1967 end if
1968
1969 strPathCurl = UnixSlashes(PathAbs(strPathCurl))
1970 if bln32Bit = True then
1971 CfgPrint "SDK_VBOX_LIBCURL-x86_INCS := " & strPathCurl & "/include"
1972 CfgPrint "SDK_VBOX_LIBCURL-x86_LIBS.x86 := " & strPathCurl & "/libcurl.lib"
1973 else
1974 CfgPrint "SDK_VBOX_LIBCURL_INCS := " & strPathCurl & "/include"
1975 CfgPrint "SDK_VBOX_LIBCURL_LIBS := " & strPathCurl & "/libcurl.lib"
1976 end if
1977
1978 PrintResult strCurl, strPathCurl
1979end sub
1980
1981''
1982' Checks if the specified path points to an usable libcurl or not.
1983function CheckForCurlSub(strPathCurl)
1984
1985 CheckForCurlSub = False
1986 LogPrint "trying: strPathCurl=" & strPathCurl
1987 if LogFileExists(strPathCurl, "include/curl/curl.h") _
1988 And LogFindFile(strPathCurl, "libcurl.dll") <> "" _
1989 And LogFindFile(strPathCurl, "libcurl.lib") <> "" _
1990 then
1991 CheckForCurlSub = True
1992 end if
1993end function
1994
1995
1996
1997''
1998' Checks for any Qt5 binaries.
1999sub CheckForQt(strOptQt5)
2000 PrintHdr "Qt5"
2001
2002 '
2003 ' Try to find the Qt5 installation (user specified path with --with-qt5)
2004 '
2005 strPathQt5 = ""
2006
2007 LogPrint "Checking for user specified path of Qt5 ... "
2008 if (strPathQt5 = "") And (strOptQt5 <> "") then
2009 strOptQt5 = UnixSlashes(strOptQt5)
2010 if CheckForQt5Sub(strOptQt5) then strPathQt5 = strOptQt5
2011 end if
2012
2013 ' Check the dev tools
2014 if (strPathQt5 = "") Then
2015 strPathQt5 = g_strPathDev & "/win." & g_strTargetArch & "/qt/v5.5.1-r138"
2016 if CheckForQt5Sub(strPathQt5) = False then strPathQt5 = ""
2017 end if
2018
2019 ' Display the result.
2020 if strPathQt5 = "" then
2021 PrintResultMsg "Qt5", "not found"
2022 else
2023 PrintResult "Qt5", strPathQt5
2024 end if
2025
2026 if strPathQt5 <> "" then
2027 CfgPrint "PATH_SDK_QT5 := " & strPathQt5
2028 CfgPrint "PATH_TOOL_QT5 := $(PATH_SDK_QT5)"
2029 CfgPrint "VBOX_PATH_QT := $(PATH_SDK_QT5)"
2030 end if
2031 if strPathQt5 = "" then
2032 CfgPrint "VBOX_WITH_QTGUI :="
2033 end if
2034end sub
2035
2036
2037''
2038' Checks if the specified path points to an usable Qt5 library.
2039function CheckForQt5Sub(strPathQt5)
2040
2041 CheckForQt5Sub = False
2042 LogPrint "trying: strPathQt5=" & strPathQt5
2043
2044 if LogFileExists(strPathQt5, "bin/moc.exe") _
2045 And LogFileExists(strPathQt5, "bin/uic.exe") _
2046 And LogFileExists(strPathQt5, "include/QtWidgets/qwidget.h") _
2047 And LogFileExists(strPathQt5, "include/QtWidgets/QApplication") _
2048 And LogFileExists(strPathQt5, "include/QtGui/QImage") _
2049 And LogFileExists(strPathQt5, "include/QtNetwork/QHostAddress") _
2050 And ( LogFileExists(strPathQt5, "lib/Qt5Core.lib") _
2051 Or LogFileExists(strPathQt5, "lib/Qt5CoreVBox.lib")) _
2052 And ( LogFileExists(strPathQt5, "lib/Qt5Network.lib") _
2053 Or LogFileExists(strPathQt5, "lib/Qt5NetworkVBox.lib")) _
2054 then
2055 CheckForQt5Sub = True
2056 end if
2057
2058end function
2059
2060
2061'
2062'
2063function CheckForPython(strPathPython)
2064
2065 PrintHdr "Python"
2066
2067 CheckForPython = False
2068 LogPrint "trying: strPathPython=" & strPathPython
2069
2070 if LogFileExists(strPathPython, "python.exe") then
2071 CfgPrint "VBOX_BLD_PYTHON := " & strPathPython & "\python.exe"
2072 CheckForPython = True
2073 end if
2074
2075 PrintResult "Python ", strPathPython
2076end function
2077
2078
2079'
2080'
2081function CheckForMkisofs(strFnameMkisofs)
2082
2083 PrintHdr "mkisofs"
2084
2085 CheckForMkisofs = False
2086 LogPrint "trying: strFnameMkisofs=" & strFnameMkisofs
2087
2088 if FileExists(strFnameMkisofs) = false then
2089 LogPrint "Testing '" & strFnameMkisofs & " not found"
2090 else
2091 CfgPrint "VBOX_MKISOFS := " & strFnameMkisofs
2092 CheckForMkisofs = True
2093 end if
2094
2095 PrintResult "mkisofs ", strFnameMkisofs
2096end function
2097
2098
2099''
2100' Show usage.
2101sub usage
2102 Print "Usage: cscript configure.vbs [options]"
2103 Print ""
2104 Print "Configuration:"
2105 Print " -h, --help"
2106 Print " --internal"
2107 Print " --internal-last"
2108 Print " --target-arch=x86|amd64"
2109 Print ""
2110 Print "Components:"
2111 Print " --disable-COM"
2112 Print " --disable-UDPTunnel"
2113 Print " --disable-SDL"
2114 Print ""
2115 Print "Locations:"
2116 Print " --with-kBuild=PATH "
2117 Print " --with-libSDL=PATH "
2118 Print " --with-MinGW32=PATH "
2119 Print " --with-MinGW-w64=PATH "
2120 Print " --with-Qt5=PATH "
2121 Print " --with-DDK=PATH "
2122 Print " --with-SDK=PATH "
2123 Print " --with-VC=PATH "
2124 Print " --with-VC-Common=PATH "
2125 Print " --with-VC-Express-Edition"
2126 Print " --with-W32API=PATH "
2127 Print " --with-libxml2=PATH "
2128 Print " --with-openssl=PATH "
2129 Print " --with-openssl32=PATH (only for 64-bit targets)"
2130 Print " --with-libcurl=PATH "
2131 Print " --with-libcurl32=PATH (only for 64-bit targets)"
2132 Print " --with-python=PATH "
2133 Print " --with-mkisofs=PATH "
2134end sub
2135
2136
2137''
2138' The main() like function.
2139'
2140Sub Main
2141 '
2142 ' Write the log header and check that we're not using wscript.
2143 '
2144 LogInit
2145 If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then
2146 Wscript.Echo "This script must be run under CScript."
2147 Wscript.Quit(1)
2148 End If
2149
2150 '
2151 ' Parse arguments.
2152 '
2153 strOptDDK = ""
2154 strOptDXDDK = ""
2155 strOptkBuild = ""
2156 strOptlibSDL = ""
2157 strOptMinGW32 = ""
2158 strOptMinGWw64 = ""
2159 strOptQt5 = ""
2160 strOptSDK = ""
2161 strOptVC = ""
2162 strOptVCCommon = ""
2163 blnOptVCExpressEdition = False
2164 strOptW32API = ""
2165 strOptXml2 = ""
2166 strOptSsl = ""
2167 strOptSsl32 = ""
2168 strOptCurl = ""
2169 strOptCurl32 = ""
2170 strOptPython = ""
2171 strOptMkisofs = ""
2172 blnOptDisableCOM = False
2173 blnOptDisableUDPTunnel = False
2174 blnOptDisableSDL = False
2175 for i = 1 to Wscript.Arguments.Count
2176 dim str, strArg, strPath
2177
2178 ' Separate argument and path value
2179 str = Wscript.Arguments.item(i - 1)
2180 if InStr(1, str, "=") > 0 then
2181 strArg = Mid(str, 1, InStr(1, str, "=") - 1)
2182 strPath = Mid(str, InStr(1, str, "=") + 1)
2183 if strPath = "" then MsgFatal "Syntax error! Argument #" & i & " is missing the path."
2184 else
2185 strArg = str
2186 strPath = ""
2187 end if
2188
2189 ' Process the argument
2190 select case LCase(strArg)
2191 case "--with-ddk"
2192 strOptDDK = strPath
2193 case "--with-dxsdk"
2194 MsgWarning "Ignoring --with-dxsdk (the DirectX SDK is no longer required)."
2195 case "--with-kbuild"
2196 strOptkBuild = strPath
2197 case "--with-libsdl"
2198 strOptlibSDL = strPath
2199 case "--with-mingw32"
2200 strOptMinGW32 = strPath
2201 case "--with-mingw-w64"
2202 strOptMinGWw64 = strPath
2203 case "--with-qt5"
2204 strOptQt5 = strPath
2205 case "--with-sdk"
2206 strOptSDK = strPath
2207 case "--with-vc"
2208 strOptVC = strPath
2209 case "--with-vc-common"
2210 strOptVCCommon = strPath
2211 case "--with-vc-express-edition"
2212 blnOptVCExpressEdition = True
2213 case "--with-w32api"
2214 strOptW32API = strPath
2215 case "--with-libxml2"
2216 strOptXml2 = strPath
2217 case "--with-openssl"
2218 strOptSsl = strPath
2219 case "--with-openssl32"
2220 strOptSsl32 = strPath
2221 case "--with-libcurl"
2222 strOptCurl = strPath
2223 case "--with-libcurl32"
2224 strOptCurl32 = strPath
2225 case "--with-python"
2226 strOptPython = strPath
2227 case "--with-mkisofs"
2228 strOptMkisofs = strPath
2229 case "--disable-com"
2230 blnOptDisableCOM = True
2231 case "--enable-com"
2232 blnOptDisableCOM = False
2233 case "--disable-udptunnel"
2234 blnOptDisableUDPTunnel = True
2235 case "--disable-sdl"
2236 blnOptDisableSDL = True
2237 case "--internal"
2238 g_blnInternalMode = True
2239 case "--internal-last"
2240 g_blnInternalFirst = False
2241 case "--target-arch"
2242 g_strTargetArch = strPath
2243 case "-h", "--help", "-?"
2244 usage
2245 Wscript.Quit(0)
2246 case else
2247 Wscript.echo "syntax error: Unknown option '" & str &"'."
2248 usage
2249 Wscript.Quit(1)
2250 end select
2251 next
2252
2253 '
2254 ' Initialize output files.
2255 '
2256 CfgInit
2257 EnvInit
2258
2259 '
2260 ' Check that the Shell function is sane.
2261 '
2262 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = "This works"
2263 if Shell("set TESTING_ENVIRONMENT_INHERITANC", False) <> 0 then ' The 'E' is missing on purpose (4nt).
2264 MsgFatal "shell execution test failed!"
2265 end if
2266 if g_strShellOutput <> "TESTING_ENVIRONMENT_INHERITANCE=This works" & CHR(13) & CHR(10) then
2267 Print "Shell test Test -> '" & g_strShellOutput & "'"
2268 MsgFatal "shell inheritance or shell execution isn't working right. Make sure you use cmd.exe."
2269 end if
2270 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = ""
2271 Print "Shell inheritance test: OK"
2272
2273 '
2274 ' Do the checks.
2275 '
2276 if blnOptDisableCOM = True then
2277 DisableCOM "--disable-com"
2278 end if
2279 if blnOptDisableUDPTunnel = True then
2280 DisableUDPTunnel "--disable-udptunnel"
2281 end if
2282 CheckSourcePath
2283 CheckForkBuild strOptkBuild
2284 CheckForWinDDK strOptDDK
2285 CheckForVisualCPP strOptVC, strOptVCCommon, blnOptVCExpressEdition
2286 CheckForPlatformSDK strOptSDK
2287 CheckForMidl
2288 CheckForMinGW32 strOptMinGW32, strOptW32API
2289 CheckForMinGWw64 strOptMinGWw64
2290 CfgPrint "VBOX_WITH_OPEN_WATCOM := " '' @todo look for openwatcom 1.9+
2291 EnvPrint "set PATH=%PATH%;" & g_strPath& "/tools/win." & g_strTargetArch & "/bin;" '' @todo look for yasm
2292 if blnOptDisableSDL = True then
2293 DisableSDL "--disable-sdl"
2294 else
2295 CheckForlibSDL strOptlibSDL
2296 end if
2297 ' Don't check for this library by default as it's part of the tarball
2298 ' Using an external library can add a dependency to iconv
2299 if (strOptXml2 <> "") then
2300 CheckForXml2 strOptXml2
2301 end if
2302 CheckForSsl strOptSsl, False
2303 if g_strTargetArch = "amd64" then
2304 ' 32-bit openssl required as well
2305 CheckForSsl strOptSsl32, True
2306 end if
2307 CheckForCurl strOptCurl, False
2308 if g_strTargetArch = "amd64" then
2309 ' 32-bit Curl required as well
2310 CheckForCurl strOptCurl32, True
2311 end if
2312 CheckForQt strOptQt5
2313 if (strOptPython <> "") then
2314 CheckForPython strOptPython
2315 end if
2316 if (strOptMkisofs <> "") then
2317 CheckForMkisofs strOptMkisofs
2318 end if
2319 if g_blnInternalMode then
2320 EnvPrint "call " & g_strPathDev & "/env.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9"
2321 end if
2322
2323 Print ""
2324 Print "Execute env.bat once before you start to build VBox:"
2325 Print ""
2326 Print " env.bat"
2327 Print " kmk"
2328 Print ""
2329
2330End Sub
2331
2332
2333Main
2334
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette