/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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