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 "ShortCut"
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)"
75 if { $SHORTCUT_HEADERS == "true" } {
76 set SHORTCUT_HEADERS "ShortCut"
79 if { [info exists ::env(HAVE_FREEIMAGE)] } {
80 set HAVE_FREEIMAGE "$::env(HAVE_FREEIMAGE)"
82 if { [info exists ::env(HAVE_GL2PS)] } {
83 set HAVE_GL2PS "$::env(HAVE_GL2PS)"
85 if { [info exists ::env(HAVE_TBB)] } {
86 set HAVE_TBB "$::env(HAVE_TBB)"
88 if { [info exists ::env(HAVE_OPENCL)] } {
89 set HAVE_OPENCL "$::env(HAVE_OPENCL)"
91 if { [info exists ::env(HAVE_VTK)] } {
92 set HAVE_VTK "$::env(HAVE_VTK)"
94 if { [info exists ::env(MACOSX_USE_GLX)] } {
95 set MACOSX_USE_GLX "$::env(MACOSX_USE_GLX)"
97 if { [info exists ::env(CHECK_QT4)] } {
98 set CHECK_QT4 "$::env(CHECK_QT4)"
100 if { [info exists ::env(CHECK_JDK)] } {
101 set CHECK_JDK "$::env(CHECK_JDK)"
103 if { [info exists ::env(PRODUCTS_PATH)] } {
104 set PRODUCTS_PATH "$::env(PRODUCTS_PATH)"
106 if { [info exists ::env(CSF_OPT_INC)] } {
107 set CSF_OPT_INC [split "$::env(CSF_OPT_INC)" $::SYS_PATH_SPLITTER]
109 if { [info exists ::env(CSF_OPT_LIB32)] } {
110 set CSF_OPT_LIB32 [split "$::env(CSF_OPT_LIB32)" $::SYS_PATH_SPLITTER]
112 if { [info exists ::env(CSF_OPT_LIB64)] } {
113 set CSF_OPT_LIB64 [split "$::env(CSF_OPT_LIB64)" $::SYS_PATH_SPLITTER]
115 if { [info exists ::env(CSF_OPT_BIN32)] } {
116 set CSF_OPT_BIN32 [split "$::env(CSF_OPT_BIN32)" $::SYS_PATH_SPLITTER]
118 if { [info exists ::env(CSF_OPT_BIN64)] } {
119 set CSF_OPT_BIN64 [split "$::env(CSF_OPT_BIN64)" $::SYS_PATH_SPLITTER]
122 # Search header file in $::CSF_OPT_INC and standard paths
123 proc wokdep:SearchHeader {theHeader} {
124 # search in custom paths
125 foreach anIncPath $::CSF_OPT_INC {
126 set aPath "${anIncPath}/${theHeader}"
127 if { [file exists "$aPath"] } {
133 set aPath "/usr/include/${theHeader}"
134 if { [file exists "$aPath"] } {
140 # Search library file in $::CSF_OPT_LIB* and standard paths
141 proc wokdep:SearchLib {theLib theBitness {theSearchPath ""}} {
142 if { "$theSearchPath" != "" } {
143 set aPath "${theSearchPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
144 if { [file exists "$aPath"] } {
151 # search in custom paths
152 foreach aLibPath [set ::CSF_OPT_LIB$theBitness] {
153 set aPath "${aLibPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
154 if { [file exists "$aPath"] } {
160 if { "$::ARCH" == "$theBitness"} {
161 set aPath "/usr/lib/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
162 if { [file exists "$aPath"] } {
168 if { "$::tcl_platform(os)" == "Linux" } {
169 if { "$theBitness" == "64" } {
170 set aPath "/usr/lib/x86_64-linux-gnu/lib${theLib}.so"
171 if { [file exists "$aPath"] } {
175 set aPath "/usr/lib/i386-linux-gnu/lib${theLib}.so"
176 if { [file exists "$aPath"] } {
185 # Search file in $::CSF_OPT_BIN* and standard paths
186 proc wokdep:SearchBin {theBin theBitness {theSearchPath ""}} {
187 if { "$theSearchPath" != "" } {
188 set aPath "${theSearchPath}/${theBin}"
189 if { [file exists "$aPath"] } {
196 # search in custom paths
197 foreach aBinPath [set ::CSF_OPT_BIN$theBitness] {
198 set aPath "${aBinPath}/${theBin}"
199 if { [file exists "$aPath"] } {
205 if { "$::ARCH" == "$theBitness"} {
206 set aPath "/usr/bin/${theBin}"
207 if { [file exists "$aPath"] } {
215 # Detect compiler C-runtime version 'vc*' and architecture '32'/'64'
216 # to determine preferred path.
217 proc wokdep:Preferred {theList theCmpl theArch} {
218 if { [llength $theList] == 0 } {
223 foreach aPath $theList {
224 if { [string first "$theCmpl" "$aPath"] != "-1" } {
225 lappend aShortList "$aPath"
229 if { [llength $aShortList] == 0 } {
230 #return [lindex $theList 0]
231 set aShortList $theList
234 set aVeryShortList {}
235 foreach aPath $aShortList {
236 if { [string first "$theArch" "$aPath"] != "-1" } {
237 lappend aVeryShortList "$aPath"
240 if { [llength $aVeryShortList] == 0 } {
241 return [lindex [lsort -decreasing $aShortList] 0]
244 return [lindex [lsort -decreasing $aVeryShortList] 0]
247 # Search Tcl/Tk libraries placement
248 proc wokdep:SearchTclTk {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
249 upvar $theErrInc anErrInc
250 upvar $theErrLib32 anErrLib32
251 upvar $theErrLib64 anErrLib64
252 upvar $theErrBin32 anErrBin32
253 upvar $theErrBin64 anErrBin64
259 set aTclHPath [wokdep:SearchHeader "tcl.h"]
260 set aTkHPath [wokdep:SearchHeader "tk.h"]
261 if { "$aTclHPath" == "" || "$aTkHPath" == "" } {
262 if { [file exists "/usr/include/tcl8.6/tcl.h"]
263 && [file exists "/usr/include/tcl8.6/tk.h" ] } {
264 lappend ::CSF_OPT_INC "/usr/include/tcl8.6"
265 set aTclHPath "/usr/include/tcl8.6/tcl.h"
267 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$::ARCH" ]
268 if { "$aPath" != "" && [file exists "$aPath/include/tcl.h"] && [file exists "$aPath/include/tk.h"] } {
269 lappend ::CSF_OPT_INC "$aPath/include"
270 set aTclHPath "$aPath/include/tcl.h"
272 lappend anErrInc "Error: 'tcl.h' or 'tk.h' not found (Tcl/Tk)"
278 # detect tcl version by parsing header file
280 set fh [open $aTclHPath]
283 regexp {define\s+TCL_MAJOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_maj
284 regexp {define\s+TCL_MINOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_min
287 if { "$::tcl_platform(platform)" == "windows" } {
288 set aTclLibName "tcl${tclver_maj}${tclver_min}"
289 set aTkLibName "tk${tclver_maj}${tclver_min}"
291 set aTclLibName "tcl${tclver_maj}.${tclver_min}"
292 set aTkLibName "tk${tclver_maj}.${tclver_min}"
295 foreach anArchIter {64 32} {
296 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter"]
297 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter"]
298 if { "$aTclLibPath" == "" || "$aTkLibPath" == "" } {
299 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
300 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter" "$aPath/lib"]
301 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter" "$aPath/lib"]
302 if { "$aTclLibPath" != "" && "$aTkLibPath" != "" } {
303 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
305 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aTclLibName}.${::SYS_LIB_SUFFIX}' or '${::SYS_LIB_PREFIX}${aTkLibName}.${::SYS_LIB_SUFFIX}' not found (Tcl/Tk)"
306 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
310 if { "$::tcl_platform(platform)" == "windows" } {
311 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter"]
312 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter"]
313 if { "$aTclDllPath" == "" || "$aTkDllPath" == "" } {
314 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
315 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter" "$aPath/bin"]
316 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter" "$aPath/bin"]
317 if { "$aTclDllPath" != "" && "$aTkDllPath" != "" } {
318 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
320 lappend anErrBin$anArchIter "Error: '${aTclLibName}.dll' or '${aTkLibName}.dll' not found (Tcl/Tk)"
321 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
330 # Search FreeType library placement
331 proc wokdep:SearchFreeType {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
332 upvar $theErrInc anErrInc
333 upvar $theErrLib32 anErrLib32
334 upvar $theErrLib64 anErrLib64
335 upvar $theErrBin32 anErrBin32
336 upvar $theErrBin64 anErrBin64
339 set aFtBuildPath [wokdep:SearchHeader "ft2build.h"]
341 if { "$aFtBuildPath" == "" } {
342 # TODO - use `freetype-config --cflags` instead
343 set aSysFreeType "/usr/include/freetype2"
344 if { [file exists "$aSysFreeType/ft2build.h"] } {
345 lappend ::CSF_OPT_INC "$aSysFreeType"
346 } elseif { [file exists "$aSysFreeType/freetype2/ft2build.h"] } {
347 lappend ::CSF_OPT_INC "$aSysFreeType/freetype2"
349 set aSysFreeType "/usr/X11/include/freetype2"
350 if { [file exists "$aSysFreeType/ft2build.h"] } {
351 lappend ::CSF_OPT_INC "/usr/X11/include"
352 lappend ::CSF_OPT_INC "$aSysFreeType"
354 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$::ARCH" ]
355 if {"$aPath" != ""} {
356 if {[file exists "$aPath/include/ft2build.h"]} {
357 lappend ::CSF_OPT_INC "$aPath/include"
358 } elseif {[file exists "$aPath/include/freetype2/ft2build.h"]} {
359 lappend ::CSF_OPT_INC "$aPath/include/freetype2"
362 lappend anErrInc "Error: 'freetype.h' not found (FreeType2)"
369 # parse 'freetype-config --libs'
371 if { [catch { set aConfLibs [exec freetype-config --libs] } ] == 0 } {
372 foreach aPath [split $aConfLibs " "] {
373 if { [string first "-L" "$aPath"] == 0 } {
374 set aConfLibPath [string range "$aPath" 2 [string length "$aPath"]]
379 foreach anArchIter {64 32} {
380 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter"]
381 if { "$aFtLibPath" == "" } {
382 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
383 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aPath/lib"]
384 if { "$aFtLibPath" != "" } {
385 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
387 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aConfLibPath"]
388 if { "$aFtLibPath" != "" } {
389 lappend ::CSF_OPT_LIB$anArchIter "$aConfLibPath"
391 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freetype.${::SYS_LIB_SUFFIX}' not found (FreeType2)"
392 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
396 if { "$::tcl_platform(platform)" == "windows" } {
397 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter"]
398 if { "$aFtDllPath" == "" } {
399 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
400 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/bin"]
401 if { "$aFtDllPath" != "" } {
402 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
404 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/lib"]
405 if { "$aFtDllPath" != "" } {
406 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
408 lappend anErrBin$anArchIter "Error: 'freetype.dll' not found (FreeType2)"
409 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
419 # Search FreeImage library placement
420 proc wokdep:SearchFreeImage {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
421 upvar $theErrInc anErrInc
422 upvar $theErrLib32 anErrLib32
423 upvar $theErrLib64 anErrLib64
424 upvar $theErrBin32 anErrBin32
425 upvar $theErrBin64 anErrBin64
427 # binary distribution has another layout
428 set aFImageDist "Dist"
429 set aFImagePlusDist "Wrapper/FreeImagePlus/dist"
432 set aFImageHPath [wokdep:SearchHeader "FreeImage.h"]
433 if { "$aFImageHPath" == "" } {
434 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$::ARCH" ]
435 if { "$aPath" != "" && [file exists "$aPath/include/FreeImage.h"] } {
436 lappend ::CSF_OPT_INC "$aPath/include"
437 } elseif { "$aPath" != "" && [file exists "$aPath/$aFImageDist/FreeImage.h"] } {
438 lappend ::CSF_OPT_INC "$aPath/$aFImageDist"
439 if { [file exists "$aPath/$aFImagePlusDist/FreeImagePlus.h"] } {
440 lappend ::CSF_OPT_INC "$aPath/$aFImagePlusDist"
443 lappend anErrInc "Error: 'FreeImage.h' not found (FreeImage)"
448 set aFImagePlusHPath [wokdep:SearchHeader "FreeImagePlus.h"]
449 if { "$::tcl_platform(platform)" == "windows" && "$aFImagePlusHPath" == "" } {
450 lappend anErrInc "Error: 'FreeImagePlus.h' not found (FreeImage)"
454 foreach anArchIter {64 32} {
455 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter"]
456 if { "$aFImageLibPath" == "" } {
457 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
458 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/lib"]
459 if { "$aFImageLibPath" != "" } {
460 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
462 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/$aFImageDist"]
463 if { "$aFImageLibPath" != "" } {
464 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImageDist"
465 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter" "$aPath/$aFImagePlusDist"]
466 if { "$aFImagePlusLibPath" != "" } {
467 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImagePlusDist"
470 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimage.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
471 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
475 if { "$::tcl_platform(platform)" == "windows" } {
476 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter"]
477 if { "$aFImagePlusLibPath" == "" } {
478 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimageplus.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
479 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
482 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter"]
483 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter"]
484 if { "$aFImageDllPath" == "" || "$aFImagePlusDllPath" == "" } {
485 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
486 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/bin"]
487 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter" "$aPath/bin"]
488 if { "$aFImageDllPath" != "" && "$aFImagePlusDllPath" != "" } {
489 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
491 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/$aFImageDist"]
492 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter" "$aPath/$aFImagePlusDist"]
493 if { "$aFImageDllPath" != "" && "$aFImagePlusDllPath" != "" } {
494 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImageDist"
495 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImagePlusDist"
497 lappend anErrBin$anArchIter "Error: 'freeimage.dll' or 'freeimageplus.dll' not found (FreeImage)"
498 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
508 # Search GL2PS library placement
509 proc wokdep:SearchGL2PS {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
510 upvar $theErrInc anErrInc
511 upvar $theErrLib32 anErrLib32
512 upvar $theErrLib64 anErrLib64
513 upvar $theErrBin32 anErrBin32
514 upvar $theErrBin64 anErrBin64
517 set aGl2psHPath [wokdep:SearchHeader "gl2ps.h"]
518 if { "$aGl2psHPath" == "" } {
519 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$::ARCH" ]
520 if { "$aPath" != "" && [file exists "$aPath/include/gl2ps.h"] } {
521 lappend ::CSF_OPT_INC "$aPath/include"
523 lappend anErrInc "Error: 'gl2ps.h' not found (GL2PS)"
528 foreach anArchIter {64 32} {
529 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter"]
530 if { "$aGl2psLibPath" == "" } {
531 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
532 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter" "$aPath/lib"]
533 if { "$aGl2psLibPath" != "" } {
534 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
536 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}gl2ps.${::SYS_LIB_SUFFIX}' not found (GL2PS)"
537 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
540 if { "$::tcl_platform(platform)" == "windows" } {
541 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter"]
542 if { "$aGl2psDllPath" == "" } {
543 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
544 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/bin"]
545 if { "$aGl2psDllPath" != "" } {
546 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
548 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/lib"]
549 if { "$aGl2psDllPath" != "" } {
550 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
552 lappend anErrBin$anArchIter "Error: 'gl2ps.dll' not found (GL2PS)"
553 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
563 # Search TBB library placement
564 proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
565 upvar $theErrInc anErrInc
566 upvar $theErrLib32 anErrLib32
567 upvar $theErrLib64 anErrLib64
568 upvar $theErrBin32 anErrBin32
569 upvar $theErrBin64 anErrBin64
572 set aTbbHPath [wokdep:SearchHeader "tbb/scalable_allocator.h"]
573 if { "$aTbbHPath" == "" } {
574 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$::ARCH" ]
575 if { "$aPath" != "" && [file exists "$aPath/include/tbb/scalable_allocator.h"] } {
576 lappend ::CSF_OPT_INC "$aPath/include"
578 lappend anErrInc "Error: 'tbb/scalable_allocator.h' not found (Intel TBB)"
583 foreach anArchIter {64 32} {
585 if { "$anArchIter" == "64"} {
586 set aSubDir "intel64"
589 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter"]
590 if { "$aTbbLibPath" == "" } {
591 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
592 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir/${::VCVER}"]
593 if { "$aTbbLibPath" == "" } {
594 # Set the path to the TBB library for Linux
595 if { "$::tcl_platform(platform)" != "windows" } {
596 set aSubDir "$aSubDir/cc4.1.0_libc2.4_kernel2.6.16.21"
598 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir"]
599 if { "$aTbbLibPath" != "" } {
600 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir"
603 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/${::VCVER}"
605 if { "$aTbbLibPath" == "" } {
606 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
607 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
610 if { "$::tcl_platform(platform)" == "windows" } {
611 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"]
612 if { "$aTbbDllPath" == "" } {
613 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
614 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/${::VCVER}"]
615 if { "$aTbbDllPath" != "" } {
616 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/${::VCVER}"
618 lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)"
619 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
628 # Search OpenCL library placement
629 proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
630 upvar $theErrInc anErrInc
631 upvar $theErrLib32 anErrLib32
632 upvar $theErrLib64 anErrLib64
633 upvar $theErrBin32 anErrBin32
634 upvar $theErrBin64 anErrBin64
637 if { "$::tcl_platform(os)" == "Darwin" } {
638 # OpenCL framework available since Mac OS X 16
642 set aCLHPath [wokdep:SearchHeader "CL/cl_gl.h"]
643 if { "$aCLHPath" == "" } {
644 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$::ARCH" ]
645 if { "$aPath" != "" && [file exists "$aPath/include/CL/cl_gl.h"] } {
646 lappend ::CSF_OPT_INC "$aPath/include"
648 lappend anErrInc "Error: 'CL/cl_gl.h' not found (OpenCL)"
653 foreach anArchIter {64 32} {
654 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter"]
655 if { "$aCLLibPath" == "" } {
656 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$anArchIter" ]
657 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter" "$aPath/lib"]
658 if { "$aCLLibPath" != "" } {
659 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
661 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}OpenCL.${::SYS_LIB_SUFFIX}' not found (OpenCL)"
662 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
670 # Auxiliary function, gets VTK version to set default search directory
671 proc wokdep:VtkVersion { thePath } {
674 set aVtkRoot [lindex [regexp -all -inline {[0-9.]*} [file tail $thePath]] 0]
675 if { "$aVtkRoot" != "" } {
676 set aVtkRoot [regexp -inline {[0-9]*.[0-9]*} $aVtkRoot]
677 if { "$aVtkRoot" != "" } {
678 set aResult $aVtkRoot
685 # Search VTK library placement
686 proc wokdep:SearchVTK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
687 upvar $theErrInc anErrInc
688 upvar $theErrLib32 anErrLib32
689 upvar $theErrLib64 anErrLib64
690 upvar $theErrBin32 anErrBin32
691 upvar $theErrBin64 anErrBin64
696 set aVtkIncPath [wokdep:SearchHeader "vtkConfigure.h"]
697 set aVtkVer [wokdep:VtkVersion $aVtkIncPath]
698 if { "$aVtkIncPath" == ""} {
699 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
700 set aVtkPath [wokdep:Preferred "$aPathList" "$::VCVER" "$::ARCH" ]
701 if { "$aVtkPath" != "" && [file exists "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]/vtkConfigure.h"]} {
702 set aVtkVer [wokdep:VtkVersion $aVtkPath]
703 lappend ::CSF_OPT_INC "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]"
704 } else { # try to search in all found paths
706 foreach anIt $aPathList {
707 if { [file exists "$anIt/include/vtk-[wokdep:VtkVersion $anIt]/vtkConfigure.h"] } {
709 set aVtkVer [wokdep:VtkVersion $aVtkPath]
710 lappend ::CSF_OPT_INC "$anIt/include/vtk-[wokdep:VtkVersion $anIt]"
716 # Bad case: we do not found vtkConfigure.h in all paths.
717 if { "$isFound" == "false"} {
718 lappend anErrInc "Error: 'vtkConfigure.h' not found (VTK)"
725 foreach anArchIter {64 32} {
726 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter"]
727 if { "$aVtkLibPath" == "" } {
728 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
729 set aPath [wokdep:Preferred $aPathList "$::VCVER" "$anArchIter" ]
730 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aPath/lib"]
731 if { "$aVtkLibPath" != "" } {
732 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
734 set aPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aVtkPath/lib"]
735 if { "$aPath" != "" } {
736 set aLibPath $aVtkIncPath
737 lappend ::CSF_OPT_LIB$anArchIter "$aLibPath/lib"
739 # The last chance: search /lib directory in all found paths
740 foreach anIt $aPathList {
741 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$anIt/lib"]
742 if { "$aVtkLibPath" != ""} {
743 lappend ::CSF_OPT_LIB$anArchIter "$anIt/lib"
747 if { "$aVtkLibPath" == "" } {
748 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}vtkCommonCore-${aVtkVer}\.${::SYS_LIB_SUFFIX}' not found (VTK)"
749 if { "$::ARCH" == "$anArchIter" } {
759 if { "$::tcl_platform(platform)" == "windows" } {
760 foreach anArchIter {64 32} {
761 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter"]
762 if { "$aVtkBinPath" == "" } {
763 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*] "$::VCVER" "$anArchIter" ]
764 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/bin"]
765 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
767 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/lib"]
768 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib" }
773 # We didn't find preferred binary path => search through inc path or among all available VTK directories
774 if { "$aVtkBinPath" == "" } {
775 # Try to find in lib path
776 set aPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/bin"]
777 if { "$aPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/bin"
778 } elseif { [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/lib"] != "" } {
779 lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/lib"
781 lappend anErrBin$anArchIter "Error: 'vtkCommonCore-${aVtkVer}.dll' not found (VTK)"
790 # Search Qt4 libraries placement
791 proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
792 upvar $theErrInc anErrInc
793 upvar $theErrLib32 anErrLib32
794 upvar $theErrLib64 anErrLib64
795 upvar $theErrBin32 anErrBin32
796 upvar $theErrBin64 anErrBin64
799 set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qmessagebox.h"]
800 if { "$aQMsgBoxHPath" == "" } {
801 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$::ARCH" ]
802 if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qmessagebox.h"] } {
803 lappend ::CSF_OPT_INC "$aPath/include"
804 lappend ::CSF_OPT_INC "$aPath/include/Qt"
805 lappend ::CSF_OPT_INC "$aPath/include/QtGui"
806 lappend ::CSF_OPT_INC "$aPath/include/QtCore"
808 if { [file exists "/usr/include/qt4/QtGui/qmessagebox.h"] } {
809 lappend ::CSF_OPT_INC "/usr/include/qt4"
810 lappend ::CSF_OPT_INC "/usr/include/qt4/Qt"
811 lappend ::CSF_OPT_INC "/usr/include/qt4/QtGui"
812 lappend ::CSF_OPT_INC "/usr/include/qt4/QtCore"
814 lappend anErrInc "Error: 'QtGui/qmessagebox.h' not found (Qt4)"
820 set aQtGuiLibName "QtGui"
821 if { "$::tcl_platform(platform)" == "windows" } {
822 set aQtGuiLibName "QtGui4"
825 foreach anArchIter {64 32} {
826 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter"]
827 if { "$aQMsgBoxLibPath" == "" } {
828 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
829 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter" "$aPath/lib"]
830 if { "$aQMsgBoxLibPath" != "" } {
831 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
833 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt4)"
834 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
837 if { "$::tcl_platform(platform)" == "windows" } {
838 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter"]
839 if { "$aQMsgBoxDllPath" == "" } {
840 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
841 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter" "$aPath/bin"]
842 if { "$aQMsgBoxDllPath" != "" } {
843 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
845 lappend anErrBin$anArchIter "Error: 'QtGui4.dll' not found (Qt4)"
846 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
855 # Search JDK placement
856 proc wokdep:SearchJDK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
857 upvar $theErrInc anErrInc
858 upvar $theErrLib32 anErrLib32
859 upvar $theErrLib64 anErrLib64
860 upvar $theErrBin32 anErrBin32
861 upvar $theErrBin64 anErrBin64
864 set aJniHPath [wokdep:SearchHeader "jni.h"]
865 set aJniMdHPath [wokdep:SearchHeader "jni_md.h"]
866 if { "$aJniHPath" == "" || "$aJniMdHPath" == "" } {
867 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$::ARCH" ]
868 if { "$aPath" != "" && [file exists "$aPath/include/jni.h"] } {
869 lappend ::CSF_OPT_INC "$aPath/include"
870 if { "$::tcl_platform(platform)" == "windows" } {
871 lappend ::CSF_OPT_INC "$aPath/include/win32"
872 } elseif { [file exists "$aPath/include/linux"] } {
873 lappend ::CSF_OPT_INC "$aPath/include/linux"
876 if { [file exists "/System/Library/Frameworks/JavaVM.framework/Home/include/jni.h"] } {
877 lappend ::CSF_OPT_INC "/System/Library/Frameworks/JavaVM.framework/Home/include"
879 lappend anErrInc "Error: 'jni.h' or 'jni_md.h' not found (JDK)"
885 foreach anArchIter {64 32} {
886 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter"]
887 if { "$aJavacPath" == "" } {
888 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$anArchIter" ]
889 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter" "$aPath/bin"]
890 if { "$aJavacPath" != "" } {
891 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
893 if { "$::ARCH" == "$anArchIter" && [file exists "/System/Library/Frameworks/JavaVM.framework/Home/bin/javac${::SYS_EXE_SUFFIX}"] } {
894 lappend ::CSF_OPT_BIN$anArchIter "/System/Library/Frameworks/JavaVM.framework/Home/bin"
896 lappend anErrBin$anArchIter "Error: 'javac${::SYS_EXE_SUFFIX}' not found (JDK)"
897 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
906 # Search X11 libraries placement
907 proc wokdep:SearchX11 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
908 upvar $theErrInc anErrInc
909 upvar $theErrLib32 anErrLib32
910 upvar $theErrLib64 anErrLib64
911 upvar $theErrBin32 anErrBin32
912 upvar $theErrBin64 anErrBin64
915 if { "$::tcl_platform(platform)" == "windows" || ( "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" ) } {
919 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH"]
920 if { "$aXmuLibPath" == "" } {
921 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH" "/usr/X11/lib"]
922 if { "$aXmuLibPath" != "" } {
923 #lappend ::CSF_OPT_LIB$::ARCH "/usr/X11/lib"
925 lappend anErrLib$::ARCH "Error: '${::SYS_LIB_PREFIX}Xmu.${::SYS_LIB_SUFFIX}' not found (X11)"
933 # Generate (override) custom environment file
934 proc wokdep:SaveCustom {} {
935 if { "$::tcl_platform(platform)" == "windows" } {
936 set aCustomFilePath "./custom.bat"
937 set aFile [open $aCustomFilePath "w"]
938 puts $aFile "@echo off"
939 puts $aFile "rem This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
942 puts $aFile "set VCVER=$::VCVER"
943 puts $aFile "set ARCH=$::ARCH"
944 puts $aFile "set VCVARS=$::VCVARS"
945 puts $aFile "set SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
948 puts $aFile "set \"PRODUCTS_PATH=$::PRODUCTS_PATH\""
951 puts $aFile "rem Optional 3rd-parties switches"
952 puts $aFile "set HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
953 puts $aFile "set HAVE_GL2PS=$::HAVE_GL2PS"
954 puts $aFile "set HAVE_TBB=$::HAVE_TBB"
955 puts $aFile "set HAVE_OPENCL=$::HAVE_OPENCL"
956 puts $aFile "set HAVE_VTK=$::HAVE_VTK"
957 puts $aFile "set CHECK_QT4=$::CHECK_QT4"
958 puts $aFile "set CHECK_JDK=$::CHECK_JDK"
960 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
962 puts $aFile "rem Additional headers search paths"
963 puts $aFile "set \"CSF_OPT_INC=$aStringInc\""
965 set aStringLib32 [join $::CSF_OPT_LIB32 $::SYS_PATH_SPLITTER]
967 puts $aFile "rem Additional libraries (32-bit) search paths"
968 puts $aFile "set \"CSF_OPT_LIB32=$aStringLib32\""
970 set aStringLib64 [join $::CSF_OPT_LIB64 $::SYS_PATH_SPLITTER]
972 puts $aFile "rem Additional libraries (64-bit) search paths"
973 puts $aFile "set \"CSF_OPT_LIB64=$aStringLib64\""
975 set aStringBin32 [join $::CSF_OPT_BIN32 $::SYS_PATH_SPLITTER]
977 puts $aFile "rem Additional (32-bit) search paths"
978 puts $aFile "set \"CSF_OPT_BIN32=$aStringBin32\""
980 set aStringBin64 [join $::CSF_OPT_BIN64 $::SYS_PATH_SPLITTER]
982 puts $aFile "rem Additional (64-bit) search paths"
983 puts $aFile "set \"CSF_OPT_BIN64=$aStringBin64\""
987 set aCustomFilePath "./custom.sh"
988 set aFile [open $aCustomFilePath "w"]
989 puts $aFile "#!/bin/bash"
990 puts $aFile "# This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
993 puts $aFile "export ARCH=$::ARCH"
994 puts $aFile "export SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
997 puts $aFile "export PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
1000 puts $aFile "# Optional 3rd-parties switches"
1001 puts $aFile "export HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
1002 puts $aFile "export HAVE_GL2PS=$::HAVE_GL2PS"
1003 puts $aFile "export HAVE_TBB=$::HAVE_TBB"
1004 puts $aFile "export HAVE_OPENCL=$::HAVE_OPENCL"
1005 puts $aFile "export HAVE_VTK=$::HAVE_VTK"
1006 if { "$::tcl_platform(os)" == "Darwin" } {
1007 puts $aFile "export MACOSX_USE_GLX=$::MACOSX_USE_GLX"
1009 puts $aFile "export CHECK_QT4=$::CHECK_QT4"
1010 puts $aFile "export CHECK_JDK=$::CHECK_JDK"
1012 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
1014 puts $aFile "# Additional headers search paths"
1015 puts $aFile "export CSF_OPT_INC=\"$aStringInc\""
1017 set aStringLib$::ARCH [join [set ::CSF_OPT_LIB$::ARCH] $::SYS_PATH_SPLITTER]
1019 puts $aFile "# Additional libraries ($::ARCH-bit) search paths"
1020 puts $aFile "export CSF_OPT_LIB$::ARCH=\"[set aStringLib$::ARCH]\""
1022 set aStringBin$::ARCH [join [set ::CSF_OPT_BIN$::ARCH] $::SYS_PATH_SPLITTER]
1024 puts $aFile "# Additional ($::ARCH-bit) search paths"
1025 puts $aFile "export CSF_OPT_BIN$::ARCH=\"[set aStringBin$::ARCH]\""
1030 puts "Configuration saved to file '$aCustomFilePath'"