/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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