/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 438 - (hide annotations) (download)
Tue Apr 4 11:34:34 2006 UTC (13 years, 10 months ago) by johnpye
File size: 18175 byte(s)
Installation instructions and an RPM SPEC file (untested)
1 johnpye 393 import os, commands, platform, distutils.sysconfig, os.path
2 johnpye 385
3     #------------------------------------------------------
4     # OPTIONS
5 johnpye 392 #
6     # Note that if you set the options via the command line, they will be
7     # remembered in the file 'options.cache'. It's a feature ;-)
8 johnpye 385
9     opts = Options(['options.cache', 'config.py'])
10     print "PLATFORM = ",platform.system()
11    
12 johnpye 392 # Import the outside environment
13     env = Environment(ENV=os.environ)
14 johnpye 385
15 johnpye 415 if platform.system()=='Windows' and env.has_key('MSVS'):
16 johnpye 414 print "INCLUDE =",env['ENV']['INCLUDE']
17 johnpye 416 print "LIB =",env['ENV']['LIB']
18     print "LINK =",env['LINK']
19     print "LINKCOM =",env['LINKCOM']
20     print "AR =",env['AR']
21     print "ARCOM =",env['ARCOM']
22 johnpye 427 #env['AR']='link /lib'
23 johnpye 414 env.Append(CPPPATH=env['ENV']['INCLUDE'])
24     env.Append(LIBPATH=env['ENV']['LIB'])
25 johnpye 427 env.Append(CPPDEFINES=['_CRT_SECURE_NO_DEPRECATED','_CRT_SECURE_NO_DEPRECATE'])
26 johnpye 414
27 johnpye 385 # Package linking option
28 johnpye 386 opts.Add(EnumOption(
29     'PACKAGE_LINKING'
30 johnpye 385 , 'Style of linking for external libraries'
31     , 'DYNAMIC_PACKAGES'
32 johnpye 386 , ['DYNAMIC_PACKAGES', 'STATIC_PACKAGES', 'NO_PACKAGES']
33     ))
34 johnpye 385
35 johnpye 392 # You can turn off building of Tcl/Tk interface
36 johnpye 386 opts.Add(BoolOption(
37     'WITHOUT_TCLTK_GUI'
38     ,"Set to True if you don't want to build the original Tcl/Tk GUI."
39     , False
40     ))
41    
42 johnpye 392 # You can turn off the building of the Python interface
43 johnpye 387 opts.Add(BoolOption(
44     'WITHOUT_PYTHON'
45     ,"Set to True if you don't want to build Python wrappers."
46     , False
47     ))
48    
49 johnpye 392 # Which solvers will we allow?
50     opts.Add(ListOption(
51     'WITH_SOLVERS'
52 johnpye 393 ,"List of the solvers you want to build. The default is the minimum that"
53     +" works."
54 johnpye 392 ,["QRSLV","CMSLV"]
55     ,['QRSLV','MPS','SLV','OPTSQP'
56     ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
57     ,'LSOD','OPTSQP'
58     ]
59     ))
60    
61 johnpye 393 # Where will the local copy of the help files be kept?
62     opts.Add(PackageOption(
63     'WITH_LOCAL_HELP'
64     , "Directory containing the local copy of the help files (optional)"
65     , "no"
66     ))
67    
68     # Will bintoken support be enabled?
69     opts.Add(BoolOption(
70     'WITH_BINTOKEN'
71     ,"Enable bintoken support? This means compiling models as C-code before"
72     +" running them, to increase solving speed for large models."
73     ,False
74     ))
75    
76 johnpye 398 # What should the default ASCENDLIBRARY path be?
77     # Note: users can change it by editing their ~/.ascend.ini
78 johnpye 393 opts.Add(
79     'DEFAULT_ASCENDLIBRARY'
80     ,"Set the default value of the ASCENDLIBRARY -- the location where"
81     +" ASCEND will look for models when running ASCEND"
82     ,os.path.expanduser("~/src/ascend/trunk/models")
83     )
84    
85 johnpye 398 # Where is SWIG?
86     opts.Add(
87     'SWIG'
88     ,"SWIG location, probably only required for MinGW and MSVC users."
89     +" Enter the location as a Windows-style path, for example"
90 johnpye 404 +" 'c:\\msys\\1.0\\home\\john\\swigwin-1.3.29\\swig.exe'."
91 johnpye 398 )
92    
93 johnpye 400 # Build the test suite?
94     opts.Add(BoolOption(
95     'WITH_CUNIT_TESTS'
96     ,"Whether to build the CUnit tests. Default is off. If set to on,"
97     +" you must have CUnit installed somewhere that SCons can"
98     +" find it."
99     ,False
100     ))
101 johnpye 393
102 johnpye 400 # Where are the CUnit includes?
103     opts.Add(PackageOption(
104     'CUNIT_CPPPATH'
105     ,"Where are your CUnit include files?"
106     ,"off"
107     ))
108 johnpye 392
109 johnpye 404 # Where are the CUnit libraries?
110 johnpye 400 opts.Add(PackageOption(
111     'CUNIT_LIBPATH'
112 johnpye 404 ,"Where are your CUnit libraries?"
113 johnpye 400 ,"off"
114     ))
115    
116 johnpye 404 # Where are the Tcl includes?
117     opts.Add(PackageOption(
118     'TCL_CPPPATH'
119     ,"Where are your Tcl include files?"
120     ,None
121     ))
122    
123     # Where are the Tcl libs?
124     opts.Add(PackageOption(
125     'TCL_LIBPATH'
126     ,"Where are your Tcl libraries?"
127     ,None
128     ))
129    
130 johnpye 428 # What is the name of the Tcl lib?
131     opts.Add(
132     'TCL_LIB'
133     ,"Name of Tcl lib (eg 'tcl' or 'tcl83')"
134     ,'tcl'
135     )
136    
137 johnpye 405 # Where are the Tk includes?
138     opts.Add(PackageOption(
139     'TK_CPPPATH'
140     ,"Where are your Tk include files?"
141     ,None
142     ))
143 johnpye 404
144 johnpye 405 # Where are the Tk libs?
145     opts.Add(PackageOption(
146     'TK_LIBPATH'
147     ,"Where are your Tk libraries?"
148     ,None
149     ))
150    
151 johnpye 428 # What is the name of the Tk lib?
152     opts.Add(
153     'TK_LIB'
154     ,"Name of Tk lib (eg 'tk' or 'tk83')"
155     ,'tk'
156 johnpye 435 )
157    
158     opts.Add(
159     'INSTALL_PREFIX'
160     ,'Root location for installed files'
161     ,'/usr'
162 johnpye 428 )
163    
164 johnpye 435 opts.Add(
165     'INSTALL_BIN'
166     ,'Location to put binaries during installation'
167     ,"$INSTALL_PREFIX/bin"
168     )
169    
170     opts.Add(
171     'INSTALL_DATA'
172     ,'Location to put data files during installation'
173     ,"$INSTALL_PREFIX/share"
174     )
175    
176     opts.Add(
177     'INSTALL_INCLUDE'
178     ,'Location to put header files during installation'
179     ,"$INSTALL_PREFIX/include"
180     )
181    
182 johnpye 392 # TODO: OTHER OPTIONS?
183     # TODO: flags for optimisation
184 johnpye 393 # TODO: turning on/off bintoken functionality
185 johnpye 427 # TODO: Where will the 'Makefile.bt' file be installed?
186 johnpye 393
187 johnpye 385 opts.Update(env)
188     opts.Save('options.cache',env)
189    
190     Help(opts.GenerateHelpText(env))
191    
192 johnpye 386 with_tcltk_gui = (env['WITHOUT_TCLTK_GUI']==False)
193 johnpye 427 without_tcltk_reason = "disabled by options/config.py"
194 johnpye 386
195 johnpye 387 with_python = (env['WITHOUT_PYTHON']==False)
196 johnpye 427 without_python_reason = "disabled by options/config.py"
197 johnpye 387
198 johnpye 400 with_cunit_tests = env['WITH_CUNIT_TESTS']
199 johnpye 427 without_cunit_reason = "not requested"
200 johnpye 400
201 johnpye 392 print "SOLVERS:",env['WITH_SOLVERS']
202 johnpye 393 print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']
203     print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
204     print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
205    
206     subst_dict = {
207     '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'
208 johnpye 436 , '@GLADE_FILE@':'ascend.glade'
209 johnpye 393 , '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
210 johnpye 436 , '@ASCEND_ICON@':'ascend.png'
211 johnpye 393 , '@HELP_ROOT@':''
212 johnpye 436 , '@INSTALL_DATA@':env['INSTALL_DATA']
213     , '@INSTALL_BIN@':env['INSTALL_BIN']
214     , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
215 johnpye 393 }
216    
217     if env['WITH_LOCAL_HELP']:
218     subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']
219    
220     env.Append(SUBST_DICT=subst_dict)
221    
222 johnpye 385 #------------------------------------------------------
223 johnpye 398 # SPECIAL CONFIGURATION TESTS
224    
225 johnpye 400 #----------------
226     # SWIG
227    
228 johnpye 398 import os,re
229    
230 johnpye 427 need_fortran = False
231    
232 johnpye 413 def get_swig_version(env):
233 johnpye 403 cmd = env['SWIG']+' -version'
234 johnpye 427 (cin,coutcerr) = os.popen4(cmd)
235 johnpye 403 output = coutcerr.read()
236 johnpye 398
237 johnpye 403 restr = "SWIG\\s+Version\\s+(?P<maj>[0-9]+)\\.(?P<min>[0-9]+)\\.(?P<pat>[0-9]+)\\s*$"
238     expr = re.compile(restr,re.M);
239 johnpye 398 m = expr.search(output);
240     if not m:
241 johnpye 413 return None
242 johnpye 398 maj = int(m.group('maj'))
243     min = int(m.group('min'))
244     pat = int(m.group('pat'))
245 johnpye 413
246     return (maj,min,pat)
247 johnpye 398
248 johnpye 413
249     def CheckSwigVersion(context):
250    
251     try:
252     context.Message("Checking version of SWIG... ")
253     maj,min,pat = get_swig_version(context.env)
254     except:
255     context.Result("Failed to detect version, or failed to run SWIG")
256     return 0;
257    
258 johnpye 398 if maj == 1 and (
259 johnpye 400 min > 3
260     or (min == 3 and pat >= 24)
261 johnpye 398 ):
262     context.Result("ok, %d.%d.%d" % (maj,min,pat))
263     return 1;
264 johnpye 401 else:
265     context.Result("too old, %d.%d.%d" % (maj,min,pat))
266     return 0;
267 johnpye 398
268 johnpye 400 #----------------
269     # General purpose library-and-header test
270    
271 johnpye 404 class KeepContext:
272     def __init__(self,context,varprefix):
273     self.keep = {}
274     for k in ['LIBS','LIBPATH','CPPPATH']:
275     if context.env.has_key(k):
276     self.keep[k] = context.env[k]
277    
278     libpath_add = []
279     if context.env.has_key(varprefix+'_LIBPATH'):
280     libpath_add = [env[varprefix+'_LIBPATH']]
281 johnpye 428 #print "Adding '"+str(libpath_add)+"' to lib path"
282 johnpye 400
283 johnpye 404 cpppath_add = []
284     if context.env.has_key(varprefix+'_CPPPATH'):
285     cpppath_add = [env[varprefix+'_CPPPATH']]
286 johnpye 428 #print "Adding '"+str(cpppath_add)+"' to cpp path"
287    
288     libs_add = []
289     if context.env.has_key(varprefix+'_LIB'):
290     libs_add = [env[varprefix+'_LIB']]
291     #print "Adding '"+str(libs_add)+"' to libs"
292    
293 johnpye 405 context.env.Append(
294     LIBPATH = libpath_add
295     , CPPPATH = cpppath_add
296 johnpye 428 , LIBS = libs_add
297 johnpye 405 )
298 johnpye 404
299     def restore(self,context):
300     for k in self.keep:
301     context.env[k]=self.keep[k];
302    
303 johnpye 400 def CheckExtLib(context,libname,text,ext='.c',varprefix=None):
304     """This method will check for variables LIBNAME_LIBPATH
305     and LIBNAME_CPPPATH and try to compile and link the
306     file with the provided text, linking with the
307     library libname."""
308    
309 johnpye 405 context.Message( 'Checking for '+libname+'... ' )
310 johnpye 400
311     if varprefix==None:
312     varprefix = libname.upper()
313    
314 johnpye 404 keep = KeepContext(context,varprefix)
315 johnpye 400
316 johnpye 428 # print "TryLink with CPPPATH="+str(context.env['CPPPATH'])
317     # print "TryLink with LIBS="+str(context.env['LIBS'])
318     # print "TryLink with LIBPATH="+str(context.env['LIBPATH'])
319 johnpye 405
320 johnpye 428 if not context.env.has_key(varprefix+'_LIB'):
321     context.env.AppendUnique(LIBS=libname)
322    
323 johnpye 404 is_ok = context.TryLink(text,ext)
324 johnpye 428
325     # print "Link success? ",(is_ok != 0)
326 johnpye 400
327 johnpye 405 keep.restore(context)
328 johnpye 400
329 johnpye 428 # print "Restored CPPPATH="+str(context.env['CPPPATH'])
330     # print "Restored LIBS="+libname
331     # print "Restored LIBPATH="+str(context.env['LIBPATH'])
332    
333 johnpye 404 context.Result(is_ok)
334     return is_ok
335    
336     #----------------
337     # CUnit test
338    
339 johnpye 400 cunit_test_text = """
340     #include <CUnit/Cunit.h>
341     int maxi(int i1, int i2){
342     return (i1 > i2) ? i1 : i2;
343     }
344    
345     void test_maxi(void){
346     CU_ASSERT(maxi(0,2) == 2);
347     CU_ASSERT(maxi(0,-2) == 0);
348     CU_ASSERT(maxi(2,2) == 2);
349    
350     }
351     int main(void){
352     /* CU_initialize_registry() */
353 johnpye 404 return 0;
354 johnpye 400 }
355     """
356    
357     def CheckCUnit(context):
358 johnpye 412 return context.CheckExtLib(context
359 johnpye 400 ,'cunit'
360     ,cunit_test_text
361     )
362    
363 johnpye 404 #----------------
364 johnpye 405 # Tcl test
365 johnpye 404
366     tcl_check_text = r"""
367     #include <tcl.h>
368     #include <stdio.h>
369     int main(void){
370     printf("%s",TCL_PATCH_LEVEL);
371     return 0;
372     }
373     """
374    
375     def CheckTcl(context):
376 johnpye 405 return CheckExtLib(context,'tcl',tcl_check_text)
377    
378     def CheckTclVersion(context):
379 johnpye 404 keep = KeepContext(context,'TCL')
380 johnpye 405 context.Message("Checking Tcl version... ")
381     (is_ok,output) = context.TryRun(tcl_check_text,'.c')
382 johnpye 404 keep.restore(context)
383     if not is_ok:
384 johnpye 405 context.Result("failed to run check")
385 johnpye 404 return 0
386 johnpye 405
387     major,minor,patch = tuple(int(i) for i in output.split("."))
388     if major != 8 or minor > 3:
389 johnpye 428 context.Result(output+" (bad version)")
390 johnpye 405 # bad version
391     return 0
392    
393     # good version
394 johnpye 428 context.Result(output+" (good)")
395 johnpye 404 return 1
396    
397 johnpye 405 #----------------
398     # Tcl test
399    
400     tk_check_text = r"""
401     #include <tk.h>
402     #include <stdio.h>
403     int main(void){
404     printf("%s",TK_PATCH_LEVEL);
405     return 0;
406     }
407     """
408     def CheckTk(context):
409 johnpye 428 return CheckExtLib(context,'tk',tcl_check_text)
410 johnpye 405
411 johnpye 428
412 johnpye 405 def CheckTkVersion(context):
413     keep = KeepContext(context,'TK')
414     context.Message("Checking Tk version... ")
415     (is_ok,output) = context.TryRun(tk_check_text,'.c')
416 johnpye 404 keep.restore(context)
417     if not is_ok:
418     context.Result("failed to run check")
419     return 0
420     context.Result(output)
421    
422     major,minor,patch = tuple(int(i) for i in output.split("."))
423     if major != 8 or minor > 3:
424     # bad version
425     return 0
426 johnpye 400
427 johnpye 404 # good version
428     return 1
429    
430 johnpye 398 #------------------------------------------------------
431 johnpye 385 # CONFIGURATION
432    
433     conf = Configure(env
434     , custom_tests = {
435 johnpye 398 'CheckSwigVersion' : CheckSwigVersion
436 johnpye 400 , 'CheckCUnit' : CheckCUnit
437 johnpye 404 , 'CheckTcl' : CheckTcl
438     , 'CheckTclVersion' : CheckTclVersion
439 johnpye 405 , 'CheckTk' : CheckTk
440     , 'CheckTkVersion' : CheckTkVersion
441 johnpye 400 # , 'CheckIsNan' : CheckIsNan
442     # , 'CheckCppUnitConfig' : CheckCppUnitConfig
443 johnpye 385 }
444     , config_h = "config.h"
445     )
446    
447 johnpye 398
448 johnpye 385 # Math library
449    
450 johnpye 427 #if not conf.CheckFunc('sinh') and not conf.CheckLibWithHeader(['m','c','libc'], 'math.h', 'C'):
451     # print 'Did not find math library, exiting!'
452     # Exit(1)
453    
454 johnpye 385 # Where is 'isnan'?
455    
456     if not conf.CheckFunc('isnan'):
457     print "Didn't find isnan"
458 johnpye 414 # Exit(1)
459 johnpye 385
460 johnpye 387 # Tcl/Tk
461 johnpye 386
462 johnpye 428 if conf.CheckTcl():
463     if with_tcltk_gui and conf.CheckTclVersion():
464     if conf.CheckTk():
465     if with_tcltk_gui and not conf.CheckTkVersion():
466     without_tcltk_reason = "Require Tk version <= 8.3. See 'scons -h'"
467     with_tcltk_gui = False
468     else:
469     without_tcltk_reason = "Tk not found."
470     with_tcltk_gui = False
471     else:
472 johnpye 405 without_tcltk_reason = "Require Tcl <= 8.3 Tcl."
473 johnpye 404 with_tcltk_gui = False
474 johnpye 386
475 johnpye 405 else:
476 johnpye 428 without_tcltk_reason = "Tcl not found."
477 johnpye 412 with_tcltk_gui = False
478    
479 johnpye 395 # Python... obviously we're already running python, so we just need to
480     # check that we can link to the python library OK:
481    
482 johnpye 391 if platform.system()=="Windows":
483 johnpye 395 python_lib='python24'
484 johnpye 391 else:
485 johnpye 395 python_lib='python2.4'
486 johnpye 391
487 johnpye 395 # SWIG version
488    
489 johnpye 396 if platform.system()=="Windows":
490     env['ENV']['SWIGFEATURES']='-O'
491     else:
492     env['ENV']['SWIGFEATURES']='-O'
493 johnpye 395
494 johnpye 413
495     if not conf.CheckSwigVersion():
496     without_python_reason = 'SWIG >= 1.3.24 is required'
497     with_python = False
498    
499 johnpye 400 # CUnit
500    
501     if with_cunit_tests:
502 johnpye 404 if not conf.CheckCUnit():
503 johnpye 427 without_cunit_reason = 'CUnit not found'
504    
505     # BLAS
506    
507     if conf.CheckLib('blas'):
508     print "FOUND BLAS"
509     with_local_blas = False
510     without_local_blas_reason = "Found BLAS installed on system"
511     else:
512     print "DIDN'T FIND BLAS"
513     with_local_blas = True
514     need_fortran = True
515    
516     # FORTRAN
517    
518     if need_fortran:
519     conf.env.Tool('f77')
520     detect_fortran = conf.env.Detect(['g77','f77'])
521     if detect_fortran:
522     # For some reason, g77 doesn't get detected properly on MinGW
523     if not env.has_key('F77'):
524     conf.env.Replace(F77=detect_fortran)
525     conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
526     conf.env.Replace(F77FLAGS='')
527 johnpye 428 #print "F77:",conf.env['F77']
528     #print "F77COM:",conf.env['F77COM']
529     #print "F77FLAGS:",conf.env['F77FLAGS']
530 johnpye 427 fortran_builder = Builder(
531     action='$F77COM'
532     , suffix='.o'
533     , src_suffix='.f'
534     )
535     conf.env.Append(BUILDERS={'Fortran':fortran_builder})
536     else:
537     print "FORTRAN-77 required but not found"
538 johnpye 404 Exit(1)
539 johnpye 427 else:
540     print "FORTRAN not required"
541 johnpye 400
542 johnpye 385 # TODO: -D_HPUX_SOURCE is needed
543    
544     # TODO: check size of void*
545    
546 johnpye 393 # TODO: detect if dynamic libraries are possible or not
547    
548 johnpye 427 if platform.system()=="Windows" and env.has_key('MSVS'):
549     if not conf.CheckHeader('windows.h') and env['PACKAGE_LINKING']=='DYNAMIC_PACKAGES':
550     print "Reverting to STATIC_PACKAGES since windows.h is not available. Probably you "\
551     +"need to install the Microsoft Windows Server 2003 Platform SDK, or similar."
552     env['PACKAGE_LINKING']='STATIC_PACKAGES'
553    
554     if with_python and not conf.CheckHeader('basetsd.h'):
555     with_python = 0;
556     without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
557    
558     conf.env.Append(CPPDEFINES=env['PACKAGE_LINKING'])
559    
560 johnpye 395 conf.Finish()
561    
562     env.Append(PYTHON_LIBPATH=[distutils.sysconfig.PREFIX+"/libs"])
563     env.Append(PYTHON_LIB=[python_lib])
564     env.Append(PYTHON_CPPPATH=[distutils.sysconfig.get_python_inc()])
565    
566 johnpye 385 #------------------------------------------------------
567 johnpye 393 # RECIPE: 'SubstInFile', used in pygtk SConscript
568    
569     import re
570 johnpye 395 from SCons.Script import * # the usual scons stuff you get in a SConscript
571 johnpye 393
572 johnpye 395 def TOOL_SUBST(env):
573     """Adds SubstInFile builder, which substitutes the keys->values of SUBST_DICT
574     from the source to the target.
575     The values of SUBST_DICT first have any construction variables expanded
576     (its keys are not expanded).
577     If a value of SUBST_DICT is a python callable function, it is called and
578     the result is expanded as the value.
579     If there's more than one source and more than one target, each target gets
580     substituted from the corresponding source.
581 johnpye 393 """
582 johnpye 395 env.Append(TOOLS = 'SUBST')
583     def do_subst_in_file(targetfile, sourcefile, dict):
584     """Replace all instances of the keys of dict with their values.
585     For example, if dict is {'%VERSION%': '1.2345', '%BASE%': 'MyProg'},
586     then all instances of %VERSION% in the file will be replaced with 1.2345 etc.
587     """
588     try:
589     f = open(sourcefile, 'rb')
590     contents = f.read()
591     f.close()
592     except:
593     raise SCons.Errors.UserError, "Can't read source file %s"%sourcefile
594     for (k,v) in dict.items():
595     contents = re.sub(k, v, contents)
596     try:
597     f = open(targetfile, 'wb')
598     f.write(contents)
599     f.close()
600     except:
601     raise SCons.Errors.UserError, "Can't write target file %s"%targetfile
602     return 0 # success
603 johnpye 393
604 johnpye 395 def subst_in_file(target, source, env):
605     if not env.has_key('SUBST_DICT'):
606     raise SCons.Errors.UserError, "SubstInFile requires SUBST_DICT to be set."
607     d = dict(env['SUBST_DICT']) # copy it
608     for (k,v) in d.items():
609     if callable(v):
610     d[k] = env.subst(v())
611     elif SCons.Util.is_String(v):
612     d[k]=env.subst(v)
613     else:
614     raise SCons.Errors.UserError, "SubstInFile: key %s: %s must be a string or callable"%(k, repr(v))
615     for (t,s) in zip(target, source):
616     return do_subst_in_file(str(t), str(s), d)
617 johnpye 393
618 johnpye 395 def subst_in_file_string(target, source, env):
619     """This is what gets printed on the console."""
620     return '\n'.join(['Substituting vars from %s into %s'%(str(s), str(t))
621     for (t,s) in zip(target, source)])
622 johnpye 393
623 johnpye 395 def subst_emitter(target, source, env):
624     """Add dependency from substituted SUBST_DICT to target.
625     Returns original target, source tuple unchanged.
626     """
627     d = env['SUBST_DICT'].copy() # copy it
628     for (k,v) in d.items():
629     if callable(v):
630     d[k] = env.subst(v())
631     elif SCons.Util.is_String(v):
632     d[k]=env.subst(v)
633     Depends(target, SCons.Node.Python.Value(d))
634     return target, source
635 johnpye 393
636 johnpye 395 subst_action=SCons.Action.Action(subst_in_file, subst_in_file_string)
637     env['BUILDERS']['SubstInFile'] = Builder(action=subst_action, emitter=subst_emitter)
638    
639     TOOL_SUBST(env)
640    
641 johnpye 393 #------------------------------------------------------
642 johnpye 385 # SUBDIRECTORIES....
643    
644 johnpye 393
645 johnpye 385 env.Append(CPPPATH=['..'])
646    
647     env.SConscript(['base/generic/general/SConscript'],'env')
648    
649     env.SConscript(['base/generic/utilities/SConscript'],'env')
650    
651     env.SConscript(['base/generic/compiler/SConscript'],'env')
652    
653     env.SConscript(['base/generic/solver/SConscript'],'env')
654    
655     env.SConscript(['base/generic/packages/SConscript'],'env')
656 johnpye 386
657     if with_tcltk_gui:
658     env.SConscript(['tcltk98/generic/interface/SConscript'],'env')
659 johnpye 391 else:
660 johnpye 405 print "Skipping... Tcl/Tk GUI isn't being built:",without_tcltk_reason
661 johnpye 386
662 johnpye 387 if with_python:
663     env.SConscript(['pygtk/interface/SConscript'],'env')
664 johnpye 391 else:
665 johnpye 413 print "Skipping... Python GUI isn't being built:",without_python_reason
666 johnpye 400
667     if with_cunit_tests:
668     testdirs = ['general','solver','utilities']
669     for testdir in testdirs:
670     path = 'base/generic/'+testdir+'/test/'
671     env.SConscript([path+'SConscript'],'env')
672     env.SConscript(['test/SConscript'],'env')
673     env.SConscript(['base/generic/test/SConscript'],'env')
674    
675    
676     else:
677 johnpye 427 print "Skipping... CUnit tests aren't being built:",without_cunit_reason
678 johnpye 400
679 johnpye 427 #if with_tcltk_gui:
680     if with_local_blas:
681     env.SConscript(['blas/SConscript'],'env')
682     else:
683     print "Skipping... BLAS won't be build:", without_local_blas_reason
684    
685     env.SConscript(['lsod/SConscript'],'env')
686    
687     env.SConscript(['linpack/SConscript'],'env')
688    
689 johnpye 400 #------------------------------------------------------
690     # INSTALLATION
691    
692 johnpye 435 install_dirs = [env['INSTALL_BIN']]+[env['INSTALL_DATA']]
693    
694 johnpye 400 # TODO: add install options
695 johnpye 435 env.Alias('install',install_dirs)
696 johnpye 438
697     #------------------------------------------------------
698     # CREATE the SPEC file for generation of RPM packages
699    
700     env.SubsInFile('ascend.spec.in')

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22