VirtualBox

source: vbox/trunk/configure.vbs@ 7592

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

bln not b.

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