/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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