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"
435 set aFImageHPath [wokdep:SearchHeader "FreeImage.h"]
436 if { "$aFImageHPath" == "" } {
437 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$::ARCH" ]
438 if { "$aPath" != "" && [file exists "$aPath/include/FreeImage.h"] } {
439 lappend ::CSF_OPT_INC "$aPath/include"
440 } elseif { "$aPath" != "" && [file exists "$aPath/$aFImageDist/FreeImage.h"] } {
441 lappend ::CSF_OPT_INC "$aPath/$aFImageDist"
443 lappend anErrInc "Error: 'FreeImage.h' not found (FreeImage)"
448 foreach anArchIter {64 32} {
449 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter"]
450 if { "$aFImageLibPath" == "" } {
451 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
452 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/lib"]
453 if { "$aFImageLibPath" != "" } {
454 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
456 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/$aFImageDist"]
457 if { "$aFImageLibPath" != "" } {
458 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImageDist"
460 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimage.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
461 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
465 if { "$::tcl_platform(platform)" == "windows" } {
466 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter"]
467 if { "$aFImageDllPath" == "" } {
468 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
469 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/bin"]
470 if { "$aFImageDllPath" != "" } {
471 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
473 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/$aFImageDist"]
474 if { "$aFImageDllPath" != "" } {
475 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImageDist"
477 lappend anErrBin$anArchIter "Error: 'freeimage.dll' is not found (FreeImage)"
478 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
488 # Search GL2PS library placement
489 proc wokdep:SearchGL2PS {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
490 upvar $theErrInc anErrInc
491 upvar $theErrLib32 anErrLib32
492 upvar $theErrLib64 anErrLib64
493 upvar $theErrBin32 anErrBin32
494 upvar $theErrBin64 anErrBin64
497 set aGl2psHPath [wokdep:SearchHeader "gl2ps.h"]
498 if { "$aGl2psHPath" == "" } {
499 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$::ARCH" ]
500 if { "$aPath" != "" && [file exists "$aPath/include/gl2ps.h"] } {
501 lappend ::CSF_OPT_INC "$aPath/include"
503 lappend anErrInc "Error: 'gl2ps.h' not found (GL2PS)"
508 foreach anArchIter {64 32} {
509 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter"]
510 if { "$aGl2psLibPath" == "" } {
511 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
512 set aGl2psLibPath [wokdep:SearchLib "gl2ps" "$anArchIter" "$aPath/lib"]
513 if { "$aGl2psLibPath" != "" } {
514 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
516 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}gl2ps.${::SYS_LIB_SUFFIX}' not found (GL2PS)"
517 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
520 if { "$::tcl_platform(platform)" == "windows" } {
521 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter"]
522 if { "$aGl2psDllPath" == "" } {
523 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{gl2ps}*] "$::VCVER" "$anArchIter" ]
524 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/bin"]
525 if { "$aGl2psDllPath" != "" } {
526 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
528 set aGl2psDllPath [wokdep:SearchBin "gl2ps.dll" "$anArchIter" "$aPath/lib"]
529 if { "$aGl2psDllPath" != "" } {
530 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
532 lappend anErrBin$anArchIter "Error: 'gl2ps.dll' not found (GL2PS)"
533 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
543 # Search TBB library placement
544 proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
545 upvar $theErrInc anErrInc
546 upvar $theErrLib32 anErrLib32
547 upvar $theErrLib64 anErrLib64
548 upvar $theErrBin32 anErrBin32
549 upvar $theErrBin64 anErrBin64
552 set aTbbHPath [wokdep:SearchHeader "tbb/scalable_allocator.h"]
553 if { "$aTbbHPath" == "" } {
554 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$::ARCH" ]
555 if { "$aPath" != "" && [file exists "$aPath/include/tbb/scalable_allocator.h"] } {
556 lappend ::CSF_OPT_INC "$aPath/include"
558 lappend anErrInc "Error: 'tbb/scalable_allocator.h' not found (Intel TBB)"
563 foreach anArchIter {64 32} {
565 if { "$anArchIter" == "64"} {
566 set aSubDir "intel64"
569 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter"]
570 if { "$aTbbLibPath" == "" } {
571 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
572 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir/${::VCVER}"]
573 if { "$aTbbLibPath" == "" } {
574 # Set the path to the TBB library for Linux
575 if { "$::tcl_platform(platform)" != "windows" } {
576 set aSubDir "$aSubDir/cc4.1.0_libc2.4_kernel2.6.16.21"
578 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir"]
579 if { "$aTbbLibPath" != "" } {
580 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir"
583 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/${::VCVER}"
585 if { "$aTbbLibPath" == "" } {
586 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
587 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
590 if { "$::tcl_platform(platform)" == "windows" } {
591 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"]
592 if { "$aTbbDllPath" == "" } {
593 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$anArchIter" ]
594 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/${::VCVER}"]
595 if { "$aTbbDllPath" != "" } {
596 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/${::VCVER}"
598 lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)"
599 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
608 # Search OpenCL library placement
609 proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
610 upvar $theErrInc anErrInc
611 upvar $theErrLib32 anErrLib32
612 upvar $theErrLib64 anErrLib64
613 upvar $theErrBin32 anErrBin32
614 upvar $theErrBin64 anErrBin64
617 if { "$::tcl_platform(os)" == "Darwin" } {
618 # OpenCL framework available since Mac OS X 16
622 set aCLHPath [wokdep:SearchHeader "CL/cl_gl.h"]
623 if { "$aCLHPath" == "" } {
624 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$::ARCH" ]
625 if { "$aPath" != "" && [file exists "$aPath/include/CL/cl_gl.h"] } {
626 lappend ::CSF_OPT_INC "$aPath/include"
628 lappend anErrInc "Error: 'CL/cl_gl.h' not found (OpenCL)"
633 foreach anArchIter {64 32} {
634 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter"]
635 if { "$aCLLibPath" == "" } {
636 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$anArchIter" ]
637 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter" "$aPath/lib"]
638 if { "$aCLLibPath" != "" } {
639 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
641 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}OpenCL.${::SYS_LIB_SUFFIX}' not found (OpenCL)"
642 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
650 # Auxiliary function, gets VTK version to set default search directory
651 proc wokdep:VtkVersion { thePath } {
654 set aVtkRoot [lindex [regexp -all -inline {[0-9.]*} [file tail $thePath]] 0]
655 if { "$aVtkRoot" != "" } {
656 set aVtkRoot [regexp -inline {[0-9]*.[0-9]*} $aVtkRoot]
657 if { "$aVtkRoot" != "" } {
658 set aResult $aVtkRoot
665 # Search VTK library placement
666 proc wokdep:SearchVTK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
667 upvar $theErrInc anErrInc
668 upvar $theErrLib32 anErrLib32
669 upvar $theErrLib64 anErrLib64
670 upvar $theErrBin32 anErrBin32
671 upvar $theErrBin64 anErrBin64
676 set aVtkIncPath [wokdep:SearchHeader "vtkConfigure.h"]
677 set aVtkVer [wokdep:VtkVersion $aVtkIncPath]
678 if { "$aVtkIncPath" == ""} {
679 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
680 set aVtkPath [wokdep:Preferred "$aPathList" "$::VCVER" "$::ARCH" ]
681 if { "$aVtkPath" != "" && [file exists "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]/vtkConfigure.h"]} {
682 set aVtkVer [wokdep:VtkVersion $aVtkPath]
683 lappend ::CSF_OPT_INC "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]"
684 } else { # try to search in all found paths
686 foreach anIt $aPathList {
687 if { [file exists "$anIt/include/vtk-[wokdep:VtkVersion $anIt]/vtkConfigure.h"] } {
689 set aVtkVer [wokdep:VtkVersion $aVtkPath]
690 lappend ::CSF_OPT_INC "$anIt/include/vtk-[wokdep:VtkVersion $anIt]"
696 # Bad case: we do not found vtkConfigure.h in all paths.
697 if { "$isFound" == "false"} {
698 lappend anErrInc "Error: 'vtkConfigure.h' not found (VTK)"
705 foreach anArchIter {64 32} {
706 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter"]
707 if { "$aVtkLibPath" == "" } {
708 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
709 set aPath [wokdep:Preferred $aPathList "$::VCVER" "$anArchIter" ]
710 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aPath/lib"]
711 if { "$aVtkLibPath" != "" } {
712 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
714 set aPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aVtkPath/lib"]
715 if { "$aPath" != "" } {
716 set aLibPath $aVtkIncPath
717 lappend ::CSF_OPT_LIB$anArchIter "$aLibPath/lib"
719 # The last chance: search /lib directory in all found paths
720 foreach anIt $aPathList {
721 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$anIt/lib"]
722 if { "$aVtkLibPath" != ""} {
723 lappend ::CSF_OPT_LIB$anArchIter "$anIt/lib"
727 if { "$aVtkLibPath" == "" } {
728 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}vtkCommonCore-${aVtkVer}\.${::SYS_LIB_SUFFIX}' not found (VTK)"
729 if { "$::ARCH" == "$anArchIter" } {
739 if { "$::tcl_platform(platform)" == "windows" } {
740 foreach anArchIter {64 32} {
741 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter"]
742 if { "$aVtkBinPath" == "" } {
743 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*] "$::VCVER" "$anArchIter" ]
744 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/bin"]
745 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
747 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/lib"]
748 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib" }
753 # We didn't find preferred binary path => search through inc path or among all available VTK directories
754 if { "$aVtkBinPath" == "" } {
755 # Try to find in lib path
756 set aPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/bin"]
757 if { "$aPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/bin"
758 } elseif { [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/lib"] != "" } {
759 lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/lib"
761 lappend anErrBin$anArchIter "Error: 'vtkCommonCore-${aVtkVer}.dll' not found (VTK)"
770 # Search Qt4 libraries placement
771 proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
772 upvar $theErrInc anErrInc
773 upvar $theErrLib32 anErrLib32
774 upvar $theErrLib64 anErrLib64
775 upvar $theErrBin32 anErrBin32
776 upvar $theErrBin64 anErrBin64
779 set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qmessagebox.h"]
780 if { "$aQMsgBoxHPath" == "" } {
781 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$::ARCH" ]
782 if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qmessagebox.h"] } {
783 lappend ::CSF_OPT_INC "$aPath/include"
784 lappend ::CSF_OPT_INC "$aPath/include/Qt"
785 lappend ::CSF_OPT_INC "$aPath/include/QtGui"
786 lappend ::CSF_OPT_INC "$aPath/include/QtCore"
788 if { [file exists "/usr/include/qt4/QtGui/qmessagebox.h"] } {
789 lappend ::CSF_OPT_INC "/usr/include/qt4"
790 lappend ::CSF_OPT_INC "/usr/include/qt4/Qt"
791 lappend ::CSF_OPT_INC "/usr/include/qt4/QtGui"
792 lappend ::CSF_OPT_INC "/usr/include/qt4/QtCore"
794 lappend anErrInc "Error: 'QtGui/qmessagebox.h' not found (Qt4)"
800 set aQtGuiLibName "QtGui"
801 if { "$::tcl_platform(platform)" == "windows" } {
802 set aQtGuiLibName "QtGui4"
805 foreach anArchIter {64 32} {
806 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter"]
807 if { "$aQMsgBoxLibPath" == "" } {
808 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
809 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter" "$aPath/lib"]
810 if { "$aQMsgBoxLibPath" != "" } {
811 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
813 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt4)"
814 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
817 if { "$::tcl_platform(platform)" == "windows" } {
818 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter"]
819 if { "$aQMsgBoxDllPath" == "" } {
820 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
821 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter" "$aPath/bin"]
822 if { "$aQMsgBoxDllPath" != "" } {
823 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
825 lappend anErrBin$anArchIter "Error: 'QtGui4.dll' not found (Qt4)"
826 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
835 # Search JDK placement
836 proc wokdep:SearchJDK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
837 upvar $theErrInc anErrInc
838 upvar $theErrLib32 anErrLib32
839 upvar $theErrLib64 anErrLib64
840 upvar $theErrBin32 anErrBin32
841 upvar $theErrBin64 anErrBin64
844 set aJniHPath [wokdep:SearchHeader "jni.h"]
845 set aJniMdHPath [wokdep:SearchHeader "jni_md.h"]
846 if { "$aJniHPath" == "" || "$aJniMdHPath" == "" } {
847 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$::ARCH" ]
848 if { "$aPath" != "" && [file exists "$aPath/include/jni.h"] } {
849 lappend ::CSF_OPT_INC "$aPath/include"
850 if { "$::tcl_platform(platform)" == "windows" } {
851 lappend ::CSF_OPT_INC "$aPath/include/win32"
852 } elseif { [file exists "$aPath/include/linux"] } {
853 lappend ::CSF_OPT_INC "$aPath/include/linux"
856 if { [file exists "/System/Library/Frameworks/JavaVM.framework/Home/include/jni.h"] } {
857 lappend ::CSF_OPT_INC "/System/Library/Frameworks/JavaVM.framework/Home/include"
859 lappend anErrInc "Error: 'jni.h' or 'jni_md.h' not found (JDK)"
865 foreach anArchIter {64 32} {
866 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter"]
867 if { "$aJavacPath" == "" } {
868 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$anArchIter" ]
869 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter" "$aPath/bin"]
870 if { "$aJavacPath" != "" } {
871 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
873 if { "$::ARCH" == "$anArchIter" && [file exists "/System/Library/Frameworks/JavaVM.framework/Home/bin/javac${::SYS_EXE_SUFFIX}"] } {
874 lappend ::CSF_OPT_BIN$anArchIter "/System/Library/Frameworks/JavaVM.framework/Home/bin"
876 lappend anErrBin$anArchIter "Error: 'javac${::SYS_EXE_SUFFIX}' not found (JDK)"
877 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
886 # Search X11 libraries placement
887 proc wokdep:SearchX11 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
888 upvar $theErrInc anErrInc
889 upvar $theErrLib32 anErrLib32
890 upvar $theErrLib64 anErrLib64
891 upvar $theErrBin32 anErrBin32
892 upvar $theErrBin64 anErrBin64
895 if { "$::tcl_platform(platform)" == "windows" || ( "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" ) } {
899 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH"]
900 if { "$aXmuLibPath" == "" } {
901 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH" "/usr/X11/lib"]
902 if { "$aXmuLibPath" != "" } {
903 #lappend ::CSF_OPT_LIB$::ARCH "/usr/X11/lib"
905 lappend anErrLib$::ARCH "Error: '${::SYS_LIB_PREFIX}Xmu.${::SYS_LIB_SUFFIX}' not found (X11)"
913 # Generate (override) custom environment file
914 proc wokdep:SaveCustom {} {
915 if { "$::tcl_platform(platform)" == "windows" } {
916 set aCustomFilePath "./custom.bat"
917 set aFile [open $aCustomFilePath "w"]
918 puts $aFile "@echo off"
919 puts $aFile "rem This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
922 puts $aFile "set VCVER=$::VCVER"
923 puts $aFile "set ARCH=$::ARCH"
924 puts $aFile "set VCVARS=$::VCVARS"
925 puts $aFile "set SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
928 puts $aFile "set \"PRODUCTS_PATH=$::PRODUCTS_PATH\""
931 puts $aFile "rem Optional 3rd-parties switches"
932 puts $aFile "set HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
933 puts $aFile "set HAVE_GL2PS=$::HAVE_GL2PS"
934 puts $aFile "set HAVE_TBB=$::HAVE_TBB"
935 puts $aFile "set HAVE_D3D=$::HAVE_D3D"
936 puts $aFile "set HAVE_OPENCL=$::HAVE_OPENCL"
937 puts $aFile "set HAVE_VTK=$::HAVE_VTK"
938 puts $aFile "set CHECK_QT4=$::CHECK_QT4"
939 puts $aFile "set CHECK_JDK=$::CHECK_JDK"
941 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
943 puts $aFile "rem Additional headers search paths"
944 puts $aFile "set \"CSF_OPT_INC=$aStringInc\""
946 set aStringLib32 [join $::CSF_OPT_LIB32 $::SYS_PATH_SPLITTER]
948 puts $aFile "rem Additional libraries (32-bit) search paths"
949 puts $aFile "set \"CSF_OPT_LIB32=$aStringLib32\""
951 set aStringLib64 [join $::CSF_OPT_LIB64 $::SYS_PATH_SPLITTER]
953 puts $aFile "rem Additional libraries (64-bit) search paths"
954 puts $aFile "set \"CSF_OPT_LIB64=$aStringLib64\""
956 set aStringBin32 [join $::CSF_OPT_BIN32 $::SYS_PATH_SPLITTER]
958 puts $aFile "rem Additional (32-bit) search paths"
959 puts $aFile "set \"CSF_OPT_BIN32=$aStringBin32\""
961 set aStringBin64 [join $::CSF_OPT_BIN64 $::SYS_PATH_SPLITTER]
963 puts $aFile "rem Additional (64-bit) search paths"
964 puts $aFile "set \"CSF_OPT_BIN64=$aStringBin64\""
968 set aCustomFilePath "./custom.sh"
969 set aFile [open $aCustomFilePath "w"]
970 puts $aFile "#!/bin/bash"
971 puts $aFile "# This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
974 puts $aFile "export ARCH=$::ARCH"
975 puts $aFile "export SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
978 puts $aFile "export PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
981 puts $aFile "# Optional 3rd-parties switches"
982 puts $aFile "export HAVE_FREEIMAGE=$::HAVE_FREEIMAGE"
983 puts $aFile "export HAVE_GL2PS=$::HAVE_GL2PS"
984 puts $aFile "export HAVE_TBB=$::HAVE_TBB"
985 puts $aFile "export HAVE_OPENCL=$::HAVE_OPENCL"
986 puts $aFile "export HAVE_VTK=$::HAVE_VTK"
987 if { "$::tcl_platform(os)" == "Darwin" } {
988 puts $aFile "export MACOSX_USE_GLX=$::MACOSX_USE_GLX"
990 puts $aFile "export CHECK_QT4=$::CHECK_QT4"
991 puts $aFile "export CHECK_JDK=$::CHECK_JDK"
993 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
995 puts $aFile "# Additional headers search paths"
996 puts $aFile "export CSF_OPT_INC=\"$aStringInc\""
998 set aStringLib$::ARCH [join [set ::CSF_OPT_LIB$::ARCH] $::SYS_PATH_SPLITTER]
1000 puts $aFile "# Additional libraries ($::ARCH-bit) search paths"
1001 puts $aFile "export CSF_OPT_LIB$::ARCH=\"[set aStringLib$::ARCH]\""
1003 set aStringBin$::ARCH [join [set ::CSF_OPT_BIN$::ARCH] $::SYS_PATH_SPLITTER]
1005 puts $aFile "# Additional ($::ARCH-bit) search paths"
1006 puts $aFile "export CSF_OPT_BIN$::ARCH=\"[set aStringBin$::ARCH]\""
1011 puts "Configuration saved to file '$aCustomFilePath'"