VirtualBox

source: vbox/trunk/configure.vbs@ 60309

Last change on this file since 60309 was 59479, checked in by vboxsync, 9 years ago

FE/Qt: Qt5 migration (part 77): Preparing Qt5 tool: Some stuff missed in r41920.

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