VirtualBox

source: vbox/trunk/configure.vbs@ 3317

Last change on this file since 3317 was 2992, checked in by vboxsync, 17 years ago

innotek

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