/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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