0031304: Configuration - TKACIS building failure due to duplicated symbol GeomFillFus...
[occt.git] / adm / genconfdeps.tcl
CommitLineData
d1a67b9d 1# =======================================================================
2# Created on: 2012-01-26
3# Created by: Kirill GAVRILOV
4# Copyright (c) 2012 OPEN CASCADE SAS
5#
6# This file is part of Open CASCADE Technology software library.
7#
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.
13#
14# Alternatively, this file may be used under the terms of Open CASCADE
15# commercial license or contractual agreement.
16
17# =======================================================================
18# Tools for search of third-party libraries and generation on environment
19# customization script
20# =======================================================================
910970ab 21
c7d774c5 22set ARCH "64"
910970ab 23
24if { "$tcl_platform(platform)" == "unix" } {
25 set SYS_PATH_SPLITTER ":"
26 set SYS_LIB_PREFIX "lib"
27 set SYS_EXE_SUFFIX ""
28 if { "$tcl_platform(os)" == "Darwin" } {
29 set SYS_LIB_SUFFIX "dylib"
aafe169f 30 set PRJFMT "xcd"
910970ab 31 } else {
32 set SYS_LIB_SUFFIX "so"
aafe169f 33 set PRJFMT "cbp"
910970ab 34 }
35 set VCVER "gcc"
36 set VCVARS ""
37} elseif { "$tcl_platform(platform)" == "windows" } {
38 set SYS_PATH_SPLITTER ";"
39 set SYS_LIB_PREFIX ""
40 set SYS_LIB_SUFFIX "lib"
41 set SYS_EXE_SUFFIX ".exe"
42 set VCVER "vc10"
43 set VCVARS ""
aafe169f 44 set PRJFMT "vcxproj"
910970ab 45}
46
5951a088 47set SHORTCUT_HEADERS "ShortCut"
910970ab 48
910970ab 49set PRODUCTS_PATH ""
50set CSF_OPT_INC [list]
51set CSF_OPT_LIB32 [list]
52set CSF_OPT_LIB64 [list]
53set CSF_OPT_BIN32 [list]
54set CSF_OPT_BIN64 [list]
55
c7d774c5 56if { "$tcl_platform(pointerSize)" == "4" } {
57 set ARCH "32"
58}
910970ab 59if { [info exists ::env(ARCH)] } {
60 set ARCH "$::env(ARCH)"
61}
e22105a9 62
910970ab 63if { [info exists ::env(SHORTCUT_HEADERS)] } {
64 set SHORTCUT_HEADERS "$::env(SHORTCUT_HEADERS)"
5951a088 65 if { $SHORTCUT_HEADERS == "true" } {
66 set SHORTCUT_HEADERS "ShortCut"
67 }
910970ab 68}
e22105a9 69
70# fetch environment variables (e.g. set by custom.sh or custom.bat) and set them as tcl variables with the same name
27bd52b5 71set THE_ENV_VARIABLES {HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_E57 HAVE_RAPIDJSON HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo}
e22105a9 72foreach anEnvIter $THE_ENV_VARIABLES {
73 set ${anEnvIter} "false"
74 if { [info exists ::env(${anEnvIter})] } {
75 set ${anEnvIter} "$::env(${anEnvIter})"
76 }
910970ab 77}
e22105a9 78# do not export platform-specific variables
79if { "$::tcl_platform(os)" == "Darwin" } {
80 set HAVE_GLES2 ""
81} else {
82 set MACOSX_USE_GLX ""
26cfd29c 83}
84if { "$tcl_platform(platform)" != "windows" } {
85 set HAVE_D3D ""
86 set HAVE_RelWithDebInfo ""
910970ab 87}
f4b0c772 88foreach anEnvIter {ARCH VCVER VCVARS PRJFMT } {
e22105a9 89 if { [info exists ::env(${anEnvIter})] } {
90 set ${anEnvIter} "$::env(${anEnvIter})"
91 }
910970ab 92}
f4b0c772 93if { [info exists ::env(PRODUCTS_PATH)] } {
94 set PRODUCTS_PATH [file normalize "$::env(PRODUCTS_PATH)"]
95}
e22105a9 96
910970ab 97if { [info exists ::env(CSF_OPT_INC)] } {
98 set CSF_OPT_INC [split "$::env(CSF_OPT_INC)" $::SYS_PATH_SPLITTER]
99}
100if { [info exists ::env(CSF_OPT_LIB32)] } {
101 set CSF_OPT_LIB32 [split "$::env(CSF_OPT_LIB32)" $::SYS_PATH_SPLITTER]
102}
103if { [info exists ::env(CSF_OPT_LIB64)] } {
104 set CSF_OPT_LIB64 [split "$::env(CSF_OPT_LIB64)" $::SYS_PATH_SPLITTER]
105}
106if { [info exists ::env(CSF_OPT_BIN32)] } {
107 set CSF_OPT_BIN32 [split "$::env(CSF_OPT_BIN32)" $::SYS_PATH_SPLITTER]
108}
109if { [info exists ::env(CSF_OPT_BIN64)] } {
110 set CSF_OPT_BIN64 [split "$::env(CSF_OPT_BIN64)" $::SYS_PATH_SPLITTER]
111}
112
113# Search header file in $::CSF_OPT_INC and standard paths
114proc wokdep:SearchHeader {theHeader} {
115 # search in custom paths
116 foreach anIncPath $::CSF_OPT_INC {
117 set aPath "${anIncPath}/${theHeader}"
118 if { [file exists "$aPath"] } {
119 return "$aPath"
120 }
121 }
122
123 # search in system
124 set aPath "/usr/include/${theHeader}"
125 if { [file exists "$aPath"] } {
126 return "$aPath"
127 }
08f8a185 128
129 if { "$::tcl_platform(os)" == "Linux" } {
130 if { "$::ARCH" == "64" } {
131 set aPath "/usr/include/x86_64-linux-gnu/${theHeader}"
132 if { [file exists "$aPath"] } {
133 return "$aPath"
134 }
135 } else {
136 set aPath "/usr/include/i386-linux-gnu/${theHeader}"
137 if { [file exists "$aPath"] } {
138 return "$aPath"
139 }
140 }
141 }
142
910970ab 143 return ""
144}
145
146# Search library file in $::CSF_OPT_LIB* and standard paths
147proc wokdep:SearchLib {theLib theBitness {theSearchPath ""}} {
148 if { "$theSearchPath" != "" } {
27bd52b5 149 set aPath "${theSearchPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
150 set aPath2 "${theSearchPath}/${::SYS_LIB_PREFIX}${theLib}.a"
910970ab 151 if { [file exists "$aPath"] } {
152 return "$aPath"
27bd52b5 153 } elseif { "$::tcl_platform(platform)" != "windows" && [file exists "$aPath2"] } {
154 return "$aPath2"
910970ab 155 } else {
156 return ""
157 }
158 }
159
160 # search in custom paths
161 foreach aLibPath [set ::CSF_OPT_LIB$theBitness] {
27bd52b5 162 set aPath "${aLibPath}/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
163 set aPath2 "${aLibPath}/${::SYS_LIB_PREFIX}${theLib}.a"
910970ab 164 if { [file exists "$aPath"] } {
165 return "$aPath"
27bd52b5 166 } elseif { "$::tcl_platform(platform)" != "windows" && [file exists "$aPath2"] } {
167 return "$aPath2"
910970ab 168 }
169 }
170
171 # search in system
172 if { "$::ARCH" == "$theBitness"} {
27bd52b5 173 set aPath "/usr/lib/${::SYS_LIB_PREFIX}${theLib}.${::SYS_LIB_SUFFIX}"
174 set aPath2 "/usr/lib/${::SYS_LIB_PREFIX}${theLib}.a"
910970ab 175 if { [file exists "$aPath"] } {
176 return "$aPath"
27bd52b5 177 } elseif { [file exists "$aPath2"] } {
178 return "$aPath2"
910970ab 179 }
180 }
181
c7d774c5 182 if { "$::tcl_platform(os)" == "Linux" } {
910970ab 183 if { "$theBitness" == "64" } {
27bd52b5 184 set aPath "/usr/lib/x86_64-linux-gnu/lib${theLib}.so"
185 set aPath2 "/usr/lib/x86_64-linux-gnu/lib${theLib}.a"
910970ab 186 if { [file exists "$aPath"] } {
187 return "$aPath"
27bd52b5 188 } elseif { [file exists "$aPath2"] } {
189 return "$aPath2"
910970ab 190 }
191 } else {
27bd52b5 192 set aPath "/usr/lib/i386-linux-gnu/lib${theLib}.so"
193 set aPath2 "/usr/lib/i386-linux-gnu/lib${theLib}.a"
910970ab 194 if { [file exists "$aPath"] } {
195 return "$aPath"
27bd52b5 196 } elseif { [file exists "$aPath2"] } {
197 return "$aPath2"
910970ab 198 }
199 }
200 }
201
202 return ""
203}
204
205# Search file in $::CSF_OPT_BIN* and standard paths
206proc wokdep:SearchBin {theBin theBitness {theSearchPath ""}} {
207 if { "$theSearchPath" != "" } {
208 set aPath "${theSearchPath}/${theBin}"
209 if { [file exists "$aPath"] } {
210 return "$aPath"
211 } else {
212 return ""
213 }
214 }
215
216 # search in custom paths
217 foreach aBinPath [set ::CSF_OPT_BIN$theBitness] {
218 set aPath "${aBinPath}/${theBin}"
219 if { [file exists "$aPath"] } {
220 return "$aPath"
221 }
222 }
223
224 # search in system
225 if { "$::ARCH" == "$theBitness"} {
226 set aPath "/usr/bin/${theBin}"
227 if { [file exists "$aPath"] } {
228 return "$aPath"
229 }
230 }
231
232 return ""
233}
234
235# Detect compiler C-runtime version 'vc*' and architecture '32'/'64'
236# to determine preferred path.
237proc wokdep:Preferred {theList theCmpl theArch} {
238 if { [llength $theList] == 0 } {
239 return ""
240 }
241
d6cda17a 242 # keep only two first digits in "vc141"
243 if { ! [regexp {^vc[0-9][0-9]} $theCmpl aCmpl] } {
1bd04b5a 244 if { [regexp {^vclang} $theCmpl] } {
245 set aCmpl vc14
246 } else {
247 set aCmpl $theCmpl
248 }
d6cda17a 249 }
250
910970ab 251 set aShortList {}
252 foreach aPath $theList {
d6cda17a 253 if { [string first "$aCmpl" "$aPath"] != "-1" } {
910970ab 254 lappend aShortList "$aPath"
255 }
256 }
257
258 if { [llength $aShortList] == 0 } {
259 #return [lindex $theList 0]
260 set aShortList $theList
261 }
262
263 set aVeryShortList {}
264 foreach aPath $aShortList {
265 if { [string first "$theArch" "$aPath"] != "-1" } {
266 lappend aVeryShortList "$aPath"
267 }
268 }
269 if { [llength $aVeryShortList] == 0 } {
270 return [lindex [lsort -decreasing $aShortList] 0]
271 }
272
273 return [lindex [lsort -decreasing $aVeryShortList] 0]
274}
275
e22105a9 276# Search library placement
277proc wokdep:SearchStandardLibrary {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64 theName theCheckHeader theCheckLib theCheckFolders} {
278 upvar $theErrInc anErrInc
279 upvar $theErrLib32 anErrLib32
280 upvar $theErrLib64 anErrLib64
281 upvar $theErrBin32 anErrBin32
282 upvar $theErrBin64 anErrBin64
283
284 set isFound "true"
285 set aHeaderPath [wokdep:SearchHeader "$theCheckHeader"]
286 if { "$aHeaderPath" == "" } {
287 set hasHeader false
288 foreach aFolderIter $theCheckFolders {
289 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{$aFolderIter}*] "$::VCVER" "$::ARCH" ]
290 if { "$aPath" != "" && [file exists "$aPath/include/$theCheckHeader"] } {
291 lappend ::CSF_OPT_INC "$aPath/include"
292 set hasHeader true
293 break
294 }
295 }
296 if { !$hasHeader } {
297 lappend anErrInc "Error: '$theCheckHeader' not found ($theName)"
298 set isFound "false"
299 }
300 }
301
302 foreach anArchIter {64 32} {
303 set aLibPath [wokdep:SearchLib "$theCheckLib" "$anArchIter"]
304 if { "$aLibPath" == "" } {
305 set hasLib false
306 foreach aFolderIter $theCheckFolders {
307 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{$aFolderIter}*] "$::VCVER" "$anArchIter" ]
308 set aLibPath [wokdep:SearchLib "$theCheckLib" "$anArchIter" "$aPath/lib"]
309 if { "$aLibPath" != "" } {
310 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
311 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
312 set hasLib true
313 break
314 }
315 }
316 if { !$hasLib } {
317 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}$theCheckLib.${::SYS_LIB_SUFFIX}' not found ($theName)"
318 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
319 }
320 }
321
322 if { "$::tcl_platform(platform)" == "windows" } {
323 set aDllPath [wokdep:SearchBin "$theCheckLib.dll" "$anArchIter"]
324 if { "$aDllPath" == "" } {
325 set hasDll false
326 foreach aFolderIter $theCheckFolders {
327 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{$aFolderIter}*] "$::VCVER" "$anArchIter" ]
328 set aDllPath [wokdep:SearchBin "$theCheckLib.dll" "$anArchIter" "$aPath/bin"]
329 if { "$aDllPath" != "" } {
330 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
331 set hasDll true
332 break
333 } else {
334 set aDllPath [wokdep:SearchBin "$theCheckLib.dll" "$anArchIter" "$aPath/lib"]
335 if { "$aDllPath" != "" } {
336 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
337 set hasDll true
338 break
339 }
340 }
341 }
342 if { !$hasDll } {
343 lappend anErrBin$anArchIter "Error: '$theCheckLib.dll' not found ($theName)"
344 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
345 }
346 }
347 }
348 }
349
350 return "$isFound"
351}
352
910970ab 353# Search Tcl/Tk libraries placement
354proc wokdep:SearchTclTk {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
355 upvar $theErrInc anErrInc
356 upvar $theErrLib32 anErrLib32
357 upvar $theErrLib64 anErrLib64
358 upvar $theErrBin32 anErrBin32
359 upvar $theErrBin64 anErrBin64
360
361 set tclver_maj 8
362 set tclver_min 6
363
364 set isFound "true"
365 set aTclHPath [wokdep:SearchHeader "tcl.h"]
366 set aTkHPath [wokdep:SearchHeader "tk.h"]
367 if { "$aTclHPath" == "" || "$aTkHPath" == "" } {
368 if { [file exists "/usr/include/tcl8.6/tcl.h"]
369 && [file exists "/usr/include/tcl8.6/tk.h" ] } {
370 lappend ::CSF_OPT_INC "/usr/include/tcl8.6"
371 set aTclHPath "/usr/include/tcl8.6/tcl.h"
372 } else {
373 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$::ARCH" ]
374 if { "$aPath" != "" && [file exists "$aPath/include/tcl.h"] && [file exists "$aPath/include/tk.h"] } {
375 lappend ::CSF_OPT_INC "$aPath/include"
376 set aTclHPath "$aPath/include/tcl.h"
377 } else {
378 lappend anErrInc "Error: 'tcl.h' or 'tk.h' not found (Tcl/Tk)"
379 set isFound "false"
380 }
381 }
382 }
383
384 # detect tcl version by parsing header file
385 if { $isFound } {
386 set fh [open $aTclHPath]
387 set tcl_h [read $fh]
388 close $fh
389 regexp {define\s+TCL_MAJOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_maj
390 regexp {define\s+TCL_MINOR_VERSION\s+([0-9]+)} $tcl_h dummy tclver_min
391 }
392
393 if { "$::tcl_platform(platform)" == "windows" } {
394 set aTclLibName "tcl${tclver_maj}${tclver_min}"
395 set aTkLibName "tk${tclver_maj}${tclver_min}"
396 } else {
397 set aTclLibName "tcl${tclver_maj}.${tclver_min}"
398 set aTkLibName "tk${tclver_maj}.${tclver_min}"
399 }
400
401 foreach anArchIter {64 32} {
402 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter"]
403 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter"]
404 if { "$aTclLibPath" == "" || "$aTkLibPath" == "" } {
405 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
406 set aTclLibPath [wokdep:SearchLib "$aTclLibName" "$anArchIter" "$aPath/lib"]
407 set aTkLibPath [wokdep:SearchLib "$aTkLibName" "$anArchIter" "$aPath/lib"]
408 if { "$aTclLibPath" != "" && "$aTkLibPath" != "" } {
409 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
410 } else {
411 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aTclLibName}.${::SYS_LIB_SUFFIX}' or '${::SYS_LIB_PREFIX}${aTkLibName}.${::SYS_LIB_SUFFIX}' not found (Tcl/Tk)"
412 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
413 }
414 }
415
416 if { "$::tcl_platform(platform)" == "windows" } {
417 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter"]
418 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter"]
419 if { "$aTclDllPath" == "" || "$aTkDllPath" == "" } {
420 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tcl}*] "$::VCVER" "$anArchIter" ]
421 set aTclDllPath [wokdep:SearchBin "${aTclLibName}.dll" "$anArchIter" "$aPath/bin"]
422 set aTkDllPath [wokdep:SearchBin "${aTkLibName}.dll" "$anArchIter" "$aPath/bin"]
423 if { "$aTclDllPath" != "" && "$aTkDllPath" != "" } {
424 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
425 } else {
426 lappend anErrBin$anArchIter "Error: '${aTclLibName}.dll' or '${aTkLibName}.dll' not found (Tcl/Tk)"
427 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
428 }
429 }
430 }
431 }
432
433 return "$isFound"
434}
435
436# Search FreeType library placement
437proc wokdep:SearchFreeType {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
438 upvar $theErrInc anErrInc
439 upvar $theErrLib32 anErrLib32
440 upvar $theErrLib64 anErrLib64
441 upvar $theErrBin32 anErrBin32
442 upvar $theErrBin64 anErrBin64
443
444 set isFound "true"
445 set aFtBuildPath [wokdep:SearchHeader "ft2build.h"]
446
910970ab 447 if { "$aFtBuildPath" == "" } {
448 # TODO - use `freetype-config --cflags` instead
449 set aSysFreeType "/usr/include/freetype2"
c7d774c5 450 if { [file exists "$aSysFreeType/ft2build.h"] } {
910970ab 451 lappend ::CSF_OPT_INC "$aSysFreeType"
452 } elseif { [file exists "$aSysFreeType/freetype2/ft2build.h"] } {
453 lappend ::CSF_OPT_INC "$aSysFreeType/freetype2"
454 } else {
455 set aSysFreeType "/usr/X11/include/freetype2"
456 if { [file exists "$aSysFreeType/ft2build.h"] } {
457 lappend ::CSF_OPT_INC "/usr/X11/include"
458 lappend ::CSF_OPT_INC "$aSysFreeType"
459 } else {
460 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$::ARCH" ]
461 if {"$aPath" != ""} {
462 if {[file exists "$aPath/include/ft2build.h"]} {
463 lappend ::CSF_OPT_INC "$aPath/include"
464 } elseif {[file exists "$aPath/include/freetype2/ft2build.h"]} {
465 lappend ::CSF_OPT_INC "$aPath/include/freetype2"
466 }
467 } else {
468 lappend anErrInc "Error: 'freetype.h' not found (FreeType2)"
469 set isFound "false"
470 }
471 }
472 }
473 }
474
475 # parse 'freetype-config --libs'
476 set aConfLibPath ""
477 if { [catch { set aConfLibs [exec freetype-config --libs] } ] == 0 } {
478 foreach aPath [split $aConfLibs " "] {
479 if { [string first "-L" "$aPath"] == 0 } {
480 set aConfLibPath [string range "$aPath" 2 [string length "$aPath"]]
481 }
482 }
483 }
484
485 foreach anArchIter {64 32} {
486 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter"]
487 if { "$aFtLibPath" == "" } {
488 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
489 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aPath/lib"]
490 if { "$aFtLibPath" != "" } {
491 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
492 } else {
493 set aFtLibPath [wokdep:SearchLib "freetype" "$anArchIter" "$aConfLibPath"]
494 if { "$aFtLibPath" != "" } {
495 lappend ::CSF_OPT_LIB$anArchIter "$aConfLibPath"
496 } else {
497 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freetype.${::SYS_LIB_SUFFIX}' not found (FreeType2)"
498 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
499 }
500 }
501 }
502 if { "$::tcl_platform(platform)" == "windows" } {
503 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter"]
504 if { "$aFtDllPath" == "" } {
505 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freetype}*] "$::VCVER" "$anArchIter" ]
506 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/bin"]
507 if { "$aFtDllPath" != "" } {
508 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
509 } else {
510 set aFtDllPath [wokdep:SearchBin "freetype.dll" "$anArchIter" "$aPath/lib"]
511 if { "$aFtDllPath" != "" } {
512 lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib"
513 } else {
514 lappend anErrBin$anArchIter "Error: 'freetype.dll' not found (FreeType2)"
515 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
516 }
517 }
518 }
519 }
520 }
521
522 return "$isFound"
523}
524
525# Search FreeImage library placement
526proc wokdep:SearchFreeImage {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
527 upvar $theErrInc anErrInc
528 upvar $theErrLib32 anErrLib32
529 upvar $theErrLib64 anErrLib64
530 upvar $theErrBin32 anErrBin32
531 upvar $theErrBin64 anErrBin64
532
533 # binary distribution has another layout
534 set aFImageDist "Dist"
910970ab 535
536 set isFound "true"
f0d3b7af 537 set aFImageHPath [wokdep:SearchHeader "FreeImage.h"]
538 if { "$aFImageHPath" == "" } {
910970ab 539 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$::ARCH" ]
f0d3b7af 540 if { "$aPath" != "" && [file exists "$aPath/include/FreeImage.h"] } {
910970ab 541 lappend ::CSF_OPT_INC "$aPath/include"
f0d3b7af 542 } elseif { "$aPath" != "" && [file exists "$aPath/$aFImageDist/FreeImage.h"] } {
910970ab 543 lappend ::CSF_OPT_INC "$aPath/$aFImageDist"
910970ab 544 } else {
f0d3b7af 545 lappend anErrInc "Error: 'FreeImage.h' not found (FreeImage)"
910970ab 546 set isFound "false"
547 }
548 }
549
550 foreach anArchIter {64 32} {
f0d3b7af 551 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter"]
552 if { "$aFImageLibPath" == "" } {
910970ab 553 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
f0d3b7af 554 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/lib"]
555 if { "$aFImageLibPath" != "" } {
910970ab 556 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
557 } else {
f0d3b7af 558 set aFImageLibPath [wokdep:SearchLib "freeimage" "$anArchIter" "$aPath/$aFImageDist"]
559 if { "$aFImageLibPath" != "" } {
910970ab 560 lappend ::CSF_OPT_LIB$anArchIter "$aPath/$aFImageDist"
910970ab 561 } else {
f0d3b7af 562 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}freeimage.${::SYS_LIB_SUFFIX}' not found (FreeImage)"
910970ab 563 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
564 }
565 }
566 }
567 if { "$::tcl_platform(platform)" == "windows" } {
60273f77 568 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter"]
569 if { "$aFImageDllPath" == "" } {
910970ab 570 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{freeimage}*] "$::VCVER" "$anArchIter" ]
60273f77 571 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/bin"]
572 if { "$aFImageDllPath" != "" } {
910970ab 573 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
574 } else {
60273f77 575 set aFImageDllPath [wokdep:SearchBin "freeimage.dll" "$anArchIter" "$aPath/$aFImageDist"]
576 if { "$aFImageDllPath" != "" } {
910970ab 577 lappend ::CSF_OPT_BIN$anArchIter "$aPath/$aFImageDist"
910970ab 578 } else {
60273f77 579 lappend anErrBin$anArchIter "Error: 'freeimage.dll' is not found (FreeImage)"
910970ab 580 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
581 }
582 }
583 }
584 }
585 }
586
587 return "$isFound"
588}
589
e22105a9 590# Search FFmpeg framework placement
591proc wokdep:SearchFFmpeg {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
910970ab 592 upvar $theErrInc anErrInc
593 upvar $theErrLib32 anErrLib32
594 upvar $theErrLib64 anErrLib64
595 upvar $theErrBin32 anErrBin32
596 upvar $theErrBin64 anErrBin64
597
598 set isFound "true"
e22105a9 599 set aFFmpegHPath [wokdep:SearchHeader "libavutil/avutil.h"]
600 if { "$aFFmpegHPath" == "" } {
601 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{ffmpeg}*] "$::VCVER" "$::ARCH" ]
602 if { "$aPath" != "" && [file exists "$aPath/include/libavutil/avutil.h"] } {
910970ab 603 lappend ::CSF_OPT_INC "$aPath/include"
604 } else {
e22105a9 605 lappend anErrInc "Error: 'libavutil/avutil.h' not found (FFmpeg)"
910970ab 606 set isFound "false"
607 }
608 }
609
610 foreach anArchIter {64 32} {
e22105a9 611 set aFFmpegLibPath [wokdep:SearchLib "avutil" "$anArchIter"]
612 if { "$aFFmpegLibPath" == "" } {
613 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{ffmpeg}*] "$::VCVER" "$anArchIter" ]
614 set aFFmpegLibPath [wokdep:SearchLib "avutil" "$anArchIter" "$aPath/lib"]
615 if { "$aFFmpegLibPath" != "" } {
910970ab 616 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
e22105a9 617 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
910970ab 618 } else {
e22105a9 619 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}avutil.${::SYS_LIB_SUFFIX}' not found (FFmpeg)"
910970ab 620 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
621 }
622 }
910970ab 623 }
624
625 return "$isFound"
626}
627
628# Search TBB library placement
629proc wokdep:SearchTBB {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
635
d6cda17a 636 # keep only two first digits in "vc141"
637 if { ! [regexp {^vc[0-9][0-9]} ${::VCVER} aVcLib] } {
1bd04b5a 638 if { [regexp {^vclang} ${::VCVER}] } {
639 set aVcLib vc14
640 } else {
641 set aVcLib ${::VCVER}
642 }
d6cda17a 643 }
644
910970ab 645 set isFound "true"
646 set aTbbHPath [wokdep:SearchHeader "tbb/scalable_allocator.h"]
647 if { "$aTbbHPath" == "" } {
648 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] "$::VCVER" "$::ARCH" ]
649 if { "$aPath" != "" && [file exists "$aPath/include/tbb/scalable_allocator.h"] } {
650 lappend ::CSF_OPT_INC "$aPath/include"
651 } else {
652 lappend anErrInc "Error: 'tbb/scalable_allocator.h' not found (Intel TBB)"
653 set isFound "false"
654 }
655 }
656
657 foreach anArchIter {64 32} {
658 set aSubDir "ia32"
659 if { "$anArchIter" == "64"} {
660 set aSubDir "intel64"
661 }
662
663 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter"]
664 if { "$aTbbLibPath" == "" } {
d6cda17a 665 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] $aVcLib "$anArchIter" ]
666 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir/$aVcLib"]
910970ab 667 if { "$aTbbLibPath" == "" } {
668 # Set the path to the TBB library for Linux
669 if { "$::tcl_platform(platform)" != "windows" } {
670 set aSubDir "$aSubDir/cc4.1.0_libc2.4_kernel2.6.16.21"
671 }
672 set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir"]
673 if { "$aTbbLibPath" != "" } {
674 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir"
675 }
676 } else {
d6cda17a 677 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/$aVcLib"
910970ab 678 }
679 if { "$aTbbLibPath" == "" } {
680 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
681 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
682 }
683 }
684 if { "$::tcl_platform(platform)" == "windows" } {
685 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"]
686 if { "$aTbbDllPath" == "" } {
d6cda17a 687 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] $aVcLib "$anArchIter" ]
688 set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/$aVcLib"]
910970ab 689 if { "$aTbbDllPath" != "" } {
d6cda17a 690 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/$aVcLib"
910970ab 691 } else {
692 lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)"
693 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
694 }
695 }
696 }
697 }
698
699 return "$isFound"
700}
701
702# Search OpenCL library placement
703proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
704 upvar $theErrInc anErrInc
705 upvar $theErrLib32 anErrLib32
706 upvar $theErrLib64 anErrLib64
707 upvar $theErrBin32 anErrBin32
708 upvar $theErrBin64 anErrBin64
709
710 set isFound "true"
711 if { "$::tcl_platform(os)" == "Darwin" } {
712 # OpenCL framework available since Mac OS X 16
713 return "$isFound"
714 }
715
716 set aCLHPath [wokdep:SearchHeader "CL/cl_gl.h"]
717 if { "$aCLHPath" == "" } {
718 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$::ARCH" ]
719 if { "$aPath" != "" && [file exists "$aPath/include/CL/cl_gl.h"] } {
720 lappend ::CSF_OPT_INC "$aPath/include"
721 } else {
722 lappend anErrInc "Error: 'CL/cl_gl.h' not found (OpenCL)"
723 set isFound "false"
724 }
725 }
726
727 foreach anArchIter {64 32} {
728 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter"]
729 if { "$aCLLibPath" == "" } {
730 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$anArchIter" ]
731 set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter" "$aPath/lib"]
732 if { "$aCLLibPath" != "" } {
733 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
734 } else {
735 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}OpenCL.${::SYS_LIB_SUFFIX}' not found (OpenCL)"
736 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
737 }
738 }
739 }
740
741 return "$isFound"
742}
743
1ce0716b 744# Search EGL library placement
745proc wokdep:SearchEGL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
746 upvar $theErrInc anErrInc
747 upvar $theErrLib32 anErrLib32
748 upvar $theErrLib64 anErrLib64
749 upvar $theErrBin32 anErrBin32
750 upvar $theErrBin64 anErrBin64
751
752 set isFound "true"
753 set aHeaderPath [wokdep:SearchHeader "EGL/egl.h"]
754 if { "$aHeaderPath" == "" } {
755 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$::ARCH" ]
756 if { "$aPath" == "" || ![file exists "$aPath/include/EGL/egl.h"] } {
757 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$::ARCH" ]
758 }
759
760 if { "$aPath" != "" && [file exists "$aPath/include/EGL/egl.h"] } {
761 lappend ::CSF_OPT_INC "$aPath/include"
762 } else {
763 lappend anErrInc "Error: 'EGL/egl.h' not found (EGL)"
764 set isFound "false"
765 }
766 }
767
768 set aLibName "EGL"
769 if { "$::tcl_platform(platform)" == "windows" } {
770 # awkward exception
771 set aLibName "libEGL"
772 }
773
774 foreach anArchIter {64 32} {
775 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter"]
776 if { "$aLibPath" == "" } {
777 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ]
778 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
779 if { "$aLibPath" == "" } {
780 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
781 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
782 }
783
784 if { "$aLibPath" != "" } {
785 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
786 } else {
787 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aLibName}.${::SYS_LIB_SUFFIX}' not found (EGL)"
788 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
789 }
790 }
791
792 if { "$::tcl_platform(platform)" == "windows" } {
793 set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter"]
794 if { "$aDllPath" == "" } {
795 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ]
796 set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter" "$aPath/bin"]
797 if { "$aDllPath" == "" } {
798 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
799 set aDllPath [wokdep:SearchBin "libEGL.dll" "$anArchIter" "$aPath/bin"]
800 }
801
802 if { "$aDllPath" != "" } {
803 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
804 } else {
805 lappend anErrBin$anArchIter "Error: 'libEGL.dll' not found (EGL)"
806 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
807 }
808 }
809 }
810 }
811
812 return "$isFound"
813}
814
815# Search OpenGL ES 2.0 library placement
816proc wokdep:SearchGLES {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
817 upvar $theErrInc anErrInc
818 upvar $theErrLib32 anErrLib32
819 upvar $theErrLib64 anErrLib64
820 upvar $theErrBin32 anErrBin32
821 upvar $theErrBin64 anErrBin64
822
823 set isFound "true"
824 set aHeaderPath [wokdep:SearchHeader "GLES2/gl2.h"]
825 if { "$aHeaderPath" == "" } {
826 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{GLES}*] "$::VCVER" "$::ARCH" ]
827 if { "$aPath" == "" || ![file exists "$aPath/include/GLES2/gl2.h"] } {
828 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$::ARCH" ]
829 }
830
831 if { "$aPath" != "" && [file exists "$aPath/include/GLES2/gl2.h"] } {
832 lappend ::CSF_OPT_INC "$aPath/include"
833 } else {
834 lappend anErrInc "Error: 'GLES2/gl2.h' not found (OpenGL ES 2.0)"
835 set isFound "false"
836 }
837 }
838
839 set aLibName "GLESv2"
840 if { "$::tcl_platform(platform)" == "windows" } {
841 # awkward exception
842 set aLibName "libGLESv2"
843 }
844
845 foreach anArchIter {64 32} {
846 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter"]
847 if { "$aLibPath" == "" } {
848 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{GLES}*] "$::VCVER" "$anArchIter" ]
849 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
850 if { "$aLibPath" == "" } {
851 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
852 set aLibPath [wokdep:SearchLib "$aLibName" "$anArchIter" "$aPath/lib"]
853 }
854
855 if { "$aLibPath" != "" } {
856 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
857 } else {
858 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aLibName}.${::SYS_LIB_SUFFIX}' not found (OpenGL ES 2.0)"
859 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
860 }
861 }
862
863 if { "$::tcl_platform(platform)" == "windows" } {
864 set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter"]
865 if { "$aDllPath" == "" } {
866 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{EGL}*] "$::VCVER" "$anArchIter" ]
867 set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter" "$aPath/bin"]
868 if { "$aDllPath" == "" } {
869 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{angle}*] "$::VCVER" "$anArchIter" ]
870 set aDllPath [wokdep:SearchBin "libGLESv2.dll" "$anArchIter" "$aPath/bin"]
871 }
872
873 if { "$aDllPath" != "" } {
874 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
875 } else {
876 lappend anErrBin$anArchIter "Error: 'libGLESv2.dll' not found (OpenGL ES 2.0)"
877 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
878 }
879 }
880 }
881 }
882
883 return "$isFound"
884}
885
0a419c51 886# Search RapidJSON headers
887proc wokdep:SearchRapidJson {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
888 upvar $theErrInc anErrInc
889
890 set isFound "true"
891 set aRJHPath [wokdep:SearchHeader "rapidjson/rapidjson.h"]
892 if { "$aRJHPath" == "" } {
893 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{rapidjson}*] "$::VCVER" "$::ARCH" ]
894 if { "$aPath" != "" && [file exists "$aPath/include/rapidjson/rapidjson.h"] } {
895 lappend ::CSF_OPT_INC "$aPath/include"
896 } else {
897 lappend anErrInc "Error: 'rapidjson/rapidjson.h' not found (RapidJSON)"
898 set isFound "false"
899 }
900 }
901
902 return "$isFound"
903}
904
910970ab 905# Auxiliary function, gets VTK version to set default search directory
906proc wokdep:VtkVersion { thePath } {
907 set aResult "6.1"
908
909 set aVtkRoot [lindex [regexp -all -inline {[0-9.]*} [file tail $thePath]] 0]
910 if { "$aVtkRoot" != "" } {
911 set aVtkRoot [regexp -inline {[0-9]*.[0-9]*} $aVtkRoot]
912 if { "$aVtkRoot" != "" } {
913 set aResult $aVtkRoot
914 }
915 }
916
917 return $aResult
918}
919
920# Search VTK library placement
921proc wokdep:SearchVTK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
922 upvar $theErrInc anErrInc
923 upvar $theErrLib32 anErrLib32
924 upvar $theErrLib64 anErrLib64
925 upvar $theErrBin32 anErrBin32
926 upvar $theErrBin64 anErrBin64
927
928 set isFound "true"
929
930 set aVtkPath ""
931 set aVtkIncPath [wokdep:SearchHeader "vtkConfigure.h"]
932 set aVtkVer [wokdep:VtkVersion $aVtkIncPath]
933 if { "$aVtkIncPath" == ""} {
934 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
935 set aVtkPath [wokdep:Preferred "$aPathList" "$::VCVER" "$::ARCH" ]
936 if { "$aVtkPath" != "" && [file exists "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]/vtkConfigure.h"]} {
937 set aVtkVer [wokdep:VtkVersion $aVtkPath]
938 lappend ::CSF_OPT_INC "$aVtkPath/include/vtk-[wokdep:VtkVersion $aVtkPath]"
939 } else { # try to search in all found paths
940 set isFound "false"
941 foreach anIt $aPathList {
942 if { [file exists "$anIt/include/vtk-[wokdep:VtkVersion $anIt]/vtkConfigure.h"] } {
943 set aVtkPath $anIt
944 set aVtkVer [wokdep:VtkVersion $aVtkPath]
945 lappend ::CSF_OPT_INC "$anIt/include/vtk-[wokdep:VtkVersion $anIt]"
946 set isFound "true"
947 break
948 }
949 }
950
951 # Bad case: we do not found vtkConfigure.h in all paths.
952 if { "$isFound" == "false"} {
953 lappend anErrInc "Error: 'vtkConfigure.h' not found (VTK)"
954 set isFound "false"
955 }
956 }
957 }
958
959 set aVtkLibPath ""
960 foreach anArchIter {64 32} {
961 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter"]
962 if { "$aVtkLibPath" == "" } {
963 set aPathList [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*]
964 set aPath [wokdep:Preferred $aPathList "$::VCVER" "$anArchIter" ]
965 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aPath/lib"]
966 if { "$aVtkLibPath" != "" } {
967 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
968 } else {
969 set aPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$aVtkPath/lib"]
970 if { "$aPath" != "" } {
971 set aLibPath $aVtkIncPath
972 lappend ::CSF_OPT_LIB$anArchIter "$aLibPath/lib"
973 } else {
974 # The last chance: search /lib directory in all found paths
975 foreach anIt $aPathList {
976 set aVtkLibPath [wokdep:SearchLib "vtkCommonCore-$aVtkVer" "$anArchIter" "$anIt/lib"]
977 if { "$aVtkLibPath" != ""} {
978 lappend ::CSF_OPT_LIB$anArchIter "$anIt/lib"
979 break
980 }
981 }
982 if { "$aVtkLibPath" == "" } {
983 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}vtkCommonCore-${aVtkVer}\.${::SYS_LIB_SUFFIX}' not found (VTK)"
984 if { "$::ARCH" == "$anArchIter" } {
985 set isFound "false"
986 }
987 }
988 }
989 }
990 }
991 }
992
993 # Search binary path
994 if { "$::tcl_platform(platform)" == "windows" } {
995 foreach anArchIter {64 32} {
996 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter"]
997 if { "$aVtkBinPath" == "" } {
998 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{VTK}*] "$::VCVER" "$anArchIter" ]
999 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/bin"]
1000 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
1001 } else {
1002 set aVtkBinPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aPath/lib"]
1003 if { "$aVtkBinPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/lib" }
1004 }
1005 }
1006 }
1007
1008 # We didn't find preferred binary path => search through inc path or among all available VTK directories
1009 if { "$aVtkBinPath" == "" } {
1010 # Try to find in lib path
e31a8e52 1011 set aPath [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/bin"]
1012 if { "$aPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/bin"
1013 } elseif { [wokdep:SearchBin "vtkCommonCore-${aVtkVer}.dll" "$anArchIter" "$aVtkLibPath/lib"] != "" } {
1014 lappend ::CSF_OPT_BIN$anArchIter "$aVtkLibPath/lib"
910970ab 1015 } else {
1016 lappend anErrBin$anArchIter "Error: 'vtkCommonCore-${aVtkVer}.dll' not found (VTK)"
1017 set isFound "false"
1018 }
1019 }
1020 }
1021
1022 return "$isFound"
1023}
1024
1025# Search Qt4 libraries placement
1026proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
1027 upvar $theErrInc anErrInc
1028 upvar $theErrLib32 anErrLib32
1029 upvar $theErrLib64 anErrLib64
1030 upvar $theErrBin32 anErrBin32
1031 upvar $theErrBin64 anErrBin64
1032
1033 set isFound "true"
1034 set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qmessagebox.h"]
1035 if { "$aQMsgBoxHPath" == "" } {
1036 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$::ARCH" ]
1037 if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qmessagebox.h"] } {
1038 lappend ::CSF_OPT_INC "$aPath/include"
1039 lappend ::CSF_OPT_INC "$aPath/include/Qt"
1040 lappend ::CSF_OPT_INC "$aPath/include/QtGui"
1041 lappend ::CSF_OPT_INC "$aPath/include/QtCore"
1042 } else {
1043 if { [file exists "/usr/include/qt4/QtGui/qmessagebox.h"] } {
1044 lappend ::CSF_OPT_INC "/usr/include/qt4"
1045 lappend ::CSF_OPT_INC "/usr/include/qt4/Qt"
1046 lappend ::CSF_OPT_INC "/usr/include/qt4/QtGui"
1047 lappend ::CSF_OPT_INC "/usr/include/qt4/QtCore"
1048 } else {
1049 lappend anErrInc "Error: 'QtGui/qmessagebox.h' not found (Qt4)"
1050 set isFound "false"
1051 }
1052 }
1053 }
1054
1055 set aQtGuiLibName "QtGui"
1056 if { "$::tcl_platform(platform)" == "windows" } {
1057 set aQtGuiLibName "QtGui4"
1058 }
1059
1060 foreach anArchIter {64 32} {
1061 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter"]
1062 if { "$aQMsgBoxLibPath" == "" } {
1063 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
1064 set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter" "$aPath/lib"]
1065 if { "$aQMsgBoxLibPath" != "" } {
1066 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
1067 } else {
1068 lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt4)"
1069 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
1070 }
1071 }
1072 if { "$::tcl_platform(platform)" == "windows" } {
1073 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter"]
1074 if { "$aQMsgBoxDllPath" == "" } {
1075 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
1076 set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter" "$aPath/bin"]
1077 if { "$aQMsgBoxDllPath" != "" } {
1078 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
1079 } else {
1080 lappend anErrBin$anArchIter "Error: 'QtGui4.dll' not found (Qt4)"
1081 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
1082 }
1083 }
1084 }
1085 }
1086
1087 return "$isFound"
1088}
1089
1090# Search JDK placement
1091proc wokdep:SearchJDK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
1092 upvar $theErrInc anErrInc
1093 upvar $theErrLib32 anErrLib32
1094 upvar $theErrLib64 anErrLib64
1095 upvar $theErrBin32 anErrBin32
1096 upvar $theErrBin64 anErrBin64
1097
1098 set isFound "true"
1099 set aJniHPath [wokdep:SearchHeader "jni.h"]
1100 set aJniMdHPath [wokdep:SearchHeader "jni_md.h"]
1101 if { "$aJniHPath" == "" || "$aJniMdHPath" == "" } {
1102 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$::ARCH" ]
1103 if { "$aPath" != "" && [file exists "$aPath/include/jni.h"] } {
1104 lappend ::CSF_OPT_INC "$aPath/include"
1105 if { "$::tcl_platform(platform)" == "windows" } {
1106 lappend ::CSF_OPT_INC "$aPath/include/win32"
1107 } elseif { [file exists "$aPath/include/linux"] } {
1108 lappend ::CSF_OPT_INC "$aPath/include/linux"
1109 }
1110 } else {
1111 if { [file exists "/System/Library/Frameworks/JavaVM.framework/Home/include/jni.h"] } {
1112 lappend ::CSF_OPT_INC "/System/Library/Frameworks/JavaVM.framework/Home/include"
1113 } else {
1114 lappend anErrInc "Error: 'jni.h' or 'jni_md.h' not found (JDK)"
1115 set isFound "false"
1116 }
1117 }
1118 }
1119
1120 foreach anArchIter {64 32} {
1121 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter"]
1122 if { "$aJavacPath" == "" } {
1123 set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{jdk,java}*] "$::VCVER" "$anArchIter" ]
1124 set aJavacPath [wokdep:SearchBin "javac${::SYS_EXE_SUFFIX}" "$anArchIter" "$aPath/bin"]
1125 if { "$aJavacPath" != "" } {
1126 lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
1127 } else {
1128 if { "$::ARCH" == "$anArchIter" && [file exists "/System/Library/Frameworks/JavaVM.framework/Home/bin/javac${::SYS_EXE_SUFFIX}"] } {
1129 lappend ::CSF_OPT_BIN$anArchIter "/System/Library/Frameworks/JavaVM.framework/Home/bin"
1130 } else {
1131 lappend anErrBin$anArchIter "Error: 'javac${::SYS_EXE_SUFFIX}' not found (JDK)"
1132 if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
1133 }
1134 }
1135 }
1136 }
1137
1138 return "$isFound"
1139}
1140
1141# Search X11 libraries placement
1142proc wokdep:SearchX11 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
1143 upvar $theErrInc anErrInc
1144 upvar $theErrLib32 anErrLib32
1145 upvar $theErrLib64 anErrLib64
1146 upvar $theErrBin32 anErrBin32
1147 upvar $theErrBin64 anErrBin64
1148
1149 set isFound "true"
1150 if { "$::tcl_platform(platform)" == "windows" || ( "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" ) } {
1151 return "$isFound"
1152 }
1153
1154 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH"]
1155 if { "$aXmuLibPath" == "" } {
1156 set aXmuLibPath [wokdep:SearchLib "Xmu" "$::ARCH" "/usr/X11/lib"]
1157 if { "$aXmuLibPath" != "" } {
1158 #lappend ::CSF_OPT_LIB$::ARCH "/usr/X11/lib"
1159 } else {
1160 lappend anErrLib$::ARCH "Error: '${::SYS_LIB_PREFIX}Xmu.${::SYS_LIB_SUFFIX}' not found (X11)"
1161 set isFound "false"
1162 }
1163 }
1164
1165 return "$isFound"
1166}
1167
aafe169f 1168# Returns OCCT version string from file Standard_Version.hxx (if available)
1169proc wokdep:DetectCasVersion {} {
1170 set occt_ver 7.0.0
1171 set aCasRoot [file normalize [file dirname [info script]]]
1172 set filename "${aCasRoot}/src/Standard/Standard_Version.hxx"
1173 if { [file exists $filename] } {
1174 set fh [open $filename "r"]
1175 set fh_loaded [read $fh]
1176 close $fh
1177 regexp {[^/]\s*#\s*define\s+OCC_VERSION_COMPLETE\s+\"([^\s]*)\"} $fh_loaded dummy occt_ver
1178 } else {
1179 puts "Error: file '$filename' not found"
1180 }
1181 return $occt_ver
1182}
1183
910970ab 1184# Generate (override) custom environment file
1185proc wokdep:SaveCustom {} {
aafe169f 1186 set aGenInfo "This environment file was generated by genconf.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
910970ab 1187 if { "$::tcl_platform(platform)" == "windows" } {
1188 set aCustomFilePath "./custom.bat"
1189 set aFile [open $aCustomFilePath "w"]
1190 puts $aFile "@echo off"
aafe169f 1191 puts $aFile "rem $aGenInfo"
910970ab 1192
1193 puts $aFile ""
aafe169f 1194 puts $aFile "set PRJFMT=$::PRJFMT"
910970ab 1195 puts $aFile "set VCVER=$::VCVER"
1196 puts $aFile "set ARCH=$::ARCH"
1197 puts $aFile "set VCVARS=$::VCVARS"
1198 puts $aFile "set SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
1199
1200 puts $aFile ""
1201 puts $aFile "set \"PRODUCTS_PATH=$::PRODUCTS_PATH\""
1202
1203 puts $aFile ""
1204 puts $aFile "rem Optional 3rd-parties switches"
e22105a9 1205 foreach anEnvIter $::THE_ENV_VARIABLES {
1206 set aName ${anEnvIter}
1207 set aValue [set ::${anEnvIter}]
1208 if { "$aValue" != "" } {
1209 puts $aFile "set ${aName}=$aValue"
1210 }
1211 }
910970ab 1212
1213 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
2506cf29 1214 if { "$::PRODUCTS_PATH" != "" } {
1215 set aStringInc [regsub -all "$::PRODUCTS_PATH" $aStringInc "%PRODUCTS_PATH%"]
1216 }
910970ab 1217 puts $aFile ""
1218 puts $aFile "rem Additional headers search paths"
1219 puts $aFile "set \"CSF_OPT_INC=$aStringInc\""
1220
1221 set aStringLib32 [join $::CSF_OPT_LIB32 $::SYS_PATH_SPLITTER]
2506cf29 1222 if { "$::PRODUCTS_PATH" != "" } {
1223 set aStringLib32 [regsub -all "$::PRODUCTS_PATH" $aStringLib32 "%PRODUCTS_PATH%"]
1224 }
910970ab 1225 puts $aFile ""
1226 puts $aFile "rem Additional libraries (32-bit) search paths"
1227 puts $aFile "set \"CSF_OPT_LIB32=$aStringLib32\""
1228
1229 set aStringLib64 [join $::CSF_OPT_LIB64 $::SYS_PATH_SPLITTER]
2506cf29 1230 if { "$::PRODUCTS_PATH" != "" } {
1231 set aStringLib64 [regsub -all "$::PRODUCTS_PATH" $aStringLib64 "%PRODUCTS_PATH%"]
1232 }
910970ab 1233 puts $aFile ""
1234 puts $aFile "rem Additional libraries (64-bit) search paths"
1235 puts $aFile "set \"CSF_OPT_LIB64=$aStringLib64\""
1236
1237 set aStringBin32 [join $::CSF_OPT_BIN32 $::SYS_PATH_SPLITTER]
2506cf29 1238 if { "$::PRODUCTS_PATH" != "" } {
1239 set aStringBin32 [regsub -all "$::PRODUCTS_PATH" $aStringBin32 "%PRODUCTS_PATH%"]
1240 }
910970ab 1241 puts $aFile ""
1242 puts $aFile "rem Additional (32-bit) search paths"
1243 puts $aFile "set \"CSF_OPT_BIN32=$aStringBin32\""
1244
1245 set aStringBin64 [join $::CSF_OPT_BIN64 $::SYS_PATH_SPLITTER]
2506cf29 1246 if { "$::PRODUCTS_PATH" != "" } {
1247 set aStringBin64 [regsub -all "$::PRODUCTS_PATH" $aStringBin64 "%PRODUCTS_PATH%"]
1248 }
910970ab 1249 puts $aFile ""
1250 puts $aFile "rem Additional (64-bit) search paths"
1251 puts $aFile "set \"CSF_OPT_BIN64=$aStringBin64\""
1252
1253 close $aFile
1254 } else {
1255 set aCustomFilePath "./custom.sh"
1256 set aFile [open $aCustomFilePath "w"]
1257 puts $aFile "#!/bin/bash"
aafe169f 1258 puts $aFile "# $aGenInfo"
910970ab 1259
c7d774c5 1260 puts $aFile ""
aafe169f 1261 puts $aFile "export PRJFMT=$::PRJFMT"
c7d774c5 1262 puts $aFile "export ARCH=$::ARCH"
1263 puts $aFile "export SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
910970ab 1264
1265 puts $aFile ""
1266 puts $aFile "export PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
1267
1268 puts $aFile ""
1269 puts $aFile "# Optional 3rd-parties switches"
e22105a9 1270 foreach anEnvIter $::THE_ENV_VARIABLES {
1271 set aName ${anEnvIter}
1272 set aValue [set ::${anEnvIter}]
1273 if { "$aValue" != "" } {
1274 puts $aFile "export ${aName}=${aValue}"
1275 }
910970ab 1276 }
910970ab 1277
1278 set aStringInc [join $::CSF_OPT_INC $::SYS_PATH_SPLITTER]
2506cf29 1279 if { "$::PRODUCTS_PATH" != "" } {
1280 set aStringInc [regsub -all "$::PRODUCTS_PATH" $aStringInc "\${PRODUCTS_PATH}"]
1281 }
910970ab 1282 puts $aFile ""
1283 puts $aFile "# Additional headers search paths"
1284 puts $aFile "export CSF_OPT_INC=\"$aStringInc\""
1285
2506cf29 1286 set aStringLib [join [set ::CSF_OPT_LIB$::ARCH] $::SYS_PATH_SPLITTER]
1287 if { "$::PRODUCTS_PATH" != "" } {
1288 set aStringLib [regsub -all "$::PRODUCTS_PATH" $aStringLib "\${PRODUCTS_PATH}"]
1289 }
910970ab 1290 puts $aFile ""
1291 puts $aFile "# Additional libraries ($::ARCH-bit) search paths"
2506cf29 1292 puts $aFile "export CSF_OPT_LIB$::ARCH=\"[set aStringLib]\""
910970ab 1293
2506cf29 1294 set aStringBin [join [set ::CSF_OPT_BIN$::ARCH] $::SYS_PATH_SPLITTER]
1295 if { "$::PRODUCTS_PATH" != "" } {
1296 set aStringBin [regsub -all "$::PRODUCTS_PATH" $aStringBin "\${PRODUCTS_PATH}"]
1297 }
910970ab 1298 puts $aFile ""
1299 puts $aFile "# Additional ($::ARCH-bit) search paths"
2506cf29 1300 puts $aFile "export CSF_OPT_BIN$::ARCH=\"[set aStringBin]\""
910970ab 1301
1302 close $aFile
1303 }
910970ab 1304 puts "Configuration saved to file '$aCustomFilePath'"
aafe169f 1305
2506cf29 1306 # generate custom.auto.pri
1307 set toExportCustomPri 1
1308 if { $toExportCustomPri == 1 } {
aafe169f 1309 set aCasVer [wokdep:DetectCasVersion]
1310 set aCustomFilePath "./adm/qmake/custom.auto.pri"
1311 set aFile [open $aCustomFilePath "w"]
1312 puts $aFile "# $aGenInfo"
1313
1314 puts $aFile ""
1315 puts $aFile "VERSION=$aCasVer"
1316 puts $aFile "PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
1317
1318 puts $aFile ""
1319 puts $aFile "# Optional 3rd-parties switches"
1320 foreach anEnvIter $::THE_ENV_VARIABLES {
1321 set aName ${anEnvIter}
1322 set aValue [set ::${anEnvIter}]
1323 if { "$aValue" == "true" } {
1324 puts $aFile "CONFIG += ${aName}"
1325 } else {
1326 #puts $aFile "CONFIG -= ${aName}"
1327 }
1328 }
1329
1330 puts $aFile ""
1331 puts $aFile "# Additional headers search paths"
1332 foreach anIncPath $::CSF_OPT_INC {
2506cf29 1333 if { "$::PRODUCTS_PATH" != "" } {
1334 set anIncPath [regsub -all "$::PRODUCTS_PATH" $anIncPath "\$\$\{PRODUCTS_PATH\}"]
1335 }
aafe169f 1336 puts $aFile "INCLUDEPATH += \"${anIncPath}\""
1337 }
1338
1339 puts $aFile ""
1340 puts $aFile "# Additional libraries search paths"
1341 foreach aLibPath [set ::CSF_OPT_LIB$::ARCH] {
2506cf29 1342 if { "$::PRODUCTS_PATH" != "" } {
1343 set aLibPath [regsub -all "$::PRODUCTS_PATH" $aLibPath "\$\$\{PRODUCTS_PATH\}"]
1344 }
aafe169f 1345 puts $aFile "LIBS += -L\"${aLibPath}\""
1346 }
1347
1348 if { "$::tcl_platform(platform)" == "windows" } {
1349 puts $aFile ""
1350 puts $aFile "# Additional DLLs search paths"
1351 foreach aDllPath [set ::CSF_OPT_BIN$::ARCH] {
2506cf29 1352 if { "$::PRODUCTS_PATH" != "" } {
1353 set aDllPath [regsub -all "$::PRODUCTS_PATH" $aDllPath "\$\$\{PRODUCTS_PATH\}"]
1354 }
aafe169f 1355 puts $aFile "LIBS += -L\"${aDllPath}\""
1356 }
1357 }
1358
1359 puts $aFile ""
1360 close $aFile
1361 puts "Configuration saved to file '$aCustomFilePath'"
1362 }
910970ab 1363}