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"
50 set HAVE_OPENCL "false"
52 set MACOSX_USE_GLX "false"
56 set CSF_OPT_INC [list]
57 set CSF_OPT_LIB32 [list]
58 set CSF_OPT_LIB64 [list]
59 set CSF_OPT_BIN32 [list]
60 set CSF_OPT_BIN64 [list]
62 if { "$tcl_platform(pointerSize)" == "4" } {
65 if { [info exists ::env(ARCH)] } {
66 set ARCH "$::env(ARCH)"
68 if { [info exists ::env(VCVER)] } {
69 set VCVER "$::env(VCVER)"
71 if { [info exists ::env(VCVARS)] } {
72 set VCVARS "$::env(VCVARS)"
74 if { [info exists ::env(SHORTCUT_HEADERS)] } {
75 set SHORTCUT_HEADERS "$::env(SHORTCUT_HEADERS)"
76 if { $SHORTCUT_HEADERS == "true" } {
77 set SHORTCUT_HEADERS "ShortCut"
80 if { [info exists ::env(HAVE_FREEIMAGE)] } {
81 set HAVE_FREEIMAGE "$::env(HAVE_FREEIMAGE)"
83 if { [info exists ::env(HAVE_GL2PS)] } {
84 set HAVE_GL2PS "$::env(HAVE_GL2PS)"
86 if { [info exists ::env(HAVE_TBB)] } {
87 set HAVE_TBB "$::env(HAVE_TBB)"
89 if { [info exists ::env(HAVE_D3D)] } {
90 set HAVE_D3D "$::env(HAVE_D3D)"
92 if { [info exists ::env(HAVE_OPENCL)] } {
93 set HAVE_OPENCL "$::env(HAVE_OPENCL)"
95 if { [info exists ::env(HAVE_VTK)] } {
96 set HAVE_VTK "$::env(HAVE_VTK)"
98 if { [info exists ::env(MACOSX_USE_GLX)] } {
99 set MACOSX_USE_GLX "$::env(MACOSX_USE_GLX)"
101 if { [info exists ::env(CHECK_QT4)] } {
102 set CHECK_QT4 "$::env(CHECK_QT4)"
104 if { [info exists ::env(CHECK_JDK)] } {
105 set CHECK_JDK "$::env(CHECK_JDK)"
107 if { [info exists ::env(PRODUCTS_PATH)] } {
108 set PRODUCTS_PATH "$::env(PRODUCTS_PATH)"
110 if { [info exists ::env(CSF_OPT_INC)] } {
111 set CSF_OPT_INC [split "$::env(CSF_OPT_INC)" $::SYS_PATH_SPLITTER]
113 if { [info exists ::env(CSF_OPT_LIB32)] } {
114 set CSF_OPT_LIB32 [split "$::env(CSF_OPT_LIB32)" $::SYS_PATH_SPLITTER]
116 if { [info exists ::env(CSF_OPT_LIB64)] } {
117 set CSF_OPT_LIB64 [split "$::env(CSF_OPT_LIB64)" $::SYS_PATH_SPLITTER]
119 if { [info exists ::env(CSF_OPT_BIN32)] } {
120 set CSF_OPT_BIN32 [split "$::env(CSF_OPT_BIN32)" $::SYS_PATH_SPLITTER]
122 if { [info exists ::env(CSF_OPT_BIN64)] } {
123 set CSF_OPT_BIN64 [split "$::env(CSF_OPT_BIN64)" $::SYS_PATH_SPLITTER]
126 # Search header file in $::CSF_OPT_INC and standard paths
127 proc wokdep:SearchHeader {theHeader} {
128 # search in custom paths
129 foreach anIncPath $::CSF_OPT_INC {
130 set aPath "${anIncPath}/${theHeader}"
131 if { [file exists "$aPath"] } {
137 set aPath "/usr/include/${theHeader}"
138 if { [file exists "$aPath"] } {
144 # Search library file in $::CSF_OPT_LIB* and standard paths
145 proc wokdep:SearchLib {theLib theBitness {theSearchPath ""}} {
146 if { "$theSearchPath" != "" } {
147 set aPath "${theSearchPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
148 if { [file exists "$aPath"] } {
155 # search in custom paths
156 foreach aLibPath [set ::CSF_OPT_LIB$theBitness] {
157 set aPath "${aLibPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
158 if { [file exists "$aPath"] } {
164 if { "$::ARCH" == "$theBitness"} {
165 set aPath "/usr/lib/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
166 if { [file exists "$aPath"] } {
172 if { "$::tcl_platform(os)" == "Linux" } {
173 if { "$theBitness" == "64" } {
174 set aPath "/usr/lib/x86_64-linux-gnu/lib${theLib}.so"
175 if { [file exists "$aPath"] } {
179 set aPath "/usr/lib/i386-linux-gnu/lib${theLib}.so"
180 if { [file exists "$aPath"] } {
189 # Search file in $::CSF_OPT_BIN* and standard paths
190 proc wokdep:SearchBin {theBin theBitness {theSearchPath ""}} {
191 if { "$theSearchPath" != "" } {
192 set aPath "${theSearchPath}/${theBin}"
193 if { [file exists "$aPath"] } {
200 # search in custom paths
201 foreach aBinPath [set ::CSF_OPT_BIN$theBitness] {
202 set aPath "${aBinPath}/${theBin}"
203 if { [file exists "$aPath"] } {
209 if { "$::ARCH" == "$theBitness"} {
210 set aPath "/usr/bin/${theBin}"
211 if { [file exists "$aPath"] } {
219 # Detect compiler C-runtime version 'vc*' and architecture '32'/'64'
220 # to determine preferred path.
221 proc wokdep:Preferred {theList theCmpl theArch} {
222 if { [llength $theList] == 0 } {
227 foreach aPath $theList {
228 if { [string first "$theCmpl" "$aPath"] != "-1" } {
229 lappend aShortList "$aPath"
233 if { [llength $aShortList] == 0 } {
234 #return [lindex $theList 0]
235 set aShortList $theList
238 set aVeryShortList {}
239 foreach aPath $aShortList {
240 if { [string first "$theArch" "$aPath"] != "-1" } {
241 lappend aVeryShortList "$aPath"
244 if { [llength $aVeryShortList] == 0 } {
245 return [lindex [lsort -decreasing $aShortList] 0]
248 return [lindex [lsort -decreasing $aVeryShortList] 0]
251 # Search Tcl/Tk libraries placement
252 proc wokdep:SearchTclTk {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
253 upvar $theErrInc anErrInc
254 upvar $theErrLib32 anErrLib32
255 upvar $theErrLib64 anErrLib64
256 upvar $theErrBin32 anErrBin32
257 upvar $theErrBin64 anErrBin64
263 set aTclHPath [wokdep:SearchHeader "tcl.h"]
264 set aTkHPath [wokdep:SearchHeader "tk.h"]
265 if { "$aTclHPath" == "" || "$aTkHPath" == "" } {
266 if { [file exists "/usr/include/tcl8.6/tcl.h"]
267 && [file exists "/usr/include/tcl8.6/tk.h" ] } {
268 lappend ::CSF_OPT_INC "/usr/include/tcl8.6"
269 set aTclHPath "/usr/include/tcl8.6/tcl.h"
271 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$::ARCH" ]
272 if { "$aPath" != "" && [file exists "$aPath/include/tcl.h"] && [file exists "$aPath/include/tk.h"] } {
273 lappend ::CSF_OPT_INC "$aPath/include"
274 set aTclHPath "$aPath/include/tcl.h"
276 lappend anErrInc "Error: 'tcl.h' or 'tk.h' not found (Tcl/Tk)"
282 # detect tcl version by parsing header file
284 set fh [open $aTclHPath]
287 regexp {define\s+TCL_MAJOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_maj
288 regexp {define\s+TCL_MINOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_min
291 if { "$::tcl_platform(platform)" == "windows" } {
292 set aTclLibName "tcl${tclver_maj}${tclver_min}"
293 set aTkLibName "tk${tclver_maj}${tclver_min}"
295 set aTclLibName "tcl${tclver_maj}.${tclver_min}"
296 set aTkLibName "tk${tclver_maj}.${tclver_min}"
299 foreach anArchIter {64 32} {
300 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter"]
301 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter"]
302 if { "$aTclLibPath" == "" || "$aTkLibPath" == "" } {
303 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
304 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter" "$aPath/lib"]
305 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter" "$aPath/lib"]
306 if { "$aTclLibPath" != "" && "$aTkLibPath" != "" } {
307 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
309 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aTclLibName}.${::SYS_LIB_SUFFIX}' or '${::SYS_LIB_PREFIX}${aTkLibName}.${::SYS_LIB_SUFFIX}' not found (Tcl/Tk)"
310 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
314 if { "$::tcl_platform(platform)" == "windows" } {
315 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter"]
316 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter"]
317 if { "$aTclDllPath" == "" || "$aTkDllPath" == "" } {
318 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
319 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter" "$aPath/bin"]
320 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter" "$aPath/bin"]
321 if { "$aTclDllPath" != "" && "$aTkDllPath" != "" } {
322 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
324 lappend anErrBin$anArchIter "Error: '${aTclLibName}.dll' or '${aTkLibName}.dll' not found (Tcl/Tk)"
325 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
334 # Search FreeType library placement
335 proc wokdep:SearchFreeType {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
336 upvar $theErrInc anErrInc
337 upvar $theErrLib32 anErrLib32
338 upvar $theErrLib64 anErrLib64
339 upvar $theErrBin32 anErrBin32
340 upvar $theErrBin64 anErrBin64
343 set aFtBuildPath [wokdep:SearchHeader "ft2build.h"]
345 if { "$aFtBuildPath" == "" } {
346 # TODO - use `freetype-config --cflags` instead
347 set aSysFreeType "/usr/include/freetype2"
348 if { [file exists "$aSysFreeType/ft2build.h"] } {
349 lappend ::CSF_OPT_INC "$aSysFreeType"
350 } elseif { [file exists "$aSysFreeType/freetype2/ft2build.h"] } {
351 lappend ::CSF_OPT_INC "$aSysFreeType/freetype2"
353 set aSysFreeType "/usr/X11/include/freetype2"
354 if { [file exists "$aSysFreeType/ft2build.h"] } {
355 lappend ::CSF_OPT_INC "/usr/X11/include"
356 lappend ::CSF_OPT_INC "$aSysFreeType"
358 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$::ARCH" ]
359 if {"$aPath" != ""} {
360 if {[file exists "$aPath/include/ft2build.h"]} {
361 lappend ::CSF_OPT_INC "$aPath/include"
362 } elseif {[file exists "$aPath/include/freetype2/ft2build.h"]} {
363 lappend ::CSF_OPT_INC "$aPath/include/freetype2"
366 lappend anErrInc "Error: 'freetype.h' not found (FreeType2)"
373 # parse 'freetype-config --libs'
375 if { [catch { set aConfLibs [exec freetype-config --libs] } ] == 0 } {
376 foreach aPath [split $aConfLibs " "] {
377 if { [string first "-L" "$aPath"] == 0 } {
378 set aConfLibPath [string range "$aPath" 2 [string length "$aPath"]]
383 foreach anArchIter {64 32} {
384 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter"]
385 if { "$aFtLibPath" == "" } {
386 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
387 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aPath/lib"]
388 if { "$aFtLibPath" != "" } {
389 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
391 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aConfLibPath"]
392 if { "$aFtLibPath" != "" } {
393 lappend ::CSF_OPT_LIB$anArchIter "$aConfLibPath"
395 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freetype.${::SYS_LIB_SUFFIX}' not found (FreeType2)"
396 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
400 if { "$::tcl_platform(platform)" == "windows" } {
401 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter"]
402 if { "$aFtDllPath" == "" } {
403 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
404 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/bin"]
405 if { "$aFtDllPath" != "" } {
406 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
408 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/lib"]
409 if { "$aFtDllPath" != "" } {
410 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
412 lappend anErrBin$anArchIter "Error: 'freetype.dll' not found (FreeType2)"
413 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
423 # Search FreeImage library placement
424 proc wokdep:SearchFreeImage {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
425 upvar $theErrInc anErrInc
426 upvar $theErrLib32 anErrLib32
427 upvar $theErrLib64 anErrLib64
428 upvar $theErrBin32 anErrBin32
429 upvar $theErrBin64 anErrBin64
431 # binary distribution has another layout
432 set aFImageDist "Dist"
433 set aFImagePlusDist "Wrapper/FreeImagePlus/dist"
436 set aFImageHPath [wokdep:SearchHeader "FreeImage.h"]
437 if { "$aFImageHPath" == "" } {
438 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$::ARCH" ]
439 if { "$aPath" != "" && [file exists "$aPath/include/FreeImage.h"] } {
440 lappend ::CSF_OPT_INC "$aPath/include"
441 } elseif { "$aPath" != "" && [file exists "$aPath/$aFImageDist/FreeImage.h"] } {
442 lappend ::CSF_OPT_INC "$aPath/$aFImageDist"
443 if { [file exists "$aPath/$aFImagePlusDist/FreeImagePlus.h"] } {
444 lappend ::CSF_OPT_INC "$aPath/$aFImagePlusDist"
447 lappend anErrInc "Error: 'FreeImage.h' not found (FreeImage)"
452 set aFImagePlusHPath [wokdep:SearchHeader "FreeImagePlus.h"]
453 if { "$::tcl_platform(platform)" == "windows" && "$aFImagePlusHPath" == "" } {
454 lappend anErrInc "Error: 'FreeImagePlus.h' not found (FreeImage)"
458 foreach anArchIter {64 32} {
459 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter"]
460 if { "$aFImageLibPath" == "" } {
461 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
462 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/lib"]
463 if { "$aFImageLibPath" != "" } {
464 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
466 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/$aFImageDist"]
467 if { "$aFImageLibPath" != "" } {
468 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImageDist"
469 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter" "$aPath/$aFImagePlusDist"]
470 if { "$aFImagePlusLibPath" != "" } {
471 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImagePlusDist"
474 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimage.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
475 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
479 if { "$::tcl_platform(platform)" == "windows" } {
480 set aFImagePlusLibPath [wokdep:SearchLib "freeimageplus" "$anArchIter"]
481 if { "$aFImagePlusLibPath" == "" } {
482 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimageplus.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
483 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
486 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter"]
487 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter"]
488 if { "$aFImageDllPath" == "" || "$aFImagePlusDllPath" == "" } {
489 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
490 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/bin"]
491 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter" "$aPath/bin"]
492 if { "$aFImageDllPath" != "" && "$aFImagePlusDllPath" != "" } {
493 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
495 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/$aFImageDist"]
496 set aFImagePlusDllPath [wokdep:SearchBin "freeimageplus.dll" "$anArchIter" "$aPath/$aFImagePlusDist"]
497 if { "$aFImageDllPath" != "" && "$aFImagePlusDllPath" != "" } {
498 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImageDist"
499 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImagePlusDist"
501 lappend anErrBin$anArchIter "Error: 'freeimage.dll' or 'freeimageplus.dll' not found (FreeImage)"
502 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
512 # Search GL2PS library placement
513 proc wokdep:SearchGL2PS {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
514 upvar $theErrInc anErrInc
515 upvar $theErrLib32 anErrLib32
516 upvar $theErrLib64 anErrLib64
517 upvar $theErrBin32 anErrBin32
518 upvar $theErrBin64 anErrBin64
521 set aGl2psHPath [wokdep:SearchHeader "gl2ps.h"]
522 if { "$aGl2psHPath" == "" } {
523 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$::ARCH" ]
524 if { "$aPath" != "" && [file exists "$aPath/include/gl2ps.h"] } {
525 lappend ::CSF_OPT_INC "$aPath/include"
527 lappend anErrInc "Error: 'gl2ps.h' not found (GL2PS)"
532 foreach anArchIter {64 32} {
533 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter"]
534 if { "$aGl2psLibPath" == "" } {
535 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
536 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter" "$aPath/lib"]
537 if { "$aGl2psLibPath" != "" } {
538 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
540 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}gl2ps.${::SYS_LIB_SUFFIX}' not found (GL2PS)"
541 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
544 if { "$::tcl_platform(platform)" == "windows" } {
545 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter"]
546 if { "$aGl2psDllPath" == "" } {
547 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
548 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/bin"]
549 if { "$aGl2psDllPath" != "" } {
550 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
552 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/lib"]
553 if { "$aGl2psDllPath" != "" } {
554 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
556 lappend anErrBin$anArchIter "Error: 'gl2ps.dll' not found (GL2PS)"
557 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
567 # Search TBB library placement
568 proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
569 upvar $theErrInc anErrInc
570 upvar $theErrLib32 anErrLib32
571 upvar $theErrLib64 anErrLib64
572 upvar $theErrBin32 anErrBin32
573 upvar $theErrBin64 anErrBin64
576 set aTbbHPath [wokdep:SearchHeader "tbb/scalable_allocator.h"]
577 if { "$aTbbHPath" == "" } {
578 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$::ARCH" ]
579 if { "$aPath" != "" && [file exists "$aPath/include/tbb/scalable_allocator.h"] } {
580 lappend ::CSF_OPT_INC "$aPath/include"
582 lappend anErrInc "Error: 'tbb/scalable_allocator.h' not found (Intel TBB)"
587 foreach anArchIter {64 32} {
589 if { "$anArchIter" == "64"} {
590 set aSubDir "intel64"
593 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter"]
594 if { "$aTbbLibPath" == "" } {
595 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
596 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir/${::VCVER}"]
597 if { "$aTbbLibPath" == "" } {
598 # Set the path to the TBB library for Linux
599 if { "$::tcl_platform(platform)" != "windows" } {
600 set aSubDir "$aSubDir/cc4.1.0_libc2.4_kernel2.6.16.21"
602 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir"]
603 if { "$aTbbLibPath" != "" } {
604 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir"
607 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/${::VCVER}"
609 if { "$aTbbLibPath" == "" } {
610 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
611 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
614 if { "$::tcl_platform(platform)" == "windows" } {
615 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"]
616 if { "$aTbbDllPath" == "" } {
617 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
618 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/${::VCVER}"]
619 if { "$aTbbDllPath" != "" } {
620 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/${::VCVER}"
622 lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)"
623 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
632 # Search OpenCL library placement
633 proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
634 upvar $theErrInc anErrInc
635 upvar $theErrLib32 anErrLib32
636 upvar $theErrLib64 anErrLib64
637 upvar $theErrBin32 anErrBin32
638 upvar $theErrBin64 anErrBin64
641 if { "$::tcl_platform(os)" == "Darwin" } {
642 # OpenCL framework available since Mac OS X 16
646 set aCLHPath [wokdep:SearchHeader "CL/cl_gl.h"]
647 if { "$aCLHPath" == "" } {
648 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$::ARCH" ]
649 if { "$aPath" != "" && [file exists "$aPath/include/CL/cl_gl.h"] } {
650 lappend ::CSF_OPT_INC "$aPath/include"
652 lappend anErrInc "Error: 'CL/cl_gl.h' not found (OpenCL)"
657 foreach anArchIter {64 32} {
658 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter"]
659 if { "$aCLLibPath" == "" } {
660 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$anArchIter" ]
661 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter" "$aPath/lib"]
662 if { "$aCLLibPath" != "" } {
663 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
665 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}OpenCL.${::SYS_LIB_SUFFIX}' not found (OpenCL)"
666 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
674 # Auxiliary function, gets VTK version to set default search directory
675 proc wokdep:VtkVersion { thePath } {
678 set aVtkRoot [lindex [regexp -all -inline {[0-9.]*} [file tail $thePath]] 0]
679 if { "$aVtkRoot" != "" } {
680 set aVtkRoot [regexp -inline {[0-9]*.[0-9]*} $aVtkRoot]
681 if { "$aVtkRoot" != "" } {
682 set aResult $aVtkRoot
689 # Search VTK library placement
690 proc wokdep:SearchVTK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
691 upvar $theErrInc anErrInc
692 upvar $theErrLib32 anErrLib32
693 upvar $theErrLib64 anErrLib64
694 upvar $theErrBin32 anErrBin32
695 upvar $theErrBin64 anErrBin64
700 set aVtkIncPath [wokdep:SearchHeader "vtkConfigure.h"]
701 set aVtkVer [wokdep:VtkVersion $aVtkIncPath]
702 if { "$aVtkIncPath" == ""} {
703 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
704 set aVtkPath [wokdep:Preferred "$aPathList" "$::VCVER" "$::ARCH" ]
705 if { "$aVtkPath" != "" && [file exists "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]/vtkConfigure.h"]} {
706 set aVtkVer [wokdep:VtkVersion $aVtkPath]
707 lappend ::CSF_OPT_INC "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]"
708 } else { # try to search in all found paths
710 foreach anIt $aPathList {
711 if { [file exists "$anIt/include/vtk-[wokdep:VtkVersion $anIt]/vtkConfigure.h"] } {
713 set aVtkVer [wokdep:VtkVersion $aVtkPath]
714 lappend ::CSF_OPT_INC "$anIt/include/vtk-[wokdep:VtkVersion $anIt]"
720 # Bad case: we do not found vtkConfigure.h in all paths.
721 if { "$isFound" == "false"} {
722 lappend anErrInc "Error: 'vtkConfigure.h' not found (VTK)"
729 foreach anArchIter {64 32} {
730 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter"]
731 if { "$aVtkLibPath" == "" } {
732 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
733 set aPath [wokdep:Preferred $aPathList "$::VCVER" "$anArchIter" ]
734 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aPath/lib"]
735 if { "$aVtkLibPath" != "" } {
736 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
738 set aPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aVtkPath/lib"]
739 if { "$aPath" != "" } {
740 set aLibPath $aVtkIncPath
741 lappend ::CSF_OPT_LIB$anArchIter "$aLibPath/lib"
743 # The last chance: search /lib directory in all found paths
744 foreach anIt $aPathList {
745 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$anIt/lib"]
746 if { "$aVtkLibPath" != ""} {
747 lappend ::CSF_OPT_LIB$anArchIter "$anIt/lib"
751 if { "$aVtkLibPath" == "" } {
752 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}vtkCommonCore-${aVtkVer}\.${::SYS_LIB_SUFFIX}' not found (VTK)"
753 if { "$::ARCH" == "$anArchIter" } {
763 if { "$::tcl_platform(platform)" == "windows" } {
764 foreach anArchIter {64 32} {
765 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter"]
766 if { "$aVtkBinPath" == "" } {
767 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*] "$::VCVER" "$anArchIter" ]
768 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/bin"]
769 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
771 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/lib"]
772 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib" }
777 # We didn't find preferred binary path => search through inc path or among all available VTK directories
778 if { "$aVtkBinPath" == "" } {
779 # Try to find in lib path
780 set aPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/bin"]
781 if { "$aPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/bin"
782 } elseif { [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/lib"] != "" } {
783 lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/lib"
785 lappend anErrBin$anArchIter "Error: 'vtkCommonCore-${aVtkVer}.dll' not found (VTK)"
794 # Search Qt4 libraries placement
795 proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
796 upvar $theErrInc anErrInc
797 upvar $theErrLib32 anErrLib32
798 upvar $theErrLib64 anErrLib64
799 upvar $theErrBin32 anErrBin32
800 upvar $theErrBin64 anErrBin64
803 set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qmessagebox.h"]
804 if { "$aQMsgBoxHPath" == "" } {
805 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$::ARCH" ]
806 if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qmessagebox.h"] } {
807 lappend ::CSF_OPT_INC "$aPath/include"
808 lappend ::CSF_OPT_INC "$aPath/include/Qt"
809 lappend ::CSF_OPT_INC "$aPath/include/QtGui"
810 lappend ::CSF_OPT_INC "$aPath/include/QtCore"
812 if { [file exists "/usr/include/qt4/QtGui/qmessagebox.h"] } {
813 lappend ::CSF_OPT_INC "/usr/include/qt4"
814 lappend ::CSF_OPT_INC "/usr/include/qt4/Qt"
815 lappend ::CSF_OPT_INC "/usr/include/qt4/QtGui"
816 lappend ::CSF_OPT_INC "/usr/include/qt4/QtCore"
818 lappend anErrInc "Error: 'QtGui/qmessagebox.h' not found (Qt4)"
824 set aQtGuiLibName "QtGui"
825 if { "$::tcl_platform(platform)" == "windows" } {
826 set aQtGuiLibName "QtGui4"
829 foreach anArchIter {64 32} {
830 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter"]
831 if { "$aQMsgBoxLibPath" == "" } {
832 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
833 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter" "$aPath/lib"]
834 if { "$aQMsgBoxLibPath" != "" } {
835 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
837 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt4)"
838 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
841 if { "$::tcl_platform(platform)" == "windows" } {
842 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter"]
843 if { "$aQMsgBoxDllPath" == "" } {
844 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
845 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter" "$aPath/bin"]
846 if { "$aQMsgBoxDllPath" != "" } {
847 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
849 lappend anErrBin$anArchIter "Error: 'QtGui4.dll' not found (Qt4)"
850 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
859 # Search JDK placement
860 proc wokdep:SearchJDK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
861 upvar $theErrInc anErrInc
862 upvar $theErrLib32 anErrLib32
863 upvar $theErrLib64 anErrLib64
864 upvar $theErrBin32 anErrBin32
865 upvar $theErrBin64 anErrBin64
868 set aJniHPath [wokdep:SearchHeader "jni.h"]
869 set aJniMdHPath [wokdep:SearchHeader "jni_md.h"]
870 if { "$aJniHPath" == "" || "$aJniMdHPath" == "" } {
871 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$::ARCH" ]
872 if { "$aPath" != "" && [file exists "$aPath/include/jni.h"] } {
873 lappend ::CSF_OPT_INC "$aPath/include"
874 if { "$::tcl_platform(platform)" == "windows" } {
875 lappend ::CSF_OPT_INC "$aPath/include/win32"
876 } elseif { [file exists "$aPath/include/linux"] } {
877 lappend ::CSF_OPT_INC "$aPath/include/linux"
880 if { [file exists "/System/Library/Frameworks/JavaVM.framework/Home/include/jni.h"] } {
881 lappend ::CSF_OPT_INC "/System/Library/Frameworks/JavaVM.framework/Home/include"
883 lappend anErrInc "Error: 'jni.h' or 'jni_md.h' not found (JDK)"
889 foreach anArchIter {64 32} {
890 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter"]
891 if { "$aJavacPath" == "" } {
892 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$anArchIter" ]
893 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter" "$aPath/bin"]
894 if { "$aJavacPath" != "" } {
895 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
897 if { "$::ARCH" == "$anArchIter" && [file exists "/System/Library/Frameworks/JavaVM.framework/Home/bin/javac${::SYS_EXE_SUFFIX}"] } {
898 lappend ::CSF_OPT_BIN$anArchIter "/System/Library/Frameworks/JavaVM.framework/Home/bin"
900 lappend anErrBin$anArchIter "Error: 'javac${::SYS_EXE_SUFFIX}' not found (JDK)"
901 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
910 # Search X11 libraries placement
911 proc wokdep:SearchX11 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
912 upvar $theErrInc anErrInc
913 upvar $theErrLib32 anErrLib32
914 upvar $theErrLib64 anErrLib64
915 upvar $theErrBin32 anErrBin32
916 upvar $theErrBin64 anErrBin64
919 if { "$::tcl_platform(platform)" == "windows" || ( "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" ) } {
923 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH"]
924 if { "$aXmuLibPath" == "" } {
925 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH" "/usr/X11/lib"]
926 if { "$aXmuLibPath" != "" } {
927 #lappend ::CSF_OPT_LIB$::ARCH "/usr/X11/lib"
929 lappend anErrLib$::ARCH "Error: '${::SYS_LIB_PREFIX}Xmu.${::SYS_LIB_SUFFIX}' not found (X11)"
937 # Generate (override) custom environment file
938 proc wokdep:SaveCustom {} {
939 if { "$::tcl_platform(platform)" == "windows" } {
940 set aCustomFilePath "./custom.bat"
941 set aFile [open $aCustomFilePath "w"]
942 puts $aFile "@echo off"
943 puts $aFile "rem This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
946 puts $aFile "set VCVER=$::VCVER"
947 puts $aFile "set ARCH=$::ARCH"
948 puts $aFile "set VCVARS=$::VCVARS"
949 puts $aFile "set SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
952 puts $aFile "set \"PRODUCTS_PATH=$::PRODUCTS_PATH\""
955 puts $aFile "rem Optional 3rd-parties switches"
956 puts $aFile "set HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
957 puts $aFile "set HAVE_GL2PS=$::HAVE_GL2PS"
958 puts $aFile "set HAVE_TBB=$::HAVE_TBB"
959 puts $aFile "set HAVE_D3D=$::HAVE_D3D"
960 puts $aFile "set HAVE_OPENCL=$::HAVE_OPENCL"
961 puts $aFile "set HAVE_VTK=$::HAVE_VTK"
962 puts $aFile "set CHECK_QT4=$::CHECK_QT4"
963 puts $aFile "set CHECK_JDK=$::CHECK_JDK"
965 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
967 puts $aFile "rem Additional headers search paths"
968 puts $aFile "set \"CSF_OPT_INC=$aStringInc\""
970 set aStringLib32 [join $::CSF_OPT_LIB32 $::SYS_PATH_SPLITTER]
972 puts $aFile "rem Additional libraries (32-bit) search paths"
973 puts $aFile "set \"CSF_OPT_LIB32=$aStringLib32\""
975 set aStringLib64 [join $::CSF_OPT_LIB64 $::SYS_PATH_SPLITTER]
977 puts $aFile "rem Additional libraries (64-bit) search paths"
978 puts $aFile "set \"CSF_OPT_LIB64=$aStringLib64\""
980 set aStringBin32 [join $::CSF_OPT_BIN32 $::SYS_PATH_SPLITTER]
982 puts $aFile "rem Additional (32-bit) search paths"
983 puts $aFile "set \"CSF_OPT_BIN32=$aStringBin32\""
985 set aStringBin64 [join $::CSF_OPT_BIN64 $::SYS_PATH_SPLITTER]
987 puts $aFile "rem Additional (64-bit) search paths"
988 puts $aFile "set \"CSF_OPT_BIN64=$aStringBin64\""
992 set aCustomFilePath "./custom.sh"
993 set aFile [open $aCustomFilePath "w"]
994 puts $aFile "#!/bin/bash"
995 puts $aFile "# This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
998 puts $aFile "export ARCH=$::ARCH"
999 puts $aFile "export SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
1002 puts $aFile "export PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
1005 puts $aFile "# Optional 3rd-parties switches"
1006 puts $aFile "export HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
1007 puts $aFile "export HAVE_GL2PS=$::HAVE_GL2PS"
1008 puts $aFile "export HAVE_TBB=$::HAVE_TBB"
1009 puts $aFile "export HAVE_OPENCL=$::HAVE_OPENCL"
1010 puts $aFile "export HAVE_VTK=$::HAVE_VTK"
1011 if { "$::tcl_platform(os)" == "Darwin" } {
1012 puts $aFile "export MACOSX_USE_GLX=$::MACOSX_USE_GLX"
1014 puts $aFile "export CHECK_QT4=$::CHECK_QT4"
1015 puts $aFile "export CHECK_JDK=$::CHECK_JDK"
1017 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
1019 puts $aFile "# Additional headers search paths"
1020 puts $aFile "export CSF_OPT_INC=\"$aStringInc\""
1022 set aStringLib$::ARCH [join [set ::CSF_OPT_LIB$::ARCH] $::SYS_PATH_SPLITTER]
1024 puts $aFile "# Additional libraries ($::ARCH-bit) search paths"
1025 puts $aFile "export CSF_OPT_LIB$::ARCH=\"[set aStringLib$::ARCH]\""
1027 set aStringBin$::ARCH [join [set ::CSF_OPT_BIN$::ARCH] $::SYS_PATH_SPLITTER]
1029 puts $aFile "# Additional ($::ARCH-bit) search paths"
1030 puts $aFile "export CSF_OPT_BIN$::ARCH=\"[set aStringBin$::ARCH]\""
1035 puts "Configuration saved to file '$aCustomFilePath'"