/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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