1 # =======================================================================
2 # Created on: 2012-01-26
3 # Created by: Kirill GAVRILOV
4 # Copyright (c) 2012 OPEN CASCADE SAS
6 # This file is part of Open CASCADE Technology software library.
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.
14 # Alternatively, this file may be used under the terms of Open CASCADE
15 # commercial license or contractual agreement.
17 # =======================================================================
18 # Tools for search of third-party libraries and generation on environment
19 # customization script
20 # =======================================================================
24 if { "$tcl_platform(platform)" == "unix" } {
25 set SYS_PATH_SPLITTER ":"
26 set SYS_LIB_PREFIX "lib"
28 if { "$tcl_platform(os)" == "Darwin" } {
29 set SYS_LIB_SUFFIX "dylib"
31 set SYS_LIB_SUFFIX "so"
35 } elseif { "$tcl_platform(platform)" == "windows" } {
36 set SYS_PATH_SPLITTER ";"
38 set SYS_LIB_SUFFIX "lib"
39 set SYS_EXE_SUFFIX ".exe"
44 set SHORTCUT_HEADERS "true"
46 set HAVE_FREEIMAGE "false"
47 set HAVE_GL2PS "false"
49 set HAVE_OPENCL "false"
51 set MACOSX_USE_GLX "false"
55 set CSF_OPT_INC [list]
56 set CSF_OPT_LIB32 [list]
57 set CSF_OPT_LIB64 [list]
58 set CSF_OPT_BIN32 [list]
59 set CSF_OPT_BIN64 [list]
61 if { "$tcl_platform(pointerSize)" == "4" } {
64 if { [info exists ::env(ARCH)] } {
65 set ARCH "$::env(ARCH)"
67 if { [info exists ::env(VCVER)] } {
68 set VCVER "$::env(VCVER)"
70 if { [info exists ::env(VCVARS)] } {
71 set VCVARS "$::env(VCVARS)"
73 if { [info exists ::env(SHORTCUT_HEADERS)] } {
74 set SHORTCUT_HEADERS "$::env(SHORTCUT_HEADERS)"
76 if { [info exists ::env(HAVE_FREEIMAGE)] } {
77 set HAVE_FREEIMAGE "$::env(HAVE_FREEIMAGE)"
79 if { [info exists ::env(HAVE_GL2PS)] } {
80 set HAVE_GL2PS "$::env(HAVE_GL2PS)"
82 if { [info exists ::env(HAVE_TBB)] } {
83 set HAVE_TBB "$::env(HAVE_TBB)"
85 if { [info exists ::env(HAVE_OPENCL)] } {
86 set HAVE_OPENCL "$::env(HAVE_OPENCL)"
88 if { [info exists ::env(HAVE_VTK)] } {
89 set HAVE_VTK "$::env(HAVE_VTK)"
91 if { [info exists ::env(MACOSX_USE_GLX)] } {
92 set MACOSX_USE_GLX "$::env(MACOSX_USE_GLX)"
94 if { [info exists ::env(CHECK_QT4)] } {
95 set CHECK_QT4 "$::env(CHECK_QT4)"
97 if { [info exists ::env(CHECK_JDK)] } {
98 set CHECK_JDK "$::env(CHECK_JDK)"
100 if { [info exists ::env(PRODUCTS_PATH)] } {
101 set PRODUCTS_PATH "$::env(PRODUCTS_PATH)"
103 if { [info exists ::env(CSF_OPT_INC)] } {
104 set CSF_OPT_INC [split "$::env(CSF_OPT_INC)" $::SYS_PATH_SPLITTER]
106 if { [info exists ::env(CSF_OPT_LIB32)] } {
107 set CSF_OPT_LIB32 [split "$::env(CSF_OPT_LIB32)" $::SYS_PATH_SPLITTER]
109 if { [info exists ::env(CSF_OPT_LIB64)] } {
110 set CSF_OPT_LIB64 [split "$::env(CSF_OPT_LIB64)" $::SYS_PATH_SPLITTER]
112 if { [info exists ::env(CSF_OPT_BIN32)] } {
113 set CSF_OPT_BIN32 [split "$::env(CSF_OPT_BIN32)" $::SYS_PATH_SPLITTER]
115 if { [info exists ::env(CSF_OPT_BIN64)] } {
116 set CSF_OPT_BIN64 [split "$::env(CSF_OPT_BIN64)" $::SYS_PATH_SPLITTER]
119 # Search header file in $::CSF_OPT_INC and standard paths
120 proc wokdep:SearchHeader {theHeader} {
121 # search in custom paths
122 foreach anIncPath $::CSF_OPT_INC {
123 set aPath "${anIncPath}/${theHeader}"
124 if { [file exists "$aPath"] } {
130 set aPath "/usr/include/${theHeader}"
131 if { [file exists "$aPath"] } {
137 # Search library file in $::CSF_OPT_LIB* and standard paths
138 proc wokdep:SearchLib {theLib theBitness {theSearchPath ""}} {
139 if { "$theSearchPath" != "" } {
140 set aPath "${theSearchPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
141 if { [file exists "$aPath"] } {
148 # search in custom paths
149 foreach aLibPath [set ::CSF_OPT_LIB$theBitness] {
150 set aPath "${aLibPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
151 if { [file exists "$aPath"] } {
157 if { "$::ARCH" == "$theBitness"} {
158 set aPath "/usr/lib/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
159 if { [file exists "$aPath"] } {
165 if { "$::tcl_platform(os)" == "Linux" } {
166 if { "$theBitness" == "64" } {
167 set aPath "/usr/lib/x86_64-linux-gnu/lib${theLib}.so"
168 if { [file exists "$aPath"] } {
172 set aPath "/usr/lib/i386-linux-gnu/lib${theLib}.so"
173 if { [file exists "$aPath"] } {
182 # Search file in $::CSF_OPT_BIN* and standard paths
183 proc wokdep:SearchBin {theBin theBitness {theSearchPath ""}} {
184 if { "$theSearchPath" != "" } {
185 set aPath "${theSearchPath}/${theBin}"
186 if { [file exists "$aPath"] } {
193 # search in custom paths
194 foreach aBinPath [set ::CSF_OPT_BIN$theBitness] {
195 set aPath "${aBinPath}/${theBin}"
196 if { [file exists "$aPath"] } {
202 if { "$::ARCH" == "$theBitness"} {
203 set aPath "/usr/bin/${theBin}"
204 if { [file exists "$aPath"] } {
212 # Detect compiler C-runtime version 'vc*' and architecture '32'/'64'
213 # to determine preferred path.
214 proc wokdep:Preferred {theList theCmpl theArch} {
215 if { [llength $theList] == 0 } {
220 foreach aPath $theList {
221 if { [string first "$theCmpl" "$aPath"] != "-1" } {
222 lappend aShortList "$aPath"
226 if { [llength $aShortList] == 0 } {
227 #return [lindex $theList 0]
228 set aShortList $theList
231 set aVeryShortList {}
232 foreach aPath $aShortList {
233 if { [string first "$theArch" "$aPath"] != "-1" } {
234 lappend aVeryShortList "$aPath"
237 if { [llength $aVeryShortList] == 0 } {
238 return [lindex [lsort -decreasing $aShortList] 0]
241 return [lindex [lsort -decreasing $aVeryShortList] 0]
244 # Search Tcl/Tk libraries placement
245 proc wokdep:SearchTclTk {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
246 upvar $theErrInc anErrInc
247 upvar $theErrLib32 anErrLib32
248 upvar $theErrLib64 anErrLib64
249 upvar $theErrBin32 anErrBin32
250 upvar $theErrBin64 anErrBin64
256 set aTclHPath [wokdep:SearchHeader "tcl.h"]
257 set aTkHPath [wokdep:SearchHeader "tk.h"]
258 if { "$aTclHPath" == "" || "$aTkHPath" == "" } {
259 if { [file exists "/usr/include/tcl8.6/tcl.h"]
260 && [file exists "/usr/include/tcl8.6/tk.h" ] } {
261 lappend ::CSF_OPT_INC "/usr/include/tcl8.6"
262 set aTclHPath "/usr/include/tcl8.6/tcl.h"
264 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$::ARCH" ]
265 if { "$aPath" != "" && [file exists "$aPath/include/tcl.h"] && [file exists "$aPath/include/tk.h"] } {
266 lappend ::CSF_OPT_INC "$aPath/include"
267 set aTclHPath "$aPath/include/tcl.h"
269 lappend anErrInc "Error: 'tcl.h' or 'tk.h' not found (Tcl/Tk)"
275 # detect tcl version by parsing header file
277 set fh [open $aTclHPath]
280 regexp {define\s+TCL_MAJOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_maj
281 regexp {define\s+TCL_MINOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_min
284 if { "$::tcl_platform(platform)" == "windows" } {
285 set aTclLibName "tcl${tclver_maj}${tclver_min}"
286 set aTkLibName "tk${tclver_maj}${tclver_min}"
288 set aTclLibName "tcl${tclver_maj}.${tclver_min}"
289 set aTkLibName "tk${tclver_maj}.${tclver_min}"
292 foreach anArchIter {64 32} {
293 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter"]
294 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter"]
295 if { "$aTclLibPath" == "" || "$aTkLibPath" == "" } {
296 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
297 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter" "$aPath/lib"]
298 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter" "$aPath/lib"]
299 if { "$aTclLibPath" != "" && "$aTkLibPath" != "" } {
300 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
302 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aTclLibName}.${::SYS_LIB_SUFFIX}' or '${::SYS_LIB_PREFIX}${aTkLibName}.${::SYS_LIB_SUFFIX}' not found (Tcl/Tk)"
303 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
307 if { "$::tcl_platform(platform)" == "windows" } {
308 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter"]
309 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter"]
310 if { "$aTclDllPath" == "" || "$aTkDllPath" == "" } {
311 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
312 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter" "$aPath/bin"]
313 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter" "$aPath/bin"]
314 if { "$aTclDllPath" != "" && "$aTkDllPath" != "" } {
315 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
317 lappend anErrBin$anArchIter "Error: '${aTclLibName}.dll' or '${aTkLibName}.dll' not found (Tcl/Tk)"
318 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
327 # Search FreeType library placement
328 proc wokdep:SearchFreeType {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
329 upvar $theErrInc anErrInc
330 upvar $theErrLib32 anErrLib32
331 upvar $theErrLib64 anErrLib64
332 upvar $theErrBin32 anErrBin32
333 upvar $theErrBin64 anErrBin64
336 set aFtBuildPath [wokdep:SearchHeader "ft2build.h"]
338 if { "$aFtBuildPath" == "" } {
339 # TODO - use `freetype-config --cflags` instead
340 set aSysFreeType "/usr/include/freetype2"
341 if { [file exists "$aSysFreeType/ft2build.h"] } {
342 lappend ::CSF_OPT_INC "$aSysFreeType"
343 } elseif { [file exists "$aSysFreeType/freetype2/ft2build.h"] } {
344 lappend ::CSF_OPT_INC "$aSysFreeType/freetype2"
346 set aSysFreeType "/usr/X11/include/freetype2"
347 if { [file exists "$aSysFreeType/ft2build.h"] } {
348 lappend ::CSF_OPT_INC "/usr/X11/include"
349 lappend ::CSF_OPT_INC "$aSysFreeType"
351 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$::ARCH" ]
352 if {"$aPath" != ""} {
353 if {[file exists "$aPath/include/ft2build.h"]} {
354 lappend ::CSF_OPT_INC "$aPath/include"
355 } elseif {[file exists "$aPath/include/freetype2/ft2build.h"]} {
356 lappend ::CSF_OPT_INC "$aPath/include/freetype2"
359 lappend anErrInc "Error: 'freetype.h' not found (FreeType2)"
366 # parse 'freetype-config --libs'
368 if { [catch { set aConfLibs [exec freetype-config --libs] } ] == 0 } {
369 foreach aPath [split $aConfLibs " "] {
370 if { [string first "-L" "$aPath"] == 0 } {
371 set aConfLibPath [string range "$aPath" 2 [string length "$aPath"]]
376 foreach anArchIter {64 32} {
377 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter"]
378 if { "$aFtLibPath" == "" } {
379 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
380 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aPath/lib"]
381 if { "$aFtLibPath" != "" } {
382 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
384 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aConfLibPath"]
385 if { "$aFtLibPath" != "" } {
386 lappend ::CSF_OPT_LIB$anArchIter "$aConfLibPath"
388 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freetype.${::SYS_LIB_SUFFIX}' not found (FreeType2)"
389 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
393 if { "$::tcl_platform(platform)" == "windows" } {
394 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter"]
395 if { "$aFtDllPath" == "" } {
396 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
397 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/bin"]
398 if { "$aFtDllPath" != "" } {
399 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
401 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/lib"]
402 if { "$aFtDllPath" != "" } {
403 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
405 lappend anErrBin$anArchIter "Error: 'freetype.dll' not found (FreeType2)"
406 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
416 # Search FreeImage library placement
417 proc wokdep:SearchFreeImage {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
418 upvar $theErrInc anErrInc
419 upvar $theErrLib32 anErrLib32
420 upvar $theErrLib64 anErrLib64
421 upvar $theErrBin32 anErrBin32
422 upvar $theErrBin64 anErrBin64
424 # binary distribution has another layout
425 set aFImageDist "Dist"
426 set aFImagePlusDist "Wrapper/FreeImagePlus/dist"
429 set aFImageHPath [wokdep:SearchHeader "FreeImage.h"]
430 set aFImagePlusHPath [wokdep:SearchHeader "FreeImagePlus.h"]
431 if { "$aFImageHPath" == "" || "$aFImagePlusHPath" == "" } {
432 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$::ARCH" ]
433 if { "$aPath" != "" && [file exists "$aPath/include/FreeImage.h"] && [file exists "$aPath/include/FreeImagePlus.h"] } {
434 lappend ::CSF_OPT_INC "$aPath/include"
435 } elseif { "$aPath" != "" && [file exists "$aPath/$aFImageDist/FreeImage.h"] && [file exists "$aPath/$aFImagePlusDist/FreeImagePlus.h"] } {
436 lappend ::CSF_OPT_INC "$aPath/$aFImageDist"
437 lappend ::CSF_OPT_INC "$aPath/$aFImagePlusDist"
439 lappend anErrInc "Error: 'FreeImage.h' or 'FreeImagePlus.h' not found (FreeImage)"
444 foreach anArchIter {64 32} {
445 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter"]
446 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter"]
447 if { "$aFImageLibPath" == "" || "$aFImagePlusLibPath" == "" } {
448 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
449 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/lib"]
450 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter" "$aPath/lib"]
451 if { "$aFImageLibPath" != "" && "$aFImagePlusLibPath" != "" } {
452 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
454 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/$aFImageDist"]
455 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter" "$aPath/$aFImagePlusDist"]
456 if { "$aFImageLibPath" != "" && "$aFImagePlusLibPath" != "" } {
457 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImageDist"
458 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImagePlusDist"
460 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimage.${::SYS_LIB_SUFFIX}' or '${::SYS_LIB_PREFIX}freeimageplus.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
461 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
465 if { "$::tcl_platform(platform)" == "windows" } {
466 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter"]
467 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter"]
468 if { "$aFImageDllPath" == "" || "$aFImagePlusDllPath" == "" } {
469 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
470 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/bin"]
471 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter" "$aPath/bin"]
472 if { "$aFImageDllPath" != "" && "$aFImagePlusDllPath" != "" } {
473 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
475 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/$aFImageDist"]
476 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter" "$aPath/$aFImagePlusDist"]
477 if { "$aFImageDllPath" != "" && "$aFImagePlusDllPath" != "" } {
478 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImageDist"
479 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImagePlusDist"
481 lappend anErrBin$anArchIter "Error: 'freeimage.dll' or 'freeimageplus.dll' not found (FreeImage)"
482 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
492 # Search GL2PS library placement
493 proc wokdep:SearchGL2PS {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
494 upvar $theErrInc anErrInc
495 upvar $theErrLib32 anErrLib32
496 upvar $theErrLib64 anErrLib64
497 upvar $theErrBin32 anErrBin32
498 upvar $theErrBin64 anErrBin64
501 set aGl2psHPath [wokdep:SearchHeader "gl2ps.h"]
502 if { "$aGl2psHPath" == "" } {
503 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$::ARCH" ]
504 if { "$aPath" != "" && [file exists "$aPath/include/gl2ps.h"] } {
505 lappend ::CSF_OPT_INC "$aPath/include"
507 lappend anErrInc "Error: 'gl2ps.h' not found (GL2PS)"
512 foreach anArchIter {64 32} {
513 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter"]
514 if { "$aGl2psLibPath" == "" } {
515 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
516 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter" "$aPath/lib"]
517 if { "$aGl2psLibPath" != "" } {
518 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
520 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}gl2ps.${::SYS_LIB_SUFFIX}' not found (GL2PS)"
521 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
524 if { "$::tcl_platform(platform)" == "windows" } {
525 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter"]
526 if { "$aGl2psDllPath" == "" } {
527 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
528 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/bin"]
529 if { "$aGl2psDllPath" != "" } {
530 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
532 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/lib"]
533 if { "$aGl2psDllPath" != "" } {
534 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
536 lappend anErrBin$anArchIter "Error: 'gl2ps.dll' not found (GL2PS)"
537 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
547 # Search TBB library placement
548 proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
549 upvar $theErrInc anErrInc
550 upvar $theErrLib32 anErrLib32
551 upvar $theErrLib64 anErrLib64
552 upvar $theErrBin32 anErrBin32
553 upvar $theErrBin64 anErrBin64
556 set aTbbHPath [wokdep:SearchHeader "tbb/scalable_allocator.h"]
557 if { "$aTbbHPath" == "" } {
558 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$::ARCH" ]
559 if { "$aPath" != "" && [file exists "$aPath/include/tbb/scalable_allocator.h"] } {
560 lappend ::CSF_OPT_INC "$aPath/include"
562 lappend anErrInc "Error: 'tbb/scalable_allocator.h' not found (Intel TBB)"
567 foreach anArchIter {64 32} {
569 if { "$anArchIter" == "64"} {
570 set aSubDir "intel64"
573 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter"]
574 if { "$aTbbLibPath" == "" } {
575 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
576 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir/${::VCVER}"]
577 if { "$aTbbLibPath" == "" } {
578 # Set the path to the TBB library for Linux
579 if { "$::tcl_platform(platform)" != "windows" } {
580 set aSubDir "$aSubDir/cc4.1.0_libc2.4_kernel2.6.16.21"
582 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir"]
583 if { "$aTbbLibPath" != "" } {
584 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir"
587 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/${::VCVER}"
589 if { "$aTbbLibPath" == "" } {
590 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
591 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
594 if { "$::tcl_platform(platform)" == "windows" } {
595 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"]
596 if { "$aTbbDllPath" == "" } {
597 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
598 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/${::VCVER}"]
599 if { "$aTbbDllPath" != "" } {
600 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/${::VCVER}"
602 lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)"
603 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
612 # Search OpenCL library placement
613 proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
614 upvar $theErrInc anErrInc
615 upvar $theErrLib32 anErrLib32
616 upvar $theErrLib64 anErrLib64
617 upvar $theErrBin32 anErrBin32
618 upvar $theErrBin64 anErrBin64
621 if { "$::tcl_platform(os)" == "Darwin" } {
622 # OpenCL framework available since Mac OS X 16
626 set aCLHPath [wokdep:SearchHeader "CL/cl_gl.h"]
627 if { "$aCLHPath" == "" } {
628 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$::ARCH" ]
629 if { "$aPath" != "" && [file exists "$aPath/include/CL/cl_gl.h"] } {
630 lappend ::CSF_OPT_INC "$aPath/include"
632 lappend anErrInc "Error: 'CL/cl_gl.h' not found (OpenCL)"
637 foreach anArchIter {64 32} {
638 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter"]
639 if { "$aCLLibPath" == "" } {
640 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$anArchIter" ]
641 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter" "$aPath/lib"]
642 if { "$aCLLibPath" != "" } {
643 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
645 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}OpenCL.${::SYS_LIB_SUFFIX}' not found (OpenCL)"
646 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
654 # Auxiliary function, gets VTK version to set default search directory
655 proc wokdep:VtkVersion { thePath } {
658 set aVtkRoot [lindex [regexp -all -inline {[0-9.]*} [file tail $thePath]] 0]
659 if { "$aVtkRoot" != "" } {
660 set aVtkRoot [regexp -inline {[0-9]*.[0-9]*} $aVtkRoot]
661 if { "$aVtkRoot" != "" } {
662 set aResult $aVtkRoot
669 # Search VTK library placement
670 proc wokdep:SearchVTK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
671 upvar $theErrInc anErrInc
672 upvar $theErrLib32 anErrLib32
673 upvar $theErrLib64 anErrLib64
674 upvar $theErrBin32 anErrBin32
675 upvar $theErrBin64 anErrBin64
680 set aVtkIncPath [wokdep:SearchHeader "vtkConfigure.h"]
681 set aVtkVer [wokdep:VtkVersion $aVtkIncPath]
682 if { "$aVtkIncPath" == ""} {
683 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
684 set aVtkPath [wokdep:Preferred "$aPathList" "$::VCVER" "$::ARCH" ]
685 if { "$aVtkPath" != "" && [file exists "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]/vtkConfigure.h"]} {
686 set aVtkVer [wokdep:VtkVersion $aVtkPath]
687 lappend ::CSF_OPT_INC "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]"
688 } else { # try to search in all found paths
690 foreach anIt $aPathList {
691 if { [file exists "$anIt/include/vtk-[wokdep:VtkVersion $anIt]/vtkConfigure.h"] } {
693 set aVtkVer [wokdep:VtkVersion $aVtkPath]
694 lappend ::CSF_OPT_INC "$anIt/include/vtk-[wokdep:VtkVersion $anIt]"
700 # Bad case: we do not found vtkConfigure.h in all paths.
701 if { "$isFound" == "false"} {
702 lappend anErrInc "Error: 'vtkConfigure.h' not found (VTK)"
709 foreach anArchIter {64 32} {
710 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter"]
711 if { "$aVtkLibPath" == "" } {
712 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
713 set aPath [wokdep:Preferred $aPathList "$::VCVER" "$anArchIter" ]
714 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aPath/lib"]
715 if { "$aVtkLibPath" != "" } {
716 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
718 set aPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aVtkPath/lib"]
719 if { "$aPath" != "" } {
720 set aLibPath $aVtkIncPath
721 lappend ::CSF_OPT_LIB$anArchIter "$aLibPath/lib"
723 # The last chance: search /lib directory in all found paths
724 foreach anIt $aPathList {
725 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$anIt/lib"]
726 if { "$aVtkLibPath" != ""} {
727 lappend ::CSF_OPT_LIB$anArchIter "$anIt/lib"
731 if { "$aVtkLibPath" == "" } {
732 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}vtkCommonCore-${aVtkVer}\.${::SYS_LIB_SUFFIX}' not found (VTK)"
733 if { "$::ARCH" == "$anArchIter" } {
743 if { "$::tcl_platform(platform)" == "windows" } {
744 foreach anArchIter {64 32} {
745 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter"]
746 if { "$aVtkBinPath" == "" } {
747 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*] "$::VCVER" "$anArchIter" ]
748 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/bin"]
749 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
751 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/lib"]
752 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib" }
757 # We didn't find preferred binary path => search through inc path or among all available VTK directories
758 if { "$aVtkBinPath" == "" } {
759 # Try to find in lib path
760 set aPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aLibPath/bin"]
761 if { "$aPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aLibPath/bin"
762 } elseif { [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aLibPath/lib"] != "" } {
763 lappend ::CSF_OPT_BIN$anArchIter "$aLibPath/lib"
765 lappend anErrBin$anArchIter "Error: 'vtkCommonCore-${aVtkVer}.dll' not found (VTK)"
774 # Search Qt4 libraries placement
775 proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
776 upvar $theErrInc anErrInc
777 upvar $theErrLib32 anErrLib32
778 upvar $theErrLib64 anErrLib64
779 upvar $theErrBin32 anErrBin32
780 upvar $theErrBin64 anErrBin64
783 set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qmessagebox.h"]
784 if { "$aQMsgBoxHPath" == "" } {
785 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$::ARCH" ]
786 if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qmessagebox.h"] } {
787 lappend ::CSF_OPT_INC "$aPath/include"
788 lappend ::CSF_OPT_INC "$aPath/include/Qt"
789 lappend ::CSF_OPT_INC "$aPath/include/QtGui"
790 lappend ::CSF_OPT_INC "$aPath/include/QtCore"
792 if { [file exists "/usr/include/qt4/QtGui/qmessagebox.h"] } {
793 lappend ::CSF_OPT_INC "/usr/include/qt4"
794 lappend ::CSF_OPT_INC "/usr/include/qt4/Qt"
795 lappend ::CSF_OPT_INC "/usr/include/qt4/QtGui"
796 lappend ::CSF_OPT_INC "/usr/include/qt4/QtCore"
798 lappend anErrInc "Error: 'QtGui/qmessagebox.h' not found (Qt4)"
804 set aQtGuiLibName "QtGui"
805 if { "$::tcl_platform(platform)" == "windows" } {
806 set aQtGuiLibName "QtGui4"
809 foreach anArchIter {64 32} {
810 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter"]
811 if { "$aQMsgBoxLibPath" == "" } {
812 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
813 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter" "$aPath/lib"]
814 if { "$aQMsgBoxLibPath" != "" } {
815 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
817 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt4)"
818 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
821 if { "$::tcl_platform(platform)" == "windows" } {
822 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter"]
823 if { "$aQMsgBoxDllPath" == "" } {
824 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
825 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter" "$aPath/bin"]
826 if { "$aQMsgBoxDllPath" != "" } {
827 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
829 lappend anErrBin$anArchIter "Error: 'QtGui4.dll' not found (Qt4)"
830 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
839 # Search JDK placement
840 proc wokdep:SearchJDK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
841 upvar $theErrInc anErrInc
842 upvar $theErrLib32 anErrLib32
843 upvar $theErrLib64 anErrLib64
844 upvar $theErrBin32 anErrBin32
845 upvar $theErrBin64 anErrBin64
848 set aJniHPath [wokdep:SearchHeader "jni.h"]
849 set aJniMdHPath [wokdep:SearchHeader "jni_md.h"]
850 if { "$aJniHPath" == "" || "$aJniMdHPath" == "" } {
851 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$::ARCH" ]
852 if { "$aPath" != "" && [file exists "$aPath/include/jni.h"] } {
853 lappend ::CSF_OPT_INC "$aPath/include"
854 if { "$::tcl_platform(platform)" == "windows" } {
855 lappend ::CSF_OPT_INC "$aPath/include/win32"
856 } elseif { [file exists "$aPath/include/linux"] } {
857 lappend ::CSF_OPT_INC "$aPath/include/linux"
860 if { [file exists "/System/Library/Frameworks/JavaVM.framework/Home/include/jni.h"] } {
861 lappend ::CSF_OPT_INC "/System/Library/Frameworks/JavaVM.framework/Home/include"
863 lappend anErrInc "Error: 'jni.h' or 'jni_md.h' not found (JDK)"
869 foreach anArchIter {64 32} {
870 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter"]
871 if { "$aJavacPath" == "" } {
872 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$anArchIter" ]
873 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter" "$aPath/bin"]
874 if { "$aJavacPath" != "" } {
875 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
877 if { "$::ARCH" == "$anArchIter" && [file exists "/System/Library/Frameworks/JavaVM.framework/Home/bin/javac${::SYS_EXE_SUFFIX}"] } {
878 lappend ::CSF_OPT_BIN$anArchIter "/System/Library/Frameworks/JavaVM.framework/Home/bin"
880 lappend anErrBin$anArchIter "Error: 'javac${::SYS_EXE_SUFFIX}' not found (JDK)"
881 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
890 # Search X11 libraries placement
891 proc wokdep:SearchX11 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
892 upvar $theErrInc anErrInc
893 upvar $theErrLib32 anErrLib32
894 upvar $theErrLib64 anErrLib64
895 upvar $theErrBin32 anErrBin32
896 upvar $theErrBin64 anErrBin64
899 if { "$::tcl_platform(platform)" == "windows" || ( "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" ) } {
903 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH"]
904 if { "$aXmuLibPath" == "" } {
905 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH" "/usr/X11/lib"]
906 if { "$aXmuLibPath" != "" } {
907 #lappend ::CSF_OPT_LIB$::ARCH "/usr/X11/lib"
909 lappend anErrLib$::ARCH "Error: '${::SYS_LIB_PREFIX}Xmu.${::SYS_LIB_SUFFIX}' not found (X11)"
917 # Generate (override) custom environment file
918 proc wokdep:SaveCustom {} {
919 if { "$::tcl_platform(platform)" == "windows" } {
920 set aCustomFilePath "./custom.bat"
921 set aFile [open $aCustomFilePath "w"]
922 puts $aFile "@echo off"
923 puts $aFile "rem This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
926 puts $aFile "set VCVER=$::VCVER"
927 puts $aFile "set ARCH=$::ARCH"
928 puts $aFile "set VCVARS=$::VCVARS"
929 puts $aFile "set SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
932 puts $aFile "set \"PRODUCTS_PATH=$::PRODUCTS_PATH\""
935 puts $aFile "rem Optional 3rd-parties switches"
936 puts $aFile "set HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
937 puts $aFile "set HAVE_GL2PS=$::HAVE_GL2PS"
938 puts $aFile "set HAVE_TBB=$::HAVE_TBB"
939 puts $aFile "set HAVE_OPENCL=$::HAVE_OPENCL"
940 puts $aFile "set HAVE_VTK=$::HAVE_VTK"
941 puts $aFile "set CHECK_QT4=$::CHECK_QT4"
942 puts $aFile "set CHECK_JDK=$::CHECK_JDK"
944 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
946 puts $aFile "rem Additional headers search paths"
947 puts $aFile "set \"CSF_OPT_INC=$aStringInc\""
949 set aStringLib32 [join $::CSF_OPT_LIB32 $::SYS_PATH_SPLITTER]
951 puts $aFile "rem Additional libraries (32-bit) search paths"
952 puts $aFile "set \"CSF_OPT_LIB32=$aStringLib32\""
954 set aStringLib64 [join $::CSF_OPT_LIB64 $::SYS_PATH_SPLITTER]
956 puts $aFile "rem Additional libraries (64-bit) search paths"
957 puts $aFile "set \"CSF_OPT_LIB64=$aStringLib64\""
959 set aStringBin32 [join $::CSF_OPT_BIN32 $::SYS_PATH_SPLITTER]
961 puts $aFile "rem Additional (32-bit) search paths"
962 puts $aFile "set \"CSF_OPT_BIN32=$aStringBin32\""
964 set aStringBin64 [join $::CSF_OPT_BIN64 $::SYS_PATH_SPLITTER]
966 puts $aFile "rem Additional (64-bit) search paths"
967 puts $aFile "set \"CSF_OPT_BIN64=$aStringBin64\""
971 set aCustomFilePath "./custom.sh"
972 set aFile [open $aCustomFilePath "w"]
973 puts $aFile "#!/bin/bash"
974 puts $aFile "# This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
977 puts $aFile "export ARCH=$::ARCH"
978 puts $aFile "export SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
981 puts $aFile "export PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
984 puts $aFile "# Optional 3rd-parties switches"
985 puts $aFile "export HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
986 puts $aFile "export HAVE_GL2PS=$::HAVE_GL2PS"
987 puts $aFile "export HAVE_TBB=$::HAVE_TBB"
988 puts $aFile "export HAVE_OPENCL=$::HAVE_OPENCL"
989 puts $aFile "export HAVE_VTK=$::HAVE_VTK"
990 if { "$::tcl_platform(os)" == "Darwin" } {
991 puts $aFile "export MACOSX_USE_GLX=$::MACOSX_USE_GLX"
993 puts $aFile "export CHECK_QT4=$::CHECK_QT4"
994 puts $aFile "export CHECK_JDK=$::CHECK_JDK"
996 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
998 puts $aFile "# Additional headers search paths"
999 puts $aFile "export CSF_OPT_INC=\"$aStringInc\""
1001 set aStringLib$::ARCH [join [set ::CSF_OPT_LIB$::ARCH] $::SYS_PATH_SPLITTER]
1003 puts $aFile "# Additional libraries ($::ARCH-bit) search paths"
1004 puts $aFile "export CSF_OPT_LIB$::ARCH=\"[set aStringLib$::ARCH]\""
1006 set aStringBin$::ARCH [join [set ::CSF_OPT_BIN$::ARCH] $::SYS_PATH_SPLITTER]
1008 puts $aFile "# Additional ($::ARCH-bit) search paths"
1009 puts $aFile "export CSF_OPT_BIN$::ARCH=\"[set aStringBin$::ARCH]\""
1014 puts "Configuration saved to file '$aCustomFilePath'"