VirtualBox

source: vbox/trunk/configure.vbs@ 15957

Last change on this file since 15957 was 14460, checked in by vboxsync, 16 years ago

configure.vbs: removed the xalan/xerces cruft and attempted to put the libxml2/xslt discovery in instead. totally untested.

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