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