/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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