VirtualBox

source: vbox/trunk/configure.vbs@ 85568

Last change on this file since 85568 was 84726, checked in by vboxsync, 5 years ago

configure.vbs: if the VCC version is 10, unset the "use new VCC" flag

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Id
File size: 74.2 KB
Line 
1' $Id: configure.vbs 84726 2020-06-08 16:51:48Z 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-2020 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 CfgPrint "VBOX_WITH_NEW_VCC :="
1117 if LogFileExists(strPathVC, "atlmfc/include/atlbase.h") then
1118 PrintResult "Visual C++ v10 with ATL", g_strPathVCC
1119 elseif LogFileExists(g_strPathDDK, "inc/atl71/atlbase.h") _
1120 And LogFileExists(g_strPathDDK, "lib/ATL/i386/atls.lib") then
1121 CfgPrint "VBOX_WITHOUT_COMPILER_REDIST=1"
1122 CfgPrint "PATH_TOOL_VCC100_ATLMFC_INC = " & g_strPathDDK & "/inc/atl71"
1123 CfgPrint "PATH_TOOL_VCC100_ATLMFC_LIB.amd64 = " & g_strPathDDK & "/lib/ATL/amd64"
1124 CfgPrint "PATH_TOOL_VCC100_ATLMFC_LIB.x86 = " & g_strPathDDK & "/lib/ATL/i386"
1125 CfgPrint "PATH_TOOL_VCC100AMD64_ATLMFC_INC = " & g_strPathDDK & "/inc/atl71"
1126 CfgPrint "PATH_TOOL_VCC100AMD64_ATLMFC_LIB = " & g_strPathDDK & "/lib/ATL/amd64"
1127 CfgPrint "PATH_TOOL_VCC100X86_ATLMFC_INC = " & g_strPathDDK & "/inc/atl71"
1128 CfgPrint "PATH_TOOL_VCC100X86_ATLMFC_LIB = " & g_strPathDDK & "/lib/ATL/i386"
1129 PrintResult "Visual C++ v10 with DDK ATL", g_strPathVCC
1130 else
1131 CfgPrint "VBOX_WITHOUT_COMPILER_REDIST=1"
1132 DisableCOM "No ATL"
1133 PrintResult "Visual C++ v10 (or later) without ATL", g_strPathVCC
1134 end if
1135
1136 elseif InStr(1, g_strShellOutput, "Version 17.") > 0 then
1137 CfgPrint "PATH_TOOL_VCC110 := " & g_strPathVCC
1138 CfgPrint "PATH_TOOL_VCC110X86 := $(PATH_TOOL_VCC110)"
1139 CfgPrint "PATH_TOOL_VCC110AMD64 := $(PATH_TOOL_VCC110)"
1140 PrintResult "Visual C++ v11", g_strPathVCC
1141 MsgWarning "The support for Visual C++ v11 (aka 2012) is experimental"
1142
1143 else
1144 MsgError "The Visual C++ compiler we found ('" & strPathVC & "') isn't 10.0 or 11.0. Check the build requirements."
1145 exit sub
1146 end if
1147
1148 ' and the env.bat path fix.
1149 if strPathVCCommon <> "" then
1150 EnvPrint "set PATH=%PATH%;" & strPathVCCommon & "/IDE;"
1151 end if
1152end sub
1153
1154''
1155' Checks if the specified path points to a usable PSDK.
1156function CheckForVisualCPPSub(strPathVC, strPathVCCommon, blnOptVCExpressEdition)
1157 strPathVC = UnixSlashes(PathAbs(strPathVC))
1158 CheckForVisualCPPSub = False
1159 LogPrint "trying: strPathVC=" & strPathVC & " strPathVCCommon=" & strPathVCCommon & " blnOptVCExpressEdition=" & blnOptVCExpressEdition
1160 if LogFileExists(strPathVC, "bin/cl.exe") _
1161 And LogFileExists(strPathVC, "bin/link.exe") _
1162 And LogFileExists(strPathVC, "include/string.h") _
1163 And LogFileExists(strPathVC, "lib/libcmt.lib") _
1164 And LogFileExists(strPathVC, "lib/msvcrt.lib") _
1165 then
1166 if blnOptVCExpressEdition _
1167 Or ( LogFileExists(strPathVC, "atlmfc/include/atlbase.h") _
1168 And LogFileExists(strPathVC, "atlmfc/lib/atls.lib")) _
1169 Or ( LogFileExists(g_strPathDDK, "inc/atl71/atlbase.h") _
1170 And LogFileExists(g_strPathDDK, "lib/ATL/i386/atls.lib")) _
1171 Then
1172 '' @todo figure out a way we can verify the version/build!
1173 CheckForVisualCPPSub = True
1174 end if
1175 end if
1176end function
1177
1178
1179''
1180' Checks for a platform SDK that works with the compiler
1181sub CheckForPlatformSDK(strOptSDK)
1182 dim strPathPSDK, str
1183 PrintHdr "Windows Platform SDK (recent)"
1184
1185 strPathPSDK = ""
1186
1187 ' Check the supplied argument first.
1188 str = strOptSDK
1189 if str <> "" then
1190 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1191 end if
1192
1193 ' The tools location (first).
1194 if strPathPSDK = "" And g_blnInternalFirst then
1195 str = g_strPathDev & "/win.x86/sdk/v7.1"
1196 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1197 end if
1198
1199 if strPathPSDK = "" And g_blnInternalFirst then
1200 str = g_strPathDev & "/win.x86/sdk/v8.0"
1201 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1202 end if
1203
1204 ' Look for it in the environment
1205 str = EnvGet("MSSdk")
1206 if strPathPSDK = "" And str <> "" then
1207 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1208 end if
1209
1210 str = EnvGet("Mstools")
1211 if strPathPSDK = "" And str <> "" then
1212 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1213 end if
1214
1215 ' Check if there is one installed with the compiler.
1216 if strPathPSDK = "" And str <> "" then
1217 str = g_strPathVCC & "/PlatformSDK"
1218 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1219 end if
1220
1221 ' Check the registry next (ASSUMES sorting).
1222 arrSubKeys = RegEnumSubKeysRSort("HKLM", "SOFTWARE\Microsoft\Microsoft SDKs\Windows")
1223 for each strSubKey in arrSubKeys
1224 str = RegGetString("HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")
1225 if strPathPSDK = "" And str <> "" then
1226 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1227 end if
1228 Next
1229 arrSubKeys = RegEnumSubKeysRSort("HKCU", "SOFTWARE\Microsoft\Microsoft SDKs\Windows")
1230 for each strSubKey in arrSubKeys
1231 str = RegGetString("HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")
1232 if strPathPSDK = "" And str <> "" then
1233 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1234 end if
1235 Next
1236
1237 ' The tools location (post).
1238 if (strPathPSDK = "") And (g_blnInternalFirst = False) then
1239 str = g_strPathDev & "/win.x86/sdk/v7.1"
1240 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1241 end if
1242
1243 if (strPathPSDK = "") And (g_blnInternalFirst = False) then
1244 str = g_strPathDev & "/win.x86/sdk/v8.0"
1245 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1246 end if
1247
1248 ' Give up.
1249 if strPathPSDK = "" then
1250 MsgError "Cannot find a suitable Platform SDK. Check configure.log and the build requirements."
1251 exit sub
1252 end if
1253
1254 '
1255 ' Emit the config.
1256 '
1257 strPathPSDK = UnixSlashes(PathAbs(strPathPSDK))
1258 CfgPrint "PATH_SDK_WINPSDK" & g_strVerPSDK & " := " & strPathPSDK
1259 CfgPrint "VBOX_WINPSDK := WINPSDK" & g_strVerPSDK
1260
1261 PrintResult "Windows Platform SDK (v" & g_strVerPSDK & ")", strPathPSDK
1262 g_strPathPSDK = strPathPSDK
1263end sub
1264
1265''
1266' Checks if the specified path points to a usable PSDK.
1267function CheckForPlatformSDKSub(strPathPSDK)
1268 CheckForPlatformSDKSub = False
1269 LogPrint "trying: strPathPSDK=" & strPathPSDK
1270 if LogFileExists(strPathPSDK, "include/Windows.h") _
1271 And LogFileExists(strPathPSDK, "lib/Kernel32.Lib") _
1272 And LogFileExists(strPathPSDK, "lib/User32.Lib") _
1273 And LogFileExists(strPathPSDK, "bin/rc.exe") _
1274 And Shell("""" & DosSlashes(strPathPSDK & "/bin/rc.exe") & """" , True) <> 0 _
1275 then
1276 if InStr(1, g_strShellOutput, "Resource Compiler Version 6.2.") > 0 then
1277 g_strVerPSDK = "80"
1278 CheckForPlatformSDKSub = True
1279 elseif InStr(1, g_strShellOutput, "Resource Compiler Version 6.1.") > 0 then
1280 g_strVerPSDK = "71"
1281 CheckForPlatformSDKSub = True
1282 end if
1283 end if
1284end function
1285
1286
1287''
1288' Checks for a Windows 7 Driver Kit.
1289sub CheckForWinDDK(strOptDDK)
1290 dim strPathDDK, str, strSubKeys
1291 PrintHdr "Windows DDK v7.1"
1292
1293 '
1294 ' Find the DDK.
1295 '
1296 strPathDDK = ""
1297 ' The specified path.
1298 if strPathDDK = "" And strOptDDK <> "" then
1299 if CheckForWinDDKSub(strOptDDK, True) then strPathDDK = strOptDDK
1300 end if
1301
1302 ' The tools location (first).
1303 if strPathDDK = "" And g_blnInternalFirst then
1304 str = g_strPathDev & "/win.x86/ddk/7600.16385.1"
1305 if CheckForWinDDKSub(str, False) then strPathDDK = str
1306 end if
1307
1308 ' Check the environment
1309 str = EnvGet("DDK_INC_PATH")
1310 if strPathDDK = "" And str <> "" then
1311 str = PathParent(PathParent(str))
1312 if CheckForWinDDKSub(str, True) then strPathDDK = str
1313 end if
1314
1315 str = EnvGet("BASEDIR")
1316 if strPathDDK = "" And str <> "" then
1317 if CheckForWinDDKSub(str, True) then strPathDDK = str
1318 end if
1319
1320 ' Some array constants to ease the work.
1321 arrSoftwareKeys = array("SOFTWARE", "SOFTWARE\Wow6432Node")
1322 arrRoots = array("HKLM", "HKCU")
1323
1324 ' Windows 7 WDK.
1325 arrLocations = array()
1326 for each strSoftwareKey in arrSoftwareKeys
1327 for each strSubKey in RegEnumSubKeysFull("HKLM", strSoftwareKey & "\Microsoft\KitSetup\configured-kits")
1328 for each strSubKey2 in RegEnumSubKeysFull("HKLM", strSubKey)
1329 str = RegGetString("HKLM\" & strSubKey2 & "\setup-install-location")
1330 if str <> "" then
1331 arrLocations = ArrayAppend(arrLocations, PathAbsLong(str))
1332 end if
1333 next
1334 next
1335 next
1336 arrLocations = ArrayRSortStrings(arrLocations)
1337
1338 ' Check the locations we've gathered.
1339 for each str in arrLocations
1340 if strPathDDK = "" then
1341 if CheckForWinDDKSub(str, True) then strPathDDK = str
1342 end if
1343 next
1344
1345 ' The tools location (post).
1346 if (strPathDDK = "") And (g_blnInternalFirst = False) then
1347 str = g_strPathDev & "/win.x86/ddk/7600.16385.1"
1348 if CheckForWinDDKSub(str, False) then strPathDDK = str
1349 end if
1350
1351 ' Give up.
1352 if strPathDDK = "" then
1353 MsgError "Cannot find the Windows DDK v7.1. Check configure.log and the build requirements."
1354 exit sub
1355 end if
1356
1357 '
1358 ' Emit the config.
1359 '
1360 strPathDDK = UnixSlashes(PathAbs(strPathDDK))
1361 CfgPrint "PATH_SDK_WINDDK71 := " & strPathDDK
1362
1363 PrintResult "Windows DDK v7.1", strPathDDK
1364 g_strPathDDK = strPathDDK
1365end sub
1366
1367'' Quick check if the DDK is in the specified directory or not.
1368function CheckForWinDDKSub(strPathDDK, blnCheckBuild)
1369 CheckForWinDDKSub = False
1370 LogPrint "trying: strPathDDK=" & strPathDDK & " blnCheckBuild=" & blnCheckBuild
1371 if LogFileExists(strPathDDK, "inc/api/ntdef.h") _
1372 And LogFileExists(strPathDDK, "lib/win7/i386/int64.lib") _
1373 And LogFileExists(strPathDDK, "lib/wlh/i386/int64.lib") _
1374 And LogFileExists(strPathDDK, "lib/wnet/i386/int64.lib") _
1375 And LogFileExists(strPathDDK, "lib/wxp/i386/int64.lib") _
1376 And Not LogFileExists(strPathDDK, "lib/win8/i386/int64.lib") _
1377 And LogFileExists(strPathDDK, "bin/x86/rc.exe") _
1378 then
1379 if Not blnCheckBuild then
1380 CheckForWinDDKSub = True
1381 '' @todo Find better build check.
1382 elseif Shell("""" & DosSlashes(strPathDDK & "/bin/x86/rc.exe") & """" , True) <> 0 _
1383 And InStr(1, g_strShellOutput, "Resource Compiler Version 6.1.") > 0 then
1384 CheckForWinDDKSub = True
1385 end if
1386 end if
1387end function
1388
1389
1390''
1391' Finds midl.exe
1392sub CheckForMidl()
1393 dim strMidl
1394 PrintHdr "Midl.exe"
1395
1396 ' Skip if no COM/ATL.
1397 if g_blnDisableCOM then
1398 PrintResultMsg "Midl", "Skipped (" & g_strDisableCOM & ")"
1399 exit sub
1400 end if
1401
1402 if LogFileExists(g_strPathPSDK, "bin/Midl.exe") then
1403 strMidl = g_strPathPSDK & "/bin/Midl.exe"
1404 elseif LogFileExists(g_strPathVCC, "Common7/Tools/Bin/Midl.exe") then
1405 strMidl = g_strPathVCC & "/Common7/Tools/Bin/Midl.exe"
1406 elseif LogFileExists(g_strPathDDK, "bin/x86/Midl.exe") then
1407 strMidl = g_strPathDDK & "/bin/x86/Midl.exe"
1408 elseif LogFileExists(g_strPathDDK, "bin/Midl.exe") then
1409 strMidl = g_strPathDDK & "/bin/Midl.exe"
1410 elseif LogFileExists(g_strPathDev, "win.x86/bin/Midl.exe") then
1411 strMidl = g_strPathDev & "/win.x86/bin/Midl.exe"
1412 else
1413 MsgWarning "Midl.exe not found!"
1414 exit sub
1415 end if
1416
1417 CfgPrint "VBOX_MAIN_IDL := " & strMidl
1418 PrintResult "Midl.exe", strMidl
1419end sub
1420
1421
1422''
1423' Checks for a MinGW32 suitable for building the recompiler.
1424'
1425' strOptW32API is currently ignored.
1426'
1427sub CheckForMinGW32(strOptMinGW32, strOptW32API)
1428 dim strPathMingW32, strPathW32API, str
1429 PrintHdr "MinGW32 GCC v3.3.x + Binutils + Runtime + W32API"
1430
1431 '
1432 ' Find the MinGW and W32API tools.
1433 '
1434 strPathMingW32 = ""
1435 strPathW32API = ""
1436
1437 ' The specified path.
1438 if (strPathMingW32 = "") And (strOptMinGW32 <> "") then
1439 if CheckForMinGW32Sub(strOptMinGW32, strOptW32API) then
1440 strPathMingW32 = strOptMinGW32
1441 strPathW32API = strOptW32API
1442 end if
1443 end if
1444
1445 ' The tools location (first).
1446 if (strPathMingW32 = "") And (g_blnInternalFirst = True) then
1447 str = g_strPathDev & "/win.x86/mingw32/v3.3.3"
1448 str2 = g_strPathDev & "/win.x86/w32api/v2.5"
1449 if CheckForMinGW32Sub(str, str2) then
1450 strPathMingW32 = str
1451 strPathW32API = str2
1452 end if
1453 end if
1454
1455 ' See if there is any gcc around.
1456 if strPathMingW32 = "" then
1457 str = Which("mingw32-gcc.exe")
1458 if (str <> "") then
1459 str = PathParent(PathStripFilename(str))
1460 if CheckForMinGW32Sub(str, str) then strPathMingW32 = str
1461 end if
1462 end if
1463
1464 if strPathMingW32 = "" then
1465 str = Which("gcc.exe")
1466 if (str <> "") then
1467 str = PathParent(PathStripFilename(str))
1468 if CheckForMinGW32Sub(str, str) then strPathMingW32 = str
1469 end if
1470 end if
1471
1472 ' The tools location (post).
1473 if (strPathMingW32 = "") And (g_blnInternalFirst = False) then
1474 str = g_strPathDev & "/win.x86/mingw32/v3.3.3"
1475 str2 = g_strPathDev & "/win.x86/w32api/v2.5"
1476 if CheckForMinGW32Sub(str, str2) then
1477 strPathMingW32 = str
1478 strPathW32API = str2
1479 end if
1480 end if
1481
1482 ' Success?
1483 if strPathMingW32 = "" then
1484 if g_strTargetArch = "amd64" then
1485 MsgWarning "Can't locate a suitable MinGW32 installation, ignoring since we're targeting AMD64 and won't need it."
1486 elseif strOptMinGW32 = "" then
1487 MsgError "Can't locate a suitable MinGW32 installation. Try specify the path with " _
1488 & "the --with-MinGW32=<path> argument. If still no luck, consult the configure.log and the build requirements."
1489 else
1490 MsgError "Can't locate a suitable MinGW32 installation. Please consult the configure.log and the build requirements."
1491 end if
1492 exit sub
1493 end if
1494
1495 '
1496 ' Emit the config.
1497 '
1498 strPathMingW32 = UnixSlashes(PathAbs(strPathMingW32))
1499 CfgPrint "PATH_TOOL_MINGW32 := " & strPathMingW32
1500 PrintResult "MinGW32 (GCC v" & g_strSubOutput & ")", strPathMingW32
1501 if (strPathMingW32 = strPathW32API) Or strPathW32API = "" then
1502 CfgPrint "PATH_SDK_W32API := $(PATH_TOOL_MINGW32)"
1503 else
1504 CfgPrint "PATH_SDK_W32API := " & strPathW32API
1505 PrintResult "W32API", strPathW32API
1506 end if
1507end sub
1508
1509''
1510' Checks if the specified path points to an usable MinGW or not.
1511function CheckForMinGW32Sub(strPathMingW32, strPathW32API)
1512 g_strSubOutput = ""
1513 if strPathW32API = "" then strPathW32API = strPathMingW32
1514 LogPrint "trying: strPathMingW32=" &strPathMingW32 & " strPathW32API=" & strPathW32API
1515
1516 if LogFileExists(strPathMingW32, "bin/mingw32-gcc.exe") _
1517 And LogFileExists(strPathMingW32, "bin/ld.exe") _
1518 And LogFileExists(strPathMingW32, "bin/objdump.exe") _
1519 And LogFileExists(strPathMingW32, "bin/dllwrap.exe") _
1520 And LogFileExists(strPathMingW32, "bin/as.exe") _
1521 And LogFileExists(strPathMingW32, "include/string.h") _
1522 And LogFileExists(strPathMingW32, "include/_mingw.h") _
1523 And LogFileExists(strPathMingW32, "lib/dllcrt1.o") _
1524 And LogFileExists(strPathMingW32, "lib/dllcrt2.o") _
1525 And LogFileExists(strPathMingW32, "lib/libmsvcrt.a") _
1526 _
1527 And LogFileExists(strPathW32API, "lib/libkernel32.a") _
1528 And LogFileExists(strPathW32API, "include/windows.h") _
1529 then
1530 if Shell(DosSlashes(strPathMingW32 & "/bin/gcc.exe") & " --version", True) = 0 then
1531 dim offVer, iMajor, iMinor, iPatch, strVer
1532
1533 ' extract the version.
1534 strVer = ""
1535 offVer = InStr(1, g_strShellOutput, "(GCC) ")
1536 if offVer > 0 then
1537 strVer = LTrim(Mid(g_strShellOutput, offVer + Len("(GCC) ")))
1538 strVer = RTrim(Left(strVer, InStr(1, strVer, " ")))
1539 if (Mid(strVer, 2, 1) = ".") _
1540 And (Mid(strVer, 4, 1) = ".") then
1541 iMajor = Int(Left(strVer, 1)) ' Is Int() the right thing here? I want atoi()!!!
1542 iMinor = Int(Mid(strVer, 3, 1))
1543 iPatch = Int(Mid(strVer, 5))
1544 else
1545 LogPrint "Malformed version: '" & strVer & "'"
1546 strVer = ""
1547 end if
1548 end if
1549 if strVer <> "" then
1550 if (iMajor = 3) And (iMinor = 3) then
1551 CheckForMinGW32Sub = True
1552 g_strSubOutput = strVer
1553 else
1554 LogPrint "MinGW32 version '" & iMajor & "." & iMinor & "." & iPatch & "' is not supported (or configure.vbs failed to parse it correctly)."
1555 end if
1556 else
1557 LogPrint "Couldn't locate the GCC version in the output!"
1558 end if
1559
1560 else
1561 LogPrint "Failed to run gcc.exe!"
1562 end if
1563 end if
1564end function
1565
1566
1567''
1568' Checks for a MinGW-w64 suitable for building the recompiler.
1569sub CheckForMinGWw64(strOptMinGWw64)
1570 dim strPathMingWw64, str
1571 PrintHdr "MinGW-w64 GCC (unprefixed)"
1572
1573 '
1574 ' Find the MinGW-w64 tools.
1575 '
1576 strPathMingWw64 = ""
1577
1578 ' The specified path.
1579 if (strPathMingWw64 = "") And (strOptMinGWw64 <> "") then
1580 if CheckForMinGWw64Sub(strOptMinGWw64) then
1581 strPathMingWw64 = strOptMinGWw64
1582 end if
1583 end if
1584
1585 ' The tools location (first).
1586 if (strPathMinGWw64 = "") And (g_blnInternalFirst = True) then
1587 str = g_strPathDev & "/win.amd64/mingw-w64/r1"
1588 if CheckForMinGWw64Sub(str) then
1589 strPathMinGWw64 = str
1590 end if
1591 end if
1592
1593 ' See if there is any gcc around.
1594 if strPathMinGWw64 = "" then
1595 str = Which("x86_64-w64-mingw32-gcc.exe")
1596 if (str <> "") then
1597 str = PathParent(PathStripFilename(str))
1598 if CheckForMinGWw64Sub(str) then strPathMinGWw64 = str
1599 end if
1600 end if
1601
1602 if strPathMinGWw64 = "" then
1603 str = Which("gcc.exe")
1604 if (str <> "") then
1605 str = PathParent(PathStripFilename(str))
1606 if CheckForMinGWw64Sub(str) then strPathMinGWw64 = str
1607 end if
1608 end if
1609
1610 ' The tools location (post).
1611 if (strPathMinGWw64 = "") And (g_blnInternalFirst = False) then
1612 str = g_strPathDev & "/win.amd64/mingw-w64/r1"
1613 if CheckForMinGWw64Sub(str) then
1614 strPathMinGWw64 = str
1615 end if
1616 end if
1617
1618 ' Success?
1619 if strPathMinGWw64 = "" then
1620 if g_strTargetArch = "x86" then
1621 MsgWarning "Can't locate a suitable MinGW-w64 installation, ignoring since we're targeting x86 and won't need it."
1622 elseif strOptMinGWw64 = "" then
1623 MsgError "Can't locate a suitable MinGW-w64 installation. Try specify the path with " _
1624 & "the --with-MinGW-w64=<path> argument. If still no luck, consult the configure.log and the build requirements."
1625 else
1626 MsgError "Can't locate a suitable MinGW-w64 installation. Please consult the configure.log and the build requirements."
1627 end if
1628 exit sub
1629 end if
1630
1631 '
1632 ' Emit the config.
1633 '
1634 strPathMinGWw64 = UnixSlashes(PathAbs(strPathMinGWw64))
1635 CfgPrint "PATH_TOOL_MINGWW64 := " & strPathMinGWw64
1636 PrintResult "MinGW-w64 (GCC v" & g_strSubOutput & ")", strPathMinGWw64
1637end sub
1638
1639''
1640' Checks if the specified path points to an usable MinGW-w64 or not.
1641function CheckForMinGWw64Sub(strPathMinGWw64)
1642 g_strSubOutput = ""
1643 LogPrint "trying: strPathMinGWw64=" &strPathMinGWw64
1644
1645 if LogFileExists(strPathMinGWw64, "bin/gcc.exe") _
1646 And LogFileExists(strPathMinGWw64, "bin/ld.exe") _
1647 And LogFileExists(strPathMinGWw64, "bin/objdump.exe") _
1648 And LogFileExists(strPathMinGWw64, "bin/dllwrap.exe") _
1649 And LogFileExists(strPathMinGWw64, "bin/dlltool.exe") _
1650 And LogFileExists(strPathMinGWw64, "bin/as.exe") _
1651 And LogFileExists(strPathMinGWw64, "include/bfd.h") _
1652 And LogFileExists(strPathMinGWw64, "lib64/libgcc_s.a") _
1653 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/dllcrt1.o") _
1654 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/dllcrt2.o") _
1655 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/libmsvcrt.a") _
1656 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/libmsvcr100.a") _
1657 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/include/_mingw.h") _
1658 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/include/stdint.h") _
1659 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/include/windows.h") _
1660 then
1661 if Shell(DosSlashes(strPathMinGWw64 & "/bin/gcc.exe") & " -dumpversion", True) = 0 then
1662 dim offVer, iMajor, iMinor, iPatch, strVer
1663
1664 ' extract the version.
1665 strVer = Trim(Replace(Replace(g_strShellOutput, vbCr, ""), vbLf, ""))
1666 if (Mid(strVer, 2, 1) = ".") _
1667 And (Mid(strVer, 4, 1) = ".") then
1668 iMajor = Int(Left(strVer, 1)) ' Is Int() the right thing here? I want atoi()!!!
1669 iMinor = Int(Mid(strVer, 3, 1))
1670 iPatch = Int(Mid(strVer, 5))
1671 else
1672 LogPrint "Malformed version: '" & strVer & "'"
1673 strVer = ""
1674 end if
1675 if strVer <> "" then
1676 if (iMajor = 4) And (iMinor >= 4) then
1677 CheckForMinGWw64Sub = True
1678 g_strSubOutput = strVer
1679 else
1680 LogPrint "MinGW-w64 version '" & iMajor & "." & iMinor & "." & iPatch & "' is not supported (or configure.vbs failed to parse it correctly)."
1681 end if
1682 else
1683 LogPrint "Couldn't locate the GCC version in the output!"
1684 end if
1685
1686 else
1687 LogPrint "Failed to run gcc.exe!"
1688 end if
1689 end if
1690end function
1691
1692
1693''
1694' Checks for any libSDL binaries.
1695sub CheckForlibSDL(strOptlibSDL)
1696 dim strPathlibSDL, str
1697 PrintHdr "libSDL"
1698
1699 '
1700 ' Try find some SDL library.
1701 '
1702
1703 ' First, the specific location.
1704 strPathlibSDL = ""
1705 if (strPathlibSDL = "") And (strOptlibSDL <> "") then
1706 if CheckForlibSDLSub(strOptlibSDL) then strPathlibSDL = strOptlibSDL
1707 end if
1708
1709 ' The tools location (first).
1710 if (strPathlibSDL = "") And (g_blnInternalFirst = True) Then
1711 str = g_strPathDev & "/win.x86/libsdl/v1.2.11"
1712 if CheckForlibSDLSub(str) then strPathlibSDL = str
1713 end if
1714
1715 if (strPathlibSDL = "") And (g_blnInternalFirst = True) Then
1716 str = g_strPathDev & "/win.x86/libsdl/v1.2.7-InnoTek"
1717 if CheckForlibSDLSub(str) then strPathlibSDL = str
1718 end if
1719
1720 ' Poke about in the path.
1721 str = Which("SDLmain.lib")
1722 if (strPathlibSDL = "") And (str <> "") Then
1723 str = PathParent(PathStripFilename(str))
1724 if CheckForlibSDLSub(str) then strPathlibSDL = str
1725 end if
1726
1727 str = Which("SDL.dll")
1728 if (strPathlibSDL = "") And (str <> "") Then
1729 str = PathParent(PathStripFilename(str))
1730 if CheckForlibSDLSub(str) then strPathlibSDL = str
1731 end if
1732
1733 ' The tools location (post).
1734 if (strPathlibSDL = "") And (g_blnInternalFirst = False) Then
1735 str = g_strPathDev & "/win.x86/libsdl/v1.2.11"
1736 if CheckForlibSDLSub(str) then strPathlibSDL = str
1737 end if
1738
1739 if (strPathlibSDL = "") And (g_blnInternalFirst = False) Then
1740 str = g_strPathDev & "/win.x86/libsdl/v1.2.7-InnoTek"
1741 if CheckForlibSDLSub(str) then strPathlibSDL = str
1742 end if
1743
1744 ' Success?
1745 if strPathlibSDL = "" then
1746 if strOptlibSDL = "" then
1747 MsgError "Can't locate libSDL. Try specify the path with the --with-libSDL=<path> argument. " _
1748 & "If still no luck, consult the configure.log and the build requirements."
1749 else
1750 MsgError "Can't locate libSDL. Please consult the configure.log and the build requirements."
1751 end if
1752 exit sub
1753 end if
1754
1755 strPathLibSDL = UnixSlashes(PathAbs(strPathLibSDL))
1756 CfgPrint "PATH_SDK_LIBSDL := " & strPathlibSDL
1757
1758 PrintResult "libSDL", strPathlibSDL
1759end sub
1760
1761''
1762' Checks if the specified path points to an usable libSDL or not.
1763function CheckForlibSDLSub(strPathlibSDL)
1764 CheckForlibSDLSub = False
1765 LogPrint "trying: strPathlibSDL=" & strPathlibSDL
1766 if LogFileExists(strPathlibSDL, "lib/SDL.lib") _
1767 And LogFileExists(strPathlibSDL, "lib/SDLmain.lib") _
1768 And LogFileExists(strPathlibSDL, "lib/SDL.dll") _
1769 And LogFileExists(strPathlibSDL, "include/SDL.h") _
1770 And LogFileExists(strPathlibSDL, "include/SDL_syswm.h") _
1771 And LogFileExists(strPathlibSDL, "include/SDL_version.h") _
1772 then
1773 CheckForlibSDLSub = True
1774 end if
1775end function
1776
1777
1778''
1779' Checks for libxml2.
1780sub CheckForXml2(strOptXml2)
1781 dim strPathXml2, str
1782 PrintHdr "libxml2"
1783
1784 ' Skip if no COM/ATL.
1785 if g_blnDisableCOM then
1786 PrintResultMsg "libxml2", "Skipped (" & g_strDisableCOM & ")"
1787 exit sub
1788 end if
1789
1790 '
1791 ' Try find some xml2 dll/lib.
1792 '
1793 strPathXml2 = ""
1794 if (strPathXml2 = "") And (strOptXml2 <> "") then
1795 if CheckForXml2Sub(strOptXml2) then strPathXml2 = strOptXml2
1796 end if
1797
1798 if strPathXml2 = "" Then
1799 str = Which("libxml2.lib")
1800 if str <> "" Then
1801 str = PathParent(PathStripFilename(str))
1802 if CheckForXml2Sub(str) then strPathXml2 = str
1803 end if
1804 end if
1805
1806 ' Ignore failure if we're in 'internal' mode.
1807 if (strPathXml2 = "") and g_blnInternalMode then
1808 PrintResultMsg "libxml2", "ignored (internal mode)"
1809 exit sub
1810 end if
1811
1812 ' Success?
1813 if strPathXml2 = "" then
1814 if strOptXml2 = "" then
1815 MsgError "Can't locate libxml2. Try specify the path with the --with-libxml2=<path> argument. " _
1816 & "If still no luck, consult the configure.log and the build requirements."
1817 else
1818 MsgError "Can't locate libxml2. Please consult the configure.log and the build requirements."
1819 end if
1820 exit sub
1821 end if
1822
1823 strPathXml2 = UnixSlashes(PathAbs(strPathXml2))
1824 CfgPrint "SDK_VBOX_LIBXML2_DEFS := _REENTRANT"
1825 CfgPrint "SDK_VBOX_LIBXML2_INCS := " & strPathXml2 & "/include"
1826 CfgPrint "SDK_VBOX_LIBXML2_LIBS := " & strPathXml2 & "/lib/libxml2.lib"
1827
1828 PrintResult "libxml2", strPathXml2
1829end sub
1830
1831''
1832' Checks if the specified path points to an usable libxml2 or not.
1833function CheckForXml2Sub(strPathXml2)
1834 dim str
1835
1836 CheckForXml2Sub = False
1837 LogPrint "trying: strPathXml2=" & strPathXml2
1838 if LogFileExists(strPathXml2, "include/libxml/xmlexports.h") _
1839 And LogFileExists(strPathXml2, "include/libxml/xmlreader.h") _
1840 then
1841 str = LogFindFile(strPathXml2, "bin/libxml2.dll")
1842 if str <> "" then
1843 if LogFindFile(strPathXml2, "lib/libxml2.lib") <> "" then
1844 CheckForXml2Sub = True
1845 end if
1846 end if
1847 end if
1848end function
1849
1850
1851''
1852' Checks for openssl
1853sub CheckForSsl(strOptSsl, bln32Bit)
1854 dim strPathSsl, str
1855 PrintHdr "openssl"
1856
1857 strOpenssl = "openssl"
1858 if bln32Bit = True then
1859 strOpenssl = "openssl32"
1860 end if
1861
1862 '
1863 ' Try find some openssl dll/lib.
1864 '
1865 strPathSsl = ""
1866 if (strPathSsl = "") And (strOptSsl <> "") then
1867 if CheckForSslSub(strOptSsl) then strPathSsl = strOptSsl
1868 end if
1869
1870 if strPathSsl = "" Then
1871 str = Which("libssl.lib")
1872 if str <> "" Then
1873 str = PathParent(PathStripFilename(str))
1874 if CheckForSslSub(str) then strPathSsl = str
1875 end if
1876 end if
1877
1878 ' Ignore failure if we're in 'internal' mode.
1879 if (strPathSsl = "") and g_blnInternalMode then
1880 PrintResultMsg strOpenssl, "ignored (internal mode)"
1881 exit sub
1882 end if
1883
1884 ' Success?
1885 if strPathSsl = "" then
1886 if strOptSsl = "" then
1887 MsgError "Can't locate " & strOpenssl & ". " _
1888 & "Try specify the path with the --with-" & strOpenssl & "=<path> argument. " _
1889 & "If still no luck, consult the configure.log and the build requirements."
1890 else
1891 MsgError "Can't locate " & strOpenssl & ". " _
1892 & "Please consult the configure.log and the build requirements."
1893 end if
1894 exit sub
1895 end if
1896
1897 strPathSsl = UnixSlashes(PathAbs(strPathSsl))
1898 if bln32Bit = True then
1899 CfgPrint "SDK_VBOX_OPENSSL-x86_INCS := " & strPathSsl & "/include"
1900 CfgPrint "SDK_VBOX_OPENSSL-x86_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1901 CfgPrint "SDK_VBOX_BLD_OPENSSL-x86_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1902 else
1903 CfgPrint "SDK_VBOX_OPENSSL_INCS := " & strPathSsl & "/include"
1904 CfgPrint "SDK_VBOX_OPENSSL_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1905 CfgPrint "SDK_VBOX_BLD_OPENSSL_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1906 end if
1907
1908 PrintResult strOpenssl, strPathSsl
1909end sub
1910
1911''
1912' Checks if the specified path points to an usable openssl or not.
1913function CheckForSslSub(strPathSsl)
1914
1915 CheckForSslSub = False
1916 LogPrint "trying: strPathSsl=" & strPathSsl
1917 if LogFileExists(strPathSsl, "include/openssl/md5.h") _
1918 And LogFindFile(strPathSsl, "lib/libssl.lib") <> "" _
1919 then
1920 CheckForSslSub = True
1921 end if
1922end function
1923
1924
1925''
1926' Checks for libcurl
1927sub CheckForCurl(strOptCurl, bln32Bit)
1928 dim strPathCurl, str
1929 PrintHdr "libcurl"
1930
1931 strCurl = "libcurl"
1932 if bln32Bit = True then
1933 strCurl = "libcurl32"
1934 end if
1935
1936 '
1937 ' Try find some cURL dll/lib.
1938 '
1939 strPathCurl = ""
1940 if (strPathCurl = "") And (strOptCurl <> "") then
1941 if CheckForCurlSub(strOptCurl) then strPathCurl = strOptCurl
1942 end if
1943
1944 if strPathCurl = "" Then
1945 str = Which("libcurl.lib")
1946 if str <> "" Then
1947 str = PathParent(PathStripFilename(str))
1948 if CheckForCurlSub(str) then strPathCurl = str
1949 end if
1950 end if
1951
1952 ' Ignore failure if we're in 'internal' mode.
1953 if (strPathCurl = "") and g_blnInternalMode then
1954 PrintResultMsg strCurl, "ignored (internal mode)"
1955 exit sub
1956 end if
1957
1958 ' Success?
1959 if strPathCurl = "" then
1960 if strOptCurl = "" then
1961 MsgError "Can't locate " & strCurl & ". " _
1962 & "Try specify the path with the --with-" & strCurl & "=<path> argument. " _
1963 & "If still no luck, consult the configure.log and the build requirements."
1964 else
1965 MsgError "Can't locate " & strCurl & ". " _
1966 & "Please consult the configure.log and the build requirements."
1967 end if
1968 exit sub
1969 end if
1970
1971 strPathCurl = UnixSlashes(PathAbs(strPathCurl))
1972 if bln32Bit = True then
1973 CfgPrint "SDK_VBOX_LIBCURL-x86_INCS := " & strPathCurl & "/include"
1974 CfgPrint "SDK_VBOX_LIBCURL-x86_LIBS.x86 := " & strPathCurl & "/libcurl.lib"
1975 else
1976 CfgPrint "SDK_VBOX_LIBCURL_INCS := " & strPathCurl & "/include"
1977 CfgPrint "SDK_VBOX_LIBCURL_LIBS := " & strPathCurl & "/libcurl.lib"
1978 end if
1979
1980 PrintResult strCurl, strPathCurl
1981end sub
1982
1983''
1984' Checks if the specified path points to an usable libcurl or not.
1985function CheckForCurlSub(strPathCurl)
1986
1987 CheckForCurlSub = False
1988 LogPrint "trying: strPathCurl=" & strPathCurl
1989 if LogFileExists(strPathCurl, "include/curl/curl.h") _
1990 And LogFindFile(strPathCurl, "libcurl.dll") <> "" _
1991 And LogFindFile(strPathCurl, "libcurl.lib") <> "" _
1992 then
1993 CheckForCurlSub = True
1994 end if
1995end function
1996
1997
1998
1999''
2000' Checks for any Qt5 binaries.
2001sub CheckForQt(strOptQt5)
2002 PrintHdr "Qt5"
2003
2004 '
2005 ' Try to find the Qt5 installation (user specified path with --with-qt5)
2006 '
2007 strPathQt5 = ""
2008
2009 LogPrint "Checking for user specified path of Qt5 ... "
2010 if (strPathQt5 = "") And (strOptQt5 <> "") then
2011 strOptQt5 = UnixSlashes(strOptQt5)
2012 if CheckForQt5Sub(strOptQt5) then strPathQt5 = strOptQt5
2013 end if
2014
2015 ' Check the dev tools
2016 if (strPathQt5 = "") Then
2017 strPathQt5 = g_strPathDev & "/win." & g_strTargetArch & "/qt/v5.5.1-r138"
2018 if CheckForQt5Sub(strPathQt5) = False then strPathQt5 = ""
2019 end if
2020
2021 ' Display the result.
2022 if strPathQt5 = "" then
2023 PrintResultMsg "Qt5", "not found"
2024 else
2025 PrintResult "Qt5", strPathQt5
2026 end if
2027
2028 if strPathQt5 <> "" then
2029 CfgPrint "PATH_SDK_QT5 := " & strPathQt5
2030 CfgPrint "PATH_TOOL_QT5 := $(PATH_SDK_QT5)"
2031 CfgPrint "VBOX_PATH_QT := $(PATH_SDK_QT5)"
2032 end if
2033 if strPathQt5 = "" then
2034 CfgPrint "VBOX_WITH_QTGUI :="
2035 end if
2036end sub
2037
2038
2039''
2040' Checks if the specified path points to an usable Qt5 library.
2041function CheckForQt5Sub(strPathQt5)
2042
2043 CheckForQt5Sub = False
2044 LogPrint "trying: strPathQt5=" & strPathQt5
2045
2046 if LogFileExists(strPathQt5, "bin/moc.exe") _
2047 And LogFileExists(strPathQt5, "bin/uic.exe") _
2048 And LogFileExists(strPathQt5, "include/QtWidgets/qwidget.h") _
2049 And LogFileExists(strPathQt5, "include/QtWidgets/QApplication") _
2050 And LogFileExists(strPathQt5, "include/QtGui/QImage") _
2051 And LogFileExists(strPathQt5, "include/QtNetwork/QHostAddress") _
2052 And ( LogFileExists(strPathQt5, "lib/Qt5Core.lib") _
2053 Or LogFileExists(strPathQt5, "lib/Qt5CoreVBox.lib")) _
2054 And ( LogFileExists(strPathQt5, "lib/Qt5Network.lib") _
2055 Or LogFileExists(strPathQt5, "lib/Qt5NetworkVBox.lib")) _
2056 then
2057 CheckForQt5Sub = True
2058 end if
2059
2060end function
2061
2062
2063'
2064'
2065function CheckForPython(strPathPython)
2066
2067 PrintHdr "Python"
2068
2069 CheckForPython = False
2070 LogPrint "trying: strPathPython=" & strPathPython
2071
2072 if LogFileExists(strPathPython, "python.exe") then
2073 CfgPrint "VBOX_BLD_PYTHON := " & strPathPython & "\python.exe"
2074 CheckForPython = True
2075 end if
2076
2077 PrintResult "Python ", strPathPython
2078end function
2079
2080
2081''
2082' Show usage.
2083sub usage
2084 Print "Usage: cscript configure.vbs [options]"
2085 Print ""
2086 Print "Configuration:"
2087 Print " -h, --help"
2088 Print " --internal"
2089 Print " --internal-last"
2090 Print " --target-arch=x86|amd64"
2091 Print ""
2092 Print "Components:"
2093 Print " --disable-COM"
2094 Print " --disable-UDPTunnel"
2095 Print " --disable-SDL"
2096 Print ""
2097 Print "Locations:"
2098 Print " --with-kBuild=PATH "
2099 Print " --with-libSDL=PATH "
2100 Print " --with-MinGW32=PATH "
2101 Print " --with-MinGW-w64=PATH "
2102 Print " --with-Qt5=PATH "
2103 Print " --with-DDK=PATH "
2104 Print " --with-SDK=PATH "
2105 Print " --with-VC=PATH "
2106 Print " --with-VC-Common=PATH "
2107 Print " --with-VC-Express-Edition"
2108 Print " --with-W32API=PATH "
2109 Print " --with-libxml2=PATH "
2110 Print " --with-openssl=PATH "
2111 Print " --with-openssl32=PATH (only for 64-bit targets)"
2112 Print " --with-libcurl=PATH "
2113 Print " --with-libcurl32=PATH (only for 64-bit targets)"
2114 Print " --with-python=PATH "
2115end sub
2116
2117
2118''
2119' The main() like function.
2120'
2121Sub Main
2122 '
2123 ' Write the log header and check that we're not using wscript.
2124 '
2125 LogInit
2126 If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then
2127 Wscript.Echo "This script must be run under CScript."
2128 Wscript.Quit(1)
2129 End If
2130
2131 '
2132 ' Parse arguments.
2133 '
2134 strOptDDK = ""
2135 strOptDXDDK = ""
2136 strOptkBuild = ""
2137 strOptlibSDL = ""
2138 strOptMinGW32 = ""
2139 strOptMinGWw64 = ""
2140 strOptQt5 = ""
2141 strOptSDK = ""
2142 strOptVC = ""
2143 strOptVCCommon = ""
2144 blnOptVCExpressEdition = False
2145 strOptW32API = ""
2146 strOptXml2 = ""
2147 strOptSsl = ""
2148 strOptSsl32 = ""
2149 strOptCurl = ""
2150 strOptCurl32 = ""
2151 strOptPython = ""
2152 blnOptDisableCOM = False
2153 blnOptDisableUDPTunnel = False
2154 blnOptDisableSDL = False
2155 for i = 1 to Wscript.Arguments.Count
2156 dim str, strArg, strPath
2157
2158 ' Separate argument and path value
2159 str = Wscript.Arguments.item(i - 1)
2160 if InStr(1, str, "=") > 0 then
2161 strArg = Mid(str, 1, InStr(1, str, "=") - 1)
2162 strPath = Mid(str, InStr(1, str, "=") + 1)
2163 if strPath = "" then MsgFatal "Syntax error! Argument #" & i & " is missing the path."
2164 else
2165 strArg = str
2166 strPath = ""
2167 end if
2168
2169 ' Process the argument
2170 select case LCase(strArg)
2171 case "--with-ddk"
2172 strOptDDK = strPath
2173 case "--with-dxsdk"
2174 MsgWarning "Ignoring --with-dxsdk (the DirectX SDK is no longer required)."
2175 case "--with-kbuild"
2176 strOptkBuild = strPath
2177 case "--with-libsdl"
2178 strOptlibSDL = strPath
2179 case "--with-mingw32"
2180 strOptMinGW32 = strPath
2181 case "--with-mingw-w64"
2182 strOptMinGWw64 = strPath
2183 case "--with-qt5"
2184 strOptQt5 = strPath
2185 case "--with-sdk"
2186 strOptSDK = strPath
2187 case "--with-vc"
2188 strOptVC = strPath
2189 case "--with-vc-common"
2190 strOptVCCommon = strPath
2191 case "--with-vc-express-edition"
2192 blnOptVCExpressEdition = True
2193 case "--with-w32api"
2194 strOptW32API = strPath
2195 case "--with-libxml2"
2196 strOptXml2 = strPath
2197 case "--with-openssl"
2198 strOptSsl = strPath
2199 case "--with-openssl32"
2200 strOptSsl32 = strPath
2201 case "--with-libcurl"
2202 strOptCurl = strPath
2203 case "--with-libcurl32"
2204 strOptCurl32 = strPath
2205 case "--with-python"
2206 strOptPython = strPath
2207 case "--disable-com"
2208 blnOptDisableCOM = True
2209 case "--enable-com"
2210 blnOptDisableCOM = False
2211 case "--disable-udptunnel"
2212 blnOptDisableUDPTunnel = True
2213 case "--disable-sdl"
2214 blnOptDisableSDL = True
2215 case "--internal"
2216 g_blnInternalMode = True
2217 case "--internal-last"
2218 g_blnInternalFirst = False
2219 case "--target-arch"
2220 g_strTargetArch = strPath
2221 case "-h", "--help", "-?"
2222 usage
2223 Wscript.Quit(0)
2224 case else
2225 Wscript.echo "syntax error: Unknown option '" & str &"'."
2226 usage
2227 Wscript.Quit(1)
2228 end select
2229 next
2230
2231 '
2232 ' Initialize output files.
2233 '
2234 CfgInit
2235 EnvInit
2236
2237 '
2238 ' Check that the Shell function is sane.
2239 '
2240 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = "This works"
2241 if Shell("set TESTING_ENVIRONMENT_INHERITANC", False) <> 0 then ' The 'E' is missing on purpose (4nt).
2242 MsgFatal "shell execution test failed!"
2243 end if
2244 if g_strShellOutput <> "TESTING_ENVIRONMENT_INHERITANCE=This works" & CHR(13) & CHR(10) then
2245 Print "Shell test Test -> '" & g_strShellOutput & "'"
2246 MsgFatal "shell inheritance or shell execution isn't working right. Make sure you use cmd.exe."
2247 end if
2248 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = ""
2249 Print "Shell inheritance test: OK"
2250
2251 '
2252 ' Do the checks.
2253 '
2254 if blnOptDisableCOM = True then
2255 DisableCOM "--disable-com"
2256 end if
2257 if blnOptDisableUDPTunnel = True then
2258 DisableUDPTunnel "--disable-udptunnel"
2259 end if
2260 CheckSourcePath
2261 CheckForkBuild strOptkBuild
2262 CheckForWinDDK strOptDDK
2263 CheckForVisualCPP strOptVC, strOptVCCommon, blnOptVCExpressEdition
2264 CheckForPlatformSDK strOptSDK
2265 CheckForMidl
2266 CheckForMinGW32 strOptMinGW32, strOptW32API
2267 CheckForMinGWw64 strOptMinGWw64
2268 CfgPrint "VBOX_WITH_OPEN_WATCOM := " '' @todo look for openwatcom 1.9+
2269 CfgPrint "VBOX_WITH_LIBVPX := " '' @todo look for libvpx 1.1.0+
2270 CfgPrint "VBOX_WITH_LIBOPUS := " '' @todo look for libopus 1.2.1+
2271 EnvPrint "set PATH=%PATH%;" & g_strPath& "/tools/win." & g_strTargetArch & "/bin;" '' @todo look for yasm
2272 if blnOptDisableSDL = True then
2273 DisableSDL "--disable-sdl"
2274 else
2275 CheckForlibSDL strOptlibSDL
2276 end if
2277 ' Don't check for this library by default as it's part of the tarball
2278 ' Using an external library can add a dependency to iconv
2279 if (strOptXml2 <> "") then
2280 CheckForXml2 strOptXml2
2281 end if
2282 CheckForSsl strOptSsl, False
2283 if g_strTargetArch = "amd64" then
2284 ' 32-bit openssl required as well
2285 CheckForSsl strOptSsl32, True
2286 end if
2287 CheckForCurl strOptCurl, False
2288 if g_strTargetArch = "amd64" then
2289 ' 32-bit Curl required as well
2290 CheckForCurl strOptCurl32, True
2291 end if
2292 CheckForQt strOptQt5
2293 if (strOptPython <> "") then
2294 CheckForPython strOptPython
2295 end if
2296 if g_blnInternalMode then
2297 EnvPrint "call " & g_strPathDev & "/env.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9"
2298 end if
2299
2300 Print ""
2301 Print "Execute env.bat once before you start to build VBox:"
2302 Print ""
2303 Print " env.bat"
2304 Print " kmk"
2305 Print ""
2306
2307End Sub
2308
2309
2310Main
2311
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