17 |
default_tktable_lib = "Tktable28" |
default_tktable_lib = "Tktable28" |
18 |
default_install_assets = "glade/" |
default_install_assets = "glade/" |
19 |
icon_extension = '.png' |
icon_extension = '.png' |
20 |
|
default_tcl = "c:\\Tcl" |
21 |
else: |
else: |
22 |
default_tcl_lib = "tcl" |
default_tcl_lib = "tcl8.3" |
23 |
default_tk_lib = "tk" |
default_tk_lib = "tk8.3" |
24 |
default_tktable_lib = "Tktable2.8" |
default_tktable_lib = "Tktable2.8" |
25 |
default_install_assets = "$INSTALL_DATA/ascend/glade/" |
default_install_assets = "$INSTALL_DATA/ascend/glade/" |
26 |
icon_extension = '.svg' |
icon_extension = '.svg' |
27 |
|
default_tcl = os.path.expanduser("~/activetcl") |
28 |
|
|
29 |
|
|
30 |
# Package linking option |
# Package linking option |
116 |
,'off' |
,'off' |
117 |
)) |
)) |
118 |
|
|
119 |
|
|
120 |
|
opts.Add(PackageOption( |
121 |
|
'TCL' |
122 |
|
,'Base of Tcl distribution' |
123 |
|
,default_tcl |
124 |
|
)) |
125 |
|
|
126 |
# Where are the Tcl includes? |
# Where are the Tcl includes? |
127 |
opts.Add(PackageOption( |
opts.Add(PackageOption( |
128 |
'TCL_CPPPATH' |
'TCL_CPPPATH' |
129 |
,"Where are your Tcl include files?" |
,"Where are your Tcl include files?" |
130 |
,"disable" |
,"$TCL/include" |
131 |
)) |
)) |
132 |
|
|
133 |
# Where are the Tcl libs? |
# Where are the Tcl libs? |
134 |
opts.Add(PackageOption( |
opts.Add(PackageOption( |
135 |
'TCL_LIBPATH' |
'TCL_LIBPATH' |
136 |
,"Where are your Tcl libraries?" |
,"Where are your Tcl libraries?" |
137 |
,'off' |
,"$TCL/lib" |
138 |
)) |
)) |
139 |
|
|
140 |
# What is the name of the Tcl lib? |
# What is the name of the Tcl lib? |
141 |
opts.Add( |
opts.Add( |
142 |
'TCL_LIB' |
'TCL_LIB' |
143 |
,"Name of Tcl lib (eg 'tcl' or 'tcl83')" |
,"Name of Tcl lib (eg 'tcl' or 'tcl83'), for full path to static library" |
144 |
,default_tcl_lib |
,default_tcl_lib |
145 |
) |
) |
146 |
|
|
161 |
# What is the name of the Tk lib? |
# What is the name of the Tk lib? |
162 |
opts.Add( |
opts.Add( |
163 |
'TK_LIB' |
'TK_LIB' |
164 |
,"Name of Tk lib (eg 'tk' or 'tk83')" |
,"Name of Tk lib (eg 'tk' or 'tk83'), or full path to static library" |
165 |
,default_tk_lib |
,default_tk_lib |
166 |
) |
) |
167 |
|
|
168 |
# Static linking to TkTable |
# Static linking to TkTable |
169 |
|
|
170 |
opts.Add(BoolOption( |
opts.Add(BoolOption( |
171 |
'STATIC_TKTABLE' |
'STATIC_TCLTK' |
172 |
,'Use static linking to TkTable or not' |
,'Set true for static linking for Tcl/Tk and TkTable' |
173 |
,False |
,False |
174 |
)) |
)) |
175 |
|
|
181 |
|
|
182 |
opts.Add( |
opts.Add( |
183 |
'TKTABLE_LIB' |
'TKTABLE_LIB' |
184 |
,'Name of TkTable static library (excluding suffix/prefix, eg libtktable2.8.so -> tktable2.8)' |
,'Stem name of TkTable (eg tktable2.8, no ".so" or "lib") shared library, or full path of static tktable (/usr/lib/...)' |
185 |
,default_tktable_lib |
,default_tktable_lib |
186 |
) |
) |
187 |
|
|
188 |
opts.Add( |
opts.Add( |
189 |
|
'TKTABLE_CPPPATH' |
190 |
|
,'Location of TkTable header file' |
191 |
|
,'$TCL_CPPPATH' |
192 |
|
) |
193 |
|
|
194 |
|
opts.Add( |
195 |
|
'X11' |
196 |
|
,'Base X11 directory' |
197 |
|
,'/usr/X11R6' |
198 |
|
) |
199 |
|
|
200 |
|
opts.Add( |
201 |
|
'X11_LIBPATH' |
202 |
|
,'Location of X11 lib' |
203 |
|
,'$X11/lib' |
204 |
|
) |
205 |
|
|
206 |
|
opts.Add( |
207 |
|
'X11_CPPPATH' |
208 |
|
,'Location of X11 includes' |
209 |
|
,'$X11/include' |
210 |
|
) |
211 |
|
|
212 |
|
opts.Add( |
213 |
|
'X11_LIB' |
214 |
|
,'Name of X11 lib' |
215 |
|
,'X11' |
216 |
|
) |
217 |
|
|
218 |
|
opts.Add( |
219 |
'INSTALL_PREFIX' |
'INSTALL_PREFIX' |
220 |
,'Root location for installed files' |
,'Root location for installed files' |
221 |
,'/usr/local' |
,'/usr/local' |
292 |
print "PATH =",env['ENV']['PATH'] |
print "PATH =",env['ENV']['PATH'] |
293 |
env.Append(CPPPATH=env['ENV']['INCLUDE']) |
env.Append(CPPPATH=env['ENV']['INCLUDE']) |
294 |
env.Append(LIBPATH=env['ENV']['LIB']) |
env.Append(LIBPATH=env['ENV']['LIB']) |
|
#env.Append(CPPDEFINES=['_CRT_SECURE_NO_DEPRECATED','_CRT_SECURE_NO_DEPRECATE']) |
|
295 |
|
|
296 |
opts.Update(env) |
opts.Update(env) |
297 |
opts.Save('options.cache',env) |
opts.Save('options.cache',env) |
317 |
|
|
318 |
env['CAN_INSTALL']=can_install |
env['CAN_INSTALL']=can_install |
319 |
|
|
320 |
|
print "TCL_CPPPATH =",env['TCL_CPPPATH'] |
321 |
|
print "TCL_LIBPATH =",env['TCL_LIBPATH'] |
322 |
|
print "TCL_LIB =",env['TCL_LIB'] |
323 |
|
|
324 |
#------------------------------------------------------ |
#------------------------------------------------------ |
325 |
# SPECIAL CONFIGURATION TESTS |
# SPECIAL CONFIGURATION TESTS |
373 |
# General purpose library-and-header test |
# General purpose library-and-header test |
374 |
|
|
375 |
class KeepContext: |
class KeepContext: |
376 |
def __init__(self,context,varprefix): |
def __init__(self,context,varprefix,static=False): |
377 |
self.keep = {} |
self.keep = {} |
378 |
for k in ['LIBS','LIBPATH','CPPPATH']: |
for k in ['LIBS','LIBPATH','CPPPATH','LINKFLAGS']: |
379 |
if context.env.has_key(k): |
if context.env.has_key(k): |
380 |
self.keep[k] = context.env[k] |
self.keep[k] = context.env[k] |
381 |
else: |
else: |
382 |
self.keep[k] = None |
self.keep[k] = None |
383 |
|
|
|
libpath_add = [] |
|
|
if context.env.has_key(varprefix+'_LIBPATH'): |
|
|
libpath_add = [env[varprefix+'_LIBPATH']] |
|
|
#print "Adding '"+str(libpath_add)+"' to lib path" |
|
|
|
|
|
cpppath_add = [] |
|
384 |
if context.env.has_key(varprefix+'_CPPPATH'): |
if context.env.has_key(varprefix+'_CPPPATH'): |
385 |
cpppath_add = [env[varprefix+'_CPPPATH']] |
context.env.Append(CPPPATH=[env[varprefix+'_CPPPATH']]) |
386 |
#print "Adding '"+str(cpppath_add)+"' to cpp path" |
#print "Adding '"+str(cpppath_add)+"' to cpp path" |
387 |
|
|
388 |
libs_add = [] |
if static: |
389 |
if context.env.has_key(varprefix+'_LIB'): |
staticlib=env[varprefix+'_LIB'] |
390 |
libs_add = [env[varprefix+'_LIB']] |
#print "STATIC LIB = ",staticlib |
391 |
#print "Adding '"+str(libs_add)+"' to libs" |
context.env.Append( |
392 |
|
LINKFLAGS=[staticlib] |
393 |
context.env.Append( |
) |
394 |
LIBPATH = libpath_add |
else: |
395 |
, CPPPATH = cpppath_add |
if context.env.has_key(varprefix+'_LIBPATH'): |
396 |
, LIBS = libs_add |
context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']]) |
397 |
) |
#print "Adding '"+str(libpath_add)+"' to lib path" |
398 |
|
|
399 |
|
if context.env.has_key(varprefix+'_LIB'): |
400 |
|
context.env.Append(LIBS=[env[varprefix+'_LIB']]) |
401 |
|
#print "Adding '"+str(libs_add)+"' to libs" |
402 |
|
|
403 |
def restore(self,context): |
def restore(self,context): |
404 |
#print "RESTORING CONTEXT" |
#print "RESTORING CONTEXT" |
406 |
#print "..." |
#print "..." |
407 |
for k in self.keep: |
for k in self.keep: |
408 |
if self.keep[k]==None: |
if self.keep[k]==None: |
409 |
#print "Clearing "+str(k) |
if context.env.has_key(k): |
410 |
del context.env[k]; |
#print "Clearing "+str(k) |
411 |
|
del context.env[k]; |
412 |
else: |
else: |
413 |
#print "Restoring "+str(k)+" to '"+self.keep[k]+"'" |
#print "Restoring "+str(k)+" to '"+self.keep[k]+"'" |
414 |
context.env[k]=self.keep[k]; |
context.env[k]=self.keep[k]; |
415 |
|
|
416 |
def CheckExtLib(context,libname,text,ext='.c',varprefix=None): |
def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False): |
417 |
"""This method will check for variables LIBNAME_LIBPATH |
"""This method will check for variables LIBNAME_LIBPATH |
418 |
and LIBNAME_CPPPATH and try to compile and link the |
and LIBNAME_CPPPATH and try to compile and link the |
419 |
file with the provided text, linking with the |
file with the provided text, linking with the |
420 |
library libname.""" |
library libname.""" |
421 |
|
|
422 |
context.Message( 'Checking for '+libname+'... ' ) |
if static: |
423 |
|
context.Message( 'Checking for static '+libname+'... ' ) |
424 |
|
else: |
425 |
|
context.Message( 'Checking for '+libname+'... ' ) |
426 |
|
|
427 |
if varprefix==None: |
if varprefix==None: |
428 |
varprefix = libname.upper() |
varprefix = libname.upper() |
429 |
|
|
430 |
keep = KeepContext(context,varprefix) |
keep = KeepContext(context,varprefix,static) |
431 |
|
|
432 |
if not context.env.has_key(varprefix+'_LIB'): |
if not context.env.has_key(varprefix+'_LIB'): |
433 |
# if varprefix_LIB were in env, KeepContext would |
# if varprefix_LIB were in env, KeepContext would |
436 |
|
|
437 |
is_ok = context.TryLink(text,ext) |
is_ok = context.TryLink(text,ext) |
438 |
|
|
439 |
# print "Link success? ",(is_ok != 0) |
#print "Link success? ",(is_ok != 0) |
440 |
|
|
441 |
keep.restore(context) |
keep.restore(context) |
442 |
|
|
544 |
""" |
""" |
545 |
|
|
546 |
def CheckTcl(context): |
def CheckTcl(context): |
547 |
return CheckExtLib(context,'tcl',tcl_check_text) |
return CheckExtLib(context,'tcl',tcl_check_text,static=env['STATIC_TCLTK']) |
548 |
|
|
549 |
def CheckTclVersion(context): |
def CheckTclVersion(context): |
550 |
keep = KeepContext(context,'TCL') |
keep = KeepContext(context,'TCL',static=env['STATIC_TCLTK']) |
551 |
context.Message("Checking Tcl version... ") |
context.Message("Checking Tcl version... ") |
552 |
(is_ok,output) = context.TryRun(tcl_check_text,'.c') |
(is_ok,output) = context.TryRun(tcl_check_text,'.c') |
553 |
keep.restore(context) |
keep.restore(context) |
577 |
} |
} |
578 |
""" |
""" |
579 |
def CheckTk(context): |
def CheckTk(context): |
580 |
return CheckExtLib(context,'tk',tcl_check_text) |
return CheckExtLib(context,'tk',tcl_check_text,static=env['STATIC_TCLTK']) |
581 |
|
|
582 |
|
|
583 |
def CheckTkVersion(context): |
def CheckTkVersion(context): |
584 |
keep = KeepContext(context,'TK') |
keep = KeepContext(context,'TK',static=context.env['STATIC_TCLTK']) |
585 |
context.Message("Checking Tk version... ") |
context.Message("Checking Tk version... ") |
586 |
|
#print "LINKFLAGS =",context.env['LINKFLAGS'] |
587 |
(is_ok,output) = context.TryRun(tk_check_text,'.c') |
(is_ok,output) = context.TryRun(tk_check_text,'.c') |
588 |
keep.restore(context) |
keep.restore(context) |
589 |
if not is_ok: |
if not is_ok: |
600 |
return 1 |
return 1 |
601 |
|
|
602 |
#---------------- |
#---------------- |
603 |
|
# Tktable test |
604 |
|
|
605 |
|
tktable_check_text = r""" |
606 |
|
#include <tkTable.h> |
607 |
|
#include <stdio.h> |
608 |
|
int main(void){ |
609 |
|
Table mytable; |
610 |
|
return 0; |
611 |
|
} |
612 |
|
""" |
613 |
|
|
614 |
|
def CheckTkTable(context): |
615 |
|
return CheckExtLib(context,'tktable',tktable_check_text,static=env['STATIC_TCLTK']) |
616 |
|
|
617 |
|
#--------------- |
618 |
|
# X11 test |
619 |
|
|
620 |
|
x11_check_text = r""" |
621 |
|
#include <X11/Xlib.h> |
622 |
|
#include <X11/IntrinsicP.h> |
623 |
|
#include <X11/Intrinsic.h> |
624 |
|
#include <X11/ObjectP.h> |
625 |
|
#include <X11/Object.h> |
626 |
|
int main(void){ |
627 |
|
Object mything; |
628 |
|
return 0; |
629 |
|
} |
630 |
|
""" |
631 |
|
|
632 |
|
def CheckX11(context): |
633 |
|
return CheckExtLib(context,'X11',x11_check_text) |
634 |
|
|
635 |
|
#---------------- |
636 |
# GCC Version sniffing |
# GCC Version sniffing |
637 |
|
|
638 |
# TODO FIXME |
# TODO FIXME |
653 |
, 'CheckGcc' : CheckGcc |
, 'CheckGcc' : CheckGcc |
654 |
, 'CheckGccVisibility' : CheckGccVisibility |
, 'CheckGccVisibility' : CheckGccVisibility |
655 |
, 'CheckYacc' : CheckYacc |
, 'CheckYacc' : CheckYacc |
656 |
|
, 'CheckTkTable' : CheckTkTable |
657 |
|
, 'CheckX11' : CheckX11 |
658 |
# , 'CheckIsNan' : CheckIsNan |
# , 'CheckIsNan' : CheckIsNan |
659 |
# , 'CheckCppUnitConfig' : CheckCppUnitConfig |
# , 'CheckCppUnitConfig' : CheckCppUnitConfig |
660 |
} |
} |
697 |
if conf.CheckTcl(): |
if conf.CheckTcl(): |
698 |
if with_tcltk_gui and conf.CheckTclVersion(): |
if with_tcltk_gui and conf.CheckTclVersion(): |
699 |
if conf.CheckTk(): |
if conf.CheckTk(): |
700 |
if with_tcltk_gui and not conf.CheckTkVersion(): |
if with_tcltk_gui and conf.CheckTkVersion(): |
701 |
|
if conf.CheckTkTable(): |
702 |
|
pass |
703 |
|
else: |
704 |
|
without_tcltk_reason = "TkTable not found" |
705 |
|
with_tcltk_gui = False |
706 |
|
else: |
707 |
without_tcltk_reason = "Require Tk version <= 8.3. See 'scons -h'" |
without_tcltk_reason = "Require Tk version <= 8.3. See 'scons -h'" |
708 |
with_tcltk_gui = False |
with_tcltk_gui = False |
709 |
else: |
else: |
717 |
without_tcltk_reason = "Tcl not found." |
without_tcltk_reason = "Tcl not found." |
718 |
with_tcltk_gui = False |
with_tcltk_gui = False |
719 |
|
|
720 |
|
if env['STATIC_TCLTK']: |
721 |
|
conf.CheckX11() |
722 |
|
|
723 |
# Python... obviously we're already running python, so we just need to |
# Python... obviously we're already running python, so we just need to |
724 |
# check that we can link to the python library OK: |
# check that we can link to the python library OK: |
725 |
|
|