/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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