VirtualBox

source: vbox/trunk/configure.vbs@ 67306

Last change on this file since 67306 was 67300, checked in by vboxsync, 8 years ago

configure.vbs: forward-ported r115992 from 5.1:

  • introduced --target-arch=x86|amd64 allowing to define the target architecture
  • properly set KBUILD_TARGET_ARCH and KBUILD_HOST_ARCH
  • dropped obsolete check for libxslt
  • added --with-openssl32=PATH and --with-libcurl32=PATH to specify the 32-bit variants for 64-bit targets
  • adapted the openssl test to the 1.1.0 library names (libssl.lib and libcrypto.lib)
  • dropped obsolete Qt4 check
  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Id
File size: 74.1 KB
Line 
1' $Id: configure.vbs 67300 2017-06-08 13:49:05Z 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-2016 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_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 CfgPrint "VBOX_VCC_WERR = $(NO_SUCH_VARIABLE)"
722 end if
723end sub
724
725
726''
727' Prints a string to the config file.
728sub CfgPrint(str)
729 FileAppendLine g_strCfgFile, str
730end sub
731
732
733''
734' Initializes the environment batch script.
735sub EnvInit
736 FileDelete g_strEnvFile
737 EnvPrint "@echo off"
738 EnvPrint "rem"
739 EnvPrint "rem Environment setup script generated by " & GetCommandline()
740 EnvPrint "rem"
741end sub
742
743
744''
745' Prints a string to the environment batch script.
746sub EnvPrint(str)
747 FileAppendLine g_strEnvFile, str
748end sub
749
750
751''
752' No COM
753sub DisableCOM(strReason)
754 if g_blnDisableCOM = False then
755 LogPrint "Disabled COM components: " & strReason
756 g_blnDisableCOM = True
757 g_strDisableCOM = strReason
758 CfgPrint "VBOX_WITH_MAIN="
759 CfgPrint "VBOX_WITH_QTGUI="
760 CfgPrint "VBOX_WITH_VBOXSDL="
761 CfgPrint "VBOX_WITH_DEBUGGER_GUI="
762 end if
763end sub
764
765
766''
767' No UDPTunnel
768sub DisableUDPTunnel(strReason)
769 if g_blnDisableUDPTunnel = False then
770 LogPrint "Disabled UDPTunnel network transport: " & strReason
771 g_blnDisableUDPTunnel = True
772 g_strDisableUDPTunnel = strReason
773 CfgPrint "VBOX_WITH_UDPTUNNEL="
774 end if
775end sub
776
777
778''
779' Checks the the path doesn't contain characters the tools cannot deal with.
780sub CheckSourcePath
781 dim sPwd
782
783 sPwd = PathAbs(g_strPath)
784 if InStr(1, sPwd, " ") > 0 then
785 MsgError "Source path contains spaces! Please move it. (" & sPwd & ")"
786 end if
787 if InStr(1, sPwd, "$") > 0 then
788 MsgError "Source path contains the '$' char! Please move it. (" & sPwd & ")"
789 end if
790 if InStr(1, sPwd, "%") > 0 then
791 MsgError "Source path contains the '%' char! Please move it. (" & sPwd & ")"
792 end if
793 if InStr(1, sPwd, Chr(10)) > 0 _
794 Or InStr(1, sPwd, Chr(13)) > 0 _
795 Or InStr(1, sPwd, Chr(9)) > 0 _
796 then
797 MsgError "Source path contains control characters! Please move it. (" & sPwd & ")"
798 end if
799 Print "Source path: OK"
800end sub
801
802
803''
804' Checks for kBuild - very simple :)
805sub CheckForkBuild(strOptkBuild)
806 PrintHdr "kBuild"
807
808 '
809 ' Check if there is a 'kmk' in the path somewhere without
810 ' any KBUILD_*PATH stuff around.
811 '
812 blnNeedEnvVars = True
813 g_strPathkBuild = strOptkBuild
814 g_strPathkBuildBin = ""
815 if (g_strPathkBuild = "") _
816 And (EnvGetFirst("KBUILD_PATH", "PATH_KBUILD") = "") _
817 And (EnvGetFirst("KBUILD_BIN_PATH", "PATH_KBUILD_BIN") = "") _
818 And (Shell("kmk.exe --version", True) = 0) _
819 And (InStr(1,g_strShellOutput, "kBuild Make 0.1") > 0) _
820 And (InStr(1,g_strShellOutput, "KBUILD_PATH") > 0) _
821 And (InStr(1,g_strShellOutput, "KBUILD_BIN_PATH") > 0) then
822 '' @todo Need to parse out the KBUILD_PATH and KBUILD_BIN_PATH values to complete the other tests.
823 'blnNeedEnvVars = False
824 MsgWarning "You've installed kBuild it seems. configure.vbs hasn't been updated to " _
825 & "deal with that yet and will use the one it ships with. Sorry."
826 end if
827
828 '
829 ' Check for the KBUILD_PATH env.var. and fall back on root/kBuild otherwise.
830 '
831 if g_strPathkBuild = "" then
832 g_strPathkBuild = EnvGetFirst("KBUILD_PATH", "PATH_KBUILD")
833 if (g_strPathkBuild <> "") and (FileExists(g_strPathkBuild & "/footer.kmk") = False) then
834 MsgWarning "Ignoring incorrect kBuild path (KBUILD_PATH=" & g_strPathkBuild & ")"
835 g_strPathkBuild = ""
836 end if
837
838 if g_strPathkBuild = "" then
839 g_strPathkBuild = g_strPath & "/kBuild"
840 end if
841 end if
842
843 g_strPathkBuild = UnixSlashes(PathAbs(g_strPathkBuild))
844
845 '
846 ' Check for env.vars that kBuild uses (do this early to set g_strTargetArch).
847 '
848 str = EnvGetFirst("KBUILD_TYPE", "BUILD_TYPE")
849 if (str <> "") _
850 And (InStr(1, "|release|debug|profile|kprofile", str) <= 0) then
851 EnvPrint "set KBUILD_TYPE=release"
852 EnvSet "KBUILD_TYPE", "release"
853 MsgWarning "Found unknown KBUILD_TYPE value '" & str &"' in your environment. Setting it to 'release'."
854 end if
855
856 str = EnvGetFirst("KBUILD_TARGET", "BUILD_TARGET")
857 if (str <> "") _
858 And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
859 EnvPrint "set KBUILD_TARGET=win"
860 EnvSet "KBUILD_TARGET", "win"
861 MsgWarning "Found unknown KBUILD_TARGET value '" & str &"' in your environment. Setting it to 'win32'."
862 end if
863
864 str = EnvGetFirst("KBUILD_TARGET_ARCH", "BUILD_TARGET_ARCH")
865 if (str <> "") _
866 And (InStr(1, "x86|amd64", str) <= 0) then
867 EnvPrint "set KBUILD_TARGET_ARCH=x86"
868 EnvSet "KBUILD_TARGET_ARCH", "x86"
869 MsgWarning "Found unknown KBUILD_TARGET_ARCH value '" & str &"' in your environment. Setting it to 'x86'."
870 str = "x86"
871 end if
872 if g_strTargetArch = "" then '' command line parameter --target-arch=x86|amd64 has priority
873 if str <> "" then
874 g_strTargetArch = str
875 elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _
876 Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then
877 g_strTargetArch = "amd64"
878 else
879 g_strTargetArch = "x86"
880 end if
881 else
882 if InStr(1, "x86|amd64", g_strTargetArch) <= 0 then
883 EnvPrint "set KBUILD_TARGET_ARCH=x86"
884 EnvSet "KBUILD_TARGET_ARCH", "x86"
885 MsgWarning "Unknown --target-arch=" & str &". Setting it to 'x86'."
886 end if
887 end if
888 LogPrint " Target architecture: " & g_strTargetArch & "."
889 Wscript.Echo " Target architecture: " & g_strTargetArch & "."
890 EnvPrint "set KBUILD_TARGET_ARCH=" & g_strTargetArch
891
892 str = EnvGetFirst("KBUILD_TARGET_CPU", "BUILD_TARGET_CPU")
893 ' perhaps a bit pedantic this since this isn't clearly define nor used much...
894 if (str <> "") _
895 And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then
896 EnvPrint "set BUILD_TARGET_CPU=i386"
897 EnvSet "KBUILD_TARGET_CPU", "i386"
898 MsgWarning "Found unknown KBUILD_TARGET_CPU value '" & str &"' in your environment. Setting it to 'i386'."
899 end if
900
901 str = EnvGetFirst("KBUILD_HOST", "BUILD_PLATFORM")
902 if (str <> "") _
903 And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
904 EnvPrint "set KBUILD_HOST=win"
905 EnvSet "KBUILD_HOST", "win"
906 MsgWarning "Found unknown KBUILD_HOST value '" & str &"' in your environment. Setting it to 'win32'."
907 end if
908
909 str = EnvGetFirst("KBUILD_HOST_ARCH", "BUILD_PLATFORM_ARCH")
910 if str <> "" then
911 if InStr(1, "x86|amd64", str) <= 0 then
912 str = "x86"
913 MsgWarning "Found unknown KBUILD_HOST_ARCH value '" & str &"' in your environment. Setting it to 'x86'."
914 end if
915 elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _
916 Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then
917 str = "amd64"
918 else
919 str = "x86"
920 end if
921 LogPrint " Host architecture: " & str & "."
922 Wscript.Echo " Host architecture: " & str & "."
923 EnvPrint "set KBUILD_HOST_ARCH=" & str
924
925 str = EnvGetFirst("KBUILD_HOST_CPU", "BUILD_PLATFORM_CPU")
926 ' perhaps a bit pedantic this since this isn't clearly define nor used much...
927 if (str <> "") _
928 And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then
929 EnvPrint "set KBUILD_HOST_CPU=i386"
930 EnvSet "KBUILD_HOST_CPU", "i386"
931 MsgWarning "Found unknown KBUILD_HOST_CPU value '" & str &"' in your environment. Setting it to 'i386'."
932 end if
933
934 '
935 ' Determin the location of the kBuild binaries.
936 '
937 if g_strPathkBuildBin = "" then
938 g_strPathkBuildBin = g_strPathkBuild & "/bin/win." & g_strTargetArch
939 if FileExists(g_strPathkBuild & "/kmk.exe") = False then
940 g_strPathkBuildBin = g_strPathkBuild & "/bin/win.x86"
941 end if
942 end if
943
944 '
945 ' Perform basic validations of the kBuild installation.
946 '
947 if (FileExists(g_strPathkBuild & "/footer.kmk") = False) _
948 Or (FileExists(g_strPathkBuild & "/header.kmk") = False) _
949 Or (FileExists(g_strPathkBuild & "/rules.kmk") = False) then
950 MsgFatal "Can't find valid kBuild at '" & g_strPathkBuild & "'. Either there is an " _
951 & "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."
952 exit sub
953 end if
954 if (FileExists(g_strPathkBuildBin & "/kmk.exe") = False) _
955 Or (FileExists(g_strPathkBuildBin & "/kmk_ash.exe") = False) then
956 MsgFatal "Can't find valid kBuild binaries at '" & g_strPathkBuildBin & "'. Either there is an " _
957 & "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."
958 exit sub
959 end if
960
961 if (Shell(DosSlashes(g_strPathkBuildBin & "/kmk.exe") & " --version", True) <> 0) Then
962 MsgFatal "Can't execute '" & g_strPathkBuildBin & "/kmk.exe --version'. check configure.log for the out."
963 exit sub
964 end if
965
966 '
967 ' If PATH_DEV is set, check that it's pointing to something useful.
968 '
969 str = EnvGet("PATH_DEV")
970 g_strPathDev = str
971 if (str <> "") _
972 And False then '' @todo add some proper tests here.
973 strNew = UnixSlashes(g_strPath & "/tools")
974 EnvPrint "set PATH_DEV=" & strNew
975 EnvSet "PATH_DEV", strNew
976 MsgWarning "Found PATH_DEV='" & str &"' in your environment. Setting it to '" & strNew & "'."
977 g_strPathDev = strNew
978 end if
979 if g_strPathDev = "" then g_strPathDev = UnixSlashes(g_strPath & "/tools")
980
981 '
982 ' Write KBUILD_PATH to the environment script if necessary.
983 '
984 if blnNeedEnvVars = True then
985 EnvPrint "set KBUILD_PATH=" & g_strPathkBuild
986 EnvSet "KBUILD_PATH", g_strPathkBuild
987 EnvPrint "set PATH=" & g_strPathkBuildBin & ";%PATH%"
988 EnvPrepend "PATH", g_strPathkBuildBin & ";"
989 end if
990
991 PrintResult "kBuild", g_strPathkBuild
992 PrintResult "kBuild binaries", g_strPathkBuildBin
993end sub
994
995
996''
997' Checks for Visual C++ version 10 (2010).
998sub CheckForVisualCPP(strOptVC, strOptVCCommon, blnOptVCExpressEdition)
999 dim strPathVC, strPathVCCommon, str, str2, blnNeedMsPDB
1000 PrintHdr "Visual C++"
1001
1002 '
1003 ' Try find it...
1004 '
1005 strPathVC = ""
1006 strPathVCCommon = ""
1007 if (strPathVC = "") And (strOptVC <> "") then
1008 if CheckForVisualCPPSub(strOptVC, strOptVCCommon, blnOptVCExpressEdition) then
1009 strPathVC = strOptVC
1010 strPathVCCommon = strOptVCCommon
1011 end if
1012 end if
1013
1014 if (strPathVC = "") And (g_blnInternalFirst = True) Then
1015 strPathVC = g_strPathDev & "/win.x86/vcc/v10sp1"
1016 if CheckForVisualCPPSub(strPathVC, "", blnOptVCExpressEdition) = False then
1017 strPathVC = ""
1018 end if
1019 end if
1020
1021 if (strPathVC = "") _
1022 And (Shell("cl.exe", True) = 0) then
1023 str = Which("cl.exe")
1024 if FileExists(PathStripFilename(strClExe) & "/build.exe") then
1025 ' don't know how to deal with this cl.
1026 Warning "Ignoring DDK cl.exe (" & str & ")."
1027 else
1028 strPathVC = PathParent(PathStripFilename(str))
1029 strPathVCCommon = PathParent(strPathVC) & "/Common7"
1030 end if
1031 end if
1032
1033 if (strPathVC = "") then
1034 str = RegGetString("HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Setup\VS\ProductDir")
1035 if str <> "" Then
1036 str2 = str & "Common7"
1037 str = str & "VC"
1038 if CheckForVisualCPPSub(str, str2, blnOptVCExpressEdition) then
1039 strPathVC = str
1040 strPathVCCommon = str2
1041 end if
1042 end if
1043 end if
1044
1045 if (strPathVC = "") then
1046 str = RegGetString("HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\Setup\VS\ProductDir")
1047 if str <> "" Then
1048 str2 = str & "Common7"
1049 str = str & "VC"
1050 if CheckForVisualCPPSub(str, str2, blnOptVCExpressEdition) then
1051 strPathVC = str
1052 strPathVCCommon = str2
1053 end if
1054 end if
1055 end if
1056
1057 if (strPathVC = "") And (g_blnInternalFirst = False) Then
1058 strPathVC = g_strPathDev & "/win.x86/vcc/v10sp1"
1059 if CheckForVisualCPPSub(strPathVC, "", blnOptVCExpressEdition) = False then
1060 strPathVC = ""
1061 end if
1062 end if
1063
1064 if strPathVC = "" then
1065 MsgError "Cannot find cl.exe (Visual C++) anywhere on your system. Check the build requirements."
1066 exit sub
1067 end if
1068
1069 '
1070 ' Clean up the path and determin the VC directory.
1071 '
1072 strPathVC = UnixSlashes(PathAbs(strPathVC))
1073 g_strPathVCC = strPathVC
1074
1075 '
1076 ' Check the version.
1077 ' We'll have to make sure mspdbXX.dll is somewhere in the PATH.
1078 '
1079 if (strPathVCCommon <> "") Then
1080 EnvAppend "PATH", ";" & strPathVCCommon & "/IDE"
1081 end if
1082 if Shell(DosSlashes(strPathVC & "/bin/cl.exe"), True) <> 0 then
1083 MsgError "Executing '" & strClExe & "' (which we believe to be the Visual C++ compiler driver) failed."
1084 exit sub
1085 end if
1086
1087 if (InStr(1, g_strShellOutput, "Version 16.") <= 0) _
1088 And (InStr(1, g_strShellOutput, "Version 17.") <= 0) then
1089 MsgError "The Visual C++ compiler we found ('" & strPathVC & "') isn't 10.0 or 11.0. Check the build requirements."
1090 exit sub
1091 end if
1092
1093 '
1094 ' Ok, emit build config variables.
1095 '
1096 if InStr(1, g_strShellOutput, "Version 16.") > 0 then
1097 CfgPrint "PATH_TOOL_VCC100 := " & g_strPathVCC
1098 CfgPrint "PATH_TOOL_VCC100X86 := $(PATH_TOOL_VCC100)"
1099 CfgPrint "PATH_TOOL_VCC100AMD64 := $(PATH_TOOL_VCC100)"
1100 if LogFileExists(strPathVC, "atlmfc/include/atlbase.h") then
1101 PrintResult "Visual C++ v10 with ATL", g_strPathVCC
1102 elseif LogFileExists(g_strPathDDK, "inc/atl71/atlbase.h") _
1103 And LogFileExists(g_strPathDDK, "lib/ATL/i386/atls.lib") then
1104 CfgPrint "VBOX_WITHOUT_COMPILER_REDIST=1"
1105 CfgPrint "PATH_TOOL_VCC100_ATLMFC_INC = " & g_strPathDDK & "/inc/atl71"
1106 CfgPrint "PATH_TOOL_VCC100_ATLMFC_LIB.amd64 = " & g_strPathDDK & "/lib/ATL/amd64"
1107 CfgPrint "PATH_TOOL_VCC100_ATLMFC_LIB.x86 = " & g_strPathDDK & "/lib/ATL/i386"
1108 CfgPrint "PATH_TOOL_VCC100AMD64_ATLMFC_INC = " & g_strPathDDK & "/inc/atl71"
1109 CfgPrint "PATH_TOOL_VCC100AMD64_ATLMFC_LIB = " & g_strPathDDK & "/lib/ATL/amd64"
1110 CfgPrint "PATH_TOOL_VCC100X86_ATLMFC_INC = " & g_strPathDDK & "/inc/atl71"
1111 CfgPrint "PATH_TOOL_VCC100X86_ATLMFC_LIB = " & g_strPathDDK & "/lib/ATL/i386"
1112 PrintResult "Visual C++ v10 with DDK ATL", g_strPathVCC
1113 else
1114 CfgPrint "VBOX_WITHOUT_COMPILER_REDIST=1"
1115 DisableCOM "No ATL"
1116 PrintResult "Visual C++ v10 (or later) without ATL", g_strPathVCC
1117 end if
1118
1119 elseif InStr(1, g_strShellOutput, "Version 17.") > 0 then
1120 CfgPrint "PATH_TOOL_VCC110 := " & g_strPathVCC
1121 CfgPrint "PATH_TOOL_VCC110X86 := $(PATH_TOOL_VCC110)"
1122 CfgPrint "PATH_TOOL_VCC110AMD64 := $(PATH_TOOL_VCC110)"
1123 PrintResult "Visual C++ v11", g_strPathVCC
1124 MsgWarning "The support for Visual C++ v11 (aka 2012) is experimental"
1125
1126 else
1127 MsgError "The Visual C++ compiler we found ('" & strPathVC & "') isn't 10.0 or 11.0. Check the build requirements."
1128 exit sub
1129 end if
1130
1131 ' and the env.bat path fix.
1132 if strPathVCCommon <> "" then
1133 EnvPrint "set PATH=%PATH%;" & strPathVCCommon & "/IDE;"
1134 end if
1135end sub
1136
1137''
1138' Checks if the specified path points to a usable PSDK.
1139function CheckForVisualCPPSub(strPathVC, strPathVCCommon, blnOptVCExpressEdition)
1140 strPathVC = UnixSlashes(PathAbs(strPathVC))
1141 CheckForVisualCPPSub = False
1142 LogPrint "trying: strPathVC=" & strPathVC & " strPathVCCommon=" & strPathVCCommon & " blnOptVCExpressEdition=" & blnOptVCExpressEdition
1143 if LogFileExists(strPathVC, "bin/cl.exe") _
1144 And LogFileExists(strPathVC, "bin/link.exe") _
1145 And LogFileExists(strPathVC, "include/string.h") _
1146 And LogFileExists(strPathVC, "lib/libcmt.lib") _
1147 And LogFileExists(strPathVC, "lib/msvcrt.lib") _
1148 then
1149 if blnOptVCExpressEdition _
1150 Or ( LogFileExists(strPathVC, "atlmfc/include/atlbase.h") _
1151 And LogFileExists(strPathVC, "atlmfc/lib/atls.lib")) _
1152 Or ( LogFileExists(g_strPathDDK, "inc/atl71/atlbase.h") _
1153 And LogFileExists(g_strPathDDK, "lib/ATL/i386/atls.lib")) _
1154 Then
1155 '' @todo figure out a way we can verify the version/build!
1156 CheckForVisualCPPSub = True
1157 end if
1158 end if
1159end function
1160
1161
1162''
1163' Checks for a platform SDK that works with the compiler
1164sub CheckForPlatformSDK(strOptSDK)
1165 dim strPathPSDK, str
1166 PrintHdr "Windows Platform SDK (recent)"
1167
1168 strPathPSDK = ""
1169
1170 ' Check the supplied argument first.
1171 str = strOptSDK
1172 if str <> "" then
1173 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1174 end if
1175
1176 ' The tools location (first).
1177 if strPathPSDK = "" And g_blnInternalFirst then
1178 str = g_strPathDev & "/win.x86/sdk/v7.1"
1179 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1180 end if
1181
1182 if strPathPSDK = "" And g_blnInternalFirst then
1183 str = g_strPathDev & "/win.x86/sdk/v8.0"
1184 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1185 end if
1186
1187 ' Look for it in the environment
1188 str = EnvGet("MSSdk")
1189 if strPathPSDK = "" And str <> "" then
1190 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1191 end if
1192
1193 str = EnvGet("Mstools")
1194 if strPathPSDK = "" And str <> "" then
1195 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1196 end if
1197
1198 ' Check if there is one installed with the compiler.
1199 if strPathPSDK = "" And str <> "" then
1200 str = g_strPathVCC & "/PlatformSDK"
1201 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1202 end if
1203
1204 ' Check the registry next (ASSUMES sorting).
1205 arrSubKeys = RegEnumSubKeysRSort("HKLM", "SOFTWARE\Microsoft\Microsoft SDKs\Windows")
1206 for each strSubKey in arrSubKeys
1207 str = RegGetString("HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")
1208 if strPathPSDK = "" And str <> "" then
1209 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1210 end if
1211 Next
1212 arrSubKeys = RegEnumSubKeysRSort("HKCU", "SOFTWARE\Microsoft\Microsoft SDKs\Windows")
1213 for each strSubKey in arrSubKeys
1214 str = RegGetString("HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")
1215 if strPathPSDK = "" And str <> "" then
1216 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1217 end if
1218 Next
1219
1220 ' The tools location (post).
1221 if (strPathPSDK = "") And (g_blnInternalFirst = False) then
1222 str = g_strPathDev & "/win.x86/sdk/v7.1"
1223 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1224 end if
1225
1226 if (strPathPSDK = "") And (g_blnInternalFirst = False) then
1227 str = g_strPathDev & "/win.x86/sdk/v8.0"
1228 if CheckForPlatformSDKSub(str) then strPathPSDK = str
1229 end if
1230
1231 ' Give up.
1232 if strPathPSDK = "" then
1233 MsgError "Cannot find a suitable Platform SDK. Check configure.log and the build requirements."
1234 exit sub
1235 end if
1236
1237 '
1238 ' Emit the config.
1239 '
1240 strPathPSDK = UnixSlashes(PathAbs(strPathPSDK))
1241 CfgPrint "PATH_SDK_WINPSDK" & g_strVerPSDK & " := " & strPathPSDK
1242 CfgPrint "VBOX_WINPSDK := WINPSDK" & g_strVerPSDK
1243
1244 PrintResult "Windows Platform SDK (v" & g_strVerPSDK & ")", strPathPSDK
1245 g_strPathPSDK = strPathPSDK
1246end sub
1247
1248''
1249' Checks if the specified path points to a usable PSDK.
1250function CheckForPlatformSDKSub(strPathPSDK)
1251 CheckForPlatformSDKSub = False
1252 LogPrint "trying: strPathPSDK=" & strPathPSDK
1253 if LogFileExists(strPathPSDK, "include/Windows.h") _
1254 And LogFileExists(strPathPSDK, "lib/Kernel32.Lib") _
1255 And LogFileExists(strPathPSDK, "lib/User32.Lib") _
1256 And LogFileExists(strPathPSDK, "bin/rc.exe") _
1257 And Shell("""" & DosSlashes(strPathPSDK & "/bin/rc.exe") & """" , True) <> 0 _
1258 then
1259 if InStr(1, g_strShellOutput, "Resource Compiler Version 6.2.") > 0 then
1260 g_strVerPSDK = "80"
1261 CheckForPlatformSDKSub = True
1262 elseif InStr(1, g_strShellOutput, "Resource Compiler Version 6.1.") > 0 then
1263 g_strVerPSDK = "71"
1264 CheckForPlatformSDKSub = True
1265 end if
1266 end if
1267end function
1268
1269
1270''
1271' Checks for a Windows 7 Driver Kit.
1272sub CheckForWinDDK(strOptDDK)
1273 dim strPathDDK, str, strSubKeys
1274 PrintHdr "Windows DDK v7.1"
1275
1276 '
1277 ' Find the DDK.
1278 '
1279 strPathDDK = ""
1280 ' The specified path.
1281 if strPathDDK = "" And strOptDDK <> "" then
1282 if CheckForWinDDKSub(strOptDDK, True) then strPathDDK = strOptDDK
1283 end if
1284
1285 ' The tools location (first).
1286 if strPathDDK = "" And g_blnInternalFirst then
1287 str = g_strPathDev & "/win.x86/ddk/7600.16385.1"
1288 if CheckForWinDDKSub(str, False) then strPathDDK = str
1289 end if
1290
1291 ' Check the environment
1292 str = EnvGet("DDK_INC_PATH")
1293 if strPathDDK = "" And str <> "" then
1294 str = PathParent(PathParent(str))
1295 if CheckForWinDDKSub(str, True) then strPathDDK = str
1296 end if
1297
1298 str = EnvGet("BASEDIR")
1299 if strPathDDK = "" And str <> "" then
1300 if CheckForWinDDKSub(str, True) then strPathDDK = str
1301 end if
1302
1303 ' Some array constants to ease the work.
1304 arrSoftwareKeys = array("SOFTWARE", "SOFTWARE\Wow6432Node")
1305 arrRoots = array("HKLM", "HKCU")
1306
1307 ' Windows 7 WDK.
1308 arrLocations = array()
1309 for each strSoftwareKey in arrSoftwareKeys
1310 for each strSubKey in RegEnumSubKeysFull("HKLM", strSoftwareKey & "\Microsoft\KitSetup\configured-kits")
1311 for each strSubKey2 in RegEnumSubKeysFull("HKLM", strSubKey)
1312 str = RegGetString("HKLM\" & strSubKey2 & "\setup-install-location")
1313 if str <> "" then
1314 arrLocations = ArrayAppend(arrLocations, PathAbsLong(str))
1315 end if
1316 next
1317 next
1318 next
1319 arrLocations = ArrayRSortStrings(arrLocations)
1320
1321 ' Check the locations we've gathered.
1322 for each str in arrLocations
1323 if strPathDDK = "" then
1324 if CheckForWinDDKSub(str, True) then strPathDDK = str
1325 end if
1326 next
1327
1328 ' The tools location (post).
1329 if (strPathDDK = "") And (g_blnInternalFirst = False) then
1330 str = g_strPathDev & "/win.x86/ddk/7600.16385.1"
1331 if CheckForWinDDKSub(str, False) then strPathDDK = str
1332 end if
1333
1334 ' Give up.
1335 if strPathDDK = "" then
1336 MsgError "Cannot find the Windows DDK v7.1. Check configure.log and the build requirements."
1337 exit sub
1338 end if
1339
1340 '
1341 ' Emit the config.
1342 '
1343 strPathDDK = UnixSlashes(PathAbs(strPathDDK))
1344 CfgPrint "PATH_SDK_WINDDK71 := " & strPathDDK
1345
1346 PrintResult "Windows DDK v7.1", strPathDDK
1347 g_strPathDDK = strPathDDK
1348end sub
1349
1350'' Quick check if the DDK is in the specified directory or not.
1351function CheckForWinDDKSub(strPathDDK, blnCheckBuild)
1352 CheckForWinDDKSub = False
1353 LogPrint "trying: strPathDDK=" & strPathDDK & " blnCheckBuild=" & blnCheckBuild
1354 if LogFileExists(strPathDDK, "inc/api/ntdef.h") _
1355 And LogFileExists(strPathDDK, "lib/win7/i386/int64.lib") _
1356 And LogFileExists(strPathDDK, "lib/wlh/i386/int64.lib") _
1357 And LogFileExists(strPathDDK, "lib/wnet/i386/int64.lib") _
1358 And LogFileExists(strPathDDK, "lib/wxp/i386/int64.lib") _
1359 And Not LogFileExists(strPathDDK, "lib/win8/i386/int64.lib") _
1360 And LogFileExists(strPathDDK, "bin/x86/rc.exe") _
1361 then
1362 if Not blnCheckBuild then
1363 CheckForWinDDKSub = True
1364 '' @todo Find better build check.
1365 elseif Shell("""" & DosSlashes(strPathDDK & "/bin/x86/rc.exe") & """" , True) <> 0 _
1366 And InStr(1, g_strShellOutput, "Resource Compiler Version 6.1.") > 0 then
1367 CheckForWinDDKSub = True
1368 end if
1369 end if
1370end function
1371
1372
1373''
1374' Finds midl.exe
1375sub CheckForMidl()
1376 dim strMidl
1377 PrintHdr "Midl.exe"
1378
1379 ' Skip if no COM/ATL.
1380 if g_blnDisableCOM then
1381 PrintResultMsg "Midl", "Skipped (" & g_strDisableCOM & ")"
1382 exit sub
1383 end if
1384
1385 if LogFileExists(g_strPathPSDK, "bin/Midl.exe") then
1386 strMidl = g_strPathPSDK & "/bin/Midl.exe"
1387 elseif LogFileExists(g_strPathVCC, "Common7/Tools/Bin/Midl.exe") then
1388 strMidl = g_strPathVCC & "/Common7/Tools/Bin/Midl.exe"
1389 elseif LogFileExists(g_strPathDDK, "bin/x86/Midl.exe") then
1390 strMidl = g_strPathDDK & "/bin/x86/Midl.exe"
1391 elseif LogFileExists(g_strPathDDK, "bin/Midl.exe") then
1392 strMidl = g_strPathDDK & "/bin/Midl.exe"
1393 elseif LogFileExists(g_strPathDev, "win.x86/bin/Midl.exe") then
1394 strMidl = g_strPathDev & "/win.x86/bin/Midl.exe"
1395 else
1396 MsgWarning "Midl.exe not found!"
1397 exit sub
1398 end if
1399
1400 CfgPrint "VBOX_MAIN_IDL := " & strMidl
1401 PrintResult "Midl.exe", strMidl
1402end sub
1403
1404
1405''
1406' Checks for a MinGW32 suitable for building the recompiler.
1407'
1408' strOptW32API is currently ignored.
1409'
1410sub CheckForMinGW32(strOptMinGW32, strOptW32API)
1411 dim strPathMingW32, strPathW32API, str
1412 PrintHdr "MinGW32 GCC v3.3.x + Binutils + Runtime + W32API"
1413
1414 '
1415 ' Find the MinGW and W32API tools.
1416 '
1417 strPathMingW32 = ""
1418 strPathW32API = ""
1419
1420 ' The specified path.
1421 if (strPathMingW32 = "") And (strOptMinGW32 <> "") then
1422 if CheckForMinGW32Sub(strOptMinGW32, strOptW32API) then
1423 strPathMingW32 = strOptMinGW32
1424 strPathW32API = strOptW32API
1425 end if
1426 end if
1427
1428 ' The tools location (first).
1429 if (strPathMingW32 = "") And (g_blnInternalFirst = True) then
1430 str = g_strPathDev & "/win.x86/mingw32/v3.3.3"
1431 str2 = g_strPathDev & "/win.x86/w32api/v2.5"
1432 if CheckForMinGW32Sub(str, str2) then
1433 strPathMingW32 = str
1434 strPathW32API = str2
1435 end if
1436 end if
1437
1438 ' See if there is any gcc around.
1439 if strPathMingW32 = "" then
1440 str = Which("mingw32-gcc.exe")
1441 if (str <> "") then
1442 str = PathParent(PathStripFilename(str))
1443 if CheckForMinGW32Sub(str, str) then strPathMingW32 = str
1444 end if
1445 end if
1446
1447 if strPathMingW32 = "" then
1448 str = Which("gcc.exe")
1449 if (str <> "") then
1450 str = PathParent(PathStripFilename(str))
1451 if CheckForMinGW32Sub(str, str) then strPathMingW32 = str
1452 end if
1453 end if
1454
1455 ' The tools location (post).
1456 if (strPathMingW32 = "") And (g_blnInternalFirst = False) then
1457 str = g_strPathDev & "/win.x86/mingw32/v3.3.3"
1458 str2 = g_strPathDev & "/win.x86/w32api/v2.5"
1459 if CheckForMinGW32Sub(str, str2) then
1460 strPathMingW32 = str
1461 strPathW32API = str2
1462 end if
1463 end if
1464
1465 ' Success?
1466 if strPathMingW32 = "" then
1467 if g_strTargetArch = "amd64" then
1468 MsgWarning "Can't locate a suitable MinGW32 installation, ignoring since we're targeting AMD64 and won't need it."
1469 elseif strOptMinGW32 = "" then
1470 MsgError "Can't locate a suitable MinGW32 installation. Try specify the path with " _
1471 & "the --with-MinGW32=<path> argument. If still no luck, consult the configure.log and the build requirements."
1472 else
1473 MsgError "Can't locate a suitable MinGW32 installation. Please consult the configure.log and the build requirements."
1474 end if
1475 exit sub
1476 end if
1477
1478 '
1479 ' Emit the config.
1480 '
1481 strPathMingW32 = UnixSlashes(PathAbs(strPathMingW32))
1482 CfgPrint "PATH_TOOL_MINGW32 := " & strPathMingW32
1483 PrintResult "MinGW32 (GCC v" & g_strSubOutput & ")", strPathMingW32
1484 if (strPathMingW32 = strPathW32API) Or strPathW32API = "" then
1485 CfgPrint "PATH_SDK_W32API := $(PATH_TOOL_MINGW32)"
1486 else
1487 CfgPrint "PATH_SDK_W32API := " & strPathW32API
1488 PrintResult "W32API", strPathW32API
1489 end if
1490end sub
1491
1492''
1493' Checks if the specified path points to an usable MinGW or not.
1494function CheckForMinGW32Sub(strPathMingW32, strPathW32API)
1495 g_strSubOutput = ""
1496 if strPathW32API = "" then strPathW32API = strPathMingW32
1497 LogPrint "trying: strPathMingW32=" &strPathMingW32 & " strPathW32API=" & strPathW32API
1498
1499 if LogFileExists(strPathMingW32, "bin/mingw32-gcc.exe") _
1500 And LogFileExists(strPathMingW32, "bin/ld.exe") _
1501 And LogFileExists(strPathMingW32, "bin/objdump.exe") _
1502 And LogFileExists(strPathMingW32, "bin/dllwrap.exe") _
1503 And LogFileExists(strPathMingW32, "bin/as.exe") _
1504 And LogFileExists(strPathMingW32, "include/string.h") _
1505 And LogFileExists(strPathMingW32, "include/_mingw.h") _
1506 And LogFileExists(strPathMingW32, "lib/dllcrt1.o") _
1507 And LogFileExists(strPathMingW32, "lib/dllcrt2.o") _
1508 And LogFileExists(strPathMingW32, "lib/libmsvcrt.a") _
1509 _
1510 And LogFileExists(strPathW32API, "lib/libkernel32.a") _
1511 And LogFileExists(strPathW32API, "include/windows.h") _
1512 then
1513 if Shell(DosSlashes(strPathMingW32 & "/bin/gcc.exe") & " --version", True) = 0 then
1514 dim offVer, iMajor, iMinor, iPatch, strVer
1515
1516 ' extract the version.
1517 strVer = ""
1518 offVer = InStr(1, g_strShellOutput, "(GCC) ")
1519 if offVer > 0 then
1520 strVer = LTrim(Mid(g_strShellOutput, offVer + Len("(GCC) ")))
1521 strVer = RTrim(Left(strVer, InStr(1, strVer, " ")))
1522 if (Mid(strVer, 2, 1) = ".") _
1523 And (Mid(strVer, 4, 1) = ".") then
1524 iMajor = Int(Left(strVer, 1)) ' Is Int() the right thing here? I want atoi()!!!
1525 iMinor = Int(Mid(strVer, 3, 1))
1526 iPatch = Int(Mid(strVer, 5))
1527 else
1528 LogPrint "Malformed version: '" & strVer & "'"
1529 strVer = ""
1530 end if
1531 end if
1532 if strVer <> "" then
1533 if (iMajor = 3) And (iMinor = 3) then
1534 CheckForMinGW32Sub = True
1535 g_strSubOutput = strVer
1536 else
1537 LogPrint "MinGW32 version '" & iMajor & "." & iMinor & "." & iPatch & "' is not supported (or configure.vbs failed to parse it correctly)."
1538 end if
1539 else
1540 LogPrint "Couldn't locate the GCC version in the output!"
1541 end if
1542
1543 else
1544 LogPrint "Failed to run gcc.exe!"
1545 end if
1546 end if
1547end function
1548
1549
1550''
1551' Checks for a MinGW-w64 suitable for building the recompiler.
1552sub CheckForMinGWw64(strOptMinGWw64)
1553 dim strPathMingWw64, str
1554 PrintHdr "MinGW-w64 GCC (unprefixed)"
1555
1556 '
1557 ' Find the MinGW-w64 tools.
1558 '
1559 strPathMingWw64 = ""
1560
1561 ' The specified path.
1562 if (strPathMingWw64 = "") And (strOptMinGWw64 <> "") then
1563 if CheckForMinGWw64Sub(strOptMinGWw64) then
1564 strPathMingWw64 = strOptMinGWw64
1565 end if
1566 end if
1567
1568 ' The tools location (first).
1569 if (strPathMinGWw64 = "") And (g_blnInternalFirst = True) then
1570 str = g_strPathDev & "/win.amd64/mingw-w64/r1"
1571 if CheckForMinGWw64Sub(str) then
1572 strPathMinGWw64 = str
1573 end if
1574 end if
1575
1576 ' See if there is any gcc around.
1577 if strPathMinGWw64 = "" then
1578 str = Which("x86_64-w64-mingw32-gcc.exe")
1579 if (str <> "") then
1580 str = PathParent(PathStripFilename(str))
1581 if CheckForMinGWw64Sub(str) then strPathMinGWw64 = str
1582 end if
1583 end if
1584
1585 if strPathMinGWw64 = "" then
1586 str = Which("gcc.exe")
1587 if (str <> "") then
1588 str = PathParent(PathStripFilename(str))
1589 if CheckForMinGWw64Sub(str) then strPathMinGWw64 = str
1590 end if
1591 end if
1592
1593 ' The tools location (post).
1594 if (strPathMinGWw64 = "") And (g_blnInternalFirst = False) then
1595 str = g_strPathDev & "/win.amd64/mingw-w64/r1"
1596 if CheckForMinGWw64Sub(str) then
1597 strPathMinGWw64 = str
1598 end if
1599 end if
1600
1601 ' Success?
1602 if strPathMinGWw64 = "" then
1603 if g_strTargetArch = "x86" then
1604 MsgWarning "Can't locate a suitable MinGW-w64 installation, ignoring since we're targeting x86 and won't need it."
1605 elseif strOptMinGWw64 = "" then
1606 MsgError "Can't locate a suitable MinGW-w64 installation. Try specify the path with " _
1607 & "the --with-MinGW-w64=<path> argument. If still no luck, consult the configure.log and the build requirements."
1608 else
1609 MsgError "Can't locate a suitable MinGW-w64 installation. Please consult the configure.log and the build requirements."
1610 end if
1611 exit sub
1612 end if
1613
1614 '
1615 ' Emit the config.
1616 '
1617 strPathMinGWw64 = UnixSlashes(PathAbs(strPathMinGWw64))
1618 CfgPrint "PATH_TOOL_MINGWW64 := " & strPathMinGWw64
1619 PrintResult "MinGW-w64 (GCC v" & g_strSubOutput & ")", strPathMinGWw64
1620end sub
1621
1622''
1623' Checks if the specified path points to an usable MinGW-w64 or not.
1624function CheckForMinGWw64Sub(strPathMinGWw64)
1625 g_strSubOutput = ""
1626 LogPrint "trying: strPathMinGWw64=" &strPathMinGWw64
1627
1628 if LogFileExists(strPathMinGWw64, "bin/gcc.exe") _
1629 And LogFileExists(strPathMinGWw64, "bin/ld.exe") _
1630 And LogFileExists(strPathMinGWw64, "bin/objdump.exe") _
1631 And LogFileExists(strPathMinGWw64, "bin/dllwrap.exe") _
1632 And LogFileExists(strPathMinGWw64, "bin/dlltool.exe") _
1633 And LogFileExists(strPathMinGWw64, "bin/as.exe") _
1634 And LogFileExists(strPathMinGWw64, "include/bfd.h") _
1635 And LogFileExists(strPathMinGWw64, "lib64/libgcc_s.a") _
1636 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/dllcrt1.o") _
1637 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/dllcrt2.o") _
1638 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/libmsvcrt.a") _
1639 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/lib/libmsvcr100.a") _
1640 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/include/_mingw.h") _
1641 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/include/stdint.h") _
1642 And LogFileExists(strPathMinGWw64, "x86_64-w64-mingw32/include/windows.h") _
1643 then
1644 if Shell(DosSlashes(strPathMinGWw64 & "/bin/gcc.exe") & " -dumpversion", True) = 0 then
1645 dim offVer, iMajor, iMinor, iPatch, strVer
1646
1647 ' extract the version.
1648 strVer = Trim(Replace(Replace(g_strShellOutput, vbCr, ""), vbLf, ""))
1649 if (Mid(strVer, 2, 1) = ".") _
1650 And (Mid(strVer, 4, 1) = ".") then
1651 iMajor = Int(Left(strVer, 1)) ' Is Int() the right thing here? I want atoi()!!!
1652 iMinor = Int(Mid(strVer, 3, 1))
1653 iPatch = Int(Mid(strVer, 5))
1654 else
1655 LogPrint "Malformed version: '" & strVer & "'"
1656 strVer = ""
1657 end if
1658 if strVer <> "" then
1659 if (iMajor = 4) And (iMinor >= 4) then
1660 CheckForMinGWw64Sub = True
1661 g_strSubOutput = strVer
1662 else
1663 LogPrint "MinGW-w64 version '" & iMajor & "." & iMinor & "." & iPatch & "' is not supported (or configure.vbs failed to parse it correctly)."
1664 end if
1665 else
1666 LogPrint "Couldn't locate the GCC version in the output!"
1667 end if
1668
1669 else
1670 LogPrint "Failed to run gcc.exe!"
1671 end if
1672 end if
1673end function
1674
1675
1676''
1677' Checks for any libSDL binaries.
1678sub CheckForlibSDL(strOptlibSDL)
1679 dim strPathlibSDL, str
1680 PrintHdr "libSDL"
1681
1682 '
1683 ' Try find some SDL library.
1684 '
1685
1686 ' First, the specific location.
1687 strPathlibSDL = ""
1688 if (strPathlibSDL = "") And (strOptlibSDL <> "") then
1689 if CheckForlibSDLSub(strOptlibSDL) then strPathlibSDL = strOptlibSDL
1690 end if
1691
1692 ' The tools location (first).
1693 if (strPathlibSDL = "") And (g_blnInternalFirst = True) Then
1694 str = g_strPathDev & "/win.x86/libsdl/v1.2.11"
1695 if CheckForlibSDLSub(str) then strPathlibSDL = str
1696 end if
1697
1698 if (strPathlibSDL = "") And (g_blnInternalFirst = True) Then
1699 str = g_strPathDev & "/win.x86/libsdl/v1.2.7-InnoTek"
1700 if CheckForlibSDLSub(str) then strPathlibSDL = str
1701 end if
1702
1703 ' Poke about in the path.
1704 str = Which("SDLmain.lib")
1705 if (strPathlibSDL = "") And (str <> "") Then
1706 str = PathParent(PathStripFilename(str))
1707 if CheckForlibSDLSub(str) then strPathlibSDL = str
1708 end if
1709
1710 str = Which("SDL.dll")
1711 if (strPathlibSDL = "") And (str <> "") Then
1712 str = PathParent(PathStripFilename(str))
1713 if CheckForlibSDLSub(str) then strPathlibSDL = str
1714 end if
1715
1716 ' The tools location (post).
1717 if (strPathlibSDL = "") And (g_blnInternalFirst = False) Then
1718 str = g_strPathDev & "/win.x86/libsdl/v1.2.11"
1719 if CheckForlibSDLSub(str) then strPathlibSDL = str
1720 end if
1721
1722 if (strPathlibSDL = "") And (g_blnInternalFirst = False) Then
1723 str = g_strPathDev & "/win.x86/libsdl/v1.2.7-InnoTek"
1724 if CheckForlibSDLSub(str) then strPathlibSDL = str
1725 end if
1726
1727 ' Success?
1728 if strPathlibSDL = "" then
1729 if strOptlibSDL = "" then
1730 MsgError "Can't locate libSDL. Try specify the path with the --with-libSDL=<path> argument. " _
1731 & "If still no luck, consult the configure.log and the build requirements."
1732 else
1733 MsgError "Can't locate libSDL. Please consult the configure.log and the build requirements."
1734 end if
1735 exit sub
1736 end if
1737
1738 strPathLibSDL = UnixSlashes(PathAbs(strPathLibSDL))
1739 CfgPrint "PATH_SDK_LIBSDL := " & strPathlibSDL
1740
1741 PrintResult "libSDL", strPathlibSDL
1742end sub
1743
1744''
1745' Checks if the specified path points to an usable libSDL or not.
1746function CheckForlibSDLSub(strPathlibSDL)
1747 CheckForlibSDLSub = False
1748 LogPrint "trying: strPathlibSDL=" & strPathlibSDL
1749 if LogFileExists(strPathlibSDL, "lib/SDL.lib") _
1750 And LogFileExists(strPathlibSDL, "lib/SDLmain.lib") _
1751 And LogFileExists(strPathlibSDL, "lib/SDL.dll") _
1752 And LogFileExists(strPathlibSDL, "include/SDL.h") _
1753 And LogFileExists(strPathlibSDL, "include/SDL_syswm.h") _
1754 And LogFileExists(strPathlibSDL, "include/SDL_version.h") _
1755 then
1756 CheckForlibSDLSub = True
1757 end if
1758end function
1759
1760
1761''
1762' Checks for libxml2.
1763sub CheckForXml2(strOptXml2)
1764 dim strPathXml2, str
1765 PrintHdr "libxml2"
1766
1767 ' Skip if no COM/ATL.
1768 if g_blnDisableCOM then
1769 PrintResultMsg "libxml2", "Skipped (" & g_strDisableCOM & ")"
1770 exit sub
1771 end if
1772
1773 '
1774 ' Try find some xml2 dll/lib.
1775 '
1776 strPathXml2 = ""
1777 if (strPathXml2 = "") And (strOptXml2 <> "") then
1778 if CheckForXml2Sub(strOptXml2) then strPathXml2 = strOptXml2
1779 end if
1780
1781 if strPathXml2 = "" Then
1782 str = Which("libxml2.lib")
1783 if str <> "" Then
1784 str = PathParent(PathStripFilename(str))
1785 if CheckForXml2Sub(str) then strPathXml2 = str
1786 end if
1787 end if
1788
1789 ' Ignore failure if we're in 'internal' mode.
1790 if (strPathXml2 = "") and g_blnInternalMode then
1791 PrintResultMsg "libxml2", "ignored (internal mode)"
1792 exit sub
1793 end if
1794
1795 ' Success?
1796 if strPathXml2 = "" then
1797 if strOptXml2 = "" then
1798 MsgError "Can't locate libxml2. Try specify the path with the --with-libxml2=<path> argument. " _
1799 & "If still no luck, consult the configure.log and the build requirements."
1800 else
1801 MsgError "Can't locate libxml2. Please consult the configure.log and the build requirements."
1802 end if
1803 exit sub
1804 end if
1805
1806 strPathXml2 = UnixSlashes(PathAbs(strPathXml2))
1807 CfgPrint "SDK_VBOX_LIBXML2_INCS := " & strPathXml2 & "/include"
1808 CfgPrint "SDK_VBOX_LIBXML2_LIBS := " & strPathXml2 & "/lib/libxml2.lib"
1809
1810 PrintResult "libxml2", strPathXml2
1811end sub
1812
1813''
1814' Checks if the specified path points to an usable libxml2 or not.
1815function CheckForXml2Sub(strPathXml2)
1816 dim str
1817
1818 CheckForXml2Sub = False
1819 LogPrint "trying: strPathXml2=" & strPathXml2
1820 if LogFileExists(strPathXml2, "include/libxml/xmlexports.h") _
1821 And LogFileExists(strPathXml2, "include/libxml/xmlreader.h") _
1822 then
1823 str = LogFindFile(strPathXml2, "bin/libxml2.dll")
1824 if str <> "" then
1825 if LogFindFile(strPathXml2, "lib/libxml2.lib") <> "" then
1826 CheckForXml2Sub = True
1827 end if
1828 end if
1829 end if
1830end function
1831
1832
1833''
1834' Checks for openssl
1835sub CheckForSsl(strOptSsl, bln32Bit)
1836 dim strPathSsl, str
1837 PrintHdr "openssl"
1838
1839 strOpenssl = "openssl"
1840 if bln32Bit = True then
1841 strOpenssl = "openssl32"
1842 end if
1843
1844 '
1845 ' Try find some openssl dll/lib.
1846 '
1847 strPathSsl = ""
1848 if (strPathSsl = "") And (strOptSsl <> "") then
1849 if CheckForSslSub(strOptSsl) then strPathSsl = strOptSsl
1850 end if
1851
1852 if strPathSsl = "" Then
1853 str = Which("libssl.lib")
1854 if str <> "" Then
1855 str = PathParent(PathStripFilename(str))
1856 if CheckForSslSub(str) then strPathSsl = str
1857 end if
1858 end if
1859
1860 ' Ignore failure if we're in 'internal' mode.
1861 if (strPathSsl = "") and g_blnInternalMode then
1862 PrintResultMsg strOpenssl, "ignored (internal mode)"
1863 exit sub
1864 end if
1865
1866 ' Success?
1867 if strPathSsl = "" then
1868 if strOptSsl = "" then
1869 MsgError "Can't locate " & strOpenssl & ". " _
1870 & "Try specify the path with the --with-" & strOpenssl & "=<path> argument. " _
1871 & "If still no luck, consult the configure.log and the build requirements."
1872 else
1873 MsgError "Can't locate " & strOpenssl & ". " _
1874 & "Please consult the configure.log and the build requirements."
1875 end if
1876 exit sub
1877 end if
1878
1879 strPathSsl = UnixSlashes(PathAbs(strPathSsl))
1880 if bln32Bit = True then
1881 CfgPrint "SDK_VBOX_OPENSSL-x86_INCS := " & strPathSsl & "/include"
1882 CfgPrint "SDK_VBOX_OPENSSL-x86_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1883 CfgPrint "SDK_VBOX_BLD_OPENSSL-x86_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1884 else
1885 CfgPrint "SDK_VBOX_OPENSSL_INCS := " & strPathSsl & "/include"
1886 CfgPrint "SDK_VBOX_OPENSSL_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1887 CfgPrint "SDK_VBOX_BLD_OPENSSL_LIBS := " & strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1888 end if
1889
1890 PrintResult strOpenssl, strPathSsl
1891end sub
1892
1893''
1894' Checks if the specified path points to an usable openssl or not.
1895function CheckForSslSub(strPathSsl)
1896
1897 CheckForSslSub = False
1898 LogPrint "trying: strPathSsl=" & strPathSsl
1899 if LogFileExists(strPathSsl, "include/openssl/md5.h") _
1900 And LogFindFile(strPathSsl, "lib/libssl.lib") <> "" _
1901 then
1902 CheckForSslSub = True
1903 end if
1904end function
1905
1906
1907''
1908' Checks for libcurl
1909sub CheckForCurl(strOptCurl, bln32Bit)
1910 dim strPathCurl, str
1911 PrintHdr "libcurl"
1912
1913 strCurl = "libcurl"
1914 if bln32Bit = True then
1915 strCurl = "libcurl32"
1916 end if
1917
1918 '
1919 ' Try find some cURL dll/lib.
1920 '
1921 strPathCurl = ""
1922 if (strPathCurl = "") And (strOptCurl <> "") then
1923 if CheckForCurlSub(strOptCurl) then strPathCurl = strOptCurl
1924 end if
1925
1926 if strPathCurl = "" Then
1927 str = Which("libcurl.lib")
1928 if str <> "" Then
1929 str = PathParent(PathStripFilename(str))
1930 if CheckForCurlSub(str) then strPathCurl = str
1931 end if
1932 end if
1933
1934 ' Ignore failure if we're in 'internal' mode.
1935 if (strPathCurl = "") and g_blnInternalMode then
1936 PrintResultMsg strCurl, "ignored (internal mode)"
1937 exit sub
1938 end if
1939
1940 ' Success?
1941 if strPathCurl = "" then
1942 if strOptCurl = "" then
1943 MsgError "Can't locate " & strCurl & ". " _
1944 & "Try specify the path with the --with-" & strCurl & "=<path> argument. " _
1945 & "If still no luck, consult the configure.log and the build requirements."
1946 else
1947 MsgError "Can't locate " & strCurl & ". " _
1948 & "Please consult the configure.log and the build requirements."
1949 end if
1950 exit sub
1951 end if
1952
1953 strPathCurl = UnixSlashes(PathAbs(strPathCurl))
1954 if bln32Bit = True then
1955 CfgPrint "SDK_VBOX_LIBCURL-x86_INCS := " & strPathCurl & "/include"
1956 CfgPrint "SDK_VBOX_LIBCURL-x86_LIBS.x86 := " & strPathCurl & "/libcurl.lib"
1957 else
1958 CfgPrint "SDK_VBOX_LIBCURL_INCS := " & strPathCurl & "/include"
1959 CfgPrint "SDK_VBOX_LIBCURL_LIBS := " & strPathCurl & "/libcurl.lib"
1960 end if
1961
1962 PrintResult strCurl, strPathCurl
1963end sub
1964
1965''
1966' Checks if the specified path points to an usable libcurl or not.
1967function CheckForCurlSub(strPathCurl)
1968
1969 CheckForCurlSub = False
1970 LogPrint "trying: strPathCurl=" & strPathCurl
1971 if LogFileExists(strPathCurl, "include/curl/curl.h") _
1972 And LogFindFile(strPathCurl, "libcurl.dll") <> "" _
1973 And LogFindFile(strPathCurl, "libcurl.lib") <> "" _
1974 then
1975 CheckForCurlSub = True
1976 end if
1977end function
1978
1979
1980
1981''
1982' Checks for any Qt5 binaries.
1983sub CheckForQt(strOptQt5)
1984 PrintHdr "Qt5"
1985
1986 '
1987 ' Try to find the Qt5 installation (user specified path with --with-qt5)
1988 '
1989 strPathQt5 = ""
1990
1991 LogPrint "Checking for user specified path of Qt5 ... "
1992 if (strPathQt5 = "") And (strOptQt5 <> "") then
1993 strOptQt5 = UnixSlashes(strOptQt5)
1994 if CheckForQt5Sub(strOptQt5) then strPathQt5 = strOptQt5
1995 end if
1996
1997 ' Check the dev tools
1998 if (strPathQt5 = "") Then
1999 strPathQt5 = g_strPathDev & "/win." & g_strTargetArch & "/qt/v5.5.1-r138"
2000 if CheckForQt5Sub(strPathQt5) = False then strPathQt5 = ""
2001 end if
2002
2003 ' Display the result.
2004 if strPathQt5 = "" then
2005 PrintResultMsg "Qt5", "not found"
2006 else
2007 PrintResult "Qt5", strPathQt5
2008 end if
2009
2010 if strPathQt5 <> "" then
2011 CfgPrint "PATH_SDK_QT5 := " & strPathQt5
2012 CfgPrint "PATH_TOOL_QT5 := $(PATH_SDK_QT5)"
2013 CfgPrint "VBOX_PATH_QT := $(PATH_SDK_QT5)"
2014 end if
2015 if strPathQt5 = "" then
2016 CfgPrint "VBOX_WITH_QTGUI :="
2017 end if
2018end sub
2019
2020
2021''
2022' Checks if the specified path points to an usable Qt5 library.
2023function CheckForQt5Sub(strPathQt5)
2024
2025 CheckForQt5Sub = False
2026 LogPrint "trying: strPathQt5=" & strPathQt5
2027
2028 if LogFileExists(strPathQt5, "bin/moc.exe") _
2029 And LogFileExists(strPathQt5, "bin/uic.exe") _
2030 And LogFileExists(strPathQt5, "include/QtWidgets/qwidget.h") _
2031 And LogFileExists(strPathQt5, "include/QtWidgets/QApplication") _
2032 And LogFileExists(strPathQt5, "include/QtGui/QImage") _
2033 And LogFileExists(strPathQt5, "include/QtNetwork/QHostAddress") _
2034 And ( LogFileExists(strPathQt5, "lib/Qt5Core.lib") _
2035 Or LogFileExists(strPathQt5, "lib/Qt5CoreVBox.lib")) _
2036 And ( LogFileExists(strPathQt5, "lib/Qt5Network.lib") _
2037 Or LogFileExists(strPathQt5, "lib/Qt5NetworkVBox.lib")) _
2038 then
2039 CheckForQt5Sub = True
2040 end if
2041
2042end function
2043
2044
2045'
2046'
2047function CheckForPython(strPathPython)
2048
2049 PrintHdr "Python"
2050
2051 CheckForPython = False
2052 LogPrint "trying: strPathPython=" & strPathPython
2053
2054 if LogFileExists(strPathPython, "python.exe") then
2055 CfgPrint "VBOX_BLD_PYTHON := " & strPathPython & "\python.exe"
2056 CheckForPython = True
2057 end if
2058
2059 PrintResult "Python ", strPathPython
2060end function
2061
2062
2063'
2064'
2065function CheckForMkisofs(strFnameMkisofs)
2066
2067 PrintHdr "mkisofs"
2068
2069 CheckForMkisofs = False
2070 LogPrint "trying: strFnameMkisofs=" & strFnameMkisofs
2071
2072 if FileExists(strFnameMkisofs) = false then
2073 LogPrint "Testing '" & strFnameMkisofs & " not found"
2074 else
2075 CfgPrint "VBOX_MKISOFS := " & strFnameMkisofs
2076 CheckForMkisofs = True
2077 end if
2078
2079 PrintResult "mkisofs ", strFnameMkisofs
2080end function
2081
2082
2083''
2084' Show usage.
2085sub usage
2086 Print "Usage: cscript configure.vbs [options]"
2087 Print ""
2088 Print "Configuration:"
2089 Print " -h, --help"
2090 Print " --internal"
2091 Print " --internal-last"
2092 Print " --target-arch=x86|amd64"
2093 Print ""
2094 Print "Components:"
2095 Print " --disable-COM"
2096 Print " --disable-UDPTunnel"
2097 Print ""
2098 Print "Locations:"
2099 Print " --with-kBuild=PATH "
2100 Print " --with-libSDL=PATH "
2101 Print " --with-MinGW32=PATH "
2102 Print " --with-MinGW-w64=PATH "
2103 Print " --with-Qt5=PATH "
2104 Print " --with-DDK=PATH "
2105 Print " --with-SDK=PATH "
2106 Print " --with-VC=PATH "
2107 Print " --with-VC-Common=PATH "
2108 Print " --with-VC-Express-Edition"
2109 Print " --with-W32API=PATH "
2110 Print " --with-libxml2=PATH "
2111 Print " --with-openssl=PATH "
2112 Print " --with-openssl32=PATH (only for 64-bit targets)"
2113 Print " --with-libcurl=PATH "
2114 Print " --with-libcurl32=PATH (only for 64-bit targets)"
2115 Print " --with-python=PATH "
2116 Print " --with-mkisofs=PATH "
2117end sub
2118
2119
2120''
2121' The main() like function.
2122'
2123Sub Main
2124 '
2125 ' Write the log header and check that we're not using wscript.
2126 '
2127 LogInit
2128 If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then
2129 Wscript.Echo "This script must be run under CScript."
2130 Wscript.Quit(1)
2131 End If
2132
2133 '
2134 ' Parse arguments.
2135 '
2136 strOptDDK = ""
2137 strOptDXDDK = ""
2138 strOptkBuild = ""
2139 strOptlibSDL = ""
2140 strOptMinGW32 = ""
2141 strOptMinGWw64 = ""
2142 strOptQt5 = ""
2143 strOptSDK = ""
2144 strOptVC = ""
2145 strOptVCCommon = ""
2146 blnOptVCExpressEdition = False
2147 strOptW32API = ""
2148 strOptXml2 = ""
2149 strOptSsl = ""
2150 strOptSsl32 = ""
2151 strOptCurl = ""
2152 strOptCurl32 = ""
2153 strOptPython = ""
2154 strOptMkisofs = ""
2155 blnOptDisableCOM = False
2156 blnOptDisableUDPTunnel = False
2157 for i = 1 to Wscript.Arguments.Count
2158 dim str, strArg, strPath
2159
2160 ' Separate argument and path value
2161 str = Wscript.Arguments.item(i - 1)
2162 if InStr(1, str, "=") > 0 then
2163 strArg = Mid(str, 1, InStr(1, str, "=") - 1)
2164 strPath = Mid(str, InStr(1, str, "=") + 1)
2165 if strPath = "" then MsgFatal "Syntax error! Argument #" & i & " is missing the path."
2166 else
2167 strArg = str
2168 strPath = ""
2169 end if
2170
2171 ' Process the argument
2172 select case LCase(strArg)
2173 case "--with-ddk"
2174 strOptDDK = strPath
2175 case "--with-dxsdk"
2176 MsgWarning "Ignoring --with-dxsdk (the DirectX SDK is no longer required)."
2177 case "--with-kbuild"
2178 strOptkBuild = strPath
2179 case "--with-libsdl"
2180 strOptlibSDL = strPath
2181 case "--with-mingw32"
2182 strOptMinGW32 = strPath
2183 case "--with-mingw-w64"
2184 strOptMinGWw64 = strPath
2185 case "--with-qt5"
2186 strOptQt5 = strPath
2187 case "--with-sdk"
2188 strOptSDK = strPath
2189 case "--with-vc"
2190 strOptVC = strPath
2191 case "--with-vc-common"
2192 strOptVCCommon = strPath
2193 case "--with-vc-express-edition"
2194 blnOptVCExpressEdition = True
2195 case "--with-w32api"
2196 strOptW32API = strPath
2197 case "--with-libxml2"
2198 strOptXml2 = strPath
2199 case "--with-openssl"
2200 strOptSsl = strPath
2201 case "--with-openssl32"
2202 strOptSsl32 = strPath
2203 case "--with-libcurl"
2204 strOptCurl = strPath
2205 case "--with-libcurl32"
2206 strOptCurl32 = strPath
2207 case "--with-python"
2208 strOptPython = strPath
2209 case "--with-mkisofs"
2210 strOptMkisofs = strPath
2211 case "--disable-com"
2212 blnOptDisableCOM = True
2213 case "--enable-com"
2214 blnOptDisableCOM = False
2215 case "--disable-udptunnel"
2216 blnOptDisableUDPTunnel = True
2217 case "--internal"
2218 g_blnInternalMode = True
2219 case "--internal-last"
2220 g_blnInternalFirst = False
2221 case "--target-arch"
2222 g_strTargetArch = strPath
2223 case "-h", "--help", "-?"
2224 usage
2225 Wscript.Quit(0)
2226 case else
2227 Wscript.echo "syntax error: Unknown option '" & str &"'."
2228 usage
2229 Wscript.Quit(1)
2230 end select
2231 next
2232
2233 '
2234 ' Initialize output files.
2235 '
2236 CfgInit
2237 EnvInit
2238
2239 '
2240 ' Check that the Shell function is sane.
2241 '
2242 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = "This works"
2243 if Shell("set TESTING_ENVIRONMENT_INHERITANC", False) <> 0 then ' The 'E' is missing on purpose (4nt).
2244 MsgFatal "shell execution test failed!"
2245 end if
2246 if g_strShellOutput <> "TESTING_ENVIRONMENT_INHERITANCE=This works" & CHR(13) & CHR(10) then
2247 Print "Shell test Test -> '" & g_strShellOutput & "'"
2248 MsgFatal "shell inheritance or shell execution isn't working right. Make sure you use cmd.exe."
2249 end if
2250 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = ""
2251 Print "Shell inheritance test: OK"
2252
2253 '
2254 ' Do the checks.
2255 '
2256 if blnOptDisableCOM = True then
2257 DisableCOM "--disable-com"
2258 end if
2259 if blnOptDisableUDPTunnel = True then
2260 DisableUDPTunnel "--disable-udptunnel"
2261 end if
2262 CheckSourcePath
2263 CheckForkBuild strOptkBuild
2264 CheckForWinDDK strOptDDK
2265 CfgPrint "VBOX_WITH_WDDM_W8 := " '' @todo look for WinDDKv8
2266 CheckForVisualCPP strOptVC, strOptVCCommon, blnOptVCExpressEdition
2267 CheckForPlatformSDK strOptSDK
2268 CheckForMidl
2269 CheckForMinGW32 strOptMinGW32, strOptW32API
2270 CheckForMinGWw64 strOptMinGWw64
2271 CfgPrint "VBOX_WITH_OPEN_WATCOM := " '' @todo look for openwatcom 1.9+
2272 EnvPrint "set PATH=%PATH%;" & g_strPath& "/tools/win." & g_strTargetArch & "/bin;" '' @todo look for yasm
2273 CheckForlibSDL strOptlibSDL
2274 ' Don't check for these libraries by default as they are part of OSE
2275 ' Using external libs can add a dependency to iconv
2276 if (strOptXml2 <> "") then
2277 CheckForXml2 strOptXml2
2278 end if
2279 CheckForSsl strOptSsl, False
2280 if g_strTargetArch = "amd64" then
2281 ' 32-bit openssl required as well
2282 CheckForSsl strOptSsl32, True
2283 end if
2284 CheckForCurl strOptCurl, False
2285 if g_strTargetArch = "amd64" then
2286 ' 32-bit Curl required as well
2287 CheckForCurl strOptCurl32, True
2288 end if
2289 CheckForQt strOptQt5
2290 if (strOptPython <> "") then
2291 CheckForPython strOptPython
2292 end if
2293 if (strOptMkisofs <> "") then
2294 CheckForMkisofs strOptMkisofs
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