/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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