/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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