0027398: Integrate Qt Browser Widget to Open CASCADE Technology
[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
d6cda17a 207 # keep only two first digits in "vc141"
208 if { ! [regexp {^vc[0-9][0-9]} $theCmpl aCmpl] } {
209 set aCmpl $theCmpl
210 }
211
910970ab 212 set aShortList {}
213 foreach aPath $theList {
d6cda17a 214 if { [string first "$aCmpl" "$aPath"] != "-1" } {
910970ab 215 lappend aShortList "$aPath"
216 }
217 }
218
219 if { [llength $aShortList] == 0 } {
220 #return [lindex $theList 0]
221 set aShortList $theList
222 }
223
224 set aVeryShortList {}
225 foreach aPath $aShortList {
226 if { [string first "$theArch" "$aPath"] != "-1" } {
227 lappend aVeryShortList "$aPath"
228 }
229 }
230 if { [llength $aVeryShortList] == 0 } {
231 return [lindex [lsort -decreasing $aShortList] 0]
232 }
233
234 return [lindex [lsort -decreasing $aVeryShortList] 0]
235}
236
e22105a9 237# Search library placement
238proc wokdep:SearchStandardLibrary {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64 theName theCheckHeader theCheckLib theCheckFolders} {
239 upvar $theErrInc anErrInc
240 upvar $theErrLib32 anErrLib32
241 upvar $theErrLib64 anErrLib64
242 upvar $theErrBin32 anErrBin32
243 upvar $theErrBin64 anErrBin64
244
245 set isFound "true"
246 set aHeaderPath [wokdep:SearchHeader "$theCheckHeader"]
247 if { "$aHeaderPath" == "" } {
248 set hasHeader false
249 foreach aFolderIter $theCheckFolders {
250 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{$aFolderIter}*] "$::VCVER" "$::ARCH" ]
251 if { "$aPath" != "" && [file exists "$aPath/include/$theCheckHeader"] } {
252 lappend ::CSF_OPT_INC "$aPath/include"
253 set hasHeader true
254 break
255 }
256 }
257 if { !$hasHeader } {
258 lappend anErrInc "Error: '$theCheckHeader' not found ($theName)"
259 set isFound "false"
260 }
261 }
262
263 foreach anArchIter {64 32} {
264 set aLibPath [wokdep:SearchLib "$theCheckLib" "$anArchIter"]
265 if { "$aLibPath" == "" } {
266 set hasLib false
267 foreach aFolderIter $theCheckFolders {
268 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{$aFolderIter}*] "$::VCVER" "$anArchIter" ]
269 set aLibPath [wokdep:SearchLib "$theCheckLib" "$anArchIter" "$aPath/lib"]
270 if { "$aLibPath" != "" } {
271 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
272 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
273 set hasLib true
274 break
275 }
276 }
277 if { !$hasLib } {
278 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}$theCheckLib.${::SYS_LIB_SUFFIX}' not found ($theName)"
279 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
280 }
281 }
282
283 if { "$::tcl_platform(platform)" == "windows" } {
284 set aDllPath [wokdep:SearchBin "$theCheckLib.dll" "$anArchIter"]
285 if { "$aDllPath" == "" } {
286 set hasDll false
287 foreach aFolderIter $theCheckFolders {
288 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{$aFolderIter}*] "$::VCVER" "$anArchIter" ]
289 set aDllPath [wokdep:SearchBin "$theCheckLib.dll" "$anArchIter" "$aPath/bin"]
290 if { "$aDllPath" != "" } {
291 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
292 set hasDll true
293 break
294 } else {
295 set aDllPath [wokdep:SearchBin "$theCheckLib.dll" "$anArchIter" "$aPath/lib"]
296 if { "$aDllPath" != "" } {
297 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
298 set hasDll true
299 break
300 }
301 }
302 }
303 if { !$hasDll } {
304 lappend anErrBin$anArchIter "Error: '$theCheckLib.dll' not found ($theName)"
305 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
306 }
307 }
308 }
309 }
310
311 return "$isFound"
312}
313
910970ab 314# Search Tcl/Tk libraries placement
315proc wokdep:SearchTclTk {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
316 upvar $theErrInc anErrInc
317 upvar $theErrLib32 anErrLib32
318 upvar $theErrLib64 anErrLib64
319 upvar $theErrBin32 anErrBin32
320 upvar $theErrBin64 anErrBin64
321
322 set tclver_maj 8
323 set tclver_min 6
324
325 set isFound "true"
326 set aTclHPath [wokdep:SearchHeader "tcl.h"]
327 set aTkHPath [wokdep:SearchHeader "tk.h"]
328 if { "$aTclHPath" == "" || "$aTkHPath" == "" } {
329 if { [file exists "/usr/include/tcl8.6/tcl.h"]
330 && [file exists "/usr/include/tcl8.6/tk.h" ] } {
331 lappend ::CSF_OPT_INC "/usr/include/tcl8.6"
332 set aTclHPath "/usr/include/tcl8.6/tcl.h"
333 } else {
334 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$::ARCH" ]
335 if { "$aPath" != "" && [file exists "$aPath/include/tcl.h"] && [file exists "$aPath/include/tk.h"] } {
336 lappend ::CSF_OPT_INC "$aPath/include"
337 set aTclHPath "$aPath/include/tcl.h"
338 } else {
339 lappend anErrInc "Error: 'tcl.h' or 'tk.h' not found (Tcl/Tk)"
340 set isFound "false"
341 }
342 }
343 }
344
345 # detect tcl version by parsing header file
346 if { $isFound } {
347 set fh [open $aTclHPath]
348 set tcl_h [read $fh]
349 close $fh
350 regexp {define\s+TCL_MAJOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_maj
351 regexp {define\s+TCL_MINOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_min
352 }
353
354 if { "$::tcl_platform(platform)" == "windows" } {
355 set aTclLibName "tcl${tclver_maj}${tclver_min}"
356 set aTkLibName "tk${tclver_maj}${tclver_min}"
357 } else {
358 set aTclLibName "tcl${tclver_maj}.${tclver_min}"
359 set aTkLibName "tk${tclver_maj}.${tclver_min}"
360 }
361
362 foreach anArchIter {64 32} {
363 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter"]
364 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter"]
365 if { "$aTclLibPath" == "" || "$aTkLibPath" == "" } {
366 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
367 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter" "$aPath/lib"]
368 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter" "$aPath/lib"]
369 if { "$aTclLibPath" != "" && "$aTkLibPath" != "" } {
370 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
371 } else {
372 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aTclLibName}.${::SYS_LIB_SUFFIX}' or '${::SYS_LIB_PREFIX}${aTkLibName}.${::SYS_LIB_SUFFIX}' not found (Tcl/Tk)"
373 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
374 }
375 }
376
377 if { "$::tcl_platform(platform)" == "windows" } {
378 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter"]
379 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter"]
380 if { "$aTclDllPath" == "" || "$aTkDllPath" == "" } {
381 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
382 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter" "$aPath/bin"]
383 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter" "$aPath/bin"]
384 if { "$aTclDllPath" != "" && "$aTkDllPath" != "" } {
385 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
386 } else {
387 lappend anErrBin$anArchIter "Error: '${aTclLibName}.dll' or '${aTkLibName}.dll' not found (Tcl/Tk)"
388 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
389 }
390 }
391 }
392 }
393
394 return "$isFound"
395}
396
397# Search FreeType library placement
398proc wokdep:SearchFreeType {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
399 upvar $theErrInc anErrInc
400 upvar $theErrLib32 anErrLib32
401 upvar $theErrLib64 anErrLib64
402 upvar $theErrBin32 anErrBin32
403 upvar $theErrBin64 anErrBin64
404
405 set isFound "true"
406 set aFtBuildPath [wokdep:SearchHeader "ft2build.h"]
407
910970ab 408 if { "$aFtBuildPath" == "" } {
409 # TODO - use `freetype-config --cflags` instead
410 set aSysFreeType "/usr/include/freetype2"
c7d774c5 411 if { [file exists "$aSysFreeType/ft2build.h"] } {
910970ab 412 lappend ::CSF_OPT_INC "$aSysFreeType"
413 } elseif { [file exists "$aSysFreeType/freetype2/ft2build.h"] } {
414 lappend ::CSF_OPT_INC "$aSysFreeType/freetype2"
415 } else {
416 set aSysFreeType "/usr/X11/include/freetype2"
417 if { [file exists "$aSysFreeType/ft2build.h"] } {
418 lappend ::CSF_OPT_INC "/usr/X11/include"
419 lappend ::CSF_OPT_INC "$aSysFreeType"
420 } else {
421 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$::ARCH" ]
422 if {"$aPath" != ""} {
423 if {[file exists "$aPath/include/ft2build.h"]} {
424 lappend ::CSF_OPT_INC "$aPath/include"
425 } elseif {[file exists "$aPath/include/freetype2/ft2build.h"]} {
426 lappend ::CSF_OPT_INC "$aPath/include/freetype2"
427 }
428 } else {
429 lappend anErrInc "Error: 'freetype.h' not found (FreeType2)"
430 set isFound "false"
431 }
432 }
433 }
434 }
435
436 # parse 'freetype-config --libs'
437 set aConfLibPath ""
438 if { [catch { set aConfLibs [exec freetype-config --libs] } ] == 0 } {
439 foreach aPath [split $aConfLibs " "] {
440 if { [string first "-L" "$aPath"] == 0 } {
441 set aConfLibPath [string range "$aPath" 2 [string length "$aPath"]]
442 }
443 }
444 }
445
446 foreach anArchIter {64 32} {
447 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter"]
448 if { "$aFtLibPath" == "" } {
449 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
450 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aPath/lib"]
451 if { "$aFtLibPath" != "" } {
452 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
453 } else {
454 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aConfLibPath"]
455 if { "$aFtLibPath" != "" } {
456 lappend ::CSF_OPT_LIB$anArchIter "$aConfLibPath"
457 } else {
458 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freetype.${::SYS_LIB_SUFFIX}' not found (FreeType2)"
459 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
460 }
461 }
462 }
463 if { "$::tcl_platform(platform)" == "windows" } {
464 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter"]
465 if { "$aFtDllPath" == "" } {
466 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
467 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/bin"]
468 if { "$aFtDllPath" != "" } {
469 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
470 } else {
471 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/lib"]
472 if { "$aFtDllPath" != "" } {
473 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
474 } else {
475 lappend anErrBin$anArchIter "Error: 'freetype.dll' not found (FreeType2)"
476 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
477 }
478 }
479 }
480 }
481 }
482
483 return "$isFound"
484}
485
486# Search FreeImage library placement
487proc wokdep:SearchFreeImage {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
488 upvar $theErrInc anErrInc
489 upvar $theErrLib32 anErrLib32
490 upvar $theErrLib64 anErrLib64
491 upvar $theErrBin32 anErrBin32
492 upvar $theErrBin64 anErrBin64
493
494 # binary distribution has another layout
495 set aFImageDist "Dist"
910970ab 496
497 set isFound "true"
f0d3b7af 498 set aFImageHPath [wokdep:SearchHeader "FreeImage.h"]
499 if { "$aFImageHPath" == "" } {
910970ab 500 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$::ARCH" ]
f0d3b7af 501 if { "$aPath" != "" && [file exists "$aPath/include/FreeImage.h"] } {
910970ab 502 lappend ::CSF_OPT_INC "$aPath/include"
f0d3b7af 503 } elseif { "$aPath" != "" && [file exists "$aPath/$aFImageDist/FreeImage.h"] } {
910970ab 504 lappend ::CSF_OPT_INC "$aPath/$aFImageDist"
910970ab 505 } else {
f0d3b7af 506 lappend anErrInc "Error: 'FreeImage.h' not found (FreeImage)"
910970ab 507 set isFound "false"
508 }
509 }
510
511 foreach anArchIter {64 32} {
f0d3b7af 512 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter"]
513 if { "$aFImageLibPath" == "" } {
910970ab 514 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
f0d3b7af 515 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/lib"]
516 if { "$aFImageLibPath" != "" } {
910970ab 517 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
518 } else {
f0d3b7af 519 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/$aFImageDist"]
520 if { "$aFImageLibPath" != "" } {
910970ab 521 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImageDist"
910970ab 522 } else {
f0d3b7af 523 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimage.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
910970ab 524 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
525 }
526 }
527 }
528 if { "$::tcl_platform(platform)" == "windows" } {
60273f77 529 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter"]
530 if { "$aFImageDllPath" == "" } {
910970ab 531 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
60273f77 532 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/bin"]
533 if { "$aFImageDllPath" != "" } {
910970ab 534 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
535 } else {
60273f77 536 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/$aFImageDist"]
537 if { "$aFImageDllPath" != "" } {
910970ab 538 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImageDist"
910970ab 539 } else {
60273f77 540 lappend anErrBin$anArchIter "Error: 'freeimage.dll' is not found (FreeImage)"
910970ab 541 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
542 }
543 }
544 }
545 }
546 }
547
548 return "$isFound"
549}
550
e22105a9 551# Search FFmpeg framework placement
552proc wokdep:SearchFFmpeg {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
910970ab 553 upvar $theErrInc anErrInc
554 upvar $theErrLib32 anErrLib32
555 upvar $theErrLib64 anErrLib64
556 upvar $theErrBin32 anErrBin32
557 upvar $theErrBin64 anErrBin64
558
559 set isFound "true"
e22105a9 560 set aFFmpegHPath [wokdep:SearchHeader "libavutil/avutil.h"]
561 if { "$aFFmpegHPath" == "" } {
562 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{ffmpeg}*] "$::VCVER" "$::ARCH" ]
563 if { "$aPath" != "" && [file exists "$aPath/include/libavutil/avutil.h"] } {
910970ab 564 lappend ::CSF_OPT_INC "$aPath/include"
565 } else {
e22105a9 566 lappend anErrInc "Error: 'libavutil/avutil.h' not found (FFmpeg)"
910970ab 567 set isFound "false"
568 }
569 }
570
571 foreach anArchIter {64 32} {
e22105a9 572 set aFFmpegLibPath [wokdep:SearchLib "avutil" "$anArchIter"]
573 if { "$aFFmpegLibPath" == "" } {
574 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{ffmpeg}*] "$::VCVER" "$anArchIter" ]
575 set aFFmpegLibPath [wokdep:SearchLib "avutil" "$anArchIter" "$aPath/lib"]
576 if { "$aFFmpegLibPath" != "" } {
910970ab 577 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
e22105a9 578 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
910970ab 579 } else {
e22105a9 580 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}avutil.${::SYS_LIB_SUFFIX}' not found (FFmpeg)"
910970ab 581 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
582 }
583 }
910970ab 584 }
585
586 return "$isFound"
587}
588
589# Search TBB library placement
590proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
591 upvar $theErrInc anErrInc
592 upvar $theErrLib32 anErrLib32
593 upvar $theErrLib64 anErrLib64
594 upvar $theErrBin32 anErrBin32
595 upvar $theErrBin64 anErrBin64
596
d6cda17a 597 # keep only two first digits in "vc141"
598 if { ! [regexp {^vc[0-9][0-9]} ${::VCVER} aVcLib] } {
599 set aVcLib ${::VCVER}
600 }
601
910970ab 602 set isFound "true"
603 set aTbbHPath [wokdep:SearchHeader "tbb/scalable_allocator.h"]
604 if { "$aTbbHPath" == "" } {
605 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$::ARCH" ]
606 if { "$aPath" != "" && [file exists "$aPath/include/tbb/scalable_allocator.h"] } {
607 lappend ::CSF_OPT_INC "$aPath/include"
608 } else {
609 lappend anErrInc "Error: 'tbb/scalable_allocator.h' not found (Intel TBB)"
610 set isFound "false"
611 }
612 }
613
614 foreach anArchIter {64 32} {
615 set aSubDir "ia32"
616 if { "$anArchIter" == "64"} {
617 set aSubDir "intel64"
618 }
619
620 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter"]
621 if { "$aTbbLibPath" == "" } {
d6cda17a 622 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] $aVcLib "$anArchIter" ]
623 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir/$aVcLib"]
910970ab 624 if { "$aTbbLibPath" == "" } {
625 # Set the path to the TBB library for Linux
626 if { "$::tcl_platform(platform)" != "windows" } {
627 set aSubDir "$aSubDir/cc4.1.0_libc2.4_kernel2.6.16.21"
628 }
629 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir"]
630 if { "$aTbbLibPath" != "" } {
631 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir"
632 }
633 } else {
d6cda17a 634 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/$aVcLib"
910970ab 635 }
636 if { "$aTbbLibPath" == "" } {
637 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
638 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
639 }
640 }
641 if { "$::tcl_platform(platform)" == "windows" } {
642 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"]
643 if { "$aTbbDllPath" == "" } {
d6cda17a 644 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] $aVcLib "$anArchIter" ]
645 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/$aVcLib"]
910970ab 646 if { "$aTbbDllPath" != "" } {
d6cda17a 647 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/$aVcLib"
910970ab 648 } else {
649 lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)"
650 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
651 }
652 }
653 }
654 }
655
656 return "$isFound"
657}
658
659# Search OpenCL library placement
660proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
661 upvar $theErrInc anErrInc
662 upvar $theErrLib32 anErrLib32
663 upvar $theErrLib64 anErrLib64
664 upvar $theErrBin32 anErrBin32
665 upvar $theErrBin64 anErrBin64
666
667 set isFound "true"
668 if { "$::tcl_platform(os)" == "Darwin" } {
669 # OpenCL framework available since Mac OS X 16
670 return "$isFound"
671 }
672
673 set aCLHPath [wokdep:SearchHeader "CL/cl_gl.h"]
674 if { "$aCLHPath" == "" } {
675 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$::ARCH" ]
676 if { "$aPath" != "" && [file exists "$aPath/include/CL/cl_gl.h"] } {
677 lappend ::CSF_OPT_INC "$aPath/include"
678 } else {
679 lappend anErrInc "Error: 'CL/cl_gl.h' not found (OpenCL)"
680 set isFound "false"
681 }
682 }
683
684 foreach anArchIter {64 32} {
685 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter"]
686 if { "$aCLLibPath" == "" } {
687 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$anArchIter" ]
688 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter" "$aPath/lib"]
689 if { "$aCLLibPath" != "" } {
690 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
691 } else {
692 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}OpenCL.${::SYS_LIB_SUFFIX}' not found (OpenCL)"
693 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
694 }
695 }
696 }
697
698 return "$isFound"
699}
700
1ce0716b 701# Search EGL library placement
702proc wokdep:SearchEGL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
703 upvar $theErrInc anErrInc
704 upvar $theErrLib32 anErrLib32
705 upvar $theErrLib64 anErrLib64
706 upvar $theErrBin32 anErrBin32
707 upvar $theErrBin64 anErrBin64
708
709 set isFound "true"
710 set aHeaderPath [wokdep:SearchHeader "EGL/egl.h"]
711 if { "$aHeaderPath" == "" } {
712 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$::ARCH" ]
713 if { "$aPath" == "" || ![file exists "$aPath/include/EGL/egl.h"] } {
714 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$::ARCH" ]
715 }
716
717 if { "$aPath" != "" && [file exists "$aPath/include/EGL/egl.h"] } {
718 lappend ::CSF_OPT_INC "$aPath/include"
719 } else {
720 lappend anErrInc "Error: 'EGL/egl.h' not found (EGL)"
721 set isFound "false"
722 }
723 }
724
725 set aLibName "EGL"
726 if { "$::tcl_platform(platform)" == "windows" } {
727 # awkward exception
728 set aLibName "libEGL"
729 }
730
731 foreach anArchIter {64 32} {
732 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter"]
733 if { "$aLibPath" == "" } {
734 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ]
735 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
736 if { "$aLibPath" == "" } {
737 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
738 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
739 }
740
741 if { "$aLibPath" != "" } {
742 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
743 } else {
744 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aLibName}.${::SYS_LIB_SUFFIX}' not found (EGL)"
745 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
746 }
747 }
748
749 if { "$::tcl_platform(platform)" == "windows" } {
750 set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter"]
751 if { "$aDllPath" == "" } {
752 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ]
753 set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter" "$aPath/bin"]
754 if { "$aDllPath" == "" } {
755 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
756 set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter" "$aPath/bin"]
757 }
758
759 if { "$aDllPath" != "" } {
760 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
761 } else {
762 lappend anErrBin$anArchIter "Error: 'libEGL.dll' not found (EGL)"
763 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
764 }
765 }
766 }
767 }
768
769 return "$isFound"
770}
771
772# Search OpenGL ES 2.0 library placement
773proc wokdep:SearchGLES {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
774 upvar $theErrInc anErrInc
775 upvar $theErrLib32 anErrLib32
776 upvar $theErrLib64 anErrLib64
777 upvar $theErrBin32 anErrBin32
778 upvar $theErrBin64 anErrBin64
779
780 set isFound "true"
781 set aHeaderPath [wokdep:SearchHeader "GLES2/gl2.h"]
782 if { "$aHeaderPath" == "" } {
783 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{GLES}*] "$::VCVER" "$::ARCH" ]
784 if { "$aPath" == "" || ![file exists "$aPath/include/GLES2/gl2.h"] } {
785 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$::ARCH" ]
786 }
787
788 if { "$aPath" != "" && [file exists "$aPath/include/GLES2/gl2.h"] } {
789 lappend ::CSF_OPT_INC "$aPath/include"
790 } else {
791 lappend anErrInc "Error: 'GLES2/gl2.h' not found (OpenGL ES 2.0)"
792 set isFound "false"
793 }
794 }
795
796 set aLibName "GLESv2"
797 if { "$::tcl_platform(platform)" == "windows" } {
798 # awkward exception
799 set aLibName "libGLESv2"
800 }
801
802 foreach anArchIter {64 32} {
803 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter"]
804 if { "$aLibPath" == "" } {
805 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{GLES}*] "$::VCVER" "$anArchIter" ]
806 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
807 if { "$aLibPath" == "" } {
808 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
809 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
810 }
811
812 if { "$aLibPath" != "" } {
813 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
814 } else {
815 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aLibName}.${::SYS_LIB_SUFFIX}' not found (OpenGL ES 2.0)"
816 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
817 }
818 }
819
820 if { "$::tcl_platform(platform)" == "windows" } {
821 set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter"]
822 if { "$aDllPath" == "" } {
823 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ]
824 set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter" "$aPath/bin"]
825 if { "$aDllPath" == "" } {
826 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
827 set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter" "$aPath/bin"]
828 }
829
830 if { "$aDllPath" != "" } {
831 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
832 } else {
833 lappend anErrBin$anArchIter "Error: 'libGLESv2.dll' not found (OpenGL ES 2.0)"
834 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
835 }
836 }
837 }
838 }
839
840 return "$isFound"
841}
842
910970ab 843# Auxiliary function, gets VTK version to set default search directory
844proc wokdep:VtkVersion { thePath } {
845 set aResult "6.1"
846
847 set aVtkRoot [lindex [regexp -all -inline {[0-9.]*} [file tail $thePath]] 0]
848 if { "$aVtkRoot" != "" } {
849 set aVtkRoot [regexp -inline {[0-9]*.[0-9]*} $aVtkRoot]
850 if { "$aVtkRoot" != "" } {
851 set aResult $aVtkRoot
852 }
853 }
854
855 return $aResult
856}
857
858# Search VTK library placement
859proc wokdep:SearchVTK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
860 upvar $theErrInc anErrInc
861 upvar $theErrLib32 anErrLib32
862 upvar $theErrLib64 anErrLib64
863 upvar $theErrBin32 anErrBin32
864 upvar $theErrBin64 anErrBin64
865
866 set isFound "true"
867
868 set aVtkPath ""
869 set aVtkIncPath [wokdep:SearchHeader "vtkConfigure.h"]
870 set aVtkVer [wokdep:VtkVersion $aVtkIncPath]
871 if { "$aVtkIncPath" == ""} {
872 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
873 set aVtkPath [wokdep:Preferred "$aPathList" "$::VCVER" "$::ARCH" ]
874 if { "$aVtkPath" != "" && [file exists "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]/vtkConfigure.h"]} {
875 set aVtkVer [wokdep:VtkVersion $aVtkPath]
876 lappend ::CSF_OPT_INC "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]"
877 } else { # try to search in all found paths
878 set isFound "false"
879 foreach anIt $aPathList {
880 if { [file exists "$anIt/include/vtk-[wokdep:VtkVersion $anIt]/vtkConfigure.h"] } {
881 set aVtkPath $anIt
882 set aVtkVer [wokdep:VtkVersion $aVtkPath]
883 lappend ::CSF_OPT_INC "$anIt/include/vtk-[wokdep:VtkVersion $anIt]"
884 set isFound "true"
885 break
886 }
887 }
888
889 # Bad case: we do not found vtkConfigure.h in all paths.
890 if { "$isFound" == "false"} {
891 lappend anErrInc "Error: 'vtkConfigure.h' not found (VTK)"
892 set isFound "false"
893 }
894 }
895 }
896
897 set aVtkLibPath ""
898 foreach anArchIter {64 32} {
899 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter"]
900 if { "$aVtkLibPath" == "" } {
901 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
902 set aPath [wokdep:Preferred $aPathList "$::VCVER" "$anArchIter" ]
903 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aPath/lib"]
904 if { "$aVtkLibPath" != "" } {
905 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
906 } else {
907 set aPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aVtkPath/lib"]
908 if { "$aPath" != "" } {
909 set aLibPath $aVtkIncPath
910 lappend ::CSF_OPT_LIB$anArchIter "$aLibPath/lib"
911 } else {
912 # The last chance: search /lib directory in all found paths
913 foreach anIt $aPathList {
914 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$anIt/lib"]
915 if { "$aVtkLibPath" != ""} {
916 lappend ::CSF_OPT_LIB$anArchIter "$anIt/lib"
917 break
918 }
919 }
920 if { "$aVtkLibPath" == "" } {
921 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}vtkCommonCore-${aVtkVer}\.${::SYS_LIB_SUFFIX}' not found (VTK)"
922 if { "$::ARCH" == "$anArchIter" } {
923 set isFound "false"
924 }
925 }
926 }
927 }
928 }
929 }
930
931 # Search binary path
932 if { "$::tcl_platform(platform)" == "windows" } {
933 foreach anArchIter {64 32} {
934 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter"]
935 if { "$aVtkBinPath" == "" } {
936 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*] "$::VCVER" "$anArchIter" ]
937 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/bin"]
938 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
939 } else {
940 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/lib"]
941 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib" }
942 }
943 }
944 }
945
946 # We didn't find preferred binary path => search through inc path or among all available VTK directories
947 if { "$aVtkBinPath" == "" } {
948 # Try to find in lib path
e31a8e52 949 set aPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/bin"]
950 if { "$aPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/bin"
951 } elseif { [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/lib"] != "" } {
952 lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/lib"
910970ab 953 } else {
954 lappend anErrBin$anArchIter "Error: 'vtkCommonCore-${aVtkVer}.dll' not found (VTK)"
955 set isFound "false"
956 }
957 }
958 }
959
960 return "$isFound"
961}
962
963# Search Qt4 libraries placement
964proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
965 upvar $theErrInc anErrInc
966 upvar $theErrLib32 anErrLib32
967 upvar $theErrLib64 anErrLib64
968 upvar $theErrBin32 anErrBin32
969 upvar $theErrBin64 anErrBin64
970
971 set isFound "true"
972 set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qmessagebox.h"]
973 if { "$aQMsgBoxHPath" == "" } {
974 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$::ARCH" ]
975 if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qmessagebox.h"] } {
976 lappend ::CSF_OPT_INC "$aPath/include"
977 lappend ::CSF_OPT_INC "$aPath/include/Qt"
978 lappend ::CSF_OPT_INC "$aPath/include/QtGui"
979 lappend ::CSF_OPT_INC "$aPath/include/QtCore"
980 } else {
981 if { [file exists "/usr/include/qt4/QtGui/qmessagebox.h"] } {
982 lappend ::CSF_OPT_INC "/usr/include/qt4"
983 lappend ::CSF_OPT_INC "/usr/include/qt4/Qt"
984 lappend ::CSF_OPT_INC "/usr/include/qt4/QtGui"
985 lappend ::CSF_OPT_INC "/usr/include/qt4/QtCore"
986 } else {
987 lappend anErrInc "Error: 'QtGui/qmessagebox.h' not found (Qt4)"
988 set isFound "false"
989 }
990 }
991 }
992
993 set aQtGuiLibName "QtGui"
994 if { "$::tcl_platform(platform)" == "windows" } {
995 set aQtGuiLibName "QtGui4"
996 }
997
998 foreach anArchIter {64 32} {
999 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter"]
1000 if { "$aQMsgBoxLibPath" == "" } {
1001 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
1002 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter" "$aPath/lib"]
1003 if { "$aQMsgBoxLibPath" != "" } {
1004 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
1005 } else {
1006 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt4)"
1007 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
1008 }
1009 }
1010 if { "$::tcl_platform(platform)" == "windows" } {
1011 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter"]
1012 if { "$aQMsgBoxDllPath" == "" } {
1013 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
1014 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter" "$aPath/bin"]
1015 if { "$aQMsgBoxDllPath" != "" } {
1016 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
1017 } else {
1018 lappend anErrBin$anArchIter "Error: 'QtGui4.dll' not found (Qt4)"
1019 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
1020 }
1021 }
1022 }
1023 }
1024
1025 return "$isFound"
1026}
1027
1028# Search JDK placement
1029proc wokdep:SearchJDK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
1030 upvar $theErrInc anErrInc
1031 upvar $theErrLib32 anErrLib32
1032 upvar $theErrLib64 anErrLib64
1033 upvar $theErrBin32 anErrBin32
1034 upvar $theErrBin64 anErrBin64
1035
1036 set isFound "true"
1037 set aJniHPath [wokdep:SearchHeader "jni.h"]
1038 set aJniMdHPath [wokdep:SearchHeader "jni_md.h"]
1039 if { "$aJniHPath" == "" || "$aJniMdHPath" == "" } {
1040 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$::ARCH" ]
1041 if { "$aPath" != "" && [file exists "$aPath/include/jni.h"] } {
1042 lappend ::CSF_OPT_INC "$aPath/include"
1043 if { "$::tcl_platform(platform)" == "windows" } {
1044 lappend ::CSF_OPT_INC "$aPath/include/win32"
1045 } elseif { [file exists "$aPath/include/linux"] } {
1046 lappend ::CSF_OPT_INC "$aPath/include/linux"
1047 }
1048 } else {
1049 if { [file exists "/System/Library/Frameworks/JavaVM.framework/Home/include/jni.h"] } {
1050 lappend ::CSF_OPT_INC "/System/Library/Frameworks/JavaVM.framework/Home/include"
1051 } else {
1052 lappend anErrInc "Error: 'jni.h' or 'jni_md.h' not found (JDK)"
1053 set isFound "false"
1054 }
1055 }
1056 }
1057
1058 foreach anArchIter {64 32} {
1059 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter"]
1060 if { "$aJavacPath" == "" } {
1061 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$anArchIter" ]
1062 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter" "$aPath/bin"]
1063 if { "$aJavacPath" != "" } {
1064 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
1065 } else {
1066 if { "$::ARCH" == "$anArchIter" && [file exists "/System/Library/Frameworks/JavaVM.framework/Home/bin/javac${::SYS_EXE_SUFFIX}"] } {
1067 lappend ::CSF_OPT_BIN$anArchIter "/System/Library/Frameworks/JavaVM.framework/Home/bin"
1068 } else {
1069 lappend anErrBin$anArchIter "Error: 'javac${::SYS_EXE_SUFFIX}' not found (JDK)"
1070 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
1071 }
1072 }
1073 }
1074 }
1075
1076 return "$isFound"
1077}
1078
1079# Search X11 libraries placement
1080proc wokdep:SearchX11 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
1081 upvar $theErrInc anErrInc
1082 upvar $theErrLib32 anErrLib32
1083 upvar $theErrLib64 anErrLib64
1084 upvar $theErrBin32 anErrBin32
1085 upvar $theErrBin64 anErrBin64
1086
1087 set isFound "true"
1088 if { "$::tcl_platform(platform)" == "windows" || ( "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" ) } {
1089 return "$isFound"
1090 }
1091
1092 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH"]
1093 if { "$aXmuLibPath" == "" } {
1094 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH" "/usr/X11/lib"]
1095 if { "$aXmuLibPath" != "" } {
1096 #lappend ::CSF_OPT_LIB$::ARCH "/usr/X11/lib"
1097 } else {
1098 lappend anErrLib$::ARCH "Error: '${::SYS_LIB_PREFIX}Xmu.${::SYS_LIB_SUFFIX}' not found (X11)"
1099 set isFound "false"
1100 }
1101 }
1102
1103 return "$isFound"
1104}
1105
1106# Generate (override) custom environment file
1107proc wokdep:SaveCustom {} {
1108 if { "$::tcl_platform(platform)" == "windows" } {
1109 set aCustomFilePath "./custom.bat"
1110 set aFile [open $aCustomFilePath "w"]
1111 puts $aFile "@echo off"
1112 puts $aFile "rem This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
1113
1114 puts $aFile ""
1115 puts $aFile "set VCVER=$::VCVER"
1116 puts $aFile "set ARCH=$::ARCH"
1117 puts $aFile "set VCVARS=$::VCVARS"
1118 puts $aFile "set SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
1119
1120 puts $aFile ""
1121 puts $aFile "set \"PRODUCTS_PATH=$::PRODUCTS_PATH\""
1122
1123 puts $aFile ""
1124 puts $aFile "rem Optional 3rd-parties switches"
e22105a9 1125 foreach anEnvIter $::THE_ENV_VARIABLES {
1126 set aName ${anEnvIter}
1127 set aValue [set ::${anEnvIter}]
1128 if { "$aValue" != "" } {
1129 puts $aFile "set ${aName}=$aValue"
1130 }
1131 }
910970ab 1132
1133 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
1134 puts $aFile ""
1135 puts $aFile "rem Additional headers search paths"
1136 puts $aFile "set \"CSF_OPT_INC=$aStringInc\""
1137
1138 set aStringLib32 [join $::CSF_OPT_LIB32 $::SYS_PATH_SPLITTER]
1139 puts $aFile ""
1140 puts $aFile "rem Additional libraries (32-bit) search paths"
1141 puts $aFile "set \"CSF_OPT_LIB32=$aStringLib32\""
1142
1143 set aStringLib64 [join $::CSF_OPT_LIB64 $::SYS_PATH_SPLITTER]
1144 puts $aFile ""
1145 puts $aFile "rem Additional libraries (64-bit) search paths"
1146 puts $aFile "set \"CSF_OPT_LIB64=$aStringLib64\""
1147
1148 set aStringBin32 [join $::CSF_OPT_BIN32 $::SYS_PATH_SPLITTER]
1149 puts $aFile ""
1150 puts $aFile "rem Additional (32-bit) search paths"
1151 puts $aFile "set \"CSF_OPT_BIN32=$aStringBin32\""
1152
1153 set aStringBin64 [join $::CSF_OPT_BIN64 $::SYS_PATH_SPLITTER]
1154 puts $aFile ""
1155 puts $aFile "rem Additional (64-bit) search paths"
1156 puts $aFile "set \"CSF_OPT_BIN64=$aStringBin64\""
1157
1158 close $aFile
1159 } else {
1160 set aCustomFilePath "./custom.sh"
1161 set aFile [open $aCustomFilePath "w"]
1162 puts $aFile "#!/bin/bash"
1163 puts $aFile "# This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
1164
c7d774c5 1165 puts $aFile ""
1166 puts $aFile "export ARCH=$::ARCH"
1167 puts $aFile "export SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
910970ab 1168
1169 puts $aFile ""
1170 puts $aFile "export PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
1171
1172 puts $aFile ""
1173 puts $aFile "# Optional 3rd-parties switches"
e22105a9 1174 foreach anEnvIter $::THE_ENV_VARIABLES {
1175 set aName ${anEnvIter}
1176 set aValue [set ::${anEnvIter}]
1177 if { "$aValue" != "" } {
1178 puts $aFile "export ${aName}=${aValue}"
1179 }
910970ab 1180 }
910970ab 1181
1182 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
1183 puts $aFile ""
1184 puts $aFile "# Additional headers search paths"
1185 puts $aFile "export CSF_OPT_INC=\"$aStringInc\""
1186
1187 set aStringLib$::ARCH [join [set ::CSF_OPT_LIB$::ARCH] $::SYS_PATH_SPLITTER]
1188 puts $aFile ""
1189 puts $aFile "# Additional libraries ($::ARCH-bit) search paths"
1190 puts $aFile "export CSF_OPT_LIB$::ARCH=\"[set aStringLib$::ARCH]\""
1191
1192 set aStringBin$::ARCH [join [set ::CSF_OPT_BIN$::ARCH] $::SYS_PATH_SPLITTER]
1193 puts $aFile ""
1194 puts $aFile "# Additional ($::ARCH-bit) search paths"
1195 puts $aFile "export CSF_OPT_BIN$::ARCH=\"[set aStringBin$::ARCH]\""
1196
1197 close $aFile
1198 }
1199
1200 puts "Configuration saved to file '$aCustomFilePath'"
1201}