/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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