/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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