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 if { "$aFImageHPath" == "" } {
431 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$::ARCH" ]
432 if { "$aPath" != "" && [file exists "$aPath/include/FreeImage.h"] } {
433 lappend ::CSF_OPT_INC "$aPath/include"
434 } elseif { "$aPath" != "" && [file exists "$aPath/$aFImageDist/FreeImage.h"] } {
435 lappend ::CSF_OPT_INC "$aPath/$aFImageDist"
436 if { [file exists "$aPath/$aFImagePlusDist/FreeImagePlus.h"] } {
437 lappend ::CSF_OPT_INC "$aPath/$aFImagePlusDist"
440 lappend anErrInc "Error: 'FreeImage.h' not found (FreeImage)"
445 set aFImagePlusHPath [wokdep:SearchHeader "FreeImagePlus.h"]
446 if { "$::tcl_platform(platform)" == "windows" && "$aFImagePlusHPath" == "" } {
447 lappend anErrInc "Error: 'FreeImagePlus.h' not found (FreeImage)"
451 foreach anArchIter {64 32} {
452 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter"]
453 if { "$aFImageLibPath" == "" } {
454 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
455 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/lib"]
456 if { "$aFImageLibPath" != "" } {
457 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
459 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/$aFImageDist"]
460 if { "$aFImageLibPath" != "" } {
461 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImageDist"
462 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter" "$aPath/$aFImagePlusDist"]
463 if { "$aFImagePlusLibPath" != "" } {
464 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImagePlusDist"
467 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimage.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
468 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
472 if { "$::tcl_platform(platform)" == "windows" } {
473 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter"]
474 if { "$aFImagePlusLibPath" == "" } {
475 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimageplus.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
476 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
479 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter"]
480 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter"]
481 if { "$aFImageDllPath" == "" || "$aFImagePlusDllPath" == "" } {
482 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
483 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/bin"]
484 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter" "$aPath/bin"]
485 if { "$aFImageDllPath" != "" && "$aFImagePlusDllPath" != "" } {
486 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
488 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/$aFImageDist"]
489 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter" "$aPath/$aFImagePlusDist"]
490 if { "$aFImageDllPath" != "" && "$aFImagePlusDllPath" != "" } {
491 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImageDist"
492 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImagePlusDist"
494 lappend anErrBin$anArchIter "Error: 'freeimage.dll' or 'freeimageplus.dll' not found (FreeImage)"
495 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
505 # Search GL2PS library placement
506 proc wokdep:SearchGL2PS {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
507 upvar $theErrInc anErrInc
508 upvar $theErrLib32 anErrLib32
509 upvar $theErrLib64 anErrLib64
510 upvar $theErrBin32 anErrBin32
511 upvar $theErrBin64 anErrBin64
514 set aGl2psHPath [wokdep:SearchHeader "gl2ps.h"]
515 if { "$aGl2psHPath" == "" } {
516 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$::ARCH" ]
517 if { "$aPath" != "" && [file exists "$aPath/include/gl2ps.h"] } {
518 lappend ::CSF_OPT_INC "$aPath/include"
520 lappend anErrInc "Error: 'gl2ps.h' not found (GL2PS)"
525 foreach anArchIter {64 32} {
526 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter"]
527 if { "$aGl2psLibPath" == "" } {
528 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
529 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter" "$aPath/lib"]
530 if { "$aGl2psLibPath" != "" } {
531 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
533 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}gl2ps.${::SYS_LIB_SUFFIX}' not found (GL2PS)"
534 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
537 if { "$::tcl_platform(platform)" == "windows" } {
538 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter"]
539 if { "$aGl2psDllPath" == "" } {
540 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
541 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/bin"]
542 if { "$aGl2psDllPath" != "" } {
543 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
545 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/lib"]
546 if { "$aGl2psDllPath" != "" } {
547 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
549 lappend anErrBin$anArchIter "Error: 'gl2ps.dll' not found (GL2PS)"
550 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
560 # Search TBB library placement
561 proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
562 upvar $theErrInc anErrInc
563 upvar $theErrLib32 anErrLib32
564 upvar $theErrLib64 anErrLib64
565 upvar $theErrBin32 anErrBin32
566 upvar $theErrBin64 anErrBin64
569 set aTbbHPath [wokdep:SearchHeader "tbb/scalable_allocator.h"]
570 if { "$aTbbHPath" == "" } {
571 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$::ARCH" ]
572 if { "$aPath" != "" && [file exists "$aPath/include/tbb/scalable_allocator.h"] } {
573 lappend ::CSF_OPT_INC "$aPath/include"
575 lappend anErrInc "Error: 'tbb/scalable_allocator.h' not found (Intel TBB)"
580 foreach anArchIter {64 32} {
582 if { "$anArchIter" == "64"} {
583 set aSubDir "intel64"
586 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter"]
587 if { "$aTbbLibPath" == "" } {
588 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
589 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir/${::VCVER}"]
590 if { "$aTbbLibPath" == "" } {
591 # Set the path to the TBB library for Linux
592 if { "$::tcl_platform(platform)" != "windows" } {
593 set aSubDir "$aSubDir/cc4.1.0_libc2.4_kernel2.6.16.21"
595 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir"]
596 if { "$aTbbLibPath" != "" } {
597 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir"
600 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/${::VCVER}"
602 if { "$aTbbLibPath" == "" } {
603 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
604 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
607 if { "$::tcl_platform(platform)" == "windows" } {
608 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"]
609 if { "$aTbbDllPath" == "" } {
610 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
611 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/${::VCVER}"]
612 if { "$aTbbDllPath" != "" } {
613 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/${::VCVER}"
615 lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)"
616 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
625 # Search OpenCL library placement
626 proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
627 upvar $theErrInc anErrInc
628 upvar $theErrLib32 anErrLib32
629 upvar $theErrLib64 anErrLib64
630 upvar $theErrBin32 anErrBin32
631 upvar $theErrBin64 anErrBin64
634 if { "$::tcl_platform(os)" == "Darwin" } {
635 # OpenCL framework available since Mac OS X 16
639 set aCLHPath [wokdep:SearchHeader "CL/cl_gl.h"]
640 if { "$aCLHPath" == "" } {
641 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$::ARCH" ]
642 if { "$aPath" != "" && [file exists "$aPath/include/CL/cl_gl.h"] } {
643 lappend ::CSF_OPT_INC "$aPath/include"
645 lappend anErrInc "Error: 'CL/cl_gl.h' not found (OpenCL)"
650 foreach anArchIter {64 32} {
651 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter"]
652 if { "$aCLLibPath" == "" } {
653 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$anArchIter" ]
654 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter" "$aPath/lib"]
655 if { "$aCLLibPath" != "" } {
656 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
658 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}OpenCL.${::SYS_LIB_SUFFIX}' not found (OpenCL)"
659 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
667 # Auxiliary function, gets VTK version to set default search directory
668 proc wokdep:VtkVersion { thePath } {
671 set aVtkRoot [lindex [regexp -all -inline {[0-9.]*} [file tail $thePath]] 0]
672 if { "$aVtkRoot" != "" } {
673 set aVtkRoot [regexp -inline {[0-9]*.[0-9]*} $aVtkRoot]
674 if { "$aVtkRoot" != "" } {
675 set aResult $aVtkRoot
682 # Search VTK library placement
683 proc wokdep:SearchVTK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
684 upvar $theErrInc anErrInc
685 upvar $theErrLib32 anErrLib32
686 upvar $theErrLib64 anErrLib64
687 upvar $theErrBin32 anErrBin32
688 upvar $theErrBin64 anErrBin64
693 set aVtkIncPath [wokdep:SearchHeader "vtkConfigure.h"]
694 set aVtkVer [wokdep:VtkVersion $aVtkIncPath]
695 if { "$aVtkIncPath" == ""} {
696 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
697 set aVtkPath [wokdep:Preferred "$aPathList" "$::VCVER" "$::ARCH" ]
698 if { "$aVtkPath" != "" && [file exists "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]/vtkConfigure.h"]} {
699 set aVtkVer [wokdep:VtkVersion $aVtkPath]
700 lappend ::CSF_OPT_INC "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]"
701 } else { # try to search in all found paths
703 foreach anIt $aPathList {
704 if { [file exists "$anIt/include/vtk-[wokdep:VtkVersion $anIt]/vtkConfigure.h"] } {
706 set aVtkVer [wokdep:VtkVersion $aVtkPath]
707 lappend ::CSF_OPT_INC "$anIt/include/vtk-[wokdep:VtkVersion $anIt]"
713 # Bad case: we do not found vtkConfigure.h in all paths.
714 if { "$isFound" == "false"} {
715 lappend anErrInc "Error: 'vtkConfigure.h' not found (VTK)"
722 foreach anArchIter {64 32} {
723 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter"]
724 if { "$aVtkLibPath" == "" } {
725 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
726 set aPath [wokdep:Preferred $aPathList "$::VCVER" "$anArchIter" ]
727 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aPath/lib"]
728 if { "$aVtkLibPath" != "" } {
729 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
731 set aPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aVtkPath/lib"]
732 if { "$aPath" != "" } {
733 set aLibPath $aVtkIncPath
734 lappend ::CSF_OPT_LIB$anArchIter "$aLibPath/lib"
736 # The last chance: search /lib directory in all found paths
737 foreach anIt $aPathList {
738 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$anIt/lib"]
739 if { "$aVtkLibPath" != ""} {
740 lappend ::CSF_OPT_LIB$anArchIter "$anIt/lib"
744 if { "$aVtkLibPath" == "" } {
745 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}vtkCommonCore-${aVtkVer}\.${::SYS_LIB_SUFFIX}' not found (VTK)"
746 if { "$::ARCH" == "$anArchIter" } {
756 if { "$::tcl_platform(platform)" == "windows" } {
757 foreach anArchIter {64 32} {
758 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter"]
759 if { "$aVtkBinPath" == "" } {
760 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*] "$::VCVER" "$anArchIter" ]
761 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/bin"]
762 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
764 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/lib"]
765 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib" }
770 # We didn't find preferred binary path => search through inc path or among all available VTK directories
771 if { "$aVtkBinPath" == "" } {
772 # Try to find in lib path
773 set aPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/bin"]
774 if { "$aPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/bin"
775 } elseif { [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/lib"] != "" } {
776 lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/lib"
778 lappend anErrBin$anArchIter "Error: 'vtkCommonCore-${aVtkVer}.dll' not found (VTK)"
787 # Search Qt4 libraries placement
788 proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
789 upvar $theErrInc anErrInc
790 upvar $theErrLib32 anErrLib32
791 upvar $theErrLib64 anErrLib64
792 upvar $theErrBin32 anErrBin32
793 upvar $theErrBin64 anErrBin64
796 set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qmessagebox.h"]
797 if { "$aQMsgBoxHPath" == "" } {
798 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$::ARCH" ]
799 if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qmessagebox.h"] } {
800 lappend ::CSF_OPT_INC "$aPath/include"
801 lappend ::CSF_OPT_INC "$aPath/include/Qt"
802 lappend ::CSF_OPT_INC "$aPath/include/QtGui"
803 lappend ::CSF_OPT_INC "$aPath/include/QtCore"
805 if { [file exists "/usr/include/qt4/QtGui/qmessagebox.h"] } {
806 lappend ::CSF_OPT_INC "/usr/include/qt4"
807 lappend ::CSF_OPT_INC "/usr/include/qt4/Qt"
808 lappend ::CSF_OPT_INC "/usr/include/qt4/QtGui"
809 lappend ::CSF_OPT_INC "/usr/include/qt4/QtCore"
811 lappend anErrInc "Error: 'QtGui/qmessagebox.h' not found (Qt4)"
817 set aQtGuiLibName "QtGui"
818 if { "$::tcl_platform(platform)" == "windows" } {
819 set aQtGuiLibName "QtGui4"
822 foreach anArchIter {64 32} {
823 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter"]
824 if { "$aQMsgBoxLibPath" == "" } {
825 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
826 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter" "$aPath/lib"]
827 if { "$aQMsgBoxLibPath" != "" } {
828 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
830 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt4)"
831 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
834 if { "$::tcl_platform(platform)" == "windows" } {
835 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter"]
836 if { "$aQMsgBoxDllPath" == "" } {
837 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
838 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter" "$aPath/bin"]
839 if { "$aQMsgBoxDllPath" != "" } {
840 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
842 lappend anErrBin$anArchIter "Error: 'QtGui4.dll' not found (Qt4)"
843 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
852 # Search JDK placement
853 proc wokdep:SearchJDK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
854 upvar $theErrInc anErrInc
855 upvar $theErrLib32 anErrLib32
856 upvar $theErrLib64 anErrLib64
857 upvar $theErrBin32 anErrBin32
858 upvar $theErrBin64 anErrBin64
861 set aJniHPath [wokdep:SearchHeader "jni.h"]
862 set aJniMdHPath [wokdep:SearchHeader "jni_md.h"]
863 if { "$aJniHPath" == "" || "$aJniMdHPath" == "" } {
864 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$::ARCH" ]
865 if { "$aPath" != "" && [file exists "$aPath/include/jni.h"] } {
866 lappend ::CSF_OPT_INC "$aPath/include"
867 if { "$::tcl_platform(platform)" == "windows" } {
868 lappend ::CSF_OPT_INC "$aPath/include/win32"
869 } elseif { [file exists "$aPath/include/linux"] } {
870 lappend ::CSF_OPT_INC "$aPath/include/linux"
873 if { [file exists "/System/Library/Frameworks/JavaVM.framework/Home/include/jni.h"] } {
874 lappend ::CSF_OPT_INC "/System/Library/Frameworks/JavaVM.framework/Home/include"
876 lappend anErrInc "Error: 'jni.h' or 'jni_md.h' not found (JDK)"
882 foreach anArchIter {64 32} {
883 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter"]
884 if { "$aJavacPath" == "" } {
885 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$anArchIter" ]
886 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter" "$aPath/bin"]
887 if { "$aJavacPath" != "" } {
888 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
890 if { "$::ARCH" == "$anArchIter" && [file exists "/System/Library/Frameworks/JavaVM.framework/Home/bin/javac${::SYS_EXE_SUFFIX}"] } {
891 lappend ::CSF_OPT_BIN$anArchIter "/System/Library/Frameworks/JavaVM.framework/Home/bin"
893 lappend anErrBin$anArchIter "Error: 'javac${::SYS_EXE_SUFFIX}' not found (JDK)"
894 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
903 # Search X11 libraries placement
904 proc wokdep:SearchX11 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
905 upvar $theErrInc anErrInc
906 upvar $theErrLib32 anErrLib32
907 upvar $theErrLib64 anErrLib64
908 upvar $theErrBin32 anErrBin32
909 upvar $theErrBin64 anErrBin64
912 if { "$::tcl_platform(platform)" == "windows" || ( "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" ) } {
916 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH"]
917 if { "$aXmuLibPath" == "" } {
918 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH" "/usr/X11/lib"]
919 if { "$aXmuLibPath" != "" } {
920 #lappend ::CSF_OPT_LIB$::ARCH "/usr/X11/lib"
922 lappend anErrLib$::ARCH "Error: '${::SYS_LIB_PREFIX}Xmu.${::SYS_LIB_SUFFIX}' not found (X11)"
930 # Generate (override) custom environment file
931 proc wokdep:SaveCustom {} {
932 if { "$::tcl_platform(platform)" == "windows" } {
933 set aCustomFilePath "./custom.bat"
934 set aFile [open $aCustomFilePath "w"]
935 puts $aFile "@echo off"
936 puts $aFile "rem This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
939 puts $aFile "set VCVER=$::VCVER"
940 puts $aFile "set ARCH=$::ARCH"
941 puts $aFile "set VCVARS=$::VCVARS"
942 puts $aFile "set SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
945 puts $aFile "set \"PRODUCTS_PATH=$::PRODUCTS_PATH\""
948 puts $aFile "rem Optional 3rd-parties switches"
949 puts $aFile "set HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
950 puts $aFile "set HAVE_GL2PS=$::HAVE_GL2PS"
951 puts $aFile "set HAVE_TBB=$::HAVE_TBB"
952 puts $aFile "set HAVE_OPENCL=$::HAVE_OPENCL"
953 puts $aFile "set HAVE_VTK=$::HAVE_VTK"
954 puts $aFile "set CHECK_QT4=$::CHECK_QT4"
955 puts $aFile "set CHECK_JDK=$::CHECK_JDK"
957 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
959 puts $aFile "rem Additional headers search paths"
960 puts $aFile "set \"CSF_OPT_INC=$aStringInc\""
962 set aStringLib32 [join $::CSF_OPT_LIB32 $::SYS_PATH_SPLITTER]
964 puts $aFile "rem Additional libraries (32-bit) search paths"
965 puts $aFile "set \"CSF_OPT_LIB32=$aStringLib32\""
967 set aStringLib64 [join $::CSF_OPT_LIB64 $::SYS_PATH_SPLITTER]
969 puts $aFile "rem Additional libraries (64-bit) search paths"
970 puts $aFile "set \"CSF_OPT_LIB64=$aStringLib64\""
972 set aStringBin32 [join $::CSF_OPT_BIN32 $::SYS_PATH_SPLITTER]
974 puts $aFile "rem Additional (32-bit) search paths"
975 puts $aFile "set \"CSF_OPT_BIN32=$aStringBin32\""
977 set aStringBin64 [join $::CSF_OPT_BIN64 $::SYS_PATH_SPLITTER]
979 puts $aFile "rem Additional (64-bit) search paths"
980 puts $aFile "set \"CSF_OPT_BIN64=$aStringBin64\""
984 set aCustomFilePath "./custom.sh"
985 set aFile [open $aCustomFilePath "w"]
986 puts $aFile "#!/bin/bash"
987 puts $aFile "# This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
990 puts $aFile "export ARCH=$::ARCH"
991 puts $aFile "export SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
994 puts $aFile "export PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
997 puts $aFile "# Optional 3rd-parties switches"
998 puts $aFile "export HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
999 puts $aFile "export HAVE_GL2PS=$::HAVE_GL2PS"
1000 puts $aFile "export HAVE_TBB=$::HAVE_TBB"
1001 puts $aFile "export HAVE_OPENCL=$::HAVE_OPENCL"
1002 puts $aFile "export HAVE_VTK=$::HAVE_VTK"
1003 if { "$::tcl_platform(os)" == "Darwin" } {
1004 puts $aFile "export MACOSX_USE_GLX=$::MACOSX_USE_GLX"
1006 puts $aFile "export CHECK_QT4=$::CHECK_QT4"
1007 puts $aFile "export CHECK_JDK=$::CHECK_JDK"
1009 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
1011 puts $aFile "# Additional headers search paths"
1012 puts $aFile "export CSF_OPT_INC=\"$aStringInc\""
1014 set aStringLib$::ARCH [join [set ::CSF_OPT_LIB$::ARCH] $::SYS_PATH_SPLITTER]
1016 puts $aFile "# Additional libraries ($::ARCH-bit) search paths"
1017 puts $aFile "export CSF_OPT_LIB$::ARCH=\"[set aStringLib$::ARCH]\""
1019 set aStringBin$::ARCH [join [set ::CSF_OPT_BIN$::ARCH] $::SYS_PATH_SPLITTER]
1021 puts $aFile "# Additional ($::ARCH-bit) search paths"
1022 puts $aFile "export CSF_OPT_BIN$::ARCH=\"[set aStringBin$::ARCH]\""
1027 puts "Configuration saved to file '$aCustomFilePath'"