/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1469 - (show annotations) (download)
Sun Jun 3 09:43:16 2007 UTC (15 years, 6 months ago) by jpye
File size: 53436 byte(s)
Fixing LyX detection?
(this commit equals 0.9.5.111)
1 import sys, os, commands, platform, distutils.sysconfig, os.path, re
2
3 version = "0.9.5.111"
4
5 pyversion = "%d.%d" % (sys.version_info[0],sys.version_info[1])
6
7 #------------------------------------------------------
8 # OPTIONS
9 #
10 # Note that if you set the options via the command line, they will be
11 # remembered in the file 'options.cache'. It's a feature ;-)
12
13 opts = Options(['options.cache', 'config.py'])
14 #print "PLATFORM = ",platform.system()
15
16 if platform.system()=="Windows":
17 default_tcl_lib = "tcl84"
18 default_tk_lib = "tk84"
19 default_tktable_lib = "Tktable28"
20 default_install_assets = "glade/"
21 icon_extension = '.png'
22 default_tcl = "c:\\Tcl"
23 if os.environ.get('MSYSTEM')=="MINGW32":
24 default_tcl_libpath="$TCL\\bin"
25 else:
26 default_tcl_libpath="$TCL\\lib"
27 default_rel_distdir = '.'
28 default_absolute_paths = False
29
30 default_ida_prefix = "c:\\MinGW"
31 if not os.path.exists(default_ida_prefix):
32 default_ida_prefix = None
33
34 default_conopt_prefix = "c:\\Program Files\\CONOPT"
35 default_conopt_libpath="$CONOPT_PREFIX"
36 default_conopt_cpppath="$CONOPT_PREFIX"
37 default_conopt_dlpath="$CONOPT_PREFIX"
38 default_conopt_lib="conopt3"
39 default_conopt_envvar="CONOPT_PATH"
40
41 default_prefix="c:\\MinGW"
42 default_libpath="$DEFAULT_PREFIX\\lib"
43 default_cpppath="$DEFAULT_PREFIX\\include"
44
45 if not os.path.exists(default_conopt_prefix):
46 default_conopt_prefix = None
47
48 need_libm = False
49 python_exe = "c:\\Python24\\python.exe"
50 default_with_scrollkeeper=False
51 else:
52 default_tcl_lib = "tcl8.4"
53 default_tk_lib = "tk8.4"
54 default_tktable_lib = "Tktable2.8"
55 default_install_assets = "$INSTALL_ASCDATA/glade/"
56 icon_extension = '.svg'
57 default_tcl = '/usr'
58 default_tcl_libpath = "$TCL/lib"
59 default_rel_distdir = '../share/ascend'
60 default_absolute_paths = True
61 default_ida_prefix="/usr"
62 default_conopt_prefix="/usr"
63 default_conopt_libpath="$CONOPT_PREFIX/lib"
64 default_conopt_cpppath="$CONOPT_PREFIX/include"
65 default_conopt_dlpath= default_conopt_libpath + ":/usr/local/lib"
66 default_conopt_lib="consub3"
67 default_conopt_envvar="CONOPT_PATH"
68
69 default_prefix="/usr"
70 default_libpath="$DEFAULT_PREFIX/lib"
71 default_cpppath="$DEFAULT_PREFIX/include"
72
73 need_libm = True
74 if not os.path.isdir(default_tcl):
75 default_tcl = '/usr'
76 python_exe = distutils.sysconfig.EXEC_PREFIX+"/bin/python"
77 default_with_scrollkeeper=False
78
79 opts.Add(
80 'CC'
81 ,'C Compiler command'
82 ,None
83 )
84
85 opts.Add(
86 'CXX'
87 ,'C++ Compiler command'
88 ,None
89 )
90
91 opts.Add(BoolOption(
92 'GCOV'
93 , 'Whether to enable coverage testing in object code'
94 , False
95 ))
96
97 # Package linking option
98 opts.Add(EnumOption(
99 'PACKAGE_LINKING'
100 , 'Style of linking for external libraries'
101 , 'DYNAMIC_PACKAGES'
102 , ['DYNAMIC_PACKAGES', 'STATIC_PACKAGES', 'NO_PACKAGES']
103 ))
104
105 opts.Add(BoolOption(
106 'WITH_GCCVISIBILITY'
107 ,"Whether to use GCC Visibility features (only applicable if available)"
108 ,True
109 ))
110
111 opts.Add(BoolOption(
112 'WITH_SIGNALS'
113 ,"Whether to permit use of signals for flow control in the C-level code"
114 ,True
115 ))
116
117 # You can turn off building of Tcl/Tk interface
118 opts.Add(BoolOption(
119 'WITH_TCLTK'
120 ,"Set to False if you don't want to build the original Tcl/Tk GUI."
121 , True
122 ))
123
124 # You can turn off the building of the Python interface
125 opts.Add(BoolOption(
126 'WITH_PYTHON'
127 ,"Set to False if you don't want to build Python wrappers."
128 , True
129 ))
130
131 # Which solvers will we allow?
132 opts.Add(ListOption(
133 'WITH_SOLVERS'
134 ,"List of the solvers you want to build. The default is the minimum that"
135 +" works."
136 ,["QRSLV","CMSLV","LSOD","IDA","CONOPT","LRSLV"]
137 ,['QRSLV','MPS','SLV','OPTSQP'
138 ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
139 ,'LSOD','OPTSQP',"IDA"
140 ]
141 ))
142
143 # Where will the local copy of the help files be kept?
144 opts.Add(BoolOption(
145 'WITH_DOC'
146 , "Should we try to build and install help files? If not, ASCEND will access online help files"
147 , True
148 ))
149
150 opts.Add(BoolOption(
151 'WITH_DOC_BUILD'
152 , "If true, we'll attempt to build docs. Set false, we'll assume we already have then (eg from the tarball)"
153 , "$WITH_DOC"
154 ))
155
156 opts.Add(BoolOption(
157 'WITH_DOC_INSTALL'
158 , "If true, SCons will install the documentation file(s). If false, assume rpm or dpkg is going to do it."
159 , "$WITH_DOC"
160 ))
161
162 opts.Add(
163 'HELP_ROOT'
164 , "Location of the main help file"
165 , "$INSTALL_DOC/book.pdf"
166 )
167
168 # Will bintoken support be enabled?
169 opts.Add(BoolOption(
170 'WITH_BINTOKEN'
171 ,"Enable bintoken support? This means compiling models as C-code before"
172 +" running them, to increase solving speed for large models."
173 ,False
174 ))
175
176 # What should the default ASCENDLIBRARY path be?
177 # Note: users can change it by editing their ~/.ascend.ini
178 opts.Add(
179 'DEFAULT_ASCENDLIBRARY'
180 ,"Set the default value of the ASCENDLIBRARY -- the location where"
181 +" ASCEND will look for models when running ASCEND"
182 ,"$INSTALL_ASCDATA/models"
183 )
184
185 # Where is SWIG?
186 opts.Add(
187 'SWIG'
188 ,"SWIG location, probably only required for MinGW and MSVC users."
189 +" Enter the location as a Windows-style path, for example"
190 +" 'c:\\msys\\1.0\\home\\john\\swigwin-1.3.29\\swig.exe'."
191 )
192
193 # Build the test suite?
194 opts.Add(BoolOption(
195 'WITH_CUNIT'
196 ,"You can disable CUnit tests with this option. This will basically stop"
197 +" SCons from parsing the SConscript files relating to the 'test'"
198 +" target, which just might make things marginally faster. Probably"
199 +" you can just ignore this option though. SCons will sniff for Cunit"
200 +" but build the tests only if you specify the 'test' target."
201 ,True
202 ))
203
204 # Build with MMIO matrix export support?
205 opts.Add(BoolOption(
206 'WITH_MMIO'
207 ,"Include support for exporting matrices in Matrix Market format"
208 ,True
209 ))
210
211 #----- default paths -----
212 opts.Add(PackageOption(
213 'DEFAULT_PREFIX'
214 ,"Where are most of the shared libraries located on your system?"
215 ,default_prefix
216 ))
217
218 #------ install location for python extensions ------
219
220 # (removed for the moment)
221
222 #------ cunit --------
223 # Where was CUNIT installed?
224 opts.Add(PackageOption(
225 'CUNIT_PREFIX'
226 ,"Where are your CUnit files?"
227 ,"$DEFAULT_PREFIX"
228 ))
229
230 # Where are the CUnit includes?
231 opts.Add(PackageOption(
232 'CUNIT_CPPPATH'
233 ,"Where are your CUnit include files?"
234 ,"$CUNIT_PREFIX/include"
235 ))
236
237 # Where are the CUnit libraries?
238 opts.Add(PackageOption(
239 'CUNIT_LIBPATH'
240 ,"Where are your CUnit libraries?"
241 ,"$CUNIT_PREFIX/lib"
242 ))
243
244 #-------- ida -------
245
246 opts.Add(PackageOption(
247 "SUNDIALS_PREFIX"
248 ,"Prefix for your IDA install (IDA ./configure --prefix)"
249 ,default_ida_prefix
250 ))
251
252 opts.Add(
253 'SUNDIALS_CPPPATH'
254 ,"Where is your ida.h?"
255 ,"$SUNDIALS_PREFIX/include"
256 )
257
258 #
259 opts.Add(
260 'SUNDIALS_LIBPATH'
261 ,"Where are your SUNDIALS libraries installed?"
262 ,"$SUNDIALS_PREFIX/lib"
263 )
264
265 opts.Add(
266 'SUNDIALS_LIBS'
267 ,"Where are your SUNDIALS libraries installed?"
268 ,['sundials_nvecserial','sundials_ida','m']
269 )
270
271 # ----- conopt-----
272
273 opts.Add(PackageOption(
274 "CONOPT_PREFIX"
275 ,"Prefix for your CONOPT install (CONOPT ./configure --prefix)"
276 ,default_conopt_prefix
277 ))
278
279 opts.Add(
280 "CONOPT_LIB"
281 ,"Library linked to for CONOPT"
282 ,default_conopt_lib
283 )
284
285 opts.Add(
286 'CONOPT_CPPPATH'
287 ,"Where is your conopt.h?"
288 ,default_conopt_cpppath
289 )
290
291 opts.Add(
292 'CONOPT_LIBPATH'
293 ,"Where is your CONOPT library installed?"
294 ,default_conopt_libpath
295 )
296
297 opts.Add(
298 'CONOPT_DLPATH'
299 ,"What is the default search path that ASCEND should use when dlopening the CONOPT library at runtime?"
300 ,default_conopt_dlpath
301 )
302
303 opts.Add(
304 'CONOPT_ENVVAR'
305 ,"What environment variable should be used at runtime to override the default search location for CONOPT DLL/SO?"
306 ,default_conopt_envvar
307 )
308
309 #-------- f2c ------
310
311 opts.Add(
312 "F2C_LIB"
313 ,"F2C library (eg. g2c, gfortran, f2c)"
314 ,"gfortran" # the default is gfortran now
315 )
316
317 opts.Add(PackageOption(
318 "F2C_LIBPATH"
319 ,"Directory containing F2C library (i.e. g2c, gfortran, f2c, etc.), if not already accessible"
320 ,"off"
321 ))
322
323 opts.Add(
324 "FORTRAN"
325 ,"Fortran compiler (eg g77, gfortran)"
326 ,"gfortran"
327 )
328
329 #------- tcl/tk --------
330
331 opts.Add(
332 'TCL'
333 ,'Base of Tcl distribution'
334 ,default_tcl
335 )
336
337 # Where are the Tcl includes?
338 opts.Add(
339 'TCL_CPPPATH'
340 ,"Where are your Tcl include files?"
341 ,"$TCL/include"
342 )
343
344 # Where are the Tcl libs?
345 opts.Add(
346 'TCL_LIBPATH'
347 ,"Where are your Tcl libraries?"
348 ,default_tcl_libpath
349 )
350
351 # What is the name of the Tcl lib?
352 opts.Add(
353 'TCL_LIB'
354 ,"Name of Tcl lib (eg 'tcl' or 'tcl83'), for full path to static library (if STATIC_TCLTK is set)"
355 ,default_tcl_lib
356 )
357
358 # Where are the Tk includes?
359 opts.Add(
360 'TK_CPPPATH'
361 ,"Where are your Tk include files?"
362 ,'$TCL_CPPPATH'
363 )
364
365 # Where are the Tk libs?
366 opts.Add(
367 'TK_LIBPATH'
368 ,"Where are your Tk libraries?"
369 ,'$TCL_LIBPATH'
370 )
371
372 # What is the name of the Tk lib?
373 opts.Add(
374 'TK_LIB'
375 ,"Name of Tk lib (eg 'tk' or 'tk83'), or full path to static library"
376 ,default_tk_lib
377 )
378
379 # Static linking to TkTable
380
381 opts.Add(BoolOption(
382 'STATIC_TCLTK'
383 ,'Set true for static linking for Tcl/Tk and TkTable. EXPERIMENTAL'
384 ,False
385 ))
386
387 opts.Add(
388 'TKTABLE_LIBPATH'
389 ,'Location of TkTable static library'
390 ,'$TCL_LIBPATH/Tktable2.8'
391 )
392
393 opts.Add(
394 'TKTABLE_LIB'
395 ,'Stem name of TkTable (eg tktable2.8, no ".so" or "lib") shared library, or full path of static tktable (/usr/lib/...)'
396 ,default_tktable_lib
397 )
398
399 opts.Add(
400 'TKTABLE_CPPPATH'
401 ,'Location of TkTable header file'
402 ,'$TCL_CPPPATH'
403 )
404
405 opts.Add(
406 'X11'
407 ,'Base X11 directory. Only used when STATIC_TCLTK is turned on. EXPERIMENTAL'
408 ,'/usr/X11R6'
409 )
410
411 opts.Add(
412 'X11_LIBPATH'
413 ,'Location of X11 lib. EXPERIMENTAL'
414 ,'$X11/lib'
415 )
416
417 opts.Add(
418 'X11_CPPPATH'
419 ,'Location of X11 includes. EXPERIMENTAL'
420 ,'$X11/include'
421 )
422
423 opts.Add(
424 'X11_LIB'
425 ,'Name of X11 lib. EXPERIMENTAL'
426 ,'X11'
427 )
428
429 #----- installed file locations (for 'scons install') -----
430
431 opts.Add(
432 'INSTALL_PREFIX'
433 ,'Root location for installed files'
434 ,'/usr/local'
435 )
436
437 opts.Add(
438 'INSTALL_BIN'
439 ,'Location to put binaries during installation'
440 ,"$INSTALL_PREFIX/bin"
441 )
442
443 opts.Add(
444 'INSTALL_LIB'
445 ,'Location to put libraries during installation'
446 ,"$INSTALL_PREFIX/lib"
447 )
448
449 opts.Add(
450 'INSTALL_SHARE'
451 ,'Common shared-file location on this system'
452 ,"$INSTALL_PREFIX/share"
453 )
454
455 opts.Add(
456 'INSTALL_ASCDATA'
457 ,"Location of ASCEND shared data (TK, python, models etc)"
458 ,"$INSTALL_SHARE/ascend"
459 )
460
461 opts.Add(
462 'INSTALL_DOC'
463 ,"Location of ASCEND documentation files"
464 ,"$INSTALL_SHARE/doc/ascend-"+version
465 )
466
467 opts.Add(
468 'INSTALL_INCLUDE'
469 ,'Location to put header files during installation'
470 ,"$INSTALL_PREFIX/include"
471 )
472
473
474 opts.Add(
475 'INSTALL_ROOT'
476 ,'For use by RPM only: location of %{buildroot} during rpmbuild'
477 ,""
478 )
479
480 #----------------------
481
482 opts.Add(
483 'PYGTK_ASSETS'
484 ,'Default location for Glade assets (placed in pygtk/config.py)'
485 ,default_install_assets
486 )
487
488 opts.Add(BoolOption(
489 'DEBUG'
490 ,"Compile source with debugger symbols, eg for use with 'gdb'"
491 ,False
492 ))
493
494 opts.Add(BoolOption(
495 'MALLOC_DEBUG'
496 ,"Compile with debugging version of MALLOC. Required for full CUnit testing"
497 ,False
498 ))
499
500 #------ dmalloc --------
501 opts.Add(PackageOption(
502 'DMALLOC_PREFIX'
503 ,"Where are your dmalloc files?"
504 ,default_prefix
505 ))
506
507 opts.Add(PackageOption(
508 'DMALLOC_CPPPATH'
509 ,"Where are your dmalloc include files?"
510 ,default_cpppath
511 ))
512
513 opts.Add(PackageOption(
514 'DMALLOC_LIBPATH'
515 ,"Where are your dmalloc libraries?"
516 ,default_libpath
517 ))
518
519 opts.Add(BoolOption(
520 'WITH_DMALLOC'
521 ,"Link to the DMALLOC library (if available) for debugging of memory usage."
522 ,False
523 ))
524
525 #------ f --------
526 opts.Add(PackageOption(
527 'MFGRAPH_PREFIX'
528 ,"Where are your MFGRAPH files?"
529 ,default_prefix
530 ))
531
532 opts.Add(PackageOption(
533 'MFGRAPH_CPPPATH'
534 ,"Where are your MFGRAPH include files?"
535 ,default_cpppath
536 ))
537
538 opts.Add(PackageOption(
539 'MFGRAPH_LIBPATH'
540 ,"Where are your MFGRAPH libraries?"
541 ,default_libpath
542 ))
543
544 opts.Add(BoolOption(
545 'WITH_MFGRAPH'
546 ,"Link to the MFGRAPH library (if available, for generating incidence graphs)"
547 ,True
548 ))
549
550
551 #------ ufsparse --------
552 opts.Add(PackageOption(
553 'UFSPARSE_PREFIX'
554 ,"Where are your UFSPARSE files?"
555 ,default_prefix
556 ))
557
558 opts.Add(PackageOption(
559 'UFSPARSE_CPPPATH'
560 ,"Where are your UFSPARSE include files?"
561 ,default_cpppath
562 ))
563
564 opts.Add(PackageOption(
565 'UFSPARSE_LIBPATH'
566 ,"Where are your UFSPARSE libraries?"
567 ,default_libpath
568 ))
569
570 opts.Add(BoolOption(
571 'WITH_UFSPARSE'
572 ,"Link to the UFSPARSE library (if available, for additional sparse matrix routines)"
573 ,True
574 ))
575
576 #-----------------------
577
578 opts.Add(
579 'DISTTAR_NAME'
580 ,"Stem name of the tarball created by 'scons dist'. So for 'ascend-aaa.tar.bz2', set this to 'ascend-aaa'."
581 ,"ascend-"+version
582 )
583
584 opts.Add(
585 'RELEASE'
586 ,"Release number for use in RPM spec file. This should always start with a zero for releases made by the ASCEND group, in order that third parties can make 'patch' releases of higher version numbers."
587 ,"0"
588 )
589
590 opts.Add(BoolOption(
591 'ABSOLUTE_PATHS'
592 ,"Whether to use absolute or relative paths in the installed Tcl/Tk interface. If you want to build an RPM, set this to false."
593 ,default_absolute_paths
594 ))
595
596 opts.Add(
597 'WIN_INSTALLER_NAME'
598 ,"Name of the installer .exe to create under Windows (minus the '.exe')"
599 ,"ascend-"+version+"-py"+pyversion+".exe"
600 )
601
602 opts.Add(BoolOption(
603 'WITH_XTERM_COLORS'
604 ,"Set to 0 if you don't want xterm colour codes in the console output"
605 ,True
606 ))
607
608 opts.Add(BoolOption(
609 'WITH_EXTFNS'
610 ,"Set to 0 if you don't want to attempt to build external modules bundled"
611 + " with ASCEND."
612 ,True
613 ))
614
615 opts.Add(BoolOption(
616 'WITH_SCROLLKEEPER'
617 ,"Set to to 1 if you want to install an OMF file that can be read by scrollkeeper (eg Yelp on GNOME)"
618 ,default_with_scrollkeeper
619 ))
620
621 if platform.system()!="Windows":
622 opts.Add(BoolOption(
623 'WITH_GCCVISIBILITY'
624 , 'Whether to use GCC Visibility extensions when building with GCC 4.0'
625 , True
626 ))
627
628
629
630 # TODO: OTHER OPTIONS?
631 # TODO: flags for optimisation
632 # TODO: turning on/off bintoken functionality
633 # TODO: Where will the 'Makefile.bt' file be installed?
634
635 # Import the outside environment
636
637 def c_escape(str):
638 return re.sub("\\\\","/",str)
639
640 envadditional={}
641
642 tools = ['lex','yacc','fortran','swig','nsis','substinfile','disttar']
643 if platform.system()=="Windows":
644 if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):
645 envenv = os.environ;
646 tools += ['mingw']
647 #TODO removed 'doxygen' for SCons 0.96.93
648 envadditional['IS_MINGW']=True
649 else:
650 print "Assuming VC++ build environment (Note: MinGW is preferred)"
651 envenv = {
652 'PATH':os.environ['PATH']
653 ,'INCLUDE':os.environ['INCLUDE']
654 ,'LIB':os.environ['LIB']
655 ,'MSVS_IGNORE_IDE_PATHS':1
656 }
657 tools += ['default']
658 #TODO removed 'doxygen' for SCons 0.96.93
659 envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
660 else:
661 if os.environ.get('TARGET')=='mingw':
662 envenv = os.environ
663 tools += ['crossmingw']
664 envadditional['CPPPATH']=['/usr/lib/gcc/i586-mingw32msvc/3.4.5/include','/usr/include']
665 envadditional['LIBS']=['gcc']
666 else:
667 envenv = os.environ
668 tools += ['default']
669 #TODO removed 'doxygen' for SCons 0.96.93
670
671
672 env = Environment(
673 ENV=envenv
674 , toolpath=['scons']
675 , tools=tools
676 , **envadditional
677 )
678
679 #print "PATH =",os.environ['PATH']
680 #print "PROGSUFFIX =",env['PROGSUFFIX']
681 #print "CPPPATH =",env['CPPPATH']
682
683 opts.Update(env)
684 opts.Save('options.cache',env)
685
686 Help(opts.GenerateHelpText(env))
687
688 with_tcltk = env.get('WITH_TCLTK')
689 without_tcltk_reason = "disabled by options/config.py"
690
691 with_python = env.get('WITH_PYTHON')
692 without_python_reason = "disabled by options/config.py"
693
694 with_cunit = env.get('WITH_CUNIT')
695 without_cunit_reason = "not requested"
696
697 with_extfns = env.get('WITH_EXTFNS')
698 without_extfn_reason = "disabled by options/config.py"
699
700 with_scrollkeeper = env.get('WITH_SCROLLKEEPER')
701 without_scrollkeeper_reason = "disabled by options/config.py"
702
703 with_dmalloc = env.get('WITH_DMALLOC')
704 without_dmalloc_reason = "disabled by options/config.py"
705
706 with_mfgraph = env.get('WITH_MFGRAPH')
707 without_mfgraph_reason = "disabled by options/config.py"
708
709 with_ufsparse = env.get('WITH_UFSPARSE')
710 without_ufsparse_reason = "disabled by options/config.py"
711
712 with_mmio = env.get('WITH_MMIO')
713 without_mmio_reason = "disabled by options/config.py"
714
715 with_signals = env.get('WITH_SIGNALS')
716 without_signals_reason = "disabled by options/config.py"
717
718 with_doc = env.get('WITH_DOC')
719 without_doc_reason = "disabled by options/config.py"
720
721 with_doc_build = env.get('WITH_DOC_BUILD');
722 without_doc_build = "disabled by options/config.py"
723 if not with_doc:
724 without_doc_build = "disabled by with_doc"
725
726 with_latex2html = False
727
728 if platform.system()=="Windows":
729 with_installer=1
730 else:
731 with_installer=0
732 without_installer_reason = "only possible under Windows"
733
734 if 'LSOD' in env['WITH_SOLVERS']:
735 with_lsode=True
736 else:
737 with_lsode=False
738 without_lsode_reason = "not requested (WITH_SOLVERS)"
739
740 if 'IDA' in env['WITH_SOLVERS']:
741 with_ida=True
742 else:
743 with_ida=False
744 without_ida_reason = "not requested (WITH_SOLVERS)"
745
746
747 if 'CONOPT' in env['WITH_SOLVERS']:
748 with_conopt=True
749 else:
750 with_conopt=False
751 without_conopt_reason = "not requested (WITH_SOLVERS)"
752
753
754 #print "SOLVERS:",env['WITH_SOLVERS']
755 #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
756 #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
757
758 can_install = True
759 if platform.system()=='Windows':
760 can_install = False
761
762 env['CAN_INSTALL']=can_install
763 env['INSTALL_MODELS']=env['INSTALL_ASCDATA']+"/models/"
764
765 print "TCL=",env['TCL']
766 print "TCL_CPPPATH =",env['TCL_CPPPATH']
767 print "TCL_LIBPATH =",env['TCL_LIBPATH']
768 print "TCL_LIB =",env['TCL_LIB']
769 print "CC =",env['CC']
770 print "CXX =",env['CXX']
771 print "FORTRAN=",env.get('FORTRAN')
772
773 print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
774 print "INSTALL_PREFIX =",env['INSTALL_PREFIX']
775 #------------------------------------------------------
776 # SPECIAL CONFIGURATION TESTS
777
778 need_fortran = False
779
780 #----------------
781 # CC
782
783 cc_test_text = """
784 int main(void){
785 return 0;
786 }
787 """;
788
789 def CheckCC(context):
790 context.Message("Checking C compiler ('%s')... " % context.env.get('CC'))
791 is_ok = context.TryCompile(cc_test_text,".c")
792 context.Result(is_ok)
793 return is_ok
794
795 #----------------
796 # CXX
797
798 cxx_test_text = """
799 template<class X>
800 class pair{
801 public:
802 X a;
803 X b;
804 };
805
806 int main(void){
807 pair<double> P;
808 P.a = 0;
809 return 0;
810 }
811 """;
812
813 def CheckCXX(context):
814 context.Message("Checking C++ compiler ('%s')... " % context.env.get('CXX'))
815 is_ok = context.TryCompile(cc_test_text,".cpp")
816 context.Result(is_ok)
817 return is_ok
818
819
820
821 #----------------
822 # SWIG
823
824 import os,re
825
826 def get_swig_version(env):
827 cmd = env['SWIG']+' -version'
828 (cin,coutcerr) = os.popen4(cmd)
829 output = coutcerr.read()
830
831 restr = "SWIG\\s+Version\\s+(?P<maj>[0-9]+)\\.(?P<min>[0-9]+)\\.(?P<pat>[0-9]+)\\s*$"
832 expr = re.compile(restr,re.M);
833 m = expr.search(output);
834 if not m:
835 return None
836 maj = int(m.group('maj'))
837 min = int(m.group('min'))
838 pat = int(m.group('pat'))
839
840 return (maj,min,pat)
841
842
843 def CheckSwigVersion(context):
844
845 try:
846 context.Message("Checking version of SWIG... ")
847 maj,min,pat = get_swig_version(context.env)
848 except:
849 context.Result("Failed to detect version, or failed to run SWIG")
850 return 0;
851
852 context.env['SWIGVERSION']=tuple([maj,min,pat])
853
854 if maj == 1 and (
855 min > 3
856 or (min == 3 and pat >= 24)
857 ):
858 context.Result("ok, %d.%d.%d" % (maj,min,pat))
859 return 1;
860 else:
861 context.Result("too old, %d.%d.%d" % (maj,min,pat))
862 return 0;
863
864 #----------------
865 # Scrollkeeper (Linux documentation system)
866
867 def get_scrollkeeper_omfdir(env):
868 cmd = 'scrollkeeper-config --omfdir'
869 (cin,coutcerr) = os.popen4(cmd)
870 output = coutcerr.read()
871 return output.strip()
872
873 def CheckScrollkeeperConfig(context):
874 try:
875 context.Message("Checking for scrollkeeper...")
876 dir=get_scrollkeeper_omfdir(context.env)
877 except:
878 context.Result("Failed to run 'scrollkeeper-config'")
879 return 0
880 context.env['OMFDIR']=dir
881 context.Result("OK, %s" % dir)
882 return 1
883
884 #----------------
885 # General purpose library-and-header test
886
887 class KeepContext:
888 def __init__(self,context,varprefix,static=False):
889 self.keep = {}
890 for k in ['LIBS','LIBPATH','CPPPATH','LINKFLAGS']:
891 #print "Keeping env %s = %s" % (k,context.env.get(k))
892 self.keep[k]=context.env.get(k)
893
894 if context.env.has_key(varprefix+'_CPPPATH'):
895 context.env.AppendUnique(CPPPATH=[env[varprefix+'_CPPPATH']])
896 #print "Adding '"+str(env[varprefix+'_CPPPATH'])+"' to cpp path"
897
898 if static:
899 staticlib=env[varprefix+'_LIB']
900 #print "STATIC LIB = ",staticlib
901 context.env.Append(
902 LINKFLAGS=[staticlib]
903 )
904 else:
905 if context.env.has_key(varprefix+'_LIBPATH'):
906 context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']])
907 #print "Adding '"+str(env[varprefix+'_LIBPATH'])+"' to lib path"
908
909 if context.env.has_key(varprefix+'_LIB'):
910 context.env.Append(LIBS=[env[varprefix+'_LIB']])
911 #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"
912
913 def restore(self,context):
914 #print "RESTORING CONTEXT"
915 #print self.keep
916 #print "..."
917 for k in self.keep:
918 if self.keep[k]==None:
919 if context.env.has_key(k):
920 #print "Clearing "+str(k)
921 del context.env[k];
922 else:
923 #print "Restoring %s to '%s'" %(k,self.keep.get(k))
924 context.env[k]=self.keep[k];
925
926 def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False):
927 """This method will check for variables LIBNAME_LIBPATH
928 and LIBNAME_CPPPATH and try to compile and link the
929 file with the provided text, linking with the
930 library libname."""
931
932 if static:
933 context.Message( 'Checking for static '+libname+'... ' )
934 else:
935 context.Message( 'Checking for '+libname+'... ' )
936
937 if varprefix==None:
938 varprefix = libname.upper()
939
940 #print "LIBS is currently:",context.env.get('LIBS')
941 keep = KeepContext(context,varprefix,static)
942
943 if not context.env.has_key(varprefix+'_LIB'):
944 # if varprefix_LIB were in env, KeepContext would
945 # have appended it already
946 context.env.Append(LIBS=[libname])
947
948 is_ok = context.TryLink(text,ext)
949
950 #print "Link success? ",(is_ok != 0)
951
952 keep.restore(context)
953
954 # print "Restored CPPPATH="+str(context.env['CPPPATH'])
955 # print "Restored LIBS="+str(context.env['LIBS'])
956 # print "Restored LIBPATH="+str(context.env['LIBPATH'])
957
958 context.Result(is_ok)
959 return is_ok
960
961 #----------------
962 # GCC
963
964 gcc_test_text = """
965 #ifndef __GNUC__
966 # error "Not using GCC"
967 #endif
968
969 int main(void){
970 return __GNUC__;
971 }
972 """
973
974 def CheckGcc(context):
975 context.Message("Checking for GCC... ")
976 is_ok = context.TryCompile(gcc_test_text,".c")
977 context.Result(is_ok)
978 return is_ok
979
980 #----------------
981 # GCC VISIBILITY feature
982
983 gccvisibility_test_text = """
984 #if __GNUC__ < 4
985 # error "Require GCC version 4 or newer"
986 #endif
987
988 __attribute__ ((visibility("default"))) int x;
989
990 int main(void){
991 extern int x;
992 x = 4;
993 }
994 """
995
996 def CheckGccVisibility(context):
997 context.Message("Checking for GCC 'visibility' capability... ")
998 if not context.env.has_key('WITH_GCCVISIBILITY') or not env['WITH_GCCVISIBILITY']:
999 context.Result("disabled")
1000 return 0
1001 is_ok = context.TryCompile(gccvisibility_test_text,".c")
1002 context.Result(is_ok)
1003 return is_ok
1004
1005 #----------------
1006 # YACC
1007
1008 yacc_test_text = """
1009 %{
1010 #include <stdio.h>
1011
1012 /* MSVC++ needs this before it can swallow Bison output */
1013 #ifdef _MSC_VER
1014 # define __STDC__
1015 #endif
1016 %}
1017 %token MSG
1018 %start ROOT
1019 %%
1020 ROOT:
1021 MSG { printf("HELLO"); }
1022 ;
1023 %%
1024 """
1025
1026 def CheckYacc(context):
1027 context.Message("Checking for Yacc ('%s')... " % context.env.get('YACC'))
1028 is_ok = context.TryCompile(yacc_test_text,".y")
1029 context.Result(is_ok)
1030 return is_ok
1031
1032 #----------------
1033 # LEX
1034
1035 lex_test_text = """
1036 %{
1037 #include <stdio.h>
1038 %}
1039 DIGIT [0-9]
1040 ID [a-z][a-z0-9]*
1041 %%
1042 {DIGIT}+ {
1043 printf("A digit: %s\\n",yytext);
1044 }
1045
1046 [ \\t\\n]+ /* ignore */
1047
1048 . {
1049 printf("Unrecognized guff");
1050 }
1051 %%
1052 main(){
1053 yylex();
1054 }
1055 """
1056
1057 def CheckLex(context):
1058 context.Message("Checking for Lex ('%s')... " % context.env.get('LEX'))
1059 is_ok = context.TryCompile(lex_test_text,".l")
1060 context.Result(is_ok)
1061 return is_ok
1062
1063 #----------------
1064 # CUnit test
1065
1066 cunit_test_text = """
1067 #include <CUnit/CUnit.h>
1068 int maxi(int i1, int i2){
1069 return (i1 > i2) ? i1 : i2;
1070 }
1071
1072 void test_maxi(void){
1073 CU_ASSERT(maxi(0,2) == 2);
1074 CU_ASSERT(maxi(0,-2) == 0);
1075 CU_ASSERT(maxi(2,2) == 2);
1076
1077 }
1078 int main(void){
1079 /* CU_initialize_registry() */
1080 return 0;
1081 }
1082 """
1083
1084 def CheckCUnit(context):
1085 return CheckExtLib(context,'cunit',cunit_test_text)
1086
1087 #----------------
1088 # dmalloc test
1089
1090 dmalloc_test_text = """
1091 #include <stdlib.h>
1092 #include <dmalloc.h>
1093
1094 int main(void){
1095 char *c;
1096 c = malloc(100*sizeof(char));
1097 free(c);
1098 return 0;
1099 }
1100 """
1101
1102 def CheckDMalloc(context):
1103 return CheckExtLib(context,'dmalloc',dmalloc_test_text)
1104
1105 #----------------
1106 # mfgraph test
1107
1108 mfgraph_test_text = """
1109 #include <mfgraph/mfg_draw_graph.h>
1110 int main(void){
1111 using namespace mfg;
1112 DrawGraph g;
1113 return 0;
1114 }
1115 """
1116
1117 def CheckMFGraph(context):
1118 return CheckExtLib(context,'mfgraph',mfgraph_test_text,ext=".cpp")
1119
1120 #----------------
1121 # ufsparse test
1122
1123 ufsparse_test_text = """
1124 #include <ufsparse/cs.h>
1125 int main(void){
1126 cs *A,*B,*C;
1127 C = cs_multiply(A,B);
1128 return 0;
1129 }
1130 """
1131
1132 def CheckUFSparse(context):
1133 return CheckExtLib(context
1134 ,libname='cxsparse'
1135 ,varprefix='ufsparse'
1136 ,text=ufsparse_test_text
1137 ,ext=".c"
1138 )
1139
1140 #----------------
1141 # MATH test
1142
1143 math_test_text = """
1144 #ifndef _ALL_SOURCE
1145 # define _ALL_SOURCE
1146 #endif
1147 #ifndef _XOPEN_SOURCE
1148 # define _XOPEN_SOURCE
1149 #endif
1150 #ifndef _XOPEN_SOURCE_EXTENDED
1151 # define _XOPEN_SOURCE_EXTENDED 1
1152 #endif
1153 #include <math.h>
1154 int main(void){
1155 double x = 1.0; double y = 1.0; int i = 1;
1156 acosh(x); asinh(x); atanh(x); cbrt(x); expm1(x); erf(x); erfc(x); isnan(x);
1157 j0(x); j1(x); jn(i,x); ilogb(x); logb(x); log1p(x); rint(x);
1158 y0(x); y1(x); yn(i,x);
1159 /* this part causes problems with crossmingw... */
1160 #ifdef _THREAD_SAFE
1161 gamma_r(x,&i);
1162 lgamma_r(x,&i);
1163 #else
1164 gamma(x);
1165 lgamma(x);
1166 #endif
1167 hypot(x,y); nextafter(x,y); remainder(x,y); scalb(x,y);
1168 return 0;
1169 }
1170 """
1171
1172 def CheckMath(context):
1173 context.Message('Checking for IEEE math library... ')
1174 libsave=context.env.get('LIBS');
1175 context.env.AppendUnique(LIBS=['m'])
1176 is_ok=context.TryLink(math_test_text,".c")
1177 context.Result(is_ok)
1178 if not is_ok:
1179 context.env['LIBS']=libsave
1180 return is_ok
1181
1182 #----------------
1183 # libpython test
1184
1185 libpython_test_text = """
1186 #include <Python.h>
1187 int main(void){
1188 PyObject *p;
1189 p = Py_None;
1190 return 0;
1191 }
1192 """
1193
1194 def CheckPythonLib(context):
1195 context.Message('Checking for libpython... ')
1196
1197 if platform.system()=="Windows":
1198 python_lib='python%d%d'
1199 else:
1200 python_lib='python%d.%d'
1201 python_libs = [python_lib % (sys.version_info[0],sys.version_info[1])]
1202
1203 python_cpppath = [distutils.sysconfig.get_python_inc()]
1204 cfig = distutils.sysconfig.get_config_vars()
1205
1206 lastLIBS = context.env.get('LIBS')
1207 lastLIBPATH = context.env.get('LIBPATH')
1208 lastCPPPATH = context.env.get('CPPPATH')
1209 lastLINKFLAGS = context.env.get('LINKFLAGS')
1210
1211 python_libpath = []
1212 python_linkflags = []
1213 if platform.system()=="Windows":
1214 python_libpath+=[cfig['prefix']]
1215 else:
1216 # checked on Linux and SunOS
1217 if cfig['LDLIBRARY']==cfig['LIBRARY']:
1218 sys.stdout.write("(static)")
1219 python_libpath += [cfig['LIBPL']]
1220 python_linkflags += cfig['LIBS'].split(' ')
1221
1222 context.env.AppendUnique(LIBS=python_libs)
1223 context.env.AppendUnique(LIBPATH=python_libpath)
1224 context.env.AppendUnique(CPPPATH=python_cpppath)
1225 context.env.AppendUnique(LINKFLAGS=python_linkflags)
1226 result = context.TryLink(libpython_test_text,".c");
1227
1228 context.Result(result)
1229
1230 if(result):
1231 context.env['PYTHON_LIBPATH']=python_libpath
1232 context.env['PYTHON_LIB']=python_libs
1233 context.env['PYTHON_CPPPATH']=python_cpppath
1234 context.env['PYTHON_LINKFLAGS']=python_linkflags
1235
1236 context.env['LIBS'] = lastLIBS
1237 context.env['LIBPATH'] = lastLIBPATH
1238 context.env['CPPPATH'] = lastCPPPATH
1239 context.env['LINKFLAGS'] = lastLINKFLAGS
1240
1241 return result
1242
1243 #----------------
1244 # IDA test
1245
1246 sundials_version_major_required = 2
1247 sundials_version_minor_min = 2
1248 sundials_version_minor_max = 3
1249
1250 sundials_version_text = """
1251 #include <sundials/sundials_config.h>
1252 #include <stdio.h>
1253 int main(){
1254 printf("%s",SUNDIALS_PACKAGE_VERSION);
1255 return 0;
1256 }
1257 """
1258
1259 ida_test_text = """
1260 #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1261 # include <sundials/sundials_config.h>
1262 # include <sundials/sundials_nvector.h>
1263 # include <nvector_serial.h>
1264 # include <ida.h>
1265 # include <ida/ida_spgmr.h>
1266 #else
1267 # include <sundials/sundials_config.h>
1268 # include <nvector/nvector_serial.h>
1269 # include <ida/ida.h>
1270 #endif
1271 int main(){
1272 void *ida_mem;
1273 ida_mem = IDACreate();
1274 return 0;
1275 }
1276 """
1277
1278 # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1279 # so detect the version and act accordingly.
1280 def CheckSUNDIALS(context):
1281 keep = KeepContext(context,'SUNDIALS')
1282 context.Message("Checking for SUNDIALS... ")
1283 (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1284 keep.restore(context)
1285 if not is_ok:
1286 context.Result(0)
1287 return 0
1288
1289 major,minor,patch = tuple([int(i) for i in output.split(".")])
1290 context.env['SUNDIALS_VERSION_MAJOR'] = major
1291 context.env['SUNDIALS_VERSION_MINOR'] = minor
1292 if major != sundials_version_major_required \
1293 or minor < sundials_version_minor_min \
1294 or minor > sundials_version_minor_max:
1295 context.Result(output+" (bad version)")
1296 # bad version
1297 return 0
1298
1299 # good version
1300 context.Result("%d.%d.%d, good" % (major,minor,patch))
1301
1302 return 1
1303
1304
1305 def CheckIDA(context):
1306 context.Message( 'Checking for IDA... ' )
1307
1308 keep = KeepContext(context,"SUNDIALS")
1309
1310 major = context.env['SUNDIALS_VERSION_MAJOR']
1311 minor = context.env['SUNDIALS_VERSION_MINOR']
1312
1313 cppdef = context.env.get('CPPDEFINES')
1314
1315 context.env.Append(CPPDEFINES=[
1316 ('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR")
1317 ,('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")
1318 ])
1319
1320 context.env['SUNDIALS_CPPPATH_EXTRA']=[]
1321 if major==2 and minor==2:
1322 context.env.Append(SUNDIALS_CPPPATH_EXTRA = ["$SUNDIALS_CPPPATH/sundials"])
1323
1324 context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1325 context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1326 context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1327
1328 is_ok = context.TryLink(ida_test_text,".c")
1329 context.Result(is_ok)
1330
1331 if cppdef:
1332 context.env['CPPDEFINES']=cppdef
1333 keep.restore(context)
1334
1335 return is_ok
1336
1337
1338 #----------------
1339 # CONOPT test
1340
1341 conopt_test_text = """
1342 #if !defined(_WIN32)
1343 # define FNAME_LCASE_DECOR
1344 #endif
1345
1346 #include <conopt.h>
1347 #include <stdlib.h>
1348 int main(){
1349 int s, *v, e;
1350 s = COIDEF_Size();
1351 v = (int *)malloc(s*sizeof(int));
1352 e = COIDEF_Ini(v);
1353 return e;
1354 }
1355 """
1356
1357 def CheckCONOPT(context):
1358 context.Message( 'Checking for CONOPT... ' )
1359
1360 keep = KeepContext(context,"CONOPT")
1361
1362 is_ok = context.TryLink(conopt_test_text,".c")
1363 context.Result(is_ok)
1364
1365 keep.restore(context)
1366
1367 return is_ok
1368
1369 #----------------
1370 # Tcl test
1371
1372 # TCL and TK required version 8.1, 8.2, 8.3, or 8.4:
1373 tcltk_minor_newest_acceptable = 4
1374 tcltk_major_required = 8
1375
1376 tcl_check_text = r"""
1377 #include <tcl.h>
1378 #include <stdio.h>
1379 int main(void){
1380 printf("%s",TCL_PATCH_LEVEL);
1381 return 0;
1382 }
1383 """
1384
1385 def CheckTcl(context):
1386 return CheckExtLib(context,'tcl',tcl_check_text,static=env['STATIC_TCLTK'])
1387
1388 def CheckTclVersion(context):
1389 keep = KeepContext(context,'TCL',static=env['STATIC_TCLTK'])
1390 context.Message("Checking Tcl version... ")
1391 (is_ok,output) = context.TryRun(tcl_check_text,'.c')
1392 keep.restore(context)
1393 if not is_ok:
1394 context.Result("failed to run check")
1395 return 0
1396
1397 major,minor,patch = tuple([int(i) for i in output.split(".")])
1398 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1399 context.Result(output+" (bad version)")
1400 # bad version
1401 return 0
1402
1403 # good version
1404 context.Result(output+", good")
1405 return 1
1406
1407 #----------------
1408 # Tk test
1409
1410 tk_check_text = r"""
1411 #include <tk.h>
1412 #include <stdio.h>
1413 int main(void){
1414 printf("%s",TK_PATCH_LEVEL);
1415 return 0;
1416 }
1417 """
1418 def CheckTk(context):
1419 return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
1420
1421
1422 def CheckTkVersion(context):
1423 keep = KeepContext(context,'TK',static=context.env['STATIC_TCLTK'])
1424 context.Message("Checking Tk version... ")
1425 #print "LINKFLAGS =",context.env['LINKFLAGS']
1426 (is_ok,output) = context.TryRun(tk_check_text,'.c')
1427 keep.restore(context)
1428 if not is_ok:
1429 context.Result("failed to run check")
1430 return 0
1431
1432 major,minor,patch = tuple([int(i) for i in output.split(".")])
1433 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1434 # bad version
1435 context.Result(output+" (bad version)")
1436 return 0
1437
1438 # good version
1439 context.Result(output+" (good)")
1440 return 1
1441
1442 #----------------
1443 # Tktable test
1444
1445 tktable_check_text = r"""
1446 #include <tkTable.h>
1447 #include <stdio.h>
1448 int main(void){
1449 Table mytable;
1450 return 0;
1451 }
1452 """
1453
1454 def CheckTkTable(context):
1455 return CheckExtLib(context,'tktable',tktable_check_text,static=env['STATIC_TCLTK'])
1456
1457 #---------------
1458 # X11 test
1459
1460 x11_check_text = r"""
1461 #include <X11/Xlib.h>
1462 #include <X11/IntrinsicP.h>
1463 #include <X11/Intrinsic.h>
1464 #include <X11/ObjectP.h>
1465 #include <X11/Object.h>
1466 int main(void){
1467 Object mything;
1468 return 0;
1469 }
1470 """
1471
1472 def CheckX11(context):
1473 return CheckExtLib(context,'X11',x11_check_text)
1474
1475 #----------------
1476 # Check that we can raise and catch sigint
1477
1478 sigint_test_text = r"""
1479 #include <signal.h>
1480 #include <setjmp.h>
1481 #include <stdlib.h>
1482 static jmp_buf g_jmpenv;
1483 void sighandler(int sig){
1484 longjmp(g_jmpenv,sig);
1485 }
1486 void testsigint(){
1487 raise(SIGINT);
1488 }
1489 int main(void){
1490 signal(SIGINT,&sighandler);
1491 switch(setjmp(g_jmpenv)){
1492 case 0:
1493 testsigint();
1494 exit(1);
1495 case SIGINT:
1496 exit(0);
1497 default:
1498 exit(2);
1499 }
1500 }
1501 """
1502
1503 def CheckSIGINT(context):
1504 context.Message("Checking SIGINT is catchable... ")
1505 (is_ok,output)=context.TryRun(sigint_test_text,".c")
1506 context.Result(is_ok)
1507 return is_ok
1508
1509 #----------------
1510 # Check that we're able to catch floating point errors
1511
1512 sigfpe_test_text = r"""
1513 #include <signal.h>
1514 #include <setjmp.h>
1515 #include <stdlib.h>
1516 #include <fenv.h>
1517 static jmp_buf g_jmpenv;
1518 void fpehandler(int sig){
1519 longjmp(g_jmpenv,sig);
1520 }
1521 int main(void){
1522 fenv_t myfenv;
1523 fegetenv(&myfenv);
1524 fesetenv(&myfenv);
1525 feenableexcept(FE_ALL_EXCEPT);
1526 signal(SIGFPE,&fpehandler);
1527 double x;
1528 switch(setjmp(g_jmpenv)){
1529 case 0:
1530 x = 1.0 / 0.0;
1531 /* failed to catch */
1532 exit(1);
1533 case SIGFPE:
1534 exit(0);
1535 }
1536 }
1537 """
1538
1539 def CheckFPE(context):
1540 context.Message("Checking C99 FPE behaviour... ")
1541 (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1542 context.Result(is_ok)
1543 return is_ok
1544
1545 #----------------
1546 # signal reset needed?
1547
1548 sigreset_test_text = r"""
1549 #include <signal.h>
1550 #include <setjmp.h>
1551 #include <stdlib.h>
1552 #include <stdio.h>
1553 typedef void SigHandlerFn(int);
1554 static jmp_buf g_jmpenv;
1555 void sighandler(int sig){
1556 longjmp(g_jmpenv,sig);
1557 }
1558 void testsigint(){
1559 /* fprintf(stderr,"Raising SIGINT\n"); */
1560 raise(SIGINT);
1561 }
1562 int main(void){
1563 SigHandlerFn *last,*saved;
1564 saved = signal(SIGINT,&sighandler);
1565 if(saved!=SIG_DFL){
1566 fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
1567 exit(3);
1568 }
1569 switch(setjmp(g_jmpenv)){
1570 case 0:
1571 testsigint();
1572 fprintf(stderr,"Back from SIGINT\n");
1573 exit(1);
1574 case SIGINT:
1575 break;
1576 default:
1577 exit(2);
1578 };
1579 last = signal(SIGINT,SIG_DFL);
1580 if(last!=&sighandler){
1581 printf("1");
1582 exit(0);
1583 }
1584 printf("0");
1585 exit(0);
1586 }
1587 """
1588
1589 def CheckSigReset(context):
1590 context.Message("Checking signal handler reset... ")
1591 (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
1592 if not is_ok:
1593 context.Result("ERROR")
1594 return False
1595 if int(output)==1:
1596 context.Result("required");
1597 context.env['ASC_RESETNEEDED'] = True
1598 else:
1599 context.Result("not required");
1600 context.env['ASC_RESETNEEDED'] = False
1601 return is_ok
1602
1603 #----------------
1604 # LyX on this system?
1605
1606 def CheckLyx(context):
1607 context.Message("Checking for LyX... ")
1608 r = context.env.WhereIs("lyx")
1609 if r:
1610 context.Result(r)
1611 else:
1612 context.Result(0)
1613 return r
1614
1615 #----------------
1616 # Latex2HTML on this system?
1617
1618 def CheckLatex2HTML(context):
1619 context.Message("Checking for latex2html...")
1620 if context.env.WhereIs("latex2html"):
1621 r = True
1622 else:
1623 r = False
1624 context.Result(r)
1625 return r
1626
1627 #----------------
1628 # GCC Version sniffing
1629
1630 # TODO FIXME
1631
1632 gcc_version4 = False
1633
1634 #------------------------------------------------------
1635 # CONFIGURATION
1636
1637 conf = Configure(env
1638 , custom_tests = {
1639 'CheckCC' : CheckCC
1640 , 'CheckCXX' : CheckCXX
1641 , 'CheckMath' : CheckMath
1642 , 'CheckSwigVersion' : CheckSwigVersion
1643 , 'CheckPythonLib' : CheckPythonLib
1644 , 'CheckCUnit' : CheckCUnit
1645 , 'CheckDMalloc' : CheckDMalloc
1646 , 'CheckLyx' : CheckLyx
1647 , 'CheckLatex2HTML' : CheckLatex2HTML
1648 , 'CheckMFGraph' : CheckMFGraph
1649 , 'CheckUFSparse' : CheckUFSparse
1650 , 'CheckTcl' : CheckTcl
1651 , 'CheckTclVersion' : CheckTclVersion
1652 , 'CheckTk' : CheckTk
1653 , 'CheckTkVersion' : CheckTkVersion
1654 , 'CheckGcc' : CheckGcc
1655 , 'CheckGccVisibility' : CheckGccVisibility
1656 , 'CheckYacc' : CheckYacc
1657 , 'CheckLex' : CheckLex
1658 , 'CheckTkTable' : CheckTkTable
1659 , 'CheckX11' : CheckX11
1660 , 'CheckIDA' : CheckIDA
1661 , 'CheckSUNDIALS' : CheckSUNDIALS
1662 , 'CheckCONOPT' : CheckCONOPT
1663 , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1664 , 'CheckFPE' : CheckFPE
1665 , 'CheckSIGINT' : CheckSIGINT
1666 , 'CheckSigReset' : CheckSigReset
1667 # , 'CheckIsNan' : CheckIsNan
1668 # , 'CheckCppUnitConfig' : CheckCppUnitConfig
1669 }
1670 # , config_h = "config.h"
1671 )
1672
1673 def sconsversioncheck():
1674
1675 # uncomment the following line to skip the version check:
1676 # return 1
1677
1678 import SCons
1679 v = SCons.__version__.split(".")
1680 if v[0] != '0':
1681 return 0
1682 if int(v[1]) >= 97:
1683 return 1
1684 if v[1] != '96':
1685 return 0
1686 micro = int(v[2])
1687 if micro == 92 or micro == 93 or micro == 96:
1688 return 1;
1689 return 0
1690
1691 if not sconsversioncheck():
1692 print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
1693 print "or consult the developers in the case of newer versions. Modify"
1694 print "the function 'sconsversioncheck' in the file SConstruct if you"
1695 print "want to *force* SCons to continue."
1696 Exit(1)
1697
1698 # check C compiler
1699
1700 if not conf.CheckCC():
1701 print "Failed to build simple test file with your C compiler."
1702 print "Check your compiler is installed and running correctly."
1703 Exit(1)
1704
1705 if not conf.CheckCXX():
1706 print "Failed to build simple test file with your C++ compiler."
1707 print "Check your compiler is installed and running correctly."
1708 Exit(1)
1709
1710 # stdio -- just to check that compiler is behaving
1711
1712 if not conf.CheckHeader('stdio.h'):
1713 print "CPPPATH =",env.get('CPPPATH')
1714 print "Did not find 'stdio.h'! Check your compiler configuration."
1715 print ""
1716 print "You environment is printed here:"
1717 for k,v in os.environ.iteritems():
1718 print "%-30s%s" % ("%s :" % k, v)
1719 Exit(1)
1720
1721 if not conf.CheckFunc('snprintf'):
1722 print "Didn't find snprintf";
1723 exit(1)
1724
1725 # Math library
1726
1727 conf.env['HAVE_IEEE']=True
1728
1729 if need_libm and not conf.CheckMath():
1730 conf.env['HAVE_IEEE']=False
1731 print 'Did not find math library, exiting!'
1732 Exit(1)
1733
1734 # Where is 'isnan'?
1735
1736 if not conf.CheckFunc('isnan') and not conf.CheckFunc('_isnan'):
1737 print "Didn't find isnan"
1738 # Exit(1)
1739
1740 # GCC visibility
1741
1742 if conf.CheckGcc():
1743 conf.env['HAVE_GCC']=True;
1744 if env['WITH_GCCVISIBILITY'] and conf.CheckGccVisibility():
1745 conf.env['HAVE_GCCVISIBILITY']=True;
1746 conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
1747 conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
1748 conf.env.Append(CCFLAGS=['-Wall'])
1749
1750 # Catching SIGINT
1751
1752 if env['WITH_SIGNALS']:
1753 if not conf.CheckSIGINT():
1754 with_signals = False
1755 without_signals_reason = "SIGINT uncatchable"
1756
1757 # Catching SIGFPE
1758
1759 if conf.CheckFPE():
1760 conf.env['HAVE_C99FPE']=True
1761 else:
1762 conf.env['HAVE_C99FPE']=False
1763
1764 # Checking for signal reset requirement
1765
1766 if not conf.CheckSigReset():
1767 print "Unable to determine if signal reset is required"
1768 Exit(1)
1769
1770 # YACC
1771
1772 if not conf.CheckYacc():
1773 print "YACC NOT FOUND OR NOT WORKING"
1774 else:
1775 conf.env['HAVE_YACC']=True
1776
1777 if not conf.CheckLex():
1778 print "YACC NOT FOUND OR NOT WORKING"
1779 else:
1780 conf.env['HAVE_LEX']=True
1781
1782 # Tcl/Tk
1783
1784 if with_tcltk:
1785 if conf.CheckTcl():
1786 if conf.CheckTclVersion():
1787 if conf.CheckTk():
1788 if with_tcltk and conf.CheckTkVersion():
1789 if env['STATIC_TCLTK']:
1790 if conf.CheckTkTable():
1791 pass
1792 else:
1793 without_tcltk_reason = "TkTable not found"
1794 with_tcltk = False
1795 else:
1796 without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
1797 with_tcltk = False
1798 else:
1799 without_tcltk_reason = "Tk not found."
1800 with_tcltk = False
1801 else:
1802 without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
1803 with_tcltk = False
1804
1805 else:
1806 without_tcltk_reason = "Tcl not found."
1807 with_tcltk = False
1808
1809 if env['STATIC_TCLTK']:
1810 conf.CheckX11()
1811
1812 # Python... obviously we're already running python, so we just need to
1813 # check that we can link to the python library OK:
1814
1815 if not conf.CheckPythonLib():
1816 without_python_reason = 'libpython2.x not found or not linkable'
1817 with_python = False
1818 env['WITH_PYTHON']=False
1819
1820 # SWIG version
1821
1822 if with_python and not conf.CheckSwigVersion():
1823 without_python_reason = 'SWIG >= 1.3.24 is required'
1824 with_python = False
1825 env['WITH_PYTHON']=False
1826
1827 # CUnit
1828
1829 if with_cunit:
1830 if not conf.CheckCUnit():
1831 without_cunit_reason = 'CUnit not found'
1832 with_cunit = False
1833 #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
1834
1835 # DMALLOC
1836
1837 if with_dmalloc:
1838 if not conf.CheckDMalloc():
1839 without_dmalloc_reason = 'dmalloc not found'
1840 with_dmalloc = False
1841
1842 # MFGRAPH
1843
1844 if with_mfgraph:
1845 if not conf.CheckMFGraph():
1846 without_mfgraph_reason = 'mfgraph not found'
1847 with_mfgraph = False
1848 env['WITH_MFGRAPH'] = False
1849
1850 # UFSPARSE
1851
1852 if with_ufsparse:
1853 if not conf.CheckUFSparse():
1854 without_ufsparse_reason = 'mfgraph not found'
1855 with_ufsparse = False
1856 env['WITH_UFSPARSE'] = False
1857
1858 # IDA
1859
1860 if not with_ida:
1861 without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
1862 elif not conf.CheckSUNDIALS():
1863 with_ida = False
1864 without_ida_reason = "SUNDIALS not found, or bad version"
1865 elif not conf.CheckIDA():
1866 with_ida = False
1867 without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
1868
1869 # CONOPT
1870
1871 if not with_conopt:
1872 without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
1873 elif not conf.CheckCONOPT():
1874 with_conopt = False
1875 without_conpt_reason = "CONOPT not found"
1876
1877 # BLAS
1878
1879 need_blas=False
1880
1881 if with_lsode:
1882 need_fortran = True
1883 need_blas=True
1884
1885 if need_blas:
1886 if conf.CheckLib('blas'):
1887 with_local_blas = False
1888 without_local_blas_reason = "Found BLAS installed on system"
1889 else:
1890 with_local_blas = True
1891 need_fortran = True
1892 else:
1893 with_local_blas= False;
1894 without_local_blas_reason = "BLAS not required"
1895
1896 # FORTRAN
1897
1898 if need_fortran:
1899 conf.env.Tool('fortran')
1900 detect_fortran = conf.env.Detect(['gfortran','g77'])
1901 if detect_fortran:
1902 # For some reason, g77 doesn't get detected properly on MinGW
1903 if not env.has_key('F77') and not env.has_key('FORTRAN'):
1904 print "Fixing detection of F77 on MinGW...(?)"
1905 conf.env.Replace(F77=detect_fortran)
1906 conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
1907 conf.env.Replace(F77FLAGS='')
1908 #print "F77:",conf.env['F77']
1909 #print "F77COM:",conf.env['F77COM']
1910 #print "F77FLAGS:",conf.env['F77FLAGS']
1911 fortran_builder = Builder(
1912 action='$F77COM'
1913 , suffix='.o'
1914 , src_suffix='.f'
1915 )
1916 conf.env.Append(BUILDERS={'Fortran':fortran_builder})
1917 if platform.system()=="Linux":
1918 conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
1919 else:
1920 with_lsode=False;
1921 without_lsode_reason="FORTRAN-77 required but not found"
1922
1923 #else:
1924 # print "FORTRAN not required"
1925
1926 # F2C
1927
1928 if need_fortran:
1929 if platform.system()=="Windows":
1930 pass
1931 #conf.env.Append(LIBPATH='c:\mingw\lib')
1932
1933 # scrollkeeper
1934
1935 if with_scrollkeeper:
1936 if not conf.CheckScrollkeeperConfig():
1937 with_scrollkeeper=False
1938 without_scrollkeeper_reason="unable to detect scrollkeeper-config"
1939
1940 # lyx
1941
1942 if with_doc:
1943 if not conf.CheckLyx():
1944 with_doc = False
1945 without_doc_reason="unable to locate lyx"
1946
1947 with_latext2html = conf.CheckLatex2HTML()
1948
1949 # TODO: -D_HPUX_SOURCE is needed
1950
1951 # TODO: check size of void*
1952
1953 # TODO: detect if dynamic libraries are possible or not
1954
1955 if platform.system()=="Windows" and env.has_key('MSVS'):
1956 _found_windows_h = conf.CheckHeader('Windows.h')
1957
1958 if not _found_windows_h:
1959 print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
1960 Exit(1)
1961
1962 if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):
1963 with_python = 0;
1964 without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
1965
1966 conf.env.Append(CPPDEFINES=env['PACKAGE_LINKING'])
1967
1968 conf.Finish()
1969
1970 #---------------------------------------
1971 # SUBSTITUTION DICTIONARY for .in files
1972
1973 release = env.get('RELEASE')
1974 if release=="0.":
1975 release="0"
1976
1977 #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
1978
1979 subst_dict = {
1980 '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
1981 , '@GLADE_FILE@':'ascend.glade'
1982 , '@HELP_ROOT@':''
1983 , '@ICON_EXTENSION@':icon_extension
1984 , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
1985 , '@INSTALL_BIN@':env['INSTALL_BIN']
1986 , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
1987 , '@INSTALL_LIB@':env['INSTALL_LIB']
1988 , '@INSTALL_MODELS@':env['INSTALL_MODELS']
1989 , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
1990 , '@VERSION@':version
1991 , '@RELEASE@':release
1992 , '@DISTTAR_NAME@':env['DISTTAR_NAME']
1993 , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'
1994 , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
1995 , '@SHLIBPREFIX@':env['SHLIBPREFIX']
1996 , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
1997 , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
1998 , '@PYTHON@' : python_exe
1999 , '@PYVERSION@' : pyversion
2000 , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')
2001 , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')
2002 , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_DLPATH"))
2003 , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2004 }
2005
2006 if env.get('WITH_DOC'):
2007 print "WITH_DOC:",env['WITH_DOC']
2008 subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2009
2010 # bool options...
2011 for k,v in {
2012 'ASC_WITH_IDA':with_ida
2013 ,'ASC_WITH_DMALLOC':with_dmalloc
2014 ,'ASC_WITH_MFGRAPH':with_mfgraph
2015 ,'ASC_WITH_UFSPARSE':with_ufsparse
2016 ,'ASC_WITH_CONOPT':with_conopt
2017 ,'ASC_WITH_LSODE':with_lsode
2018 ,'ASC_WITH_MMIO':with_mmio
2019 ,'ASC_SIGNAL_TRAPS':with_signals
2020 ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2021 ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2022 ,'HAVE_IEEE':env.get('HAVE_IEEE')
2023 ,'ASC_ABSOLUTE_PATHS':env.get('ABSOLUTE_PATHS')
2024 ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2025 ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2026 }.iteritems():
2027
2028 if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
2029
2030 if with_python:
2031 subst_dict['@ASCXX_USE_PYTHON@']="1"
2032 env['WITH_PYTHON']=1;
2033
2034 if with_latex2html:
2035 env['WITH_LATEX2HTML']=1
2036
2037 if env.has_key('HAVE_GCCVISIBILITY'):
2038 subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2039
2040 env.Append(SUBST_DICT=subst_dict)
2041
2042 #for k,v in subst_dict.iteritems():
2043 # print "%-50s%s" % ("'%s'"%k,v)
2044
2045 # REMOVED: long command-line support on Win2k
2046
2047 #------------------------------------------------------
2048 # RECIPE: SWIG scanner
2049
2050 import SCons.Script
2051
2052 SWIGScanner = SCons.Scanner.ClassicCPP(
2053 "SWIGScan"
2054 , ".i"
2055 , "CPPPATH"
2056 , '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
2057 )
2058
2059 env.Append(SCANNERS=[SWIGScanner])
2060
2061 #------------------------------------------------------
2062 # Recipe for 'CHMOD' ACTION
2063
2064 import SCons
2065 from SCons.Script.SConscript import SConsEnvironment
2066 SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod,
2067 lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))
2068
2069 def InstallPerm(env, dest, files, perm):
2070 obj = env.Install(dest, files)
2071 for i in obj:
2072 env.AddPostAction(i, env.Chmod(str(i), perm))
2073
2074 SConsEnvironment.InstallPerm = InstallPerm
2075
2076 # define wrappers
2077 SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)
2078 SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2079 SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2080
2081 #------------------------------------------------------
2082 # BUILD...
2083
2084 # so that #include <modulename/headername.h> works across all modules...
2085 env.AppendUnique(CPPPATH=['#base/generic'])
2086
2087 if env['DEBUG']:
2088 env.Append(CCFLAGS=['-g'])
2089
2090 if env['GCOV']:
2091 env.Append(
2092 CPPFLAGS=['-g','-fprofile-arcs','-ftest-coverage']
2093 , LIBS=['gcov']
2094 , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
2095 )
2096
2097 if with_ida:
2098 env.Append(WITH_IDA=1)
2099
2100 if with_conopt:
2101 env.Append(WITH_CONOPT=1)
2102
2103 #-------------
2104 # TCL/TK GUI
2105
2106 if with_tcltk:
2107 env.SConscript(['tcltk/generic/interface/SConscript'],'env')
2108 else:
2109 print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2110
2111 #-------------
2112 # PYTHON INTERFACE
2113
2114 if with_python:
2115 env.SConscript(['pygtk/SConscript'],'env')
2116 else:
2117 print "Skipping... Python bindings aren't being built:",without_python_reason
2118
2119 #------------
2120 # BASE/GENERIC SUBDIRECTORIES
2121
2122 libascend_env = env.Copy()
2123
2124 dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2125
2126 srcs = []
2127 for d in dirs:
2128 heresrcs = libascend_env.SConscript('base/generic/'+d+'/SConscript','libascend_env')
2129 srcs += heresrcs
2130
2131 #-------------
2132 # IMPORTED CODE: LSODE, BLAS, etc
2133
2134 if with_lsode:
2135 srcs += env.SConscript(['lsod/SConscript'],'env')
2136 srcs += env.SConscript(['linpack/SConscript'],'env')
2137 else:
2138 print "Skipping... LSODE won't be built:", without_lsode_reason
2139
2140 if with_local_blas:
2141 srcs += env.SConscript(['blas/SConscript'],'env')
2142 else:
2143 print "Skipping... BLAS won't be built:", without_local_blas_reason
2144
2145 if not with_ida:
2146 print "Skipping... IDA won't be built:", without_ida_reason
2147
2148 if with_mmio:
2149 srcs += env.SConscript(['mmio/SConscript'],'env')
2150 else:
2151 print "Skipping... MMIO export won't be built:", without_mmio_reason
2152 #-------------
2153 # LIBASCEND -- all base/generic functionality
2154
2155 if with_dmalloc:
2156 libascend_env.Append(LIBS=['dmalloc'])
2157
2158 if with_ufsparse:
2159 libascend_env.Append(LIBS=['cxsparse'])
2160
2161 libascend = libascend_env.SharedLibrary('ascend',srcs)
2162
2163 env.Alias('libascend',libascend)
2164
2165 #-------------
2166 # UNIT TESTS (C CODE)
2167
2168 if with_cunit:
2169 testdirs = ['general','solver','utilities','linear']
2170 testsrcs = []
2171 for testdir in testdirs:
2172 path = 'base/generic/'+testdir+'/test/'
2173 env.SConscript([path+'SConscript'],'env')
2174 testsrcs += [i.path for i in env['TESTSRCS_'+testdir.upper()]]
2175
2176 #print "TESTSRCS =",testsrcs
2177
2178 env.SConscript(['test/SConscript'],'env')
2179 env.SConscript(['base/generic/test/SConscript'],'env')
2180
2181 env.Alias('test',[env.Dir('test'),env.Dir('base/generic/test')])
2182
2183 else:
2184 print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2185
2186 #-------------
2187 # EXTERNAL FUNCTIONS
2188
2189 env['extfns']=[]
2190 modeldirs = env.SConscript(['models/SConscript'],'env')
2191
2192 if not with_extfns:
2193 print "Skipping... External modules aren't being built:",without_extfns_reason
2194
2195 env.Alias('extfns',env['extfns'])
2196
2197 #------------------------------------------------------
2198 # CREATE ASCEND-CONFIG scriptlet
2199
2200 ascendconfig = env.SubstInFile('ascend-config.in')
2201
2202 #------------------------------------------------------
2203 # INSTALLATION
2204
2205 if env.get('CAN_INSTALL'):
2206
2207 dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC']
2208 install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2209 install_dirs += modeldirs
2210
2211 # TODO: add install options
2212 env.Alias('install',install_dirs)
2213
2214 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2215
2216 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2217
2218 #------------------------------------------------------
2219 # WINDOWS INSTALLER
2220 # For the windows installer, please see pygtk/SConscript
2221
2222 if with_installer:
2223 env.Append(NSISDEFINES={
2224 'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2225 ,"VERSION":version
2226 ,'PYVERSION':pyversion
2227 })
2228 installer = env.Installer('installer.nsi')
2229 Depends(installer,["pygtk","tcltk","ascend.dll","models","ascend-config"])
2230 env.Alias('installer',installer)
2231 else:
2232 print "Skipping... Windows installer isn't being built:",without_installer_reason
2233
2234
2235 #------------------------------------------------------
2236 # PROJECT FILE for MSVC
2237
2238 env.SConscript(['base/msvc/SConscript'],['env','libascend']);
2239
2240 #------------------------------------------------------
2241 # CREATE the SPEC file for generation of RPM packages
2242
2243 if platform.system()=="Linux":
2244 env.SubstInFile('ascend.spec.in')
2245
2246 #------------------------------------------------------
2247 # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2248
2249 #if with_scrollkeeper:
2250 # #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2251 # #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2252
2253 #------------------------------------------------------
2254 # DISTRIBUTION TAR FILE
2255
2256 env['DISTTAR_FORMAT']='bz2'
2257 env.Append(
2258 DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.lib','.cc','.cache','.pyc','.cvsignore','.dblite','.log','.pl','.out','.exe','.aux','.idx','.toc','.lof','.lot','.mm','.warnings','.tm2','.swp',',tmp','.gz','.bz2','.7z']
2259 , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2260 )
2261
2262 tar = env.DistTar("dist/"+env['DISTTAR_NAME']
2263 , [env.Dir('#')]
2264 )
2265
2266 env.Depends(tar,'ascend.spec')
2267 env.Depends(tar,'#doc/book.pdf')
2268
2269 Alias('dist',tar)
2270
2271 #------------------------------------------------------
2272 # USER'S MANUAL
2273
2274 env.SConscript('doc/SConscript',['env'])
2275
2276
2277 #------------------------------------------------------
2278 # LIBASCEND DOXYGEN DOCUMENTATION
2279
2280 env.SConscript('base/doc/SConscript',['env'])
2281
2282 #------------------------------------------------------
2283 # RPM BUILD
2284
2285 # for RPM builds, 'scons dist' then 'rpmbuild -ta dist/ascend-*.tar.bz2'
2286 # (check * for the version number used to create the tarball)
2287
2288 #------------------------------------------------------
2289 # DEFAULT TARGETS
2290
2291 default_targets =['libascend']
2292 if with_tcltk:
2293 default_targets.append('tcltk')
2294 if with_python:
2295 default_targets.append('pygtk')
2296 if with_installer:
2297 default_targets.append('installer')
2298 if with_extfns:
2299 default_targets.append('extfns')
2300 if with_doc_build:
2301 default_targets.append('doc')
2302
2303 env.Default(default_targets)
2304
2305 print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
2306
2307 # vim: set syntax=python:

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