/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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