0028787: Configuration, genproj - add option HAVE_RelWithDebInfo for generating VS...
[occt.git] / adm / genconfdeps.tcl
CommitLineData
d1a67b9d 1# =======================================================================
2# Created on: 2012-01-26
3# Created by: Kirill GAVRILOV
4# Copyright (c) 2012 OPEN CASCADE SAS
5#
6# This file is part of Open CASCADE Technology software library.
7#
8# This library is free software; you can redistribute it and/or modify it under
9# the terms of the GNU Lesser General Public License version 2.1 as published
10# by the Free Software Foundation, with special exception defined in the file
11# OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12# distribution for complete text of the license and disclaimer of any warranty.
13#
14# Alternatively, this file may be used under the terms of Open CASCADE
15# commercial license or contractual agreement.
16
17# =======================================================================
18# Tools for search of third-party libraries and generation on environment
19# customization script
20# =======================================================================
910970ab 21
c7d774c5 22set ARCH "64"
910970ab 23
24if { "$tcl_platform(platform)" == "unix" } {
25 set SYS_PATH_SPLITTER ":"
26 set SYS_LIB_PREFIX "lib"
27 set SYS_EXE_SUFFIX ""
28 if { "$tcl_platform(os)" == "Darwin" } {
29 set SYS_LIB_SUFFIX "dylib"
30 } else {
31 set SYS_LIB_SUFFIX "so"
32 }
33 set VCVER "gcc"
34 set VCVARS ""
35} elseif { "$tcl_platform(platform)" == "windows" } {
36 set SYS_PATH_SPLITTER ";"
37 set SYS_LIB_PREFIX ""
38 set SYS_LIB_SUFFIX "lib"
39 set SYS_EXE_SUFFIX ".exe"
40 set VCVER "vc10"
41 set VCVARS ""
42}
43
5951a088 44set SHORTCUT_HEADERS "ShortCut"
910970ab 45
910970ab 46set PRODUCTS_PATH ""
47set CSF_OPT_INC [list]
48set CSF_OPT_LIB32 [list]
49set CSF_OPT_LIB64 [list]
50set CSF_OPT_BIN32 [list]
51set CSF_OPT_BIN64 [list]
52
c7d774c5 53if { "$tcl_platform(pointerSize)" == "4" } {
54 set ARCH "32"
55}
910970ab 56if { [info exists ::env(ARCH)] } {
57 set ARCH "$::env(ARCH)"
58}
e22105a9 59
910970ab 60if { [info exists ::env(SHORTCUT_HEADERS)] } {
61 set SHORTCUT_HEADERS "$::env(SHORTCUT_HEADERS)"
5951a088 62 if { $SHORTCUT_HEADERS == "true" } {
63 set SHORTCUT_HEADERS "ShortCut"
64 }
910970ab 65}
e22105a9 66
67# fetch environment variables (e.g. set by custom.sh or custom.bat) and set them as tcl variables with the same name
26cfd29c 68set THE_ENV_VARIABLES {HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_GL2PS HAVE_ZLIB HAVE_LIBLZMA HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo}
e22105a9 69foreach anEnvIter $THE_ENV_VARIABLES {
70 set ${anEnvIter} "false"
71 if { [info exists ::env(${anEnvIter})] } {
72 set ${anEnvIter} "$::env(${anEnvIter})"
73 }
910970ab 74}
e22105a9 75# do not export platform-specific variables
76if { "$::tcl_platform(os)" == "Darwin" } {
77 set HAVE_GLES2 ""
78} else {
79 set MACOSX_USE_GLX ""
26cfd29c 80}
81if { "$tcl_platform(platform)" != "windows" } {
82 set HAVE_D3D ""
83 set HAVE_RelWithDebInfo ""
910970ab 84}
e22105a9 85foreach anEnvIter {ARCH VCVER VCVARS PRODUCTS_PATH} {
86 if { [info exists ::env(${anEnvIter})] } {
87 set ${anEnvIter} "$::env(${anEnvIter})"
88 }
910970ab 89}
e22105a9 90
910970ab 91if { [info exists ::env(CSF_OPT_INC)] } {
92 set CSF_OPT_INC [split "$::env(CSF_OPT_INC)" $::SYS_PATH_SPLITTER]
93}
94if { [info exists ::env(CSF_OPT_LIB32)] } {
95 set CSF_OPT_LIB32 [split "$::env(CSF_OPT_LIB32)" $::SYS_PATH_SPLITTER]
96}
97if { [info exists ::env(CSF_OPT_LIB64)] } {
98 set CSF_OPT_LIB64 [split "$::env(CSF_OPT_LIB64)" $::SYS_PATH_SPLITTER]
99}
100if { [info exists ::env(CSF_OPT_BIN32)] } {
101 set CSF_OPT_BIN32 [split "$::env(CSF_OPT_BIN32)" $::SYS_PATH_SPLITTER]
102}
103if { [info exists ::env(CSF_OPT_BIN64)] } {
104 set CSF_OPT_BIN64 [split "$::env(CSF_OPT_BIN64)" $::SYS_PATH_SPLITTER]
105}
106
107# Search header file in $::CSF_OPT_INC and standard paths
108proc wokdep:SearchHeader {theHeader} {
109 # search in custom paths
110 foreach anIncPath $::CSF_OPT_INC {
111 set aPath "${anIncPath}/${theHeader}"
112 if { [file exists "$aPath"] } {
113 return "$aPath"
114 }
115 }
116
117 # search in system
118 set aPath "/usr/include/${theHeader}"
119 if { [file exists "$aPath"] } {
120 return "$aPath"
121 }
122 return ""
123}
124
125# Search library file in $::CSF_OPT_LIB* and standard paths
126proc wokdep:SearchLib {theLib theBitness {theSearchPath ""}} {
127 if { "$theSearchPath" != "" } {
128 set aPath "${theSearchPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
129 if { [file exists "$aPath"] } {
130 return "$aPath"
131 } else {
132 return ""
133 }
134 }
135
136 # search in custom paths
137 foreach aLibPath [set ::CSF_OPT_LIB$theBitness] {
138 set aPath "${aLibPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
139 if { [file exists "$aPath"] } {
140 return "$aPath"
141 }
142 }
143
144 # search in system
145 if { "$::ARCH" == "$theBitness"} {
146 set aPath "/usr/lib/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
147 if { [file exists "$aPath"] } {
148 return "$aPath"
149 }
150 }
151
c7d774c5 152
153 if { "$::tcl_platform(os)" == "Linux" } {
910970ab 154 if { "$theBitness" == "64" } {
155 set aPath "/usr/lib/x86_64-linux-gnu/lib${theLib}.so"
156 if { [file exists "$aPath"] } {
157 return "$aPath"
158 }
159 } else {
160 set aPath "/usr/lib/i386-linux-gnu/lib${theLib}.so"
161 if { [file exists "$aPath"] } {
162 return "$aPath"
163 }
164 }
165 }
166
167 return ""
168}
169
170# Search file in $::CSF_OPT_BIN* and standard paths
171proc wokdep:SearchBin {theBin theBitness {theSearchPath ""}} {
172 if { "$theSearchPath" != "" } {
173 set aPath "${theSearchPath}/${theBin}"
174 if { [file exists "$aPath"] } {
175 return "$aPath"
176 } else {
177 return ""
178 }
179 }
180
181 # search in custom paths
182 foreach aBinPath [set ::CSF_OPT_BIN$theBitness] {
183 set aPath "${aBinPath}/${theBin}"
184 if { [file exists "$aPath"] } {
185 return "$aPath"
186 }
187 }
188
189 # search in system
190 if { "$::ARCH" == "$theBitness"} {
191 set aPath "/usr/bin/${theBin}"
192 if { [file exists "$aPath"] } {
193 return "$aPath"
194 }
195 }
196
197 return ""
198}
199
200# Detect compiler C-runtime version 'vc*' and architecture '32'/'64'
201# to determine preferred path.
202proc wokdep:Preferred {theList theCmpl theArch} {
203 if { [llength $theList] == 0 } {
204 return ""
205 }
206
207 set aShortList {}
208 foreach aPath $theList {
209 if { [string first "$theCmpl" "$aPath"] != "-1" } {
210 lappend aShortList "$aPath"
211 }
212 }
213
214 if { [llength $aShortList] == 0 } {
215 #return [lindex $theList 0]
216 set aShortList $theList
217 }
218
219 set aVeryShortList {}
220 foreach aPath $aShortList {
221 if { [string first "$theArch" "$aPath"] != "-1" } {
222 lappend aVeryShortList "$aPath"
223 }
224 }
225 if { [llength $aVeryShortList] == 0 } {
226 return [lindex [lsort -decreasing $aShortList] 0]
227 }
228
229 return [lindex [lsort -decreasing $aVeryShortList] 0]
230}
231
e22105a9 232# Search library placement
233proc wokdep:SearchStandardLibrary {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64 theName theCheckHeader theCheckLib theCheckFolders} {
234 upvar $theErrInc anErrInc
235 upvar $theErrLib32 anErrLib32
236 upvar $theErrLib64 anErrLib64
237 upvar $theErrBin32 anErrBin32
238 upvar $theErrBin64 anErrBin64
239
240 set isFound "true"
241 set aHeaderPath [wokdep:SearchHeader "$theCheckHeader"]
242 if { "$aHeaderPath" == "" } {
243 set hasHeader false
244 foreach aFolderIter $theCheckFolders {
245 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{$aFolderIter}*] "$::VCVER" "$::ARCH" ]
246 if { "$aPath" != "" && [file exists "$aPath/include/$theCheckHeader"] } {
247 lappend ::CSF_OPT_INC "$aPath/include"
248 set hasHeader true
249 break
250 }
251 }
252 if { !$hasHeader } {
253 lappend anErrInc "Error: '$theCheckHeader' not found ($theName)"
254 set isFound "false"
255 }
256 }
257
258 foreach anArchIter {64 32} {
259 set aLibPath [wokdep:SearchLib "$theCheckLib" "$anArchIter"]
260 if { "$aLibPath" == "" } {
261 set hasLib false
262 foreach aFolderIter $theCheckFolders {
263 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{$aFolderIter}*] "$::VCVER" "$anArchIter" ]
264 set aLibPath [wokdep:SearchLib "$theCheckLib" "$anArchIter" "$aPath/lib"]
265 if { "$aLibPath" != "" } {
266 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
267 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
268 set hasLib true
269 break
270 }
271 }
272 if { !$hasLib } {
273 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}$theCheckLib.${::SYS_LIB_SUFFIX}' not found ($theName)"
274 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
275 }
276 }
277
278 if { "$::tcl_platform(platform)" == "windows" } {
279 set aDllPath [wokdep:SearchBin "$theCheckLib.dll" "$anArchIter"]
280 if { "$aDllPath" == "" } {
281 set hasDll false
282 foreach aFolderIter $theCheckFolders {
283 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{$aFolderIter}*] "$::VCVER" "$anArchIter" ]
284 set aDllPath [wokdep:SearchBin "$theCheckLib.dll" "$anArchIter" "$aPath/bin"]
285 if { "$aDllPath" != "" } {
286 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
287 set hasDll true
288 break
289 } else {
290 set aDllPath [wokdep:SearchBin "$theCheckLib.dll" "$anArchIter" "$aPath/lib"]
291 if { "$aDllPath" != "" } {
292 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
293 set hasDll true
294 break
295 }
296 }
297 }
298 if { !$hasDll } {
299 lappend anErrBin$anArchIter "Error: '$theCheckLib.dll' not found ($theName)"
300 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
301 }
302 }
303 }
304 }
305
306 return "$isFound"
307}
308
910970ab 309# Search Tcl/Tk libraries placement
310proc wokdep:SearchTclTk {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
311 upvar $theErrInc anErrInc
312 upvar $theErrLib32 anErrLib32
313 upvar $theErrLib64 anErrLib64
314 upvar $theErrBin32 anErrBin32
315 upvar $theErrBin64 anErrBin64
316
317 set tclver_maj 8
318 set tclver_min 6
319
320 set isFound "true"
321 set aTclHPath [wokdep:SearchHeader "tcl.h"]
322 set aTkHPath [wokdep:SearchHeader "tk.h"]
323 if { "$aTclHPath" == "" || "$aTkHPath" == "" } {
324 if { [file exists "/usr/include/tcl8.6/tcl.h"]
325 && [file exists "/usr/include/tcl8.6/tk.h" ] } {
326 lappend ::CSF_OPT_INC "/usr/include/tcl8.6"
327 set aTclHPath "/usr/include/tcl8.6/tcl.h"
328 } else {
329 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$::ARCH" ]
330 if { "$aPath" != "" && [file exists "$aPath/include/tcl.h"] && [file exists "$aPath/include/tk.h"] } {
331 lappend ::CSF_OPT_INC "$aPath/include"
332 set aTclHPath "$aPath/include/tcl.h"
333 } else {
334 lappend anErrInc "Error: 'tcl.h' or 'tk.h' not found (Tcl/Tk)"
335 set isFound "false"
336 }
337 }
338 }
339
340 # detect tcl version by parsing header file
341 if { $isFound } {
342 set fh [open $aTclHPath]
343 set tcl_h [read $fh]
344 close $fh
345 regexp {define\s+TCL_MAJOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_maj
346 regexp {define\s+TCL_MINOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_min
347 }
348
349 if { "$::tcl_platform(platform)" == "windows" } {
350 set aTclLibName "tcl${tclver_maj}${tclver_min}"
351 set aTkLibName "tk${tclver_maj}${tclver_min}"
352 } else {
353 set aTclLibName "tcl${tclver_maj}.${tclver_min}"
354 set aTkLibName "tk${tclver_maj}.${tclver_min}"
355 }
356
357 foreach anArchIter {64 32} {
358 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter"]
359 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter"]
360 if { "$aTclLibPath" == "" || "$aTkLibPath" == "" } {
361 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
362 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter" "$aPath/lib"]
363 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter" "$aPath/lib"]
364 if { "$aTclLibPath" != "" && "$aTkLibPath" != "" } {
365 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
366 } else {
367 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aTclLibName}.${::SYS_LIB_SUFFIX}' or '${::SYS_LIB_PREFIX}${aTkLibName}.${::SYS_LIB_SUFFIX}' not found (Tcl/Tk)"
368 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
369 }
370 }
371
372 if { "$::tcl_platform(platform)" == "windows" } {
373 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter"]
374 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter"]
375 if { "$aTclDllPath" == "" || "$aTkDllPath" == "" } {
376 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
377 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter" "$aPath/bin"]
378 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter" "$aPath/bin"]
379 if { "$aTclDllPath" != "" && "$aTkDllPath" != "" } {
380 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
381 } else {
382 lappend anErrBin$anArchIter "Error: '${aTclLibName}.dll' or '${aTkLibName}.dll' not found (Tcl/Tk)"
383 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
384 }
385 }
386 }
387 }
388
389 return "$isFound"
390}
391
392# Search FreeType library placement
393proc wokdep:SearchFreeType {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
394 upvar $theErrInc anErrInc
395 upvar $theErrLib32 anErrLib32
396 upvar $theErrLib64 anErrLib64
397 upvar $theErrBin32 anErrBin32
398 upvar $theErrBin64 anErrBin64
399
400 set isFound "true"
401 set aFtBuildPath [wokdep:SearchHeader "ft2build.h"]
402
910970ab 403 if { "$aFtBuildPath" == "" } {
404 # TODO - use `freetype-config --cflags` instead
405 set aSysFreeType "/usr/include/freetype2"
c7d774c5 406 if { [file exists "$aSysFreeType/ft2build.h"] } {
910970ab 407 lappend ::CSF_OPT_INC "$aSysFreeType"
408 } elseif { [file exists "$aSysFreeType/freetype2/ft2build.h"] } {
409 lappend ::CSF_OPT_INC "$aSysFreeType/freetype2"
410 } else {
411 set aSysFreeType "/usr/X11/include/freetype2"
412 if { [file exists "$aSysFreeType/ft2build.h"] } {
413 lappend ::CSF_OPT_INC "/usr/X11/include"
414 lappend ::CSF_OPT_INC "$aSysFreeType"
415 } else {
416 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$::ARCH" ]
417 if {"$aPath" != ""} {
418 if {[file exists "$aPath/include/ft2build.h"]} {
419 lappend ::CSF_OPT_INC "$aPath/include"
420 } elseif {[file exists "$aPath/include/freetype2/ft2build.h"]} {
421 lappend ::CSF_OPT_INC "$aPath/include/freetype2"
422 }
423 } else {
424 lappend anErrInc "Error: 'freetype.h' not found (FreeType2)"
425 set isFound "false"
426 }
427 }
428 }
429 }
430
431 # parse 'freetype-config --libs'
432 set aConfLibPath ""
433 if { [catch { set aConfLibs [exec freetype-config --libs] } ] == 0 } {
434 foreach aPath [split $aConfLibs " "] {
435 if { [string first "-L" "$aPath"] == 0 } {
436 set aConfLibPath [string range "$aPath" 2 [string length "$aPath"]]
437 }
438 }
439 }
440
441 foreach anArchIter {64 32} {
442 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter"]
443 if { "$aFtLibPath" == "" } {
444 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
445 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aPath/lib"]
446 if { "$aFtLibPath" != "" } {
447 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
448 } else {
449 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aConfLibPath"]
450 if { "$aFtLibPath" != "" } {
451 lappend ::CSF_OPT_LIB$anArchIter "$aConfLibPath"
452 } else {
453 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freetype.${::SYS_LIB_SUFFIX}' not found (FreeType2)"
454 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
455 }
456 }
457 }
458 if { "$::tcl_platform(platform)" == "windows" } {
459 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter"]
460 if { "$aFtDllPath" == "" } {
461 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
462 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/bin"]
463 if { "$aFtDllPath" != "" } {
464 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
465 } else {
466 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/lib"]
467 if { "$aFtDllPath" != "" } {
468 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
469 } else {
470 lappend anErrBin$anArchIter "Error: 'freetype.dll' not found (FreeType2)"
471 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
472 }
473 }
474 }
475 }
476 }
477
478 return "$isFound"
479}
480
481# Search FreeImage library placement
482proc wokdep:SearchFreeImage {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
483 upvar $theErrInc anErrInc
484 upvar $theErrLib32 anErrLib32
485 upvar $theErrLib64 anErrLib64
486 upvar $theErrBin32 anErrBin32
487 upvar $theErrBin64 anErrBin64
488
489 # binary distribution has another layout
490 set aFImageDist "Dist"
910970ab 491
492 set isFound "true"
f0d3b7af 493 set aFImageHPath [wokdep:SearchHeader "FreeImage.h"]
494 if { "$aFImageHPath" == "" } {
910970ab 495 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$::ARCH" ]
f0d3b7af 496 if { "$aPath" != "" && [file exists "$aPath/include/FreeImage.h"] } {
910970ab 497 lappend ::CSF_OPT_INC "$aPath/include"
f0d3b7af 498 } elseif { "$aPath" != "" && [file exists "$aPath/$aFImageDist/FreeImage.h"] } {
910970ab 499 lappend ::CSF_OPT_INC "$aPath/$aFImageDist"
910970ab 500 } else {
f0d3b7af 501 lappend anErrInc "Error: 'FreeImage.h' not found (FreeImage)"
910970ab 502 set isFound "false"
503 }
504 }
505
506 foreach anArchIter {64 32} {
f0d3b7af 507 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter"]
508 if { "$aFImageLibPath" == "" } {
910970ab 509 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
f0d3b7af 510 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/lib"]
511 if { "$aFImageLibPath" != "" } {
910970ab 512 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
513 } else {
f0d3b7af 514 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/$aFImageDist"]
515 if { "$aFImageLibPath" != "" } {
910970ab 516 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImageDist"
910970ab 517 } else {
f0d3b7af 518 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimage.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
910970ab 519 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
520 }
521 }
522 }
523 if { "$::tcl_platform(platform)" == "windows" } {
60273f77 524 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter"]
525 if { "$aFImageDllPath" == "" } {
910970ab 526 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
60273f77 527 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/bin"]
528 if { "$aFImageDllPath" != "" } {
910970ab 529 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
530 } else {
60273f77 531 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/$aFImageDist"]
532 if { "$aFImageDllPath" != "" } {
910970ab 533 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImageDist"
910970ab 534 } else {
60273f77 535 lappend anErrBin$anArchIter "Error: 'freeimage.dll' is not found (FreeImage)"
910970ab 536 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
537 }
538 }
539 }
540 }
541 }
542
543 return "$isFound"
544}
545
e22105a9 546# Search FFmpeg framework placement
547proc wokdep:SearchFFmpeg {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
910970ab 548 upvar $theErrInc anErrInc
549 upvar $theErrLib32 anErrLib32
550 upvar $theErrLib64 anErrLib64
551 upvar $theErrBin32 anErrBin32
552 upvar $theErrBin64 anErrBin64
553
554 set isFound "true"
e22105a9 555 set aFFmpegHPath [wokdep:SearchHeader "libavutil/avutil.h"]
556 if { "$aFFmpegHPath" == "" } {
557 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{ffmpeg}*] "$::VCVER" "$::ARCH" ]
558 if { "$aPath" != "" && [file exists "$aPath/include/libavutil/avutil.h"] } {
910970ab 559 lappend ::CSF_OPT_INC "$aPath/include"
560 } else {
e22105a9 561 lappend anErrInc "Error: 'libavutil/avutil.h' not found (FFmpeg)"
910970ab 562 set isFound "false"
563 }
564 }
565
566 foreach anArchIter {64 32} {
e22105a9 567 set aFFmpegLibPath [wokdep:SearchLib "avutil" "$anArchIter"]
568 if { "$aFFmpegLibPath" == "" } {
569 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{ffmpeg}*] "$::VCVER" "$anArchIter" ]
570 set aFFmpegLibPath [wokdep:SearchLib "avutil" "$anArchIter" "$aPath/lib"]
571 if { "$aFFmpegLibPath" != "" } {
910970ab 572 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
e22105a9 573 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
910970ab 574 } else {
e22105a9 575 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}avutil.${::SYS_LIB_SUFFIX}' not found (FFmpeg)"
910970ab 576 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
577 }
578 }
910970ab 579 }
580
581 return "$isFound"
582}
583
584# Search TBB library placement
585proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
586 upvar $theErrInc anErrInc
587 upvar $theErrLib32 anErrLib32
588 upvar $theErrLib64 anErrLib64
589 upvar $theErrBin32 anErrBin32
590 upvar $theErrBin64 anErrBin64
591
592 set isFound "true"
593 set aTbbHPath [wokdep:SearchHeader "tbb/scalable_allocator.h"]
594 if { "$aTbbHPath" == "" } {
595 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$::ARCH" ]
596 if { "$aPath" != "" && [file exists "$aPath/include/tbb/scalable_allocator.h"] } {
597 lappend ::CSF_OPT_INC "$aPath/include"
598 } else {
599 lappend anErrInc "Error: 'tbb/scalable_allocator.h' not found (Intel TBB)"
600 set isFound "false"
601 }
602 }
603
604 foreach anArchIter {64 32} {
605 set aSubDir "ia32"
606 if { "$anArchIter" == "64"} {
607 set aSubDir "intel64"
608 }
609
610 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter"]
611 if { "$aTbbLibPath" == "" } {
612 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
613 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir/${::VCVER}"]
614 if { "$aTbbLibPath" == "" } {
615 # Set the path to the TBB library for Linux
616 if { "$::tcl_platform(platform)" != "windows" } {
617 set aSubDir "$aSubDir/cc4.1.0_libc2.4_kernel2.6.16.21"
618 }
619 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir"]
620 if { "$aTbbLibPath" != "" } {
621 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir"
622 }
623 } else {
624 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/${::VCVER}"
625 }
626 if { "$aTbbLibPath" == "" } {
627 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
628 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
629 }
630 }
631 if { "$::tcl_platform(platform)" == "windows" } {
632 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"]
633 if { "$aTbbDllPath" == "" } {
634 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
635 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/${::VCVER}"]
636 if { "$aTbbDllPath" != "" } {
637 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/${::VCVER}"
638 } else {
639 lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)"
640 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
641 }
642 }
643 }
644 }
645
646 return "$isFound"
647}
648
649# Search OpenCL library placement
650proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
651 upvar $theErrInc anErrInc
652 upvar $theErrLib32 anErrLib32
653 upvar $theErrLib64 anErrLib64
654 upvar $theErrBin32 anErrBin32
655 upvar $theErrBin64 anErrBin64
656
657 set isFound "true"
658 if { "$::tcl_platform(os)" == "Darwin" } {
659 # OpenCL framework available since Mac OS X 16
660 return "$isFound"
661 }
662
663 set aCLHPath [wokdep:SearchHeader "CL/cl_gl.h"]
664 if { "$aCLHPath" == "" } {
665 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$::ARCH" ]
666 if { "$aPath" != "" && [file exists "$aPath/include/CL/cl_gl.h"] } {
667 lappend ::CSF_OPT_INC "$aPath/include"
668 } else {
669 lappend anErrInc "Error: 'CL/cl_gl.h' not found (OpenCL)"
670 set isFound "false"
671 }
672 }
673
674 foreach anArchIter {64 32} {
675 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter"]
676 if { "$aCLLibPath" == "" } {
677 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$anArchIter" ]
678 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter" "$aPath/lib"]
679 if { "$aCLLibPath" != "" } {
680 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
681 } else {
682 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}OpenCL.${::SYS_LIB_SUFFIX}' not found (OpenCL)"
683 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
684 }
685 }
686 }
687
688 return "$isFound"
689}
690
1ce0716b 691# Search EGL library placement
692proc wokdep:SearchEGL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
693 upvar $theErrInc anErrInc
694 upvar $theErrLib32 anErrLib32
695 upvar $theErrLib64 anErrLib64
696 upvar $theErrBin32 anErrBin32
697 upvar $theErrBin64 anErrBin64
698
699 set isFound "true"
700 set aHeaderPath [wokdep:SearchHeader "EGL/egl.h"]
701 if { "$aHeaderPath" == "" } {
702 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$::ARCH" ]
703 if { "$aPath" == "" || ![file exists "$aPath/include/EGL/egl.h"] } {
704 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$::ARCH" ]
705 }
706
707 if { "$aPath" != "" && [file exists "$aPath/include/EGL/egl.h"] } {
708 lappend ::CSF_OPT_INC "$aPath/include"
709 } else {
710 lappend anErrInc "Error: 'EGL/egl.h' not found (EGL)"
711 set isFound "false"
712 }
713 }
714
715 set aLibName "EGL"
716 if { "$::tcl_platform(platform)" == "windows" } {
717 # awkward exception
718 set aLibName "libEGL"
719 }
720
721 foreach anArchIter {64 32} {
722 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter"]
723 if { "$aLibPath" == "" } {
724 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ]
725 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
726 if { "$aLibPath" == "" } {
727 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
728 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
729 }
730
731 if { "$aLibPath" != "" } {
732 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
733 } else {
734 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aLibName}.${::SYS_LIB_SUFFIX}' not found (EGL)"
735 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
736 }
737 }
738
739 if { "$::tcl_platform(platform)" == "windows" } {
740 set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter"]
741 if { "$aDllPath" == "" } {
742 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ]
743 set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter" "$aPath/bin"]
744 if { "$aDllPath" == "" } {
745 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
746 set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter" "$aPath/bin"]
747 }
748
749 if { "$aDllPath" != "" } {
750 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
751 } else {
752 lappend anErrBin$anArchIter "Error: 'libEGL.dll' not found (EGL)"
753 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
754 }
755 }
756 }
757 }
758
759 return "$isFound"
760}
761
762# Search OpenGL ES 2.0 library placement
763proc wokdep:SearchGLES {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
764 upvar $theErrInc anErrInc
765 upvar $theErrLib32 anErrLib32
766 upvar $theErrLib64 anErrLib64
767 upvar $theErrBin32 anErrBin32
768 upvar $theErrBin64 anErrBin64
769
770 set isFound "true"
771 set aHeaderPath [wokdep:SearchHeader "GLES2/gl2.h"]
772 if { "$aHeaderPath" == "" } {
773 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{GLES}*] "$::VCVER" "$::ARCH" ]
774 if { "$aPath" == "" || ![file exists "$aPath/include/GLES2/gl2.h"] } {
775 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$::ARCH" ]
776 }
777
778 if { "$aPath" != "" && [file exists "$aPath/include/GLES2/gl2.h"] } {
779 lappend ::CSF_OPT_INC "$aPath/include"
780 } else {
781 lappend anErrInc "Error: 'GLES2/gl2.h' not found (OpenGL ES 2.0)"
782 set isFound "false"
783 }
784 }
785
786 set aLibName "GLESv2"
787 if { "$::tcl_platform(platform)" == "windows" } {
788 # awkward exception
789 set aLibName "libGLESv2"
790 }
791
792 foreach anArchIter {64 32} {
793 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter"]
794 if { "$aLibPath" == "" } {
795 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{GLES}*] "$::VCVER" "$anArchIter" ]
796 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
797 if { "$aLibPath" == "" } {
798 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
799 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
800 }
801
802 if { "$aLibPath" != "" } {
803 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
804 } else {
805 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aLibName}.${::SYS_LIB_SUFFIX}' not found (OpenGL ES 2.0)"
806 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
807 }
808 }
809
810 if { "$::tcl_platform(platform)" == "windows" } {
811 set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter"]
812 if { "$aDllPath" == "" } {
813 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ]
814 set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter" "$aPath/bin"]
815 if { "$aDllPath" == "" } {
816 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
817 set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter" "$aPath/bin"]
818 }
819
820 if { "$aDllPath" != "" } {
821 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
822 } else {
823 lappend anErrBin$anArchIter "Error: 'libGLESv2.dll' not found (OpenGL ES 2.0)"
824 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
825 }
826 }
827 }
828 }
829
830 return "$isFound"
831}
832
910970ab 833# Auxiliary function, gets VTK version to set default search directory
834proc wokdep:VtkVersion { thePath } {
835 set aResult "6.1"
836
837 set aVtkRoot [lindex [regexp -all -inline {[0-9.]*} [file tail $thePath]] 0]
838 if { "$aVtkRoot" != "" } {
839 set aVtkRoot [regexp -inline {[0-9]*.[0-9]*} $aVtkRoot]
840 if { "$aVtkRoot" != "" } {
841 set aResult $aVtkRoot
842 }
843 }
844
845 return $aResult
846}
847
848# Search VTK library placement
849proc wokdep:SearchVTK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
850 upvar $theErrInc anErrInc
851 upvar $theErrLib32 anErrLib32
852 upvar $theErrLib64 anErrLib64
853 upvar $theErrBin32 anErrBin32
854 upvar $theErrBin64 anErrBin64
855
856 set isFound "true"
857
858 set aVtkPath ""
859 set aVtkIncPath [wokdep:SearchHeader "vtkConfigure.h"]
860 set aVtkVer [wokdep:VtkVersion $aVtkIncPath]
861 if { "$aVtkIncPath" == ""} {
862 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
863 set aVtkPath [wokdep:Preferred "$aPathList" "$::VCVER" "$::ARCH" ]
864 if { "$aVtkPath" != "" && [file exists "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]/vtkConfigure.h"]} {
865 set aVtkVer [wokdep:VtkVersion $aVtkPath]
866 lappend ::CSF_OPT_INC "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]"
867 } else { # try to search in all found paths
868 set isFound "false"
869 foreach anIt $aPathList {
870 if { [file exists "$anIt/include/vtk-[wokdep:VtkVersion $anIt]/vtkConfigure.h"] } {
871 set aVtkPath $anIt
872 set aVtkVer [wokdep:VtkVersion $aVtkPath]
873 lappend ::CSF_OPT_INC "$anIt/include/vtk-[wokdep:VtkVersion $anIt]"
874 set isFound "true"
875 break
876 }
877 }
878
879 # Bad case: we do not found vtkConfigure.h in all paths.
880 if { "$isFound" == "false"} {
881 lappend anErrInc "Error: 'vtkConfigure.h' not found (VTK)"
882 set isFound "false"
883 }
884 }
885 }
886
887 set aVtkLibPath ""
888 foreach anArchIter {64 32} {
889 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter"]
890 if { "$aVtkLibPath" == "" } {
891 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
892 set aPath [wokdep:Preferred $aPathList "$::VCVER" "$anArchIter" ]
893 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aPath/lib"]
894 if { "$aVtkLibPath" != "" } {
895 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
896 } else {
897 set aPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aVtkPath/lib"]
898 if { "$aPath" != "" } {
899 set aLibPath $aVtkIncPath
900 lappend ::CSF_OPT_LIB$anArchIter "$aLibPath/lib"
901 } else {
902 # The last chance: search /lib directory in all found paths
903 foreach anIt $aPathList {
904 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$anIt/lib"]
905 if { "$aVtkLibPath" != ""} {
906 lappend ::CSF_OPT_LIB$anArchIter "$anIt/lib"
907 break
908 }
909 }
910 if { "$aVtkLibPath" == "" } {
911 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}vtkCommonCore-${aVtkVer}\.${::SYS_LIB_SUFFIX}' not found (VTK)"
912 if { "$::ARCH" == "$anArchIter" } {
913 set isFound "false"
914 }
915 }
916 }
917 }
918 }
919 }
920
921 # Search binary path
922 if { "$::tcl_platform(platform)" == "windows" } {
923 foreach anArchIter {64 32} {
924 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter"]
925 if { "$aVtkBinPath" == "" } {
926 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*] "$::VCVER" "$anArchIter" ]
927 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/bin"]
928 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
929 } else {
930 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/lib"]
931 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib" }
932 }
933 }
934 }
935
936 # We didn't find preferred binary path => search through inc path or among all available VTK directories
937 if { "$aVtkBinPath" == "" } {
938 # Try to find in lib path
e31a8e52 939 set aPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/bin"]
940 if { "$aPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/bin"
941 } elseif { [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/lib"] != "" } {
942 lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/lib"
910970ab 943 } else {
944 lappend anErrBin$anArchIter "Error: 'vtkCommonCore-${aVtkVer}.dll' not found (VTK)"
945 set isFound "false"
946 }
947 }
948 }
949
950 return "$isFound"
951}
952
953# Search Qt4 libraries placement
954proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
955 upvar $theErrInc anErrInc
956 upvar $theErrLib32 anErrLib32
957 upvar $theErrLib64 anErrLib64
958 upvar $theErrBin32 anErrBin32
959 upvar $theErrBin64 anErrBin64
960
961 set isFound "true"
962 set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qmessagebox.h"]
963 if { "$aQMsgBoxHPath" == "" } {
964 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$::ARCH" ]
965 if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qmessagebox.h"] } {
966 lappend ::CSF_OPT_INC "$aPath/include"
967 lappend ::CSF_OPT_INC "$aPath/include/Qt"
968 lappend ::CSF_OPT_INC "$aPath/include/QtGui"
969 lappend ::CSF_OPT_INC "$aPath/include/QtCore"
970 } else {
971 if { [file exists "/usr/include/qt4/QtGui/qmessagebox.h"] } {
972 lappend ::CSF_OPT_INC "/usr/include/qt4"
973 lappend ::CSF_OPT_INC "/usr/include/qt4/Qt"
974 lappend ::CSF_OPT_INC "/usr/include/qt4/QtGui"
975 lappend ::CSF_OPT_INC "/usr/include/qt4/QtCore"
976 } else {
977 lappend anErrInc "Error: 'QtGui/qmessagebox.h' not found (Qt4)"
978 set isFound "false"
979 }
980 }
981 }
982
983 set aQtGuiLibName "QtGui"
984 if { "$::tcl_platform(platform)" == "windows" } {
985 set aQtGuiLibName "QtGui4"
986 }
987
988 foreach anArchIter {64 32} {
989 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter"]
990 if { "$aQMsgBoxLibPath" == "" } {
991 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
992 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter" "$aPath/lib"]
993 if { "$aQMsgBoxLibPath" != "" } {
994 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
995 } else {
996 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt4)"
997 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
998 }
999 }
1000 if { "$::tcl_platform(platform)" == "windows" } {
1001 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter"]
1002 if { "$aQMsgBoxDllPath" == "" } {
1003 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
1004 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter" "$aPath/bin"]
1005 if { "$aQMsgBoxDllPath" != "" } {
1006 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
1007 } else {
1008 lappend anErrBin$anArchIter "Error: 'QtGui4.dll' not found (Qt4)"
1009 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
1010 }
1011 }
1012 }
1013 }
1014
1015 return "$isFound"
1016}
1017
1018# Search JDK placement
1019proc wokdep:SearchJDK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
1020 upvar $theErrInc anErrInc
1021 upvar $theErrLib32 anErrLib32
1022 upvar $theErrLib64 anErrLib64
1023 upvar $theErrBin32 anErrBin32
1024 upvar $theErrBin64 anErrBin64
1025
1026 set isFound "true"
1027 set aJniHPath [wokdep:SearchHeader "jni.h"]
1028 set aJniMdHPath [wokdep:SearchHeader "jni_md.h"]
1029 if { "$aJniHPath" == "" || "$aJniMdHPath" == "" } {
1030 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$::ARCH" ]
1031 if { "$aPath" != "" && [file exists "$aPath/include/jni.h"] } {
1032 lappend ::CSF_OPT_INC "$aPath/include"
1033 if { "$::tcl_platform(platform)" == "windows" } {
1034 lappend ::CSF_OPT_INC "$aPath/include/win32"
1035 } elseif { [file exists "$aPath/include/linux"] } {
1036 lappend ::CSF_OPT_INC "$aPath/include/linux"
1037 }
1038 } else {
1039 if { [file exists "/System/Library/Frameworks/JavaVM.framework/Home/include/jni.h"] } {
1040 lappend ::CSF_OPT_INC "/System/Library/Frameworks/JavaVM.framework/Home/include"
1041 } else {
1042 lappend anErrInc "Error: 'jni.h' or 'jni_md.h' not found (JDK)"
1043 set isFound "false"
1044 }
1045 }
1046 }
1047
1048 foreach anArchIter {64 32} {
1049 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter"]
1050 if { "$aJavacPath" == "" } {
1051 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$anArchIter" ]
1052 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter" "$aPath/bin"]
1053 if { "$aJavacPath" != "" } {
1054 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
1055 } else {
1056 if { "$::ARCH" == "$anArchIter" && [file exists "/System/Library/Frameworks/JavaVM.framework/Home/bin/javac${::SYS_EXE_SUFFIX}"] } {
1057 lappend ::CSF_OPT_BIN$anArchIter "/System/Library/Frameworks/JavaVM.framework/Home/bin"
1058 } else {
1059 lappend anErrBin$anArchIter "Error: 'javac${::SYS_EXE_SUFFIX}' not found (JDK)"
1060 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
1061 }
1062 }
1063 }
1064 }
1065
1066 return "$isFound"
1067}
1068
1069# Search X11 libraries placement
1070proc wokdep:SearchX11 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
1071 upvar $theErrInc anErrInc
1072 upvar $theErrLib32 anErrLib32
1073 upvar $theErrLib64 anErrLib64
1074 upvar $theErrBin32 anErrBin32
1075 upvar $theErrBin64 anErrBin64
1076
1077 set isFound "true"
1078 if { "$::tcl_platform(platform)" == "windows" || ( "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" ) } {
1079 return "$isFound"
1080 }
1081
1082 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH"]
1083 if { "$aXmuLibPath" == "" } {
1084 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH" "/usr/X11/lib"]
1085 if { "$aXmuLibPath" != "" } {
1086 #lappend ::CSF_OPT_LIB$::ARCH "/usr/X11/lib"
1087 } else {
1088 lappend anErrLib$::ARCH "Error: '${::SYS_LIB_PREFIX}Xmu.${::SYS_LIB_SUFFIX}' not found (X11)"
1089 set isFound "false"
1090 }
1091 }
1092
1093 return "$isFound"
1094}
1095
1096# Generate (override) custom environment file
1097proc wokdep:SaveCustom {} {
1098 if { "$::tcl_platform(platform)" == "windows" } {
1099 set aCustomFilePath "./custom.bat"
1100 set aFile [open $aCustomFilePath "w"]
1101 puts $aFile "@echo off"
1102 puts $aFile "rem This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
1103
1104 puts $aFile ""
1105 puts $aFile "set VCVER=$::VCVER"
1106 puts $aFile "set ARCH=$::ARCH"
1107 puts $aFile "set VCVARS=$::VCVARS"
1108 puts $aFile "set SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
1109
1110 puts $aFile ""
1111 puts $aFile "set \"PRODUCTS_PATH=$::PRODUCTS_PATH\""
1112
1113 puts $aFile ""
1114 puts $aFile "rem Optional 3rd-parties switches"
e22105a9 1115 foreach anEnvIter $::THE_ENV_VARIABLES {
1116 set aName ${anEnvIter}
1117 set aValue [set ::${anEnvIter}]
1118 if { "$aValue" != "" } {
1119 puts $aFile "set ${aName}=$aValue"
1120 }
1121 }
910970ab 1122
1123 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
1124 puts $aFile ""
1125 puts $aFile "rem Additional headers search paths"
1126 puts $aFile "set \"CSF_OPT_INC=$aStringInc\""
1127
1128 set aStringLib32 [join $::CSF_OPT_LIB32 $::SYS_PATH_SPLITTER]
1129 puts $aFile ""
1130 puts $aFile "rem Additional libraries (32-bit) search paths"
1131 puts $aFile "set \"CSF_OPT_LIB32=$aStringLib32\""
1132
1133 set aStringLib64 [join $::CSF_OPT_LIB64 $::SYS_PATH_SPLITTER]
1134 puts $aFile ""
1135 puts $aFile "rem Additional libraries (64-bit) search paths"
1136 puts $aFile "set \"CSF_OPT_LIB64=$aStringLib64\""
1137
1138 set aStringBin32 [join $::CSF_OPT_BIN32 $::SYS_PATH_SPLITTER]
1139 puts $aFile ""
1140 puts $aFile "rem Additional (32-bit) search paths"
1141 puts $aFile "set \"CSF_OPT_BIN32=$aStringBin32\""
1142
1143 set aStringBin64 [join $::CSF_OPT_BIN64 $::SYS_PATH_SPLITTER]
1144 puts $aFile ""
1145 puts $aFile "rem Additional (64-bit) search paths"
1146 puts $aFile "set \"CSF_OPT_BIN64=$aStringBin64\""
1147
1148 close $aFile
1149 } else {
1150 set aCustomFilePath "./custom.sh"
1151 set aFile [open $aCustomFilePath "w"]
1152 puts $aFile "#!/bin/bash"
1153 puts $aFile "# This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
1154
c7d774c5 1155 puts $aFile ""
1156 puts $aFile "export ARCH=$::ARCH"
1157 puts $aFile "export SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
910970ab 1158
1159 puts $aFile ""
1160 puts $aFile "export PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
1161
1162 puts $aFile ""
1163 puts $aFile "# Optional 3rd-parties switches"
e22105a9 1164 foreach anEnvIter $::THE_ENV_VARIABLES {
1165 set aName ${anEnvIter}
1166 set aValue [set ::${anEnvIter}]
1167 if { "$aValue" != "" } {
1168 puts $aFile "export ${aName}=${aValue}"
1169 }
910970ab 1170 }
910970ab 1171
1172 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
1173 puts $aFile ""
1174 puts $aFile "# Additional headers search paths"
1175 puts $aFile "export CSF_OPT_INC=\"$aStringInc\""
1176
1177 set aStringLib$::ARCH [join [set ::CSF_OPT_LIB$::ARCH] $::SYS_PATH_SPLITTER]
1178 puts $aFile ""
1179 puts $aFile "# Additional libraries ($::ARCH-bit) search paths"
1180 puts $aFile "export CSF_OPT_LIB$::ARCH=\"[set aStringLib$::ARCH]\""
1181
1182 set aStringBin$::ARCH [join [set ::CSF_OPT_BIN$::ARCH] $::SYS_PATH_SPLITTER]
1183 puts $aFile ""
1184 puts $aFile "# Additional ($::ARCH-bit) search paths"
1185 puts $aFile "export CSF_OPT_BIN$::ARCH=\"[set aStringBin$::ARCH]\""
1186
1187 close $aFile
1188 }
1189
1190 puts "Configuration saved to file '$aCustomFilePath'"
1191}