5 if { "$tcl_platform(platform)" == "unix" } {
6 set SYS_PATH_SPLITTER ":"
7 set SYS_LIB_PREFIX "lib"
9 if { "$tcl_platform(os)" == "Darwin" } {
10 set SYS_LIB_SUFFIX "dylib"
12 set SYS_LIB_SUFFIX "so"
16 } elseif { "$tcl_platform(platform)" == "windows" } {
17 set SYS_PATH_SPLITTER ";"
19 set SYS_LIB_SUFFIX "lib"
20 set SYS_EXE_SUFFIX ".exe"
25 set SHORTCUT_HEADERS "true"
27 set HAVE_FREEIMAGE "false"
28 set HAVE_GL2PS "false"
30 set HAVE_OPENCL "false"
32 set MACOSX_USE_GLX "false"
36 set CSF_OPT_INC [list]
37 set CSF_OPT_LIB32 [list]
38 set CSF_OPT_LIB64 [list]
39 set CSF_OPT_BIN32 [list]
40 set CSF_OPT_BIN64 [list]
42 if { [info exists ::env(ARCH)] } {
43 set ARCH "$::env(ARCH)"
45 if { [info exists ::env(VCVER)] } {
46 set VCVER "$::env(VCVER)"
48 if { [info exists ::env(VCVARS)] } {
49 set VCVARS "$::env(VCVARS)"
51 if { [info exists ::env(SHORTCUT_HEADERS)] } {
52 set SHORTCUT_HEADERS "$::env(SHORTCUT_HEADERS)"
54 if { [info exists ::env(HAVE_FREEIMAGE)] } {
55 set HAVE_FREEIMAGE "$::env(HAVE_FREEIMAGE)"
57 if { [info exists ::env(HAVE_GL2PS)] } {
58 set HAVE_GL2PS "$::env(HAVE_GL2PS)"
60 if { [info exists ::env(HAVE_TBB)] } {
61 set HAVE_TBB "$::env(HAVE_TBB)"
63 if { [info exists ::env(HAVE_OPENCL)] } {
64 set HAVE_OPENCL "$::env(HAVE_OPENCL)"
66 if { [info exists ::env(HAVE_VTK)] } {
67 set HAVE_VTK "$::env(HAVE_VTK)"
69 if { [info exists ::env(MACOSX_USE_GLX)] } {
70 set MACOSX_USE_GLX "$::env(MACOSX_USE_GLX)"
72 if { [info exists ::env(CHECK_QT4)] } {
73 set CHECK_QT4 "$::env(CHECK_QT4)"
75 if { [info exists ::env(CHECK_JDK)] } {
76 set CHECK_JDK "$::env(CHECK_JDK)"
78 if { [info exists ::env(PRODUCTS_PATH)] } {
79 set PRODUCTS_PATH "$::env(PRODUCTS_PATH)"
81 if { [info exists ::env(CSF_OPT_INC)] } {
82 set CSF_OPT_INC [split "$::env(CSF_OPT_INC)" $::SYS_PATH_SPLITTER]
84 if { [info exists ::env(CSF_OPT_LIB32)] } {
85 set CSF_OPT_LIB32 [split "$::env(CSF_OPT_LIB32)" $::SYS_PATH_SPLITTER]
87 if { [info exists ::env(CSF_OPT_LIB64)] } {
88 set CSF_OPT_LIB64 [split "$::env(CSF_OPT_LIB64)" $::SYS_PATH_SPLITTER]
90 if { [info exists ::env(CSF_OPT_BIN32)] } {
91 set CSF_OPT_BIN32 [split "$::env(CSF_OPT_BIN32)" $::SYS_PATH_SPLITTER]
93 if { [info exists ::env(CSF_OPT_BIN64)] } {
94 set CSF_OPT_BIN64 [split "$::env(CSF_OPT_BIN64)" $::SYS_PATH_SPLITTER]
97 # Search header file in $::CSF_OPT_INC and standard paths
98 proc wokdep:SearchHeader {theHeader} {
99 # search in custom paths
100 foreach anIncPath $::CSF_OPT_INC {
101 set aPath "${anIncPath}/${theHeader}"
102 if { [file exists "$aPath"] } {
108 set aPath "/usr/include/${theHeader}"
109 if { [file exists "$aPath"] } {
115 # Search library file in $::CSF_OPT_LIB* and standard paths
116 proc wokdep:SearchLib {theLib theBitness {theSearchPath ""}} {
117 if { "$theSearchPath" != "" } {
118 set aPath "${theSearchPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
119 if { [file exists "$aPath"] } {
126 # search in custom paths
127 foreach aLibPath [set ::CSF_OPT_LIB$theBitness] {
128 set aPath "${aLibPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
129 if { [file exists "$aPath"] } {
135 if { "$::ARCH" == "$theBitness"} {
136 set aPath "/usr/lib/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
137 if { [file exists "$aPath"] } {
142 if { "$::tcl_platform(platform)" == "linux" } {
143 if { "$theBitness" == "64" } {
144 set aPath "/usr/lib/x86_64-linux-gnu/lib${theLib}.so"
145 if { [file exists "$aPath"] } {
149 set aPath "/usr/lib/i386-linux-gnu/lib${theLib}.so"
150 if { [file exists "$aPath"] } {
159 # Search file in $::CSF_OPT_BIN* and standard paths
160 proc wokdep:SearchBin {theBin theBitness {theSearchPath ""}} {
161 if { "$theSearchPath" != "" } {
162 set aPath "${theSearchPath}/${theBin}"
163 if { [file exists "$aPath"] } {
170 # search in custom paths
171 foreach aBinPath [set ::CSF_OPT_BIN$theBitness] {
172 set aPath "${aBinPath}/${theBin}"
173 if { [file exists "$aPath"] } {
179 if { "$::ARCH" == "$theBitness"} {
180 set aPath "/usr/bin/${theBin}"
181 if { [file exists "$aPath"] } {
189 # Detect compiler C-runtime version 'vc*' and architecture '32'/'64'
190 # to determine preferred path.
191 proc wokdep:Preferred {theList theCmpl theArch} {
192 if { [llength $theList] == 0 } {
197 foreach aPath $theList {
198 if { [string first "$theCmpl" "$aPath"] != "-1" } {
199 lappend aShortList "$aPath"
203 if { [llength $aShortList] == 0 } {
204 #return [lindex $theList 0]
205 set aShortList $theList
208 set aVeryShortList {}
209 foreach aPath $aShortList {
210 if { [string first "$theArch" "$aPath"] != "-1" } {
211 lappend aVeryShortList "$aPath"
214 if { [llength $aVeryShortList] == 0 } {
215 return [lindex [lsort -decreasing $aShortList] 0]
218 return [lindex [lsort -decreasing $aVeryShortList] 0]
221 # Search Tcl/Tk libraries placement
222 proc wokdep:SearchTclTk {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
223 upvar $theErrInc anErrInc
224 upvar $theErrLib32 anErrLib32
225 upvar $theErrLib64 anErrLib64
226 upvar $theErrBin32 anErrBin32
227 upvar $theErrBin64 anErrBin64
233 set aTclHPath [wokdep:SearchHeader "tcl.h"]
234 set aTkHPath [wokdep:SearchHeader "tk.h"]
235 if { "$aTclHPath" == "" || "$aTkHPath" == "" } {
236 if { [file exists "/usr/include/tcl8.6/tcl.h"]
237 && [file exists "/usr/include/tcl8.6/tk.h" ] } {
238 lappend ::CSF_OPT_INC "/usr/include/tcl8.6"
239 set aTclHPath "/usr/include/tcl8.6/tcl.h"
241 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$::ARCH" ]
242 if { "$aPath" != "" && [file exists "$aPath/include/tcl.h"] && [file exists "$aPath/include/tk.h"] } {
243 lappend ::CSF_OPT_INC "$aPath/include"
244 set aTclHPath "$aPath/include/tcl.h"
246 lappend anErrInc "Error: 'tcl.h' or 'tk.h' not found (Tcl/Tk)"
252 # detect tcl version by parsing header file
254 set fh [open $aTclHPath]
257 regexp {define\s+TCL_MAJOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_maj
258 regexp {define\s+TCL_MINOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_min
261 if { "$::tcl_platform(platform)" == "windows" } {
262 set aTclLibName "tcl${tclver_maj}${tclver_min}"
263 set aTkLibName "tk${tclver_maj}${tclver_min}"
265 set aTclLibName "tcl${tclver_maj}.${tclver_min}"
266 set aTkLibName "tk${tclver_maj}.${tclver_min}"
269 foreach anArchIter {64 32} {
270 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter"]
271 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter"]
272 if { "$aTclLibPath" == "" || "$aTkLibPath" == "" } {
273 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
274 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter" "$aPath/lib"]
275 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter" "$aPath/lib"]
276 if { "$aTclLibPath" != "" && "$aTkLibPath" != "" } {
277 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
279 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aTclLibName}.${::SYS_LIB_SUFFIX}' or '${::SYS_LIB_PREFIX}${aTkLibName}.${::SYS_LIB_SUFFIX}' not found (Tcl/Tk)"
280 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
284 if { "$::tcl_platform(platform)" == "windows" } {
285 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter"]
286 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter"]
287 if { "$aTclDllPath" == "" || "$aTkDllPath" == "" } {
288 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
289 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter" "$aPath/bin"]
290 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter" "$aPath/bin"]
291 if { "$aTclDllPath" != "" && "$aTkDllPath" != "" } {
292 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
294 lappend anErrBin$anArchIter "Error: '${aTclLibName}.dll' or '${aTkLibName}.dll' not found (Tcl/Tk)"
295 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
304 # Search FreeType library placement
305 proc wokdep:SearchFreeType {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
306 upvar $theErrInc anErrInc
307 upvar $theErrLib32 anErrLib32
308 upvar $theErrLib64 anErrLib64
309 upvar $theErrBin32 anErrBin32
310 upvar $theErrBin64 anErrBin64
313 set aFtBuildPath [wokdep:SearchHeader "ft2build.h"]
315 # new layout of headers in Freetype 2.5.x
316 if { "$aFtBuildPath" == "" } {
317 set aFtBuildPath [wokdep:SearchHeader "freetype2/ft2build.h"]
320 if { "$aFtBuildPath" == "" } {
321 # TODO - use `freetype-config --cflags` instead
322 set aSysFreeType "/usr/include/freetype2"
323 if { [file exists "$aSysFreeType/ftbuild.h"] } {
324 lappend ::CSF_OPT_INC "$aSysFreeType"
325 } elseif { [file exists "$aSysFreeType/freetype2/ft2build.h"] } {
326 lappend ::CSF_OPT_INC "$aSysFreeType/freetype2"
328 set aSysFreeType "/usr/X11/include/freetype2"
329 if { [file exists "$aSysFreeType/ft2build.h"] } {
330 lappend ::CSF_OPT_INC "/usr/X11/include"
331 lappend ::CSF_OPT_INC "$aSysFreeType"
333 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$::ARCH" ]
334 if {"$aPath" != ""} {
335 if {[file exists "$aPath/include/ft2build.h"]} {
336 lappend ::CSF_OPT_INC "$aPath/include"
337 } elseif {[file exists "$aPath/include/freetype2/ft2build.h"]} {
338 lappend ::CSF_OPT_INC "$aPath/include/freetype2"
341 lappend anErrInc "Error: 'freetype.h' not found (FreeType2)"
348 # parse 'freetype-config --libs'
350 if { [catch { set aConfLibs [exec freetype-config --libs] } ] == 0 } {
351 foreach aPath [split $aConfLibs " "] {
352 if { [string first "-L" "$aPath"] == 0 } {
353 set aConfLibPath [string range "$aPath" 2 [string length "$aPath"]]
358 foreach anArchIter {64 32} {
359 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter"]
360 if { "$aFtLibPath" == "" } {
361 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
362 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aPath/lib"]
363 if { "$aFtLibPath" != "" } {
364 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
366 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aConfLibPath"]
367 if { "$aFtLibPath" != "" } {
368 lappend ::CSF_OPT_LIB$anArchIter "$aConfLibPath"
370 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freetype.${::SYS_LIB_SUFFIX}' not found (FreeType2)"
371 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
375 if { "$::tcl_platform(platform)" == "windows" } {
376 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter"]
377 if { "$aFtDllPath" == "" } {
378 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
379 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/bin"]
380 if { "$aFtDllPath" != "" } {
381 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
383 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/lib"]
384 if { "$aFtDllPath" != "" } {
385 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
387 lappend anErrBin$anArchIter "Error: 'freetype.dll' not found (FreeType2)"
388 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
398 # Search FreeImage library placement
399 proc wokdep:SearchFreeImage {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
400 upvar $theErrInc anErrInc
401 upvar $theErrLib32 anErrLib32
402 upvar $theErrLib64 anErrLib64
403 upvar $theErrBin32 anErrBin32
404 upvar $theErrBin64 anErrBin64
406 # binary distribution has another layout
407 set aFImageDist "Dist"
408 set aFImagePlusDist "Wrapper/FreeImagePlus/dist"
411 set aFImageHPath [wokdep:SearchHeader "FreeImage.h"]
412 set aFImagePlusHPath [wokdep:SearchHeader "FreeImagePlus.h"]
413 if { "$aFImageHPath" == "" || "$aFImagePlusHPath" == "" } {
414 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$::ARCH" ]
415 if { "$aPath" != "" && [file exists "$aPath/include/FreeImage.h"] && [file exists "$aPath/include/FreeImagePlus.h"] } {
416 lappend ::CSF_OPT_INC "$aPath/include"
417 } elseif { "$aPath" != "" && [file exists "$aPath/$aFImageDist/FreeImage.h"] && [file exists "$aPath/$aFImagePlusDist/FreeImagePlus.h"] } {
418 lappend ::CSF_OPT_INC "$aPath/$aFImageDist"
419 lappend ::CSF_OPT_INC "$aPath/$aFImagePlusDist"
421 lappend anErrInc "Error: 'FreeImage.h' or 'FreeImagePlus.h' not found (FreeImage)"
426 foreach anArchIter {64 32} {
427 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter"]
428 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter"]
429 if { "$aFImageLibPath" == "" || "$aFImagePlusLibPath" == "" } {
430 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
431 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/lib"]
432 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter" "$aPath/lib"]
433 if { "$aFImageLibPath" != "" && "$aFImagePlusLibPath" != "" } {
434 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
436 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/$aFImageDist"]
437 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter" "$aPath/$aFImagePlusDist"]
438 if { "$aFImageLibPath" != "" && "$aFImagePlusLibPath" != "" } {
439 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImageDist"
440 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImagePlusDist"
442 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimage.${::SYS_LIB_SUFFIX}' or '${::SYS_LIB_PREFIX}freeimageplus.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
443 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
447 if { "$::tcl_platform(platform)" == "windows" } {
448 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter"]
449 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter"]
450 if { "$aFImageDllPath" == "" || "$aFImagePlusDllPath" == "" } {
451 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
452 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/bin"]
453 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter" "$aPath/bin"]
454 if { "$aFImageDllPath" != "" && "$aFImagePlusDllPath" != "" } {
455 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
457 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/$aFImageDist"]
458 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter" "$aPath/$aFImagePlusDist"]
459 if { "$aFImageDllPath" != "" && "$aFImagePlusDllPath" != "" } {
460 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImageDist"
461 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImagePlusDist"
463 lappend anErrBin$anArchIter "Error: 'freeimage.dll' or 'freeimageplus.dll' not found (FreeImage)"
464 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
474 # Search GL2PS library placement
475 proc wokdep:SearchGL2PS {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
476 upvar $theErrInc anErrInc
477 upvar $theErrLib32 anErrLib32
478 upvar $theErrLib64 anErrLib64
479 upvar $theErrBin32 anErrBin32
480 upvar $theErrBin64 anErrBin64
483 set aGl2psHPath [wokdep:SearchHeader "gl2ps.h"]
484 if { "$aGl2psHPath" == "" } {
485 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$::ARCH" ]
486 if { "$aPath" != "" && [file exists "$aPath/include/gl2ps.h"] } {
487 lappend ::CSF_OPT_INC "$aPath/include"
489 lappend anErrInc "Error: 'gl2ps.h' not found (GL2PS)"
494 foreach anArchIter {64 32} {
495 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter"]
496 if { "$aGl2psLibPath" == "" } {
497 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
498 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter" "$aPath/lib"]
499 if { "$aGl2psLibPath" != "" } {
500 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
502 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}gl2ps.${::SYS_LIB_SUFFIX}' not found (GL2PS)"
503 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
506 if { "$::tcl_platform(platform)" == "windows" } {
507 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter"]
508 if { "$aGl2psDllPath" == "" } {
509 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
510 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/bin"]
511 if { "$aGl2psDllPath" != "" } {
512 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
514 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/lib"]
515 if { "$aGl2psDllPath" != "" } {
516 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
518 lappend anErrBin$anArchIter "Error: 'gl2ps.dll' not found (GL2PS)"
519 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
529 # Search TBB library placement
530 proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
531 upvar $theErrInc anErrInc
532 upvar $theErrLib32 anErrLib32
533 upvar $theErrLib64 anErrLib64
534 upvar $theErrBin32 anErrBin32
535 upvar $theErrBin64 anErrBin64
538 set aTbbHPath [wokdep:SearchHeader "tbb/scalable_allocator.h"]
539 if { "$aTbbHPath" == "" } {
540 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$::ARCH" ]
541 if { "$aPath" != "" && [file exists "$aPath/include/tbb/scalable_allocator.h"] } {
542 lappend ::CSF_OPT_INC "$aPath/include"
544 lappend anErrInc "Error: 'tbb/scalable_allocator.h' not found (Intel TBB)"
549 foreach anArchIter {64 32} {
551 if { "$anArchIter" == "64"} {
552 set aSubDir "intel64"
555 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter"]
556 if { "$aTbbLibPath" == "" } {
557 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
558 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir/${::VCVER}"]
559 if { "$aTbbLibPath" == "" } {
560 # Set the path to the TBB library for Linux
561 if { "$::tcl_platform(platform)" != "windows" } {
562 set aSubDir "$aSubDir/cc4.1.0_libc2.4_kernel2.6.16.21"
564 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir"]
565 if { "$aTbbLibPath" != "" } {
566 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir"
569 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/${::VCVER}"
571 if { "$aTbbLibPath" == "" } {
572 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
573 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
576 if { "$::tcl_platform(platform)" == "windows" } {
577 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"]
578 if { "$aTbbDllPath" == "" } {
579 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
580 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/${::VCVER}"]
581 if { "$aTbbDllPath" != "" } {
582 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/${::VCVER}"
584 lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)"
585 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
594 # Search OpenCL library placement
595 proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
596 upvar $theErrInc anErrInc
597 upvar $theErrLib32 anErrLib32
598 upvar $theErrLib64 anErrLib64
599 upvar $theErrBin32 anErrBin32
600 upvar $theErrBin64 anErrBin64
603 if { "$::tcl_platform(os)" == "Darwin" } {
604 # OpenCL framework available since Mac OS X 16
608 set aCLHPath [wokdep:SearchHeader "CL/cl_gl.h"]
609 if { "$aCLHPath" == "" } {
610 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$::ARCH" ]
611 if { "$aPath" != "" && [file exists "$aPath/include/CL/cl_gl.h"] } {
612 lappend ::CSF_OPT_INC "$aPath/include"
614 lappend anErrInc "Error: 'CL/cl_gl.h' not found (OpenCL)"
619 foreach anArchIter {64 32} {
620 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter"]
621 if { "$aCLLibPath" == "" } {
622 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$anArchIter" ]
623 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter" "$aPath/lib"]
624 if { "$aCLLibPath" != "" } {
625 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
627 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}OpenCL.${::SYS_LIB_SUFFIX}' not found (OpenCL)"
628 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
636 # Auxiliary function, gets VTK version to set default search directory
637 proc wokdep:VtkVersion { thePath } {
640 set aVtkRoot [lindex [regexp -all -inline {[0-9.]*} [file tail $thePath]] 0]
641 if { "$aVtkRoot" != "" } {
642 set aVtkRoot [regexp -inline {[0-9]*.[0-9]*} $aVtkRoot]
643 if { "$aVtkRoot" != "" } {
644 set aResult $aVtkRoot
651 # Search VTK library placement
652 proc wokdep:SearchVTK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
653 upvar $theErrInc anErrInc
654 upvar $theErrLib32 anErrLib32
655 upvar $theErrLib64 anErrLib64
656 upvar $theErrBin32 anErrBin32
657 upvar $theErrBin64 anErrBin64
662 set aVtkIncPath [wokdep:SearchHeader "vtkConfigure.h"]
663 set aVtkVer [wokdep:VtkVersion $aVtkIncPath]
664 if { "$aVtkIncPath" == ""} {
665 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
666 set aVtkPath [wokdep:Preferred "$aPathList" "$::VCVER" "$::ARCH" ]
667 if { "$aVtkPath" != "" && [file exists "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]/vtkConfigure.h"]} {
668 set aVtkVer [wokdep:VtkVersion $aVtkPath]
669 lappend ::CSF_OPT_INC "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]"
670 } else { # try to search in all found paths
672 foreach anIt $aPathList {
673 if { [file exists "$anIt/include/vtk-[wokdep:VtkVersion $anIt]/vtkConfigure.h"] } {
675 set aVtkVer [wokdep:VtkVersion $aVtkPath]
676 lappend ::CSF_OPT_INC "$anIt/include/vtk-[wokdep:VtkVersion $anIt]"
682 # Bad case: we do not found vtkConfigure.h in all paths.
683 if { "$isFound" == "false"} {
684 lappend anErrInc "Error: 'vtkConfigure.h' not found (VTK)"
691 foreach anArchIter {64 32} {
692 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter"]
693 if { "$aVtkLibPath" == "" } {
694 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
695 set aPath [wokdep:Preferred $aPathList "$::VCVER" "$anArchIter" ]
696 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aPath/lib"]
697 if { "$aVtkLibPath" != "" } {
698 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
700 set aPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aVtkPath/lib"]
701 if { "$aPath" != "" } {
702 set aLibPath $aVtkIncPath
703 lappend ::CSF_OPT_LIB$anArchIter "$aLibPath/lib"
705 # The last chance: search /lib directory in all found paths
706 foreach anIt $aPathList {
707 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$anIt/lib"]
708 if { "$aVtkLibPath" != ""} {
709 lappend ::CSF_OPT_LIB$anArchIter "$anIt/lib"
713 if { "$aVtkLibPath" == "" } {
714 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}vtkCommonCore-${aVtkVer}\.${::SYS_LIB_SUFFIX}' not found (VTK)"
715 if { "$::ARCH" == "$anArchIter" } {
725 if { "$::tcl_platform(platform)" == "windows" } {
726 foreach anArchIter {64 32} {
727 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter"]
728 if { "$aVtkBinPath" == "" } {
729 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*] "$::VCVER" "$anArchIter" ]
730 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/bin"]
731 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
733 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/lib"]
734 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib" }
739 # We didn't find preferred binary path => search through inc path or among all available VTK directories
740 if { "$aVtkBinPath" == "" } {
741 # Try to find in lib path
742 set aPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aLibPath/bin"]
743 if { "$aPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aLibPath/bin"
744 } elseif { [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aLibPath/lib"] != "" } {
745 lappend ::CSF_OPT_BIN$anArchIter "$aLibPath/lib"
747 lappend anErrBin$anArchIter "Error: 'vtkCommonCore-${aVtkVer}.dll' not found (VTK)"
756 # Search Qt4 libraries placement
757 proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
758 upvar $theErrInc anErrInc
759 upvar $theErrLib32 anErrLib32
760 upvar $theErrLib64 anErrLib64
761 upvar $theErrBin32 anErrBin32
762 upvar $theErrBin64 anErrBin64
765 set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qmessagebox.h"]
766 if { "$aQMsgBoxHPath" == "" } {
767 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$::ARCH" ]
768 if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qmessagebox.h"] } {
769 lappend ::CSF_OPT_INC "$aPath/include"
770 lappend ::CSF_OPT_INC "$aPath/include/Qt"
771 lappend ::CSF_OPT_INC "$aPath/include/QtGui"
772 lappend ::CSF_OPT_INC "$aPath/include/QtCore"
774 if { [file exists "/usr/include/qt4/QtGui/qmessagebox.h"] } {
775 lappend ::CSF_OPT_INC "/usr/include/qt4"
776 lappend ::CSF_OPT_INC "/usr/include/qt4/Qt"
777 lappend ::CSF_OPT_INC "/usr/include/qt4/QtGui"
778 lappend ::CSF_OPT_INC "/usr/include/qt4/QtCore"
780 lappend anErrInc "Error: 'QtGui/qmessagebox.h' not found (Qt4)"
786 set aQtGuiLibName "QtGui"
787 if { "$::tcl_platform(platform)" == "windows" } {
788 set aQtGuiLibName "QtGui4"
791 foreach anArchIter {64 32} {
792 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter"]
793 if { "$aQMsgBoxLibPath" == "" } {
794 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
795 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter" "$aPath/lib"]
796 if { "$aQMsgBoxLibPath" != "" } {
797 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
799 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt4)"
800 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
803 if { "$::tcl_platform(platform)" == "windows" } {
804 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter"]
805 if { "$aQMsgBoxDllPath" == "" } {
806 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
807 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter" "$aPath/bin"]
808 if { "$aQMsgBoxDllPath" != "" } {
809 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
811 lappend anErrBin$anArchIter "Error: 'QtGui4.dll' not found (Qt4)"
812 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
821 # Search JDK placement
822 proc wokdep:SearchJDK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
823 upvar $theErrInc anErrInc
824 upvar $theErrLib32 anErrLib32
825 upvar $theErrLib64 anErrLib64
826 upvar $theErrBin32 anErrBin32
827 upvar $theErrBin64 anErrBin64
830 set aJniHPath [wokdep:SearchHeader "jni.h"]
831 set aJniMdHPath [wokdep:SearchHeader "jni_md.h"]
832 if { "$aJniHPath" == "" || "$aJniMdHPath" == "" } {
833 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$::ARCH" ]
834 if { "$aPath" != "" && [file exists "$aPath/include/jni.h"] } {
835 lappend ::CSF_OPT_INC "$aPath/include"
836 if { "$::tcl_platform(platform)" == "windows" } {
837 lappend ::CSF_OPT_INC "$aPath/include/win32"
838 } elseif { [file exists "$aPath/include/linux"] } {
839 lappend ::CSF_OPT_INC "$aPath/include/linux"
842 if { [file exists "/System/Library/Frameworks/JavaVM.framework/Home/include/jni.h"] } {
843 lappend ::CSF_OPT_INC "/System/Library/Frameworks/JavaVM.framework/Home/include"
845 lappend anErrInc "Error: 'jni.h' or 'jni_md.h' not found (JDK)"
851 foreach anArchIter {64 32} {
852 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter"]
853 if { "$aJavacPath" == "" } {
854 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$anArchIter" ]
855 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter" "$aPath/bin"]
856 if { "$aJavacPath" != "" } {
857 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
859 if { "$::ARCH" == "$anArchIter" && [file exists "/System/Library/Frameworks/JavaVM.framework/Home/bin/javac${::SYS_EXE_SUFFIX}"] } {
860 lappend ::CSF_OPT_BIN$anArchIter "/System/Library/Frameworks/JavaVM.framework/Home/bin"
862 lappend anErrBin$anArchIter "Error: 'javac${::SYS_EXE_SUFFIX}' not found (JDK)"
863 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
872 # Search X11 libraries placement
873 proc wokdep:SearchX11 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
874 upvar $theErrInc anErrInc
875 upvar $theErrLib32 anErrLib32
876 upvar $theErrLib64 anErrLib64
877 upvar $theErrBin32 anErrBin32
878 upvar $theErrBin64 anErrBin64
881 if { "$::tcl_platform(platform)" == "windows" || ( "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" ) } {
885 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH"]
886 if { "$aXmuLibPath" == "" } {
887 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH" "/usr/X11/lib"]
888 if { "$aXmuLibPath" != "" } {
889 #lappend ::CSF_OPT_LIB$::ARCH "/usr/X11/lib"
891 lappend anErrLib$::ARCH "Error: '${::SYS_LIB_PREFIX}Xmu.${::SYS_LIB_SUFFIX}' not found (X11)"
899 # Generate (override) custom environment file
900 proc wokdep:SaveCustom {} {
901 if { "$::tcl_platform(platform)" == "windows" } {
902 set aCustomFilePath "./custom.bat"
903 set aFile [open $aCustomFilePath "w"]
904 puts $aFile "@echo off"
905 puts $aFile "rem This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
908 puts $aFile "set VCVER=$::VCVER"
909 puts $aFile "set ARCH=$::ARCH"
910 puts $aFile "set VCVARS=$::VCVARS"
911 puts $aFile "set SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
914 puts $aFile "set \"PRODUCTS_PATH=$::PRODUCTS_PATH\""
917 puts $aFile "rem Optional 3rd-parties switches"
918 puts $aFile "set HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
919 puts $aFile "set HAVE_GL2PS=$::HAVE_GL2PS"
920 puts $aFile "set HAVE_TBB=$::HAVE_TBB"
921 puts $aFile "set HAVE_OPENCL=$::HAVE_OPENCL"
922 puts $aFile "set HAVE_VTK=$::HAVE_VTK"
923 puts $aFile "set CHECK_QT4=$::CHECK_QT4"
924 puts $aFile "set CHECK_JDK=$::CHECK_JDK"
926 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
928 puts $aFile "rem Additional headers search paths"
929 puts $aFile "set \"CSF_OPT_INC=$aStringInc\""
931 set aStringLib32 [join $::CSF_OPT_LIB32 $::SYS_PATH_SPLITTER]
933 puts $aFile "rem Additional libraries (32-bit) search paths"
934 puts $aFile "set \"CSF_OPT_LIB32=$aStringLib32\""
936 set aStringLib64 [join $::CSF_OPT_LIB64 $::SYS_PATH_SPLITTER]
938 puts $aFile "rem Additional libraries (64-bit) search paths"
939 puts $aFile "set \"CSF_OPT_LIB64=$aStringLib64\""
941 set aStringBin32 [join $::CSF_OPT_BIN32 $::SYS_PATH_SPLITTER]
943 puts $aFile "rem Additional (32-bit) search paths"
944 puts $aFile "set \"CSF_OPT_BIN32=$aStringBin32\""
946 set aStringBin64 [join $::CSF_OPT_BIN64 $::SYS_PATH_SPLITTER]
948 puts $aFile "rem Additional (64-bit) search paths"
949 puts $aFile "set \"CSF_OPT_BIN64=$aStringBin64\""
953 set aCustomFilePath "./custom.sh"
954 set aFile [open $aCustomFilePath "w"]
955 puts $aFile "#!/bin/bash"
956 puts $aFile "# This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
959 #puts $aFile "export ARCH=$::ARCH"
962 puts $aFile "export PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
965 puts $aFile "# Optional 3rd-parties switches"
966 puts $aFile "export HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
967 puts $aFile "export HAVE_GL2PS=$::HAVE_GL2PS"
968 puts $aFile "export HAVE_TBB=$::HAVE_TBB"
969 puts $aFile "export HAVE_OPENCL=$::HAVE_OPENCL"
970 puts $aFile "export HAVE_VTK=$::HAVE_VTK"
971 if { "$::tcl_platform(os)" == "Darwin" } {
972 puts $aFile "export MACOSX_USE_GLX=$::MACOSX_USE_GLX"
974 puts $aFile "export CHECK_QT4=$::CHECK_QT4"
975 puts $aFile "export CHECK_JDK=$::CHECK_JDK"
977 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
979 puts $aFile "# Additional headers search paths"
980 puts $aFile "export CSF_OPT_INC=\"$aStringInc\""
982 set aStringLib$::ARCH [join [set ::CSF_OPT_LIB$::ARCH] $::SYS_PATH_SPLITTER]
984 puts $aFile "# Additional libraries ($::ARCH-bit) search paths"
985 puts $aFile "export CSF_OPT_LIB$::ARCH=\"[set aStringLib$::ARCH]\""
987 set aStringBin$::ARCH [join [set ::CSF_OPT_BIN$::ARCH] $::SYS_PATH_SPLITTER]
989 puts $aFile "# Additional ($::ARCH-bit) search paths"
990 puts $aFile "export CSF_OPT_BIN$::ARCH=\"[set aStringBin$::ARCH]\""
995 puts "Configuration saved to file '$aCustomFilePath'"