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