/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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