/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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