/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1747 - (show annotations) (download)
Sun Feb 10 03:42:42 2008 UTC (10 years, 10 months ago) by jpye
File size: 64037 byte(s)
Fixed bug #361.
Moved a number of vars out of SUBST_DICT to prevent config.h changes from spawning a rebuild of libascend.
Eliminated use of ASC_WITH_CONOPT from C code (still need ASC_LINKED_CONOPT for the moment).

1 import sys, os, commands, platform, distutils.sysconfig, os.path, re, types
2 version = "0.9.5.114"
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/IpStdCInterface.h (do not include the 'ipopt' 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 python_libs = [python_lib % (sys.version_info[0],sys.version_info[1])]
1464
1465 python_cpppath = [distutils.sysconfig.get_python_inc()]
1466 cfig = distutils.sysconfig.get_config_vars()
1467
1468 lastLIBS = context.env.get('LIBS')
1469 lastLIBPATH = context.env.get('LIBPATH')
1470 lastCPPPATH = context.env.get('CPPPATH')
1471 lastLINKFLAGS = context.env.get('LINKFLAGS')
1472
1473 python_libpath = []
1474 python_linkflags = []
1475 if platform.system()=="Windows":
1476 python_libpath += [os.path.join(sys.prefix,"libs")]
1477 else:
1478 # checked on Linux and SunOS
1479 if cfig['LDLIBRARY']==cfig['LIBRARY']:
1480 sys.stdout.write("(static)")
1481 python_libpath += [cfig['LIBPL']]
1482 python_linkflags += cfig['LIBS'].split(' ')
1483
1484 context.env.AppendUnique(LIBS=python_libs)
1485 context.env.AppendUnique(LIBPATH=python_libpath)
1486 context.env.AppendUnique(CPPPATH=python_cpppath)
1487 context.env.AppendUnique(LINKFLAGS=python_linkflags)
1488 result = context.TryLink(libpython_test_text,".c");
1489
1490 context.Result(result)
1491
1492 if(result):
1493 context.env['PYTHON_LIBPATH']=python_libpath
1494 context.env['PYTHON_LIB']=python_libs
1495 context.env['PYTHON_CPPPATH']=python_cpppath
1496 context.env['PYTHON_LINKFLAGS']=python_linkflags
1497
1498 context.env['LIBS'] = lastLIBS
1499 context.env['LIBPATH'] = lastLIBPATH
1500 context.env['CPPPATH'] = lastCPPPATH
1501 context.env['LINKFLAGS'] = lastLINKFLAGS
1502
1503 return result
1504
1505 #----------------
1506 # IDA test
1507
1508 sundials_version_major_required = 2
1509 sundials_version_minor_min = 2
1510 sundials_version_minor_max = 3
1511
1512 sundials_version_text = """
1513 #include <sundials/sundials_config.h>
1514 #include <stdio.h>
1515 int main(){
1516 printf("%s",SUNDIALS_PACKAGE_VERSION);
1517 return 0;
1518 }
1519 """
1520
1521 ida_test_text = """
1522 #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1523 # include <sundials/sundials_config.h>
1524 # include <sundials/sundials_nvector.h>
1525 # include <nvector_serial.h>
1526 # include <ida.h>
1527 # include <ida/ida_spgmr.h>
1528 #else
1529 # include <sundials/sundials_config.h>
1530 # include <nvector/nvector_serial.h>
1531 # include <ida/ida.h>
1532 #endif
1533 int main(){
1534 void *ida_mem;
1535 ida_mem = IDACreate();
1536 return 0;
1537 }
1538 """
1539
1540 # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1541 # so detect the version and act accordingly.
1542 def CheckSUNDIALS(context):
1543 keep = KeepContext(context,'SUNDIALS')
1544 context.Message("Checking for SUNDIALS... ")
1545 (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1546 keep.restore(context)
1547 if not is_ok:
1548 context.Result(0)
1549 return 0
1550
1551 major,minor,patch = tuple([int(i) for i in output.split(".")])
1552 context.env['SUNDIALS_VERSION_MAJOR'] = major
1553 context.env['SUNDIALS_VERSION_MINOR'] = minor
1554 if major != sundials_version_major_required \
1555 or minor < sundials_version_minor_min \
1556 or minor > sundials_version_minor_max:
1557 context.Result(output+" (bad version)")
1558 # bad version
1559 return 0
1560
1561 # good version
1562 context.Result("%d.%d.%d, good" % (major,minor,patch))
1563
1564 return 1
1565
1566
1567 def CheckIDA(context):
1568 context.Message( 'Checking for IDA... ' )
1569
1570 keep = KeepContext(context,"SUNDIALS")
1571
1572 major = context.env['SUNDIALS_VERSION_MAJOR']
1573 minor = context.env['SUNDIALS_VERSION_MINOR']
1574
1575 cppdef = context.env.get('CPPDEFINES')
1576
1577 context.env.Append(CPPDEFINES=[
1578 ('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR")
1579 ,('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")
1580 ])
1581
1582 context.env['SUNDIALS_CPPPATH_EXTRA']=[]
1583 if major==2 and minor==2:
1584 context.env.Append(SUNDIALS_CPPPATH_EXTRA = ["$SUNDIALS_CPPPATH/sundials"])
1585
1586 context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1587 context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1588 context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1589
1590 is_ok = context.TryLink(ida_test_text,".c")
1591 context.Result(is_ok)
1592
1593 if cppdef:
1594 context.env['CPPDEFINES']=cppdef
1595 else:
1596 del context.env['CPPDEFINES']
1597
1598 keep.restore(context)
1599
1600 return is_ok
1601
1602
1603 #----------------
1604 # CONOPT test
1605
1606 conopt_test_text = """
1607 #if !defined(_WIN32)
1608 # define FNAME_LCASE_DECOR
1609 #endif
1610
1611 #include <conopt.h>
1612 #include <stdlib.h>
1613 int main(){
1614 int s, *v, e;
1615 s = COIDEF_Size();
1616 v = (int *)malloc(s*sizeof(int));
1617 e = COIDEF_Ini(v);
1618 return e;
1619 }
1620 """
1621
1622 def CheckCONOPT(context):
1623 context.Message( 'Checking for CONOPT... ' )
1624
1625 keep = KeepContext(context,"CONOPT")
1626
1627 is_ok = context.TryLink(conopt_test_text,".c")
1628 context.Result(is_ok)
1629
1630 keep.restore(context)
1631
1632 return is_ok
1633
1634 #----------------
1635 # IPOPT test
1636
1637 ipopt_test_text = """
1638 #if !defined(_WIN32)
1639 # define FNAME_LCASE_DECOR
1640 #endif
1641
1642 #include <ipopt/IpStdCInterface.h>
1643 int main(){
1644 Number n;
1645 IpoptProblem nlp = 0;
1646 FreeIpoptProblem(nlp); // probably a crash if you run this
1647 return 0;
1648 }
1649 """
1650
1651 def CheckIPOPT(context):
1652 context.Message( 'Checking for IPOPT... ' )
1653
1654 keep = KeepContext(context,"IPOPT")
1655 is_ok = context.TryLink(ipopt_test_text,".c")
1656 context.Result(is_ok)
1657
1658 keep.restore(context)
1659
1660 return is_ok
1661
1662 #----------------
1663 # Tcl test
1664
1665 # TCL and TK required version 8.1, 8.2, 8.3, or 8.4:
1666 tcltk_minor_newest_acceptable = 4
1667 tcltk_major_required = 8
1668
1669 tcl_check_text = r"""
1670 #include <tcl.h>
1671 #include <stdio.h>
1672 int main(void){
1673 printf("%s",TCL_PATCH_LEVEL);
1674 return 0;
1675 }
1676 """
1677
1678 def CheckTcl(context):
1679 return CheckExtLib(context,'tcl',tcl_check_text,static=env['STATIC_TCLTK'])
1680
1681 def CheckTclVersion(context):
1682 keep = KeepContext(context,'TCL',static=env['STATIC_TCLTK'])
1683 context.Message("Checking Tcl version... ")
1684 (is_ok,output) = context.TryRun(tcl_check_text,'.c')
1685 keep.restore(context)
1686 if not is_ok:
1687 context.Result("failed to run check")
1688 return 0
1689
1690 major,minor,patch = tuple([int(i) for i in output.split(".")])
1691 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1692 context.Result(output+" (bad version)")
1693 # bad version
1694 return 0
1695
1696 # good version
1697 context.Result(output+", good")
1698 return 1
1699
1700 #----------------
1701 # Tk test
1702
1703 tk_check_text = r"""
1704 #include <tk.h>
1705 #include <stdio.h>
1706 int main(void){
1707 printf("%s",TK_PATCH_LEVEL);
1708 return 0;
1709 }
1710 """
1711 def CheckTk(context):
1712 return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
1713
1714
1715 def CheckTkVersion(context):
1716 keep = KeepContext(context,'TK',static=context.env['STATIC_TCLTK'])
1717 context.Message("Checking Tk version... ")
1718 #print "LINKFLAGS =",context.env['LINKFLAGS']
1719 (is_ok,output) = context.TryRun(tk_check_text,'.c')
1720 keep.restore(context)
1721 if not is_ok:
1722 context.Result("failed to run check")
1723 return 0
1724
1725 major,minor,patch = tuple([int(i) for i in output.split(".")])
1726 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1727 # bad version
1728 context.Result(output+" (bad version)")
1729 return 0
1730
1731 # good version
1732 context.Result(output+" (good)")
1733 return 1
1734
1735 #----------------
1736 # Tktable test
1737
1738 tktable_check_text = r"""
1739 #include <tkTable.h>
1740 #include <stdio.h>
1741 int main(void){
1742 Table mytable;
1743 return 0;
1744 }
1745 """
1746
1747 def CheckTkTable(context):
1748 return CheckExtLib(context,'tktable',tktable_check_text,static=env['STATIC_TCLTK'])
1749
1750 #---------------
1751 # X11 test
1752
1753 x11_check_text = r"""
1754 #include <X11/Xlib.h>
1755 #include <X11/IntrinsicP.h>
1756 #include <X11/Intrinsic.h>
1757 #include <X11/ObjectP.h>
1758 #include <X11/Object.h>
1759 int main(void){
1760 Object mything;
1761 return 0;
1762 }
1763 """
1764
1765 def CheckX11(context):
1766 return CheckExtLib(context,'X11',x11_check_text)
1767
1768 #----------------
1769 # Check that we can raise and catch sigint
1770
1771 sigint_test_text = r"""
1772 #include <signal.h>
1773 #include <setjmp.h>
1774 #include <stdlib.h>
1775 static jmp_buf g_jmpenv;
1776 void sighandler(int sig){
1777 longjmp(g_jmpenv,sig);
1778 }
1779 void testsigint(){
1780 raise(SIGINT);
1781 }
1782 int main(void){
1783 signal(SIGINT,&sighandler);
1784 switch(setjmp(g_jmpenv)){
1785 case 0:
1786 testsigint();
1787 exit(1);
1788 case SIGINT:
1789 exit(0);
1790 default:
1791 exit(2);
1792 }
1793 }
1794 """
1795
1796 def CheckSIGINT(context):
1797 context.Message("Checking SIGINT is catchable... ")
1798 (is_ok,output)=context.TryRun(sigint_test_text,".c")
1799 context.Result(is_ok)
1800 return is_ok
1801
1802 #----------------
1803 # Check that we're able to catch floating point errors
1804
1805 sigfpe_test_text = r"""
1806 #include <signal.h>
1807 #include <setjmp.h>
1808 #include <stdlib.h>
1809 #include <fenv.h>
1810 static jmp_buf g_jmpenv;
1811 void fpehandler(int sig){
1812 longjmp(g_jmpenv,sig);
1813 }
1814 int main(void){
1815 fenv_t myfenv;
1816 fegetenv(&myfenv);
1817 fesetenv(&myfenv);
1818 feenableexcept(FE_ALL_EXCEPT);
1819 signal(SIGFPE,&fpehandler);
1820 double x;
1821 switch(setjmp(g_jmpenv)){
1822 case 0:
1823 x = 1.0 / 0.0;
1824 /* failed to catch */
1825 exit(1);
1826 case SIGFPE:
1827 exit(0);
1828 }
1829 }
1830 """
1831
1832 def CheckFPE(context):
1833 context.Message("Checking C99 FPE behaviour... ")
1834 (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1835 context.Result(is_ok)
1836 return is_ok
1837
1838 #----------------
1839 # signal reset needed?
1840
1841 sigreset_test_text = r"""
1842 #include <signal.h>
1843 #include <setjmp.h>
1844 #include <stdlib.h>
1845 #include <stdio.h>
1846 typedef void SigHandlerFn(int);
1847 static jmp_buf g_jmpenv;
1848 void sighandler(int sig){
1849 longjmp(g_jmpenv,sig);
1850 }
1851 void testsigint(){
1852 /* fprintf(stderr,"Raising SIGINT\n"); */
1853 raise(SIGINT);
1854 }
1855 int main(void){
1856 SigHandlerFn *last,*saved;
1857 saved = signal(SIGINT,&sighandler);
1858 if(saved!=SIG_DFL){
1859 fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
1860 exit(3);
1861 }
1862 switch(setjmp(g_jmpenv)){
1863 case 0:
1864 testsigint();
1865 fprintf(stderr,"Back from SIGINT\n");
1866 exit(1);
1867 case SIGINT:
1868 break;
1869 default:
1870 exit(2);
1871 };
1872 last = signal(SIGINT,SIG_DFL);
1873 if(last!=&sighandler){
1874 printf("1");
1875 exit(0);
1876 }
1877 printf("0");
1878 exit(0);
1879 }
1880 """
1881
1882 def CheckSigReset(context):
1883 context.Message("Checking signal handler reset... ")
1884 (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
1885 if not is_ok:
1886 context.Result("ERROR")
1887 return False
1888 if int(output)==1:
1889 context.Result("required");
1890 context.env['ASC_RESETNEEDED'] = True
1891 else:
1892 context.Result("not required");
1893 context.env['ASC_RESETNEEDED'] = False
1894 return True
1895
1896 #----------------
1897 # LyX on this system?
1898
1899 def CheckLyx(context):
1900 context.Message("Checking for LyX... ")
1901 r = context.env.WhereIs("lyx")
1902 if r:
1903 context.Result(r)
1904 else:
1905 context.Result(0)
1906 return r
1907
1908 #----------------
1909 # Latex2HTML on this system?
1910
1911 def CheckLatex2HTML(context):
1912 context.Message("Checking for latex2html...")
1913 if context.env.WhereIs("latex2html"):
1914 r = True
1915 else:
1916 r = False
1917 context.Result(r)
1918 return r
1919
1920 #----------------
1921 # 'lmodern' package for LaTeX available?
1922
1923 lmodern_test_text = r"""
1924 \documentclass{article}
1925 \usepackage{lmodern}
1926 \title{Cartesian closed categories and the price of eggs}
1927 \author{Jane Doe}
1928 \date{September 1994}
1929 \begin{document}
1930 \maketitle
1931 Hello world!
1932 \end{document}
1933 """;
1934
1935 def CheckLModern(context):
1936 context.Message("Checking for lmodern...")
1937 b = context.env.DVI
1938 is_ok = context.TryBuild(builder=b,text=lmodern_test_text,extension=".tex")
1939 context.Result(is_ok)
1940 return is_ok
1941
1942 #----------------
1943 # GCC Version sniffing
1944
1945 # TODO FIXME
1946
1947 gcc_version4 = False
1948
1949 #------------------------------------------------------
1950 # CONFIGURATION
1951
1952 conf = Configure(env
1953 , custom_tests = {
1954 'CheckCC' : CheckCC
1955 , 'CheckCXX' : CheckCXX
1956 , 'CheckF77' : CheckF77
1957 , 'CheckMath' : CheckMath
1958 , 'CheckMalloc' : CheckMalloc
1959 , 'CheckDLOpen' : CheckDLOpen
1960 , 'CheckSwigVersion' : CheckSwigVersion
1961 , 'CheckPythonLib' : CheckPythonLib
1962 , 'CheckCUnit' : CheckCUnit
1963 , 'CheckDMalloc' : CheckDMalloc
1964 , 'CheckLyx' : CheckLyx
1965 , 'CheckLatex2HTML' : CheckLatex2HTML
1966 , 'CheckLModern' : CheckLModern
1967 , 'CheckGraphViz' : CheckGraphViz
1968 , 'CheckGraphVizBoolean' : CheckGraphVizBoolean
1969 , 'CheckUFSparse' : CheckUFSparse
1970 , 'CheckTcl' : CheckTcl
1971 , 'CheckTclVersion' : CheckTclVersion
1972 , 'CheckTk' : CheckTk
1973 , 'CheckTkVersion' : CheckTkVersion
1974 , 'CheckGcc' : CheckGcc
1975 , 'CheckGccVisibility' : CheckGccVisibility
1976 , 'CheckYacc' : CheckYacc
1977 , 'CheckLex' : CheckLex
1978 , 'CheckTkTable' : CheckTkTable
1979 , 'CheckX11' : CheckX11
1980 , 'CheckIDA' : CheckIDA
1981 , 'CheckSUNDIALS' : CheckSUNDIALS
1982 , 'CheckCONOPT' : CheckCONOPT
1983 , 'CheckIPOPT' : CheckIPOPT
1984 , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1985 , 'CheckFPE' : CheckFPE
1986 , 'CheckSIGINT' : CheckSIGINT
1987 , 'CheckSigReset' : CheckSigReset
1988 # , 'CheckIsNan' : CheckIsNan
1989 # , 'CheckCppUnitConfig' : CheckCppUnitConfig
1990 }
1991 # , config_h = "config.h"
1992 )
1993
1994 def sconsversioncheck():
1995
1996 # uncomment the following line to skip the version check:
1997 # return 1
1998
1999 import SCons
2000 v = SCons.__version__.split(".")
2001 if v[0] != '0':
2002 return 0
2003 if int(v[1]) >= 97:
2004 return 1
2005 if v[1] != '96':
2006 return 0
2007 micro = int(v[2])
2008 if micro == 92 or micro == 93 or micro == 96:
2009 return 1;
2010 return 0
2011
2012 if not sconsversioncheck():
2013 print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
2014 print "or consult the developers in the case of newer versions. Modify"
2015 print "the function 'sconsversioncheck' in the file SConstruct if you"
2016 print "want to *force* SCons to continue."
2017 Exit(1)
2018
2019 # check C compiler
2020
2021 if conf.CheckCC() is False:
2022 print "Failed to build simple test file with your C compiler."
2023 print "Check your compiler is installed and running correctly."
2024 Exit(1)
2025
2026 if conf.CheckCXX() is False:
2027 print "Failed to build simple test file with your C++ compiler."
2028 print "Check your compiler is installed and running correctly."
2029 print "You can set your C++ compiler using the CXX scons option."
2030 Exit(1)
2031
2032 # stdio -- just to check that compiler is behaving
2033
2034 if conf.CheckHeader('stdio.h') is False:
2035 print "CPPPATH =",env.get('CPPPATH')
2036 print "Did not find 'stdio.h'! Check your compiler configuration."
2037 print ""
2038 print "You environment is printed here:"
2039 for k,v in os.environ.iteritems():
2040 print "%-30s%s" % ("%s :" % k, v)
2041 Exit(1)
2042
2043 if conf.CheckFunc('snprintf') is False:
2044 print "Didn't find snprintf";
2045 exit(1)
2046
2047 if conf.CheckFunc('strdup'):
2048 conf.env['HAVE_STRDUP'] = True
2049
2050 if platform.system()=="Windows" and env.get('WITH_MSVCR71'):
2051 conf.env.Append(LIBS='msvcr71')
2052
2053 # Math library
2054
2055 conf.env['HAVE_IEEE']=True
2056
2057 if need_libm and (conf.CheckMath() is False):
2058 conf.env['HAVE_IEEE']=False
2059 print 'Did not find math library, exiting!'
2060 Exit(1)
2061
2062 # Malloc
2063
2064 if conf.CheckMalloc() is False:
2065 conf.env['HAVE_MALLOC']=False
2066 print "Did not find functioning 'malloc', exiting!"
2067 Exit(1)
2068
2069 # dlopen/LoadLibrary
2070
2071 # CURRENTLY BREAKS LATER TEST (libsave?)
2072 #if conf.CheckDLOpen() is False:
2073 # print "Did not find functioning dlopen/LoadLibrary, exiting!"
2074 # Exit(1)
2075
2076 # Where is 'isnan'?
2077
2078 if conf.CheckFunc('isnan') is False and conf.CheckFunc('_isnan') is False:
2079 print "Didn't find isnan"
2080 # Exit(1)
2081
2082 # GCC visibility
2083
2084 if conf.CheckGcc():
2085 conf.env['HAVE_GCC']=True;
2086 if env['WITH_GCCVISIBILITY'] and conf.CheckGccVisibility():
2087 conf.env['HAVE_GCCVISIBILITY']=True;
2088 conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
2089 conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
2090 conf.env.Append(CCFLAGS=['-Wall'])
2091
2092 # Catching SIGINT
2093
2094 if env['WITH_SIGNALS']:
2095 if not conf.CheckSIGINT():
2096 with_signals = False
2097 without_signals_reason = "SIGINT uncatchable"
2098
2099 # Catching SIGFPE
2100
2101 if conf.CheckFPE():
2102 conf.env['HAVE_C99FPE']=True
2103 else:
2104 conf.env['HAVE_C99FPE']=False
2105
2106 # Checking for signal reset requirement
2107
2108 if conf.CheckSigReset() is False:
2109 print "Unable to determine if signal reset is required"
2110 Exit(1)
2111
2112 # YACC
2113
2114 if conf.CheckYacc():
2115 conf.env['HAVE_YACC']=True
2116
2117 if conf.CheckLex():
2118 conf.env['HAVE_LEX']=True
2119
2120 # Tcl/Tk
2121
2122 if with_tcltk:
2123 if conf.CheckTcl():
2124 if conf.CheckTclVersion():
2125 if conf.CheckTk():
2126 if with_tcltk and conf.CheckTkVersion():
2127 if env['STATIC_TCLTK']:
2128 if conf.CheckTkTable():
2129 pass
2130 else:
2131 without_tcltk_reason = "TkTable not found"
2132 with_tcltk = False
2133 else:
2134 without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
2135 with_tcltk = False
2136 else:
2137 without_tcltk_reason = "Tk not found."
2138 with_tcltk = False
2139 else:
2140 without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
2141 with_tcltk = False
2142
2143 else:
2144 without_tcltk_reason = "Tcl not found."
2145 with_tcltk = False
2146
2147 if env['STATIC_TCLTK']:
2148 conf.CheckX11()
2149
2150 # Python... obviously we're already running python, so we just need to
2151 # check that we can link to the python library OK:
2152
2153 if not conf.CheckPythonLib():
2154 without_python_reason = 'libpython2.x not found or not linkable'
2155 with_python = False
2156 env['WITH_PYTHON']=False
2157
2158 # SWIG version
2159
2160 if with_python and conf.CheckSwigVersion() is False:
2161 without_python_reason = 'SWIG >= 1.3.24 is required'
2162 with_python = False
2163 env['WITH_PYTHON']=False
2164
2165 # CUnit
2166
2167 if with_cunit:
2168 if not conf.CheckCUnit():
2169 without_cunit_reason = 'CUnit not found'
2170 with_cunit = False
2171 #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
2172
2173 # DMALLOC
2174
2175 if with_dmalloc:
2176 if not conf.CheckDMalloc():
2177 without_dmalloc_reason = 'dmalloc not found'
2178 with_dmalloc = False
2179
2180 # GRAPHVIZ
2181
2182 if with_graphviz:
2183 if not conf.CheckGraphViz():
2184 without_graphviz_reason = 'graphviz not found'
2185 with_graphviz = False
2186 env['WITH_GRAPHVIZ'] = False
2187 env['HAVE_GRAPHVIZ_BOOLEAN'] = conf.CheckGraphVizBoolean()
2188
2189 # UFSPARSE
2190
2191 if with_ufsparse:
2192 if not conf.CheckUFSparse():
2193 without_ufsparse_reason = 'ufsparse not found'
2194 with_ufsparse = False
2195 env['WITH_UFSPARSE'] = False
2196
2197 # IDA
2198
2199 if with_ida:
2200 if not conf.CheckSUNDIALS():
2201 with_ida = False
2202 without_ida_reason = "SUNDIALS not found, or bad version"
2203 elif not conf.CheckIDA():
2204 with_ida = False
2205 without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
2206
2207 # CONOPT
2208
2209 if not with_conopt:
2210 without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2211 elif conf.CheckCONOPT() is False:
2212 if conf.env.get('CONOPT_LINKED'):
2213 conf.env['CONOPT_LINKED'] = False
2214 # we no longer require CONOPT at buildtime in order to build support for it
2215 #with_conopt = False
2216 #without_conpt_reason = "CONOPT not found"
2217
2218 # IPOPT
2219
2220 if not with_ipopt:
2221 without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2222 elif not conf.CheckIPOPT():
2223 with_ipopt = False
2224 without_ipopt_reason = "IPOPT not found"
2225
2226 # BLAS
2227
2228 need_blas=False
2229
2230 if with_lsode:
2231 need_fortran = True
2232 need_fortran_reasons.append("LSODE")
2233 need_blas=True
2234
2235 if need_blas:
2236 if conf.CheckLib('blas'):
2237 with_local_blas = False
2238 without_local_blas_reason = "Found BLAS installed on system"
2239 else:
2240 with_local_blas = True
2241 need_fortran = True
2242 need_fortran_reasons.append("BLAS")
2243 else:
2244 with_local_blas= False;
2245 without_local_blas_reason = "BLAS not required"
2246
2247 # FORTRAN
2248
2249 if need_fortran:
2250 conf.env.Tool('fortran')
2251 detect_fortran = conf.env.Detect(['gfortran','g77'])
2252 if detect_fortran:
2253 # For some reason, g77 doesn't get detected properly on MinGW
2254 if not env.has_key('F77') and not env.has_key('FORTRAN'):
2255 print "Fixing detection of F77 on MinGW...(?)"
2256 conf.env.Replace(F77=detect_fortran)
2257 conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
2258 conf.env.Replace(F77FLAGS='')
2259 #print "F77:",conf.env['F77']
2260 #print "F77COM:",conf.env['F77COM']
2261 #print "F77FLAGS:",conf.env['F77FLAGS']
2262 fortran_builder = Builder(
2263 action='$F77COM'
2264 , suffix='.o'
2265 , src_suffix='.f'
2266 )
2267 conf.env.Append(BUILDERS={'Fortran':fortran_builder})
2268 if platform.system()=="Linux":
2269 conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
2270 else:
2271 with_lsode=False;
2272 without_lsode_reason="FORTRAN-77 required but not found"
2273
2274 if need_fortran and conf.CheckF77() is False:
2275 print "Failed to build simple test file with your Fortran compiler."
2276 print "Check your compiler is installed and running correctly."
2277 print "You can set your Fortran compiler using the FORTRAN scons option."
2278 print "The fortran compiler is REQUIRED to build:",", ".join(need_fortran_reasons)
2279 print "Perhaps try examining the value of your WITH_SOLVERS option (remove LSODE, etc)."
2280 Exit(1)
2281
2282 #else:
2283 # print "FORTRAN not required"
2284
2285 # F2C
2286
2287 if need_fortran:
2288 if platform.system()=="Windows":
2289 pass
2290 #conf.env.Append(LIBPATH='c:\mingw\lib')
2291
2292 # scrollkeeper
2293
2294 if with_scrollkeeper:
2295 if conf.CheckScrollkeeperConfig() is False:
2296 with_scrollkeeper=False
2297 without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2298
2299 # lyx
2300
2301 if with_doc_build:
2302 if conf.CheckLyx() is False:
2303 with_doc_build = False
2304 without_doc_build_reason="unable to locate lyx"
2305
2306 with_latext2html = conf.CheckLatex2HTML()
2307
2308 if conf.CheckLModern() is False:
2309 with_doc_build = False
2310 without_doc_build_reason="'lmodern' is not available"
2311
2312 # TODO: -D_HPUX_SOURCE is needed
2313
2314 # TODO: check size of void*
2315
2316 # TODO: detect if dynamic libraries are possible or not
2317
2318 if platform.system()=="Windows" and env.has_key('MSVS'):
2319 _found_windows_h = conf.CheckHeader('Windows.h')
2320
2321 if not _found_windows_h:
2322 print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2323 Exit(1)
2324
2325 if with_python and conf.CheckHeader(['basetsd.h','BaseTsd.h']) is False:
2326 with_python = 0;
2327 without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
2328
2329 conf.Finish()
2330
2331 #---------------------------------------
2332 # SUBSTITUTION DICTIONARY for .in files
2333
2334 release = env.get('RELEASE')
2335 if release=="0.":
2336 release="0"
2337
2338 #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
2339
2340 subst_dict = {
2341 '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2342 ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2343 , '@GLADE_FILE@':'ascend.glade'
2344 , '@HELP_ROOT@':''
2345 , '@ICON_EXTENSION@':icon_extension
2346 , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
2347 , '@INSTALL_BIN@':env['INSTALL_BIN']
2348 , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2349 , '@INSTALL_LIB@':env['INSTALL_LIB']
2350 , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2351 , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2352 , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2353 , '@VERSION@':version
2354 , '@RELEASE@':release
2355 , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2356 , '@WEBHELPROOT@':'http://ascendwiki.cheme.cmu.edu/Category:Documentation'
2357 , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2358 , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2359 , '@EXTLIB_SUFFIX@':env['EXTLIB_SUFFIX']
2360 , '@EXTLIB_PREFIX@':env['EXTLIB_PREFIX']
2361 , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2362 , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
2363 , '@PYTHON@' : python_exe
2364 , '@PYVERSION@' : pyversion
2365 , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2366 , '@WITH_GRAPHVIZ@': str(int(env.get('WITH_GRAPHVIZ')))
2367 }
2368
2369 if env.get('WITH_DOC'):
2370 print "WITH_DOC:",env['WITH_DOC']
2371 subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2372
2373 # bool options...
2374 for k,v in {
2375 'ASC_WITH_DMALLOC':with_dmalloc
2376 ,'ASC_WITH_UFSPARSE':with_ufsparse
2377 ,'ASC_WITH_MMIO':with_mmio
2378 ,'ASC_SIGNAL_TRAPS':with_signals
2379 ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2380 ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2381 ,'HAVE_IEEE':env.get('HAVE_IEEE')
2382 ,'ASC_ABSOLUTE_PATHS':env.get('ABSOLUTE_PATHS')
2383 ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2384 ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2385 }.iteritems():
2386
2387 if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
2388
2389 if with_python:
2390 subst_dict['@ASCXX_USE_PYTHON@']="1"
2391 env['WITH_PYTHON']=1;
2392
2393 if with_latex2html:
2394 env['WITH_LATEX2HTML']=1
2395
2396 if env.has_key('HAVE_GCCVISIBILITY'):
2397 subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2398
2399 env.Append(SUBST_DICT=subst_dict)
2400
2401 #for k,v in subst_dict.iteritems():
2402 # print "%-50s%s" % ("'%s'"%k,v)
2403
2404 # REMOVED: long command-line support on Win2k
2405
2406 #------------------------------------------------------
2407 # RECIPE: SWIG scanner
2408
2409 import SCons.Script
2410
2411 SWIGScanner = SCons.Scanner.ClassicCPP(
2412 "SWIGScan"
2413 , ".i"
2414 , "CPPPATH"
2415 , '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
2416 )
2417
2418 env.Append(SCANNERS=[SWIGScanner])
2419
2420 #------------------------------------------------------
2421 # Recipe for 'CHMOD' ACTION
2422
2423 import SCons
2424 from SCons.Script.SConscript import SConsEnvironment
2425 SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod,
2426 lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))
2427
2428 def InstallPerm(env, dest, files, perm):
2429 obj = env.Install(dest, files)
2430 for i in obj:
2431 env.AddPostAction(i, env.Chmod(str(i), perm))
2432
2433 SConsEnvironment.InstallPerm = InstallPerm
2434
2435 # define wrappers
2436 SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)
2437 SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2438 SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2439
2440 #------------------------------------------------------
2441 # BUILD...
2442
2443 # so that #include <modulename/headername.h> works across all modules...
2444 env.AppendUnique(CPPPATH=['#base/generic'])
2445
2446 if env['DEBUG']:
2447 env.Append(CCFLAGS=['-g'])
2448 env.Append(LINKFLAGS=['-g'])
2449
2450 if env['GCOV']:
2451 env.Append(
2452 CPPFLAGS=['-g','-fprofile-arcs','-ftest-coverage']
2453 , LIBS=['gcov']
2454 , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
2455 )
2456
2457 if with_ida:
2458 env.Append(WITH_IDA=1)
2459
2460 if with_conopt:
2461 env.Append(WITH_CONOPT=1)
2462
2463 if with_ipopt:
2464 env.Append(WITH_IPOPT=1)
2465
2466 if with_dopri5:
2467 env.Append(WITH_DOPRI5=1)
2468
2469 if with_graphviz and env.get('GRAPHVIZ_RPATH'):
2470 env.Append(RPATH=env['GRAPHVIZ_RPATH'])
2471
2472 #-------------
2473 # TCL/TK GUI
2474
2475 if with_tcltk:
2476 env.SConscript(['tcltk/generic/interface/SConscript'],'env')
2477 else:
2478 print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2479
2480 #-------------
2481 # PYTHON INTERFACE
2482
2483 if with_python:
2484 env.SConscript(['pygtk/SConscript'],'env')
2485 else:
2486 print "Skipping... Python bindings aren't being built:",without_python_reason
2487
2488 #------------
2489 # BASE/GENERIC SUBDIRECTORIES
2490
2491 libascend_env = env.Copy()
2492
2493 dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2494
2495 srcs = []
2496 for d in dirs:
2497 heresrcs = libascend_env.SConscript('base/generic/'+d+'/SConscript','libascend_env')
2498 srcs += heresrcs
2499
2500 #-------------
2501 # IMPORTED CODE: LSODE, BLAS, etc
2502
2503 #if with_lsode:
2504 # srcs += env.SConscript(['lsod/SConscript'],'env')
2505 # srcs += env.SConscript(['linpack/SConscript'],'env')
2506 #else:
2507 # print "Skipping... LSODE won't be built:", without_lsode_reason
2508
2509 if with_local_blas:
2510 env['blasobjs'] = env.SConscript(['blas/SConscript'],'env')
2511 else:
2512 env['blasobjs'] = []
2513 print "Skipping... BLAS won't be built:", without_local_blas_reason
2514
2515 if not with_ida:
2516 print "Skipping... IDA won't be built:", without_ida_reason
2517
2518 if not with_dopri5:
2519 print "Skipping... DOPRI5 won't be built:", without_dopri5_reason
2520
2521 if with_mmio:
2522 srcs += env.SConscript(['mmio/SConscript'],'env')
2523 else:
2524 print "Skipping... MMIO export won't be built:", without_mmio_reason
2525 #-------------
2526 # LIBASCEND -- all base/generic functionality
2527
2528 if with_dmalloc:
2529 libascend_env.Append(LIBS=['dmalloc'])
2530
2531 if with_ufsparse:
2532 libascend_env.Append(LIBS=['cxsparse'])
2533
2534 libascend = libascend_env.SharedLibrary('ascend',srcs)
2535
2536 # for use in declaring dependent shared libraries in SConscript files (eg solvers/*/SConscript)
2537 env['libascend'] = libascend
2538
2539 env.Alias('libascend',libascend)
2540
2541 #-------------
2542 # UNIT TESTS (C CODE)
2543
2544 if with_cunit:
2545 testdirs = ['general','solver','utilities','linear','compiler']
2546 testsrcs = []
2547 for testdir in testdirs:
2548 path = 'base/generic/'+testdir+'/test/'
2549 env.SConscript([path+'SConscript'],'env')
2550 testsrcs += [i.path for i in env['TESTSRCS_'+testdir.upper()]]
2551
2552 #print "TESTSRCS =",testsrcs
2553
2554 env.SConscript(['test/SConscript'],'env')
2555 env.SConscript(['base/generic/test/SConscript'],'env')
2556
2557 env.Alias('test',[env.Dir('test'),env.Dir('base/generic/test')])
2558
2559 else:
2560 print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2561
2562 #-------------
2563 # EXTERNAL SOLVERS
2564
2565 env['extfns']=[]
2566
2567 env.SConscript(['solvers/SConscript'],'env')
2568
2569 #-------------
2570 # EXTERNAL FUNCTIONS
2571
2572 modeldirs = env.SConscript(['models/SConscript'],'env')
2573
2574 if not with_extfns:
2575 print "Skipping... External modules aren't being built:",without_extfns_reason
2576
2577 env.Alias('extfns',env['extfns'])
2578
2579 #------------------------------------------------------
2580 # CREATE ASCEND-CONFIG scriptlet
2581
2582 ascendconfig = env.SubstInFile('ascend-config.in')
2583
2584
2585 #------------------------------------------------------
2586 # CREATE asc4dev scriptlet
2587
2588 asc4devcmd = env.SubstInFile('tcltk/asc4dev.in')
2589 env.AddPostAction(asc4devcmd, 'chmod 755 $TARGET')
2590 #------------------------------------------------------
2591 # INSTALLATION
2592
2593 if env.get('CAN_INSTALL'):
2594
2595 dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC']
2596 install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2597 install_dirs += modeldirs + [Dir(env.subst("$INSTALL_ROOT$INSTALL_SOLVERS"))]
2598
2599 # TODO: add install options
2600 env.Alias('install',install_dirs)
2601
2602 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2603
2604 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2605
2606 #------------------------------------------------------
2607 # WINDOWS INSTALLER
2608
2609 if not env.get('NSIS'):
2610 with_installer = False
2611 without_installer_reason = "NSIS not found"
2612
2613 if with_installer:
2614 env.Append(NSISDEFINES={
2615 'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2616 ,"VERSION":version
2617 ,'PYVERSION':pyversion
2618 })
2619 installer = env.Installer('nsis/installer.nsi')
2620 Depends(installer,["pygtk","tcltk","ascend.dll","models","ascend-config"])
2621 env.Alias('installer',installer)
2622 else:
2623 print "Skipping... Windows installer isn't being built:",without_installer_reason
2624
2625
2626 #------------------------------------------------------
2627 # PROJECT FILE for MSVC
2628
2629 env.SConscript(['base/msvc/SConscript'],['env','libascend']);
2630
2631 #------------------------------------------------------
2632 # CREATE the SPEC file for generation of RPM packages
2633
2634 if platform.system()=="Linux":
2635 env.SubstInFile('ascend.spec.in')
2636
2637 #------------------------------------------------------
2638 # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2639
2640 #if with_scrollkeeper:
2641 # #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2642 # #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2643
2644 #------------------------------------------------------
2645 # DISTRIBUTION TAR FILE
2646
2647 env['DISTTAR_FORMAT']='bz2'
2648 env.Append(
2649 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']
2650 , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2651 )
2652
2653 tar = env.DistTar("dist/"+env['DISTTAR_NAME']
2654 , [env.Dir('#')]
2655 )
2656
2657 env.Depends(tar,'ascend.spec')
2658 env.Depends(tar,'#doc/book.pdf')
2659
2660 #------------------------------------------------------
2661 # DISTRIBUTION TAR FILE (new style with AccumulateBuilder)
2662
2663 # ...
2664
2665 #------------------------------------------------------
2666 # DEBIAN TARBALL for use with Build Service
2667
2668 import glob
2669 deb_manfiles = glob.glob('debian/*.man')
2670
2671 deb_tar = env.Tar(
2672 'dist/debian.tar.gz'
2673 ,deb_manfiles + ['debian/compat','debian/copyright','debian/dirs'
2674 ,'debian/postinst','debian/postrm']
2675 ,TARFLAGS = ['cz']
2676 )
2677
2678 Alias('dist',[tar,deb_tar])
2679
2680 #------------------------------------------------------
2681 # DOCUMENTATION
2682
2683
2684 if not with_doc_build:
2685 print "Skipping... Documentation isn't being built:",without_doc_build_reason
2686
2687 #user's manual
2688 env.SConscript('doc/SConscript',['env'])
2689
2690 # doxygen documentation
2691 env.SConscript('base/doc/SConscript',['env'])
2692
2693 #------------------------------------------------------
2694 # RPM BUILD
2695
2696 # for RPM builds, 'scons dist' then 'rpmbuild -ta dist/ascend-*.tar.bz2'
2697 # (check * for the version number used to create the tarball)
2698
2699 #------------------------------------------------------
2700 # DEFAULT TARGETS
2701
2702 default_targets =['libascend','solvers']
2703 if with_tcltk:
2704 default_targets.append('tcltk')
2705 if with_python:
2706 default_targets.append('pygtk')
2707 if with_installer:
2708 default_targets.append('installer')
2709 if with_extfns:
2710 default_targets.append('extfns')
2711 if with_doc_build:
2712 default_targets.append('doc')
2713
2714 env.Default(default_targets)
2715
2716 print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
2717
2718 # vim: set syntax=python:

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