/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1792 - (hide annotations) (download)
Fri Jun 20 06:44:52 2008 UTC (11 years, 5 months ago) by jpye
File size: 64282 byte(s)
Change to MUMPS from test of IPOPT.
Tested with F9.
1 jpye 1712 import sys, os, commands, platform, distutils.sysconfig, os.path, re, types
2 jpye 1759 version = "0.9.5.115"
3 johnpye 439
4 jpye 1466 pyversion = "%d.%d" % (sys.version_info[0],sys.version_info[1])
5    
6 johnpye 385 #------------------------------------------------------
7     # OPTIONS
8 johnpye 392 #
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 johnpye 385
12     opts = Options(['options.cache', 'config.py'])
13 johnpye 464 #print "PLATFORM = ",platform.system()
14 johnpye 385
15 jpye 1488 default_tcl_cpppath = "$TCL/include"
16 jpye 1501 default_tron_envvar="TRON_PATH"
17     default_conopt_envvar="CONOPT_PATH"
18 jpye 1732 default_graphviz_rpath = None
19 jpye 1488
20 johnpye 464 if platform.system()=="Windows":
21 johnpye 631 default_tcl_lib = "tcl84"
22     default_tk_lib = "tk84"
23 johnpye 464 default_tktable_lib = "Tktable28"
24 johnpye 499 default_install_assets = "glade/"
25     icon_extension = '.png'
26 johnpye 521 default_tcl = "c:\\Tcl"
27 jpye 1645 if os.environ.get('MSYSTEM'):
28 johnpye 642 default_tcl_libpath="$TCL\\bin"
29     else:
30     default_tcl_libpath="$TCL\\lib"
31 johnpye 627 default_rel_distdir = '.'
32 johnpye 628 default_absolute_paths = False
33 johnpye 739
34     default_ida_prefix = "c:\\MinGW"
35     if not os.path.exists(default_ida_prefix):
36     default_ida_prefix = None
37 johnpye 783
38 johnpye 800 default_conopt_prefix = "c:\\Program Files\\CONOPT"
39     default_conopt_libpath="$CONOPT_PREFIX"
40     default_conopt_cpppath="$CONOPT_PREFIX"
41 jpye 1399 default_conopt_dlpath="$CONOPT_PREFIX"
42 johnpye 800 default_conopt_lib="conopt3"
43 johnpye 935
44 jpye 1515 default_tron_prefix="c:\\Program Files\\TRON"
45     default_tron_dlpath="$TRON_PREFIX"
46     default_tron_lib="tron1"
47 jpye 1501
48 johnpye 938 default_prefix="c:\\MinGW"
49     default_libpath="$DEFAULT_PREFIX\\lib"
50     default_cpppath="$DEFAULT_PREFIX\\include"
51 johnpye 800
52 johnpye 783 if not os.path.exists(default_conopt_prefix):
53     default_conopt_prefix = None
54 johnpye 739
55 johnpye 673 need_libm = False
56 jpye 1592 python_exe = sys.executable
57 johnpye 816 default_with_scrollkeeper=False
58 jpye 1504 pathsep = ";"
59 jpye 1566
60     default_fortran="g77"
61     default_f2c_lib="g2c"
62 jpye 1597
63 jpye 1720 default_graphviz_libs=['graph', 'gvc', 'pathplan', 'cdt', 'expat', 'zlib1', 'ltdl', 'msvcr80']
64 jpye 1732 default_graphviz_libpath = default_libpath
65 jpye 1720
66 johnpye 464 else:
67 jpye 1787 default_tcl_lib = "tcl8.5"
68     default_tk_lib = "tk8.5"
69     default_tktable_lib = "Tktable2.9"
70 johnpye 628 default_install_assets = "$INSTALL_ASCDATA/glade/"
71 johnpye 499 icon_extension = '.svg'
72 johnpye 684 default_tcl = '/usr'
73 jpye 1488 default_tcl_libpath = "$TCL/lib"
74    
75     if os.path.exists("/etc/debian_version"):
76     default_tcl_cpppath = "/usr/include/tcl8.4"
77 jpye 1787 default_tcl_lib = "tcl8.4"
78     default_tk_lib = "tk8.4"
79     default_tktable_lib = "Tktable2.8"
80 jpye 1488
81 johnpye 627 default_rel_distdir = '../share/ascend'
82 johnpye 628 default_absolute_paths = True
83 jpye 1400 default_ida_prefix="/usr"
84 johnpye 783 default_conopt_prefix="/usr"
85 johnpye 800 default_conopt_libpath="$CONOPT_PREFIX/lib"
86     default_conopt_cpppath="$CONOPT_PREFIX/include"
87 jpye 1399 default_conopt_dlpath= default_conopt_libpath + ":/usr/local/lib"
88 johnpye 800 default_conopt_lib="consub3"
89    
90 jpye 1501 default_tron_prefix="/usr"
91     default_tron_dlpath="$TRON_PREFIX/lib"
92     default_tron_lib="tron1"
93    
94 johnpye 938 default_prefix="/usr"
95     default_libpath="$DEFAULT_PREFIX/lib"
96     default_cpppath="$DEFAULT_PREFIX/include"
97    
98 johnpye 673 need_libm = True
99 johnpye 551 if not os.path.isdir(default_tcl):
100     default_tcl = '/usr'
101 johnpye 683 python_exe = distutils.sysconfig.EXEC_PREFIX+"/bin/python"
102 johnpye 816 default_with_scrollkeeper=False
103 jpye 1504 pathsep = ":"
104 jpye 1566
105     default_fortran="gfortran"
106     default_f2c_lib="gfortran"
107 jpye 1720
108 jpye 1732
109 jpye 1792 default_graphviz_libs=["graph","cdt","gvc"]
110 jpye 1732 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 jpye 1597
116 johnpye 562 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 johnpye 591 opts.Add(BoolOption(
129     'GCOV'
130 johnpye 593 , 'Whether to enable coverage testing in object code'
131     , False
132 johnpye 591 ))
133    
134 johnpye 526 opts.Add(BoolOption(
135     'WITH_GCCVISIBILITY'
136     ,"Whether to use GCC Visibility features (only applicable if available)"
137     ,True
138     ))
139    
140 johnpye 1142 opts.Add(BoolOption(
141     'WITH_SIGNALS'
142     ,"Whether to permit use of signals for flow control in the C-level code"
143 johnpye 1234 ,True
144 johnpye 1142 ))
145    
146 johnpye 392 # You can turn off building of Tcl/Tk interface
147 johnpye 386 opts.Add(BoolOption(
148 johnpye 542 'WITH_TCLTK'
149 johnpye 673 ,"Set to False if you don't want to build the original Tcl/Tk GUI."
150 johnpye 542 , True
151 johnpye 386 ))
152    
153 johnpye 392 # You can turn off the building of the Python interface
154 johnpye 387 opts.Add(BoolOption(
155 johnpye 542 'WITH_PYTHON'
156 johnpye 673 ,"Set to False if you don't want to build Python wrappers."
157 johnpye 542 , True
158 johnpye 387 ))
159    
160 johnpye 392 # Which solvers will we allow?
161     opts.Add(ListOption(
162     'WITH_SOLVERS'
163 johnpye 393 ,"List of the solvers you want to build. The default is the minimum that"
164 jpye 1520 +" works. The option 'LSOD' is provided for backwards compatibility"
165     +"; the value 'LSODE' is preferred."
166 jpye 1734 ,["QRSLV","CMSLV","LSODE","IDA","CONOPT","LRSLV","TRON","IPOPT","DOPRI5"]
167 johnpye 392 ,['QRSLV','MPS','SLV','OPTSQP'
168     ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
169 jpye 1734 ,'LSODE','LSOD','OPTSQP',"IDA","TRON","IPOPT","DOPRI5"
170 johnpye 392 ]
171     ))
172    
173 johnpye 393 # Where will the local copy of the help files be kept?
174 jpye 1442 opts.Add(BoolOption(
175     'WITH_DOC'
176 jpye 1443 , "Should we try to build and install help files? If not, ASCEND will access online help files"
177 jpye 1442 , True
178 johnpye 393 ))
179    
180 jpye 1443 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 jpye 1442 opts.Add(
193     'HELP_ROOT'
194     , "Location of the main help file"
195     , "$INSTALL_DOC/book.pdf"
196     )
197    
198 johnpye 393 # 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 johnpye 398 # What should the default ASCENDLIBRARY path be?
207     # Note: users can change it by editing their ~/.ascend.ini
208 johnpye 393 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 jpye 1519 ,"$INSTALL_MODELS"
213 johnpye 393 )
214    
215 jpye 1519 # 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 johnpye 398 # 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 johnpye 404 +" 'c:\\msys\\1.0\\home\\john\\swigwin-1.3.29\\swig.exe'."
230 johnpye 398 )
231    
232 johnpye 400 # Build the test suite?
233     opts.Add(BoolOption(
234 johnpye 593 'WITH_CUNIT'
235 johnpye 665 ,"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 johnpye 400 ))
242 johnpye 393
243 johnpye 993 # 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 johnpye 938 #----- 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 johnpye 957 #------ install location for python extensions ------
258    
259     # (removed for the moment)
260    
261 johnpye 938 #------ cunit --------
262 johnpye 935 # Where was CUNIT installed?
263     opts.Add(PackageOption(
264     'CUNIT_PREFIX'
265     ,"Where are your CUnit files?"
266 johnpye 938 ,"$DEFAULT_PREFIX"
267 johnpye 935 ))
268    
269 johnpye 400 # Where are the CUnit includes?
270     opts.Add(PackageOption(
271     'CUNIT_CPPPATH'
272     ,"Where are your CUnit include files?"
273 johnpye 938 ,"$CUNIT_PREFIX/include"
274 johnpye 400 ))
275 johnpye 392
276 johnpye 404 # Where are the CUnit libraries?
277 johnpye 400 opts.Add(PackageOption(
278     'CUNIT_LIBPATH'
279 johnpye 404 ,"Where are your CUnit libraries?"
280 johnpye 938 ,"$CUNIT_PREFIX/lib"
281 johnpye 400 ))
282    
283 johnpye 938 #-------- ida -------
284    
285 johnpye 673 opts.Add(PackageOption(
286 jpye 1400 "SUNDIALS_PREFIX"
287 johnpye 673 ,"Prefix for your IDA install (IDA ./configure --prefix)"
288     ,default_ida_prefix
289     ))
290 johnpye 521
291 johnpye 534 opts.Add(
292 jpye 1400 'SUNDIALS_CPPPATH'
293 johnpye 673 ,"Where is your ida.h?"
294 jpye 1400 ,"$SUNDIALS_PREFIX/include"
295 johnpye 673 )
296    
297 jpye 1404 #
298 johnpye 673 opts.Add(
299 jpye 1400 'SUNDIALS_LIBPATH'
300 johnpye 673 ,"Where are your SUNDIALS libraries installed?"
301 jpye 1400 ,"$SUNDIALS_PREFIX/lib"
302 johnpye 673 )
303    
304 jpye 1404 opts.Add(
305     'SUNDIALS_LIBS'
306 jpye 1546 ,"What libraries are required for SUNDIALS?"
307 jpye 1404 ,['sundials_nvecserial','sundials_ida','m']
308     )
309    
310 johnpye 938 # ----- conopt-----
311 johnpye 783
312     opts.Add(PackageOption(
313     "CONOPT_PREFIX"
314     ,"Prefix for your CONOPT install (CONOPT ./configure --prefix)"
315 johnpye 800 ,default_conopt_prefix
316 johnpye 783 ))
317    
318 johnpye 673 opts.Add(
319 johnpye 783 "CONOPT_LIB"
320 jpye 1747 ,"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 johnpye 800 ,default_conopt_lib
322 johnpye 783 )
323    
324 jpye 1541 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 johnpye 783 opts.Add(
331     'CONOPT_CPPPATH'
332     ,"Where is your conopt.h?"
333 johnpye 800 ,default_conopt_cpppath
334 johnpye 783 )
335    
336     opts.Add(
337     'CONOPT_LIBPATH'
338 jpye 1399 ,"Where is your CONOPT library installed?"
339 johnpye 800 ,default_conopt_libpath
340 johnpye 783 )
341    
342     opts.Add(
343 jpye 1399 'CONOPT_DLPATH'
344 jpye 1747 ,"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 jpye 1399 ,default_conopt_dlpath
346     )
347    
348     opts.Add(
349 johnpye 800 'CONOPT_ENVVAR'
350 jpye 1747 ,"Name of the optional environment variable which will be used for the value of the searchpath for the CONOPT DLL/SO."
351 johnpye 800 ,default_conopt_envvar
352     )
353    
354 jpye 1546 #------- 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 jpye 1547 "IPOPT_LIBS"
364 jpye 1546 ,"Library linked to for IPOPT"
365 jpye 1547 ,["$F2C_LIB","blas","lapack","pthread","ipopt"]
366 jpye 1546 )
367    
368 jpye 1547
369 jpye 1546 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 jpye 1770 ,"Where is your IPOPT coin/IpStdCInterface.h (do not include the 'coin' in the path)"
378 jpye 1546 ,"$IPOPT_PREFIX/include"
379     )
380    
381    
382 jpye 1501 #------- 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 jpye 1515 opts.Add(
397 jpye 1501 "TRON_PREFIX"
398     ,"Prefix for your TRON install"
399     ,default_tron_prefix
400 jpye 1515 )
401 jpye 1501
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 johnpye 938 #-------- f2c ------
409    
410 johnpye 800 opts.Add(
411 johnpye 673 "F2C_LIB"
412     ,"F2C library (eg. g2c, gfortran, f2c)"
413 jpye 1566 ,default_f2c_lib # the default is gfortran now
414 johnpye 673 )
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 jpye 1398 opts.Add(
423     "FORTRAN"
424     ,"Fortran compiler (eg g77, gfortran)"
425 jpye 1566 ,default_fortran
426 jpye 1398 )
427    
428 johnpye 938 #------- tcl/tk --------
429    
430 johnpye 673 opts.Add(
431 johnpye 521 'TCL'
432     ,'Base of Tcl distribution'
433     ,default_tcl
434 johnpye 534 )
435 johnpye 521
436 johnpye 404 # Where are the Tcl includes?
437 johnpye 534 opts.Add(
438 johnpye 404 'TCL_CPPPATH'
439     ,"Where are your Tcl include files?"
440 jpye 1488 ,default_tcl_cpppath
441 johnpye 534 )
442 johnpye 404
443     # Where are the Tcl libs?
444 johnpye 534 opts.Add(
445 johnpye 404 'TCL_LIBPATH'
446     ,"Where are your Tcl libraries?"
447 johnpye 541 ,default_tcl_libpath
448 johnpye 534 )
449 johnpye 404
450 johnpye 428 # What is the name of the Tcl lib?
451     opts.Add(
452     'TCL_LIB'
453 johnpye 561 ,"Name of Tcl lib (eg 'tcl' or 'tcl83'), for full path to static library (if STATIC_TCLTK is set)"
454 johnpye 464 ,default_tcl_lib
455 johnpye 428 )
456    
457 johnpye 405 # Where are the Tk includes?
458 johnpye 534 opts.Add(
459 johnpye 405 'TK_CPPPATH'
460     ,"Where are your Tk include files?"
461 johnpye 464 ,'$TCL_CPPPATH'
462 johnpye 534 )
463 johnpye 404
464 johnpye 405 # Where are the Tk libs?
465 johnpye 534 opts.Add(
466 johnpye 405 'TK_LIBPATH'
467     ,"Where are your Tk libraries?"
468 johnpye 464 ,'$TCL_LIBPATH'
469 johnpye 534 )
470 johnpye 405
471 johnpye 428 # What is the name of the Tk lib?
472     opts.Add(
473     'TK_LIB'
474 johnpye 521 ,"Name of Tk lib (eg 'tk' or 'tk83'), or full path to static library"
475 johnpye 464 ,default_tk_lib
476 johnpye 435 )
477    
478 johnpye 460 # Static linking to TkTable
479    
480     opts.Add(BoolOption(
481 johnpye 521 'STATIC_TCLTK'
482 johnpye 554 ,'Set true for static linking for Tcl/Tk and TkTable. EXPERIMENTAL'
483 johnpye 460 ,False
484     ))
485    
486 johnpye 464 opts.Add(
487 johnpye 460 'TKTABLE_LIBPATH'
488     ,'Location of TkTable static library'
489 johnpye 464 ,'$TCL_LIBPATH/Tktable2.8'
490     )
491 johnpye 460
492 johnpye 435 opts.Add(
493 johnpye 460 'TKTABLE_LIB'
494 johnpye 521 ,'Stem name of TkTable (eg tktable2.8, no ".so" or "lib") shared library, or full path of static tktable (/usr/lib/...)'
495 johnpye 464 ,default_tktable_lib
496 johnpye 460 )
497    
498     opts.Add(
499 johnpye 521 'TKTABLE_CPPPATH'
500     ,'Location of TkTable header file'
501     ,'$TCL_CPPPATH'
502     )
503    
504     opts.Add(
505     'X11'
506 johnpye 554 ,'Base X11 directory. Only used when STATIC_TCLTK is turned on. EXPERIMENTAL'
507 johnpye 521 ,'/usr/X11R6'
508     )
509    
510     opts.Add(
511     'X11_LIBPATH'
512 johnpye 554 ,'Location of X11 lib. EXPERIMENTAL'
513 johnpye 521 ,'$X11/lib'
514     )
515    
516     opts.Add(
517     'X11_CPPPATH'
518 johnpye 554 ,'Location of X11 includes. EXPERIMENTAL'
519 johnpye 521 ,'$X11/include'
520     )
521    
522     opts.Add(
523     'X11_LIB'
524 johnpye 554 ,'Name of X11 lib. EXPERIMENTAL'
525 johnpye 521 ,'X11'
526     )
527    
528 johnpye 938 #----- installed file locations (for 'scons install') -----
529    
530 johnpye 521 opts.Add(
531 johnpye 435 'INSTALL_PREFIX'
532     ,'Root location for installed files'
533 johnpye 449 ,'/usr/local'
534 johnpye 428 )
535    
536 johnpye 435 opts.Add(
537     'INSTALL_BIN'
538     ,'Location to put binaries during installation'
539     ,"$INSTALL_PREFIX/bin"
540     )
541    
542     opts.Add(
543 johnpye 463 'INSTALL_LIB'
544 johnpye 683 ,'Location to put libraries during installation'
545 johnpye 463 ,"$INSTALL_PREFIX/lib"
546     )
547    
548     opts.Add(
549 ben.allan 624 'INSTALL_SHARE'
550 johnpye 628 ,'Common shared-file location on this system'
551     ,"$INSTALL_PREFIX/share"
552 johnpye 435 )
553    
554 johnpye 816 opts.Add(
555 johnpye 628 'INSTALL_ASCDATA'
556     ,"Location of ASCEND shared data (TK, python, models etc)"
557     ,"$INSTALL_SHARE/ascend"
558     )
559    
560     opts.Add(
561 jpye 1504 '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 jpye 1442 'INSTALL_DOC'
574     ,"Location of ASCEND documentation files"
575     ,"$INSTALL_SHARE/doc/ascend-"+version
576     )
577    
578     opts.Add(
579 johnpye 435 'INSTALL_INCLUDE'
580     ,'Location to put header files during installation'
581     ,"$INSTALL_PREFIX/include"
582     )
583    
584 johnpye 938
585 johnpye 448 opts.Add(
586 johnpye 938 'INSTALL_ROOT'
587     ,'For use by RPM only: location of %{buildroot} during rpmbuild'
588     ,""
589     )
590    
591 jpye 1597 opts.Add(
592     'EXTLIB_SUFFIX'
593     ,"Filename suffix for ASCEND 'external libraries' (for use with IMPORT"
594 jpye 1598 ,"_ascend$SHLIBSUFFIX"
595 jpye 1597 )
596    
597     opts.Add(
598     'EXTLIB_PREFIX'
599     ,"Filename suffix for ASCEND 'external libraries' (for use with IMPORT"
600     ,"$SHLIBPREFIX"
601     )
602    
603 johnpye 938 #----------------------
604    
605     opts.Add(
606 johnpye 455 'PYGTK_ASSETS'
607 johnpye 532 ,'Default location for Glade assets (placed in pygtk/config.py)'
608 johnpye 455 ,default_install_assets
609     )
610    
611 johnpye 508 opts.Add(BoolOption(
612     'DEBUG'
613     ,"Compile source with debugger symbols, eg for use with 'gdb'"
614     ,False
615     ))
616    
617 johnpye 597 opts.Add(BoolOption(
618     'MALLOC_DEBUG'
619     ,"Compile with debugging version of MALLOC. Required for full CUnit testing"
620     ,False
621     ))
622    
623 johnpye 938 #------ dmalloc --------
624     opts.Add(PackageOption(
625     'DMALLOC_PREFIX'
626     ,"Where are your dmalloc files?"
627     ,default_prefix
628     ))
629 johnpye 448
630 johnpye 938 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 jpye 1326 #------ f --------
649 johnpye 1109 opts.Add(PackageOption(
650 jpye 1678 'GRAPHVIZ_PREFIX'
651     ,"Where are your GRAPHVIZ files?"
652 johnpye 1109 ,default_prefix
653     ))
654    
655     opts.Add(PackageOption(
656 jpye 1678 'GRAPHVIZ_CPPPATH'
657 jpye 1713 ,"Where are your GRAPHVIZ include files? (don't need the final '/graphviz')"
658 johnpye 1109 ,default_cpppath
659     ))
660    
661     opts.Add(PackageOption(
662 jpye 1678 'GRAPHVIZ_LIBPATH'
663     ,"Where are your GRAPHVIZ libraries?"
664 jpye 1732 ,default_graphviz_libpath
665 johnpye 1109 ))
666    
667 jpye 1678 opts.Add(
668     'GRAPHVIZ_LIBS'
669     ,"What are your GRAPHVIZ libraries named?"
670 jpye 1720 ,default_graphviz_libs
671 jpye 1678 )
672    
673 jpye 1718 opts.Add(PackageOption(
674     'GRAPHVIZ_RPATH'
675 jpye 1732 ,"What is your GRAPHVIZ rpath for locating libraries at runtime? (only required for old Ubuntu)"
676     ,default_graphviz_rpath
677 jpye 1718 ))
678    
679 johnpye 1109 opts.Add(BoolOption(
680 jpye 1678 'WITH_GRAPHVIZ'
681     ,"Link to the GRAPHVIZ library (if available, for generating incidence graphs)"
682 johnpye 1109 ,True
683     ))
684    
685 jpye 1326
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 johnpye 938 #-----------------------
712    
713 jpye 1557 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 johnpye 563 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 johnpye 656 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 johnpye 605 opts.Add(BoolOption(
732 johnpye 628 'ABSOLUTE_PATHS'
733 johnpye 605 ,"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 johnpye 628 ,default_absolute_paths
735 johnpye 605 ))
736    
737 johnpye 578 opts.Add(
738     'WIN_INSTALLER_NAME'
739     ,"Name of the installer .exe to create under Windows (minus the '.exe')"
740 jpye 1467 ,"ascend-"+version+"-py"+pyversion+".exe"
741 johnpye 578 )
742    
743 johnpye 594 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 johnpye 761 opts.Add(BoolOption(
750     'WITH_EXTFNS'
751 jpye 1504 ,"Set to 0 if you don't want to attempt to build the external modules bundled with ASCEND"
752 johnpye 761 ,True
753     ))
754    
755 johnpye 816 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 jpye 1720 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 jpye 1557
767 johnpye 546 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 johnpye 832
775    
776 johnpye 392 # TODO: OTHER OPTIONS?
777     # TODO: flags for optimisation
778 johnpye 393 # TODO: turning on/off bintoken functionality
779 johnpye 427 # TODO: Where will the 'Makefile.bt' file be installed?
780 johnpye 393
781 johnpye 498 # Import the outside environment
782    
783 johnpye 800 def c_escape(str):
784     return re.sub("\\\\","/",str)
785    
786     envadditional={}
787 johnpye 740
788 jpye 1630 tools = [
789 jpye 1645 'lex', 'yacc', 'fortran', 'swig', 'nsis', 'substinfile'
790 jpye 1630 ,'disttar', 'tar'
791     ]
792 johnpye 832 if platform.system()=="Windows":
793 johnpye 1078 if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):
794 johnpye 832 envenv = os.environ;
795 jpye 1459 tools += ['mingw']
796 johnpye 922 #TODO removed 'doxygen' for SCons 0.96.93
797 johnpye 832 envadditional['IS_MINGW']=True
798     else:
799 johnpye 1082 print "Assuming VC++ build environment (Note: MinGW is preferred)"
800 johnpye 832 envenv = {
801     'PATH':os.environ['PATH']
802     ,'INCLUDE':os.environ['INCLUDE']
803     ,'LIB':os.environ['LIB']
804     ,'MSVS_IGNORE_IDE_PATHS':1
805     }
806 jpye 1459 tools += ['default']
807 johnpye 922 #TODO removed 'doxygen' for SCons 0.96.93
808 johnpye 832 envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
809 johnpye 498 else:
810 johnpye 832 if os.environ.get('TARGET')=='mingw':
811     envenv = os.environ
812 jpye 1459 tools += ['crossmingw']
813 jpye 1420 envadditional['CPPPATH']=['/usr/lib/gcc/i586-mingw32msvc/3.4.5/include','/usr/include']
814     envadditional['LIBS']=['gcc']
815 johnpye 832 else:
816     envenv = os.environ
817 jpye 1459 tools += ['default']
818 johnpye 922 #TODO removed 'doxygen' for SCons 0.96.93
819 johnpye 800
820 johnpye 832
821 johnpye 800 env = Environment(
822     ENV=envenv
823     , toolpath=['scons']
824     , tools=tools
825     , **envadditional
826     )
827 johnpye 498
828 jpye 1420 #print "PATH =",os.environ['PATH']
829     #print "PROGSUFFIX =",env['PROGSUFFIX']
830     #print "CPPPATH =",env['CPPPATH']
831 jpye 1380
832 johnpye 385 opts.Update(env)
833 jpye 1520
834 jpye 1712 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 jpye 1520 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 johnpye 385 opts.Save('options.cache',env)
845    
846     Help(opts.GenerateHelpText(env))
847    
848 johnpye 551 with_tcltk = env.get('WITH_TCLTK')
849 johnpye 427 without_tcltk_reason = "disabled by options/config.py"
850 johnpye 386
851 johnpye 551 with_python = env.get('WITH_PYTHON')
852 johnpye 427 without_python_reason = "disabled by options/config.py"
853 johnpye 387
854 johnpye 593 with_cunit = env.get('WITH_CUNIT')
855 johnpye 427 without_cunit_reason = "not requested"
856 johnpye 400
857 johnpye 761 with_extfns = env.get('WITH_EXTFNS')
858     without_extfn_reason = "disabled by options/config.py"
859    
860 johnpye 816 with_scrollkeeper = env.get('WITH_SCROLLKEEPER')
861     without_scrollkeeper_reason = "disabled by options/config.py"
862    
863 johnpye 938 with_dmalloc = env.get('WITH_DMALLOC')
864     without_dmalloc_reason = "disabled by options/config.py"
865    
866 jpye 1678 with_graphviz = env.get('WITH_GRAPHVIZ')
867     without_graphiviz_reason = "disabled by options/config.py"
868 johnpye 1109
869 jpye 1326 with_ufsparse = env.get('WITH_UFSPARSE')
870     without_ufsparse_reason = "disabled by options/config.py"
871    
872 johnpye 993 with_mmio = env.get('WITH_MMIO')
873     without_mmio_reason = "disabled by options/config.py"
874    
875 johnpye 1142 with_signals = env.get('WITH_SIGNALS')
876     without_signals_reason = "disabled by options/config.py"
877    
878 jpye 1442 with_doc = env.get('WITH_DOC')
879    
880 jpye 1443 with_doc_build = env.get('WITH_DOC_BUILD');
881 jpye 1470 without_doc_build_reason = "disabled by options/config.py"
882 jpye 1443 if not with_doc:
883 jpye 1470 with_doc_build = False
884     without_doc_build_reason = "disabled by with_doc"
885 jpye 1443
886 jpye 1442 with_latex2html = False
887    
888 johnpye 631 if platform.system()=="Windows":
889     with_installer=1
890     else:
891     with_installer=0
892     without_installer_reason = "only possible under Windows"
893 johnpye 673
894 jpye 1734 with_lsode = 'LSODE' in env['WITH_SOLVERS']
895     without_lsode_reason = "Not selected (see config option WITH_SOLVERS)"
896 johnpye 673
897 jpye 1734 with_ida = 'IDA' in env['WITH_SOLVERS']
898     without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
899 johnpye 783
900 jpye 1734 with_dopri5 = 'DOPRI5' in env['WITH_SOLVERS']
901     without_dopri5_reason = "Not selected (see config option WITH_SOLVERS)"
902 johnpye 783
903 jpye 1734 with_conopt = 'CONOPT' in env['WITH_SOLVERS']
904     without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
905 jpye 1529
906 jpye 1734 with_ipopt = 'IPOPT' in env['WITH_SOLVERS']
907     without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
908    
909    
910 johnpye 464 #print "SOLVERS:",env['WITH_SOLVERS']
911     #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
912     #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
913 johnpye 393
914 johnpye 463 can_install = True
915     if platform.system()=='Windows':
916     can_install = False
917    
918     env['CAN_INSTALL']=can_install
919 johnpye 721
920 jpye 1437 print "TCL=",env['TCL']
921 johnpye 521 print "TCL_CPPPATH =",env['TCL_CPPPATH']
922     print "TCL_LIBPATH =",env['TCL_LIBPATH']
923     print "TCL_LIB =",env['TCL_LIB']
924 johnpye 562 print "CC =",env['CC']
925     print "CXX =",env['CXX']
926 johnpye 673 print "FORTRAN=",env.get('FORTRAN')
927 johnpye 393
928 johnpye 628 print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
929 jpye 1504 print "INSTALL_ASCDATA =",env['INSTALL_ASCDATA']
930 jpye 1413 print "INSTALL_PREFIX =",env['INSTALL_PREFIX']
931 jpye 1504 print "INSTALL_MODELS =",env['INSTALL_MODELS']
932     print "INSTALL_SOLVERS =",env['INSTALL_SOLVERS']
933     print "DEFAULT_ASCENDLIBRARY =",env['DEFAULT_ASCENDLIBRARY']
934 jpye 1519 print "DEFAULT_ASCENDSOLVERS =",env['DEFAULT_ASCENDSOLVERS']
935 jpye 1504
936    
937 johnpye 385 #------------------------------------------------------
938 johnpye 398 # SPECIAL CONFIGURATION TESTS
939    
940 johnpye 463 need_fortran = False
941 jpye 1641 need_fortran_reasons = []
942 johnpye 463
943 johnpye 400 #----------------
944 jpye 1448 # 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 jpye 1630 if not context.env.get('CXX'):
979     context.Result("not found")
980     return False
981     is_ok = context.TryCompile(cxx_test_text,".cpp")
982 jpye 1448 context.Result(is_ok)
983     return is_ok
984    
985 jpye 1641 #----------------
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 jpye 1448
1004     #----------------
1005 johnpye 400 # SWIG
1006    
1007 johnpye 398 import os,re
1008    
1009 johnpye 413 def get_swig_version(env):
1010 johnpye 403 cmd = env['SWIG']+' -version'
1011 johnpye 427 (cin,coutcerr) = os.popen4(cmd)
1012 johnpye 403 output = coutcerr.read()
1013 johnpye 398
1014 johnpye 403 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 johnpye 398 m = expr.search(output);
1017     if not m:
1018 johnpye 413 return None
1019 johnpye 398 maj = int(m.group('maj'))
1020     min = int(m.group('min'))
1021     pat = int(m.group('pat'))
1022 johnpye 413
1023     return (maj,min,pat)
1024 johnpye 398
1025 johnpye 413
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 johnpye 478 context.env['SWIGVERSION']=tuple([maj,min,pat])
1036    
1037 johnpye 398 if maj == 1 and (
1038 johnpye 400 min > 3
1039     or (min == 3 and pat >= 24)
1040 johnpye 398 ):
1041     context.Result("ok, %d.%d.%d" % (maj,min,pat))
1042     return 1;
1043 johnpye 401 else:
1044     context.Result("too old, %d.%d.%d" % (maj,min,pat))
1045     return 0;
1046 johnpye 398
1047 johnpye 400 #----------------
1048 johnpye 816 # 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 johnpye 400 # General purpose library-and-header test
1069    
1070 johnpye 404 class KeepContext:
1071 johnpye 521 def __init__(self,context,varprefix,static=False):
1072 johnpye 404 self.keep = {}
1073 johnpye 521 for k in ['LIBS','LIBPATH','CPPPATH','LINKFLAGS']:
1074 johnpye 705 #print "Keeping env %s = %s" % (k,context.env.get(k))
1075     self.keep[k]=context.env.get(k)
1076 johnpye 404
1077     if context.env.has_key(varprefix+'_CPPPATH'):
1078 johnpye 743 context.env.AppendUnique(CPPPATH=[env[varprefix+'_CPPPATH']])
1079 johnpye 800 #print "Adding '"+str(env[varprefix+'_CPPPATH'])+"' to cpp path"
1080 johnpye 428
1081 johnpye 521 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 johnpye 800 #print "Adding '"+str(env[varprefix+'_LIBPATH'])+"' to lib path"
1091 johnpye 428
1092 johnpye 521 if context.env.has_key(varprefix+'_LIB'):
1093     context.env.Append(LIBS=[env[varprefix+'_LIB']])
1094 johnpye 705 #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"
1095 jpye 1547 elif context.env.has_key(varprefix+'_LIBS'):
1096     context.env.AppendUnique(LIBS=env[varprefix+'_LIBS'])
1097 johnpye 404
1098     def restore(self,context):
1099 johnpye 464 #print "RESTORING CONTEXT"
1100     #print self.keep
1101     #print "..."
1102 johnpye 404 for k in self.keep:
1103 johnpye 463 if self.keep[k]==None:
1104 johnpye 521 if context.env.has_key(k):
1105     #print "Clearing "+str(k)
1106     del context.env[k];
1107 johnpye 463 else:
1108 johnpye 705 #print "Restoring %s to '%s'" %(k,self.keep.get(k))
1109 johnpye 463 context.env[k]=self.keep[k];
1110 johnpye 404
1111 jpye 1721 def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False,testname=None):
1112 johnpye 400 """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 jpye 1721 if testname is None:
1118     testname = libname
1119    
1120 johnpye 521 if static:
1121 jpye 1721 context.Message( 'Checking for static '+testname+'... ' )
1122 johnpye 521 else:
1123 jpye 1721 context.Message( 'Checking for '+testname+'... ' )
1124 johnpye 521
1125 johnpye 400 if varprefix==None:
1126     varprefix = libname.upper()
1127    
1128 johnpye 705 #print "LIBS is currently:",context.env.get('LIBS')
1129 johnpye 521 keep = KeepContext(context,varprefix,static)
1130 johnpye 400
1131 jpye 1678 if not context.env.has_key(varprefix+'_LIB') and not context.env.has_key(varprefix+'_LIBS'):
1132 johnpye 463 # if varprefix_LIB were in env, KeepContext would
1133     # have appended it already
1134 johnpye 705 context.env.Append(LIBS=[libname])
1135 johnpye 428
1136 johnpye 404 is_ok = context.TryLink(text,ext)
1137 johnpye 428
1138 johnpye 521 #print "Link success? ",(is_ok != 0)
1139 johnpye 400
1140 johnpye 405 keep.restore(context)
1141 johnpye 400
1142 johnpye 428 # print "Restored CPPPATH="+str(context.env['CPPPATH'])
1143 johnpye 705 # print "Restored LIBS="+str(context.env['LIBS'])
1144 johnpye 428 # print "Restored LIBPATH="+str(context.env['LIBPATH'])
1145    
1146 johnpye 404 context.Result(is_ok)
1147     return is_ok
1148    
1149     #----------------
1150 johnpye 502 # 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 johnpye 500 # 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 johnpye 546 if not context.env.has_key('WITH_GCCVISIBILITY') or not env['WITH_GCCVISIBILITY']:
1187     context.Result("disabled")
1188     return 0
1189 johnpye 500 is_ok = context.TryCompile(gccvisibility_test_text,".c")
1190     context.Result(is_ok)
1191     return is_ok
1192 johnpye 502
1193 johnpye 500 #----------------
1194 johnpye 502 # YACC
1195    
1196     yacc_test_text = """
1197 johnpye 646 %{
1198     #include <stdio.h>
1199 johnpye 741
1200     /* MSVC++ needs this before it can swallow Bison output */
1201     #ifdef _MSC_VER
1202     # define __STDC__
1203     #endif
1204 johnpye 646 %}
1205     %token MSG
1206 johnpye 502 %start ROOT
1207 johnpye 646 %%
1208     ROOT:
1209     MSG { printf("HELLO"); }
1210     ;
1211     %%
1212 johnpye 502 """
1213    
1214     def CheckYacc(context):
1215 johnpye 644 context.Message("Checking for Yacc ('%s')... " % context.env.get('YACC'))
1216 johnpye 502 is_ok = context.TryCompile(yacc_test_text,".y")
1217     context.Result(is_ok)
1218     return is_ok
1219    
1220     #----------------
1221 johnpye 1025 # 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 johnpye 404 # CUnit test
1253    
1254 johnpye 400 cunit_test_text = """
1255 johnpye 451 #include <CUnit/CUnit.h>
1256 johnpye 400 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 johnpye 404 return 0;
1269 johnpye 400 }
1270     """
1271    
1272     def CheckCUnit(context):
1273 johnpye 451 return CheckExtLib(context,'cunit',cunit_test_text)
1274 johnpye 400
1275 johnpye 404 #----------------
1276 johnpye 938 # dmalloc test
1277    
1278     dmalloc_test_text = """
1279     #include <stdlib.h>
1280     #include <dmalloc.h>
1281    
1282     int main(void){
1283     char *c;
1284 jpye 1733 c = (char *)malloc(100*sizeof(char));
1285 johnpye 938 free(c);
1286     return 0;
1287     }
1288     """
1289    
1290     def CheckDMalloc(context):
1291     return CheckExtLib(context,'dmalloc',dmalloc_test_text)
1292    
1293     #----------------
1294 jpye 1678 # graphviz test
1295 johnpye 1109
1296 jpye 1678 graphviz_test_text = """
1297 jpye 1714 #ifdef __WIN32__
1298     # include <gvc.h>
1299     #else
1300     # include <graphviz/gvc.h>
1301     #endif
1302 johnpye 1109 int main(void){
1303 jpye 1678 Agraph_t *g;
1304     GVC_t *gvc;
1305     gvc = gvContext();
1306     g = agopen("g", AGDIGRAPH);
1307 johnpye 1109 return 0;
1308     }
1309     """
1310    
1311 jpye 1678 def CheckGraphViz(context):
1312     return CheckExtLib(context,'graphviz',graphviz_test_text,ext=".c")
1313 johnpye 1109
1314 jpye 1721 graphviz_boolean_test = """
1315     #ifdef __WIN32__
1316 jpye 1722 # include <types.h>
1317 jpye 1721 #else
1318 jpye 1722 # include <graphviz/types.h>
1319 jpye 1721 #endif
1320 jpye 1722 #ifndef GV_TYPES_H
1321     # error WHERE IS GV_TYPES_H?
1322     #endif
1323     int main(void){
1324 jpye 1721 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 johnpye 1109 #----------------
1336 jpye 1326 # 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 johnpye 673 # MATH test
1357    
1358     math_test_text = """
1359 johnpye 705 #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 johnpye 673 #include <math.h>
1369     int main(void){
1370 johnpye 705 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 jpye 1420 /* this part causes problems with crossmingw... */
1375 johnpye 705 #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 johnpye 673 return 0;
1384     }
1385     """
1386    
1387     def CheckMath(context):
1388 johnpye 832 context.Message('Checking for IEEE math library... ')
1389 johnpye 705 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 johnpye 673 #----------------
1398 jpye 1656 # malloc.h test
1399    
1400     malloc_test_text = """
1401 jpye 1660 #include <stdlib.h>
1402 jpye 1656 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 johnpye 957 # 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 jpye 1786 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 johnpye 957
1475     lastLIBS = context.env.get('LIBS')
1476     lastLIBPATH = context.env.get('LIBPATH')
1477     lastCPPPATH = context.env.get('CPPPATH')
1478 johnpye 959 lastLINKFLAGS = context.env.get('LINKFLAGS')
1479 johnpye 957
1480     python_libpath = []
1481 johnpye 959 python_linkflags = []
1482 johnpye 965 if platform.system()=="Windows":
1483 jpye 1551 python_libpath += [os.path.join(sys.prefix,"libs")]
1484 johnpye 965 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 johnpye 957
1491 johnpye 958 context.env.AppendUnique(LIBS=python_libs)
1492 johnpye 957 context.env.AppendUnique(LIBPATH=python_libpath)
1493     context.env.AppendUnique(CPPPATH=python_cpppath)
1494 johnpye 959 context.env.AppendUnique(LINKFLAGS=python_linkflags)
1495 johnpye 957 result = context.TryLink(libpython_test_text,".c");
1496    
1497 johnpye 958 context.Result(result)
1498 johnpye 957
1499     if(result):
1500 johnpye 958 context.env['PYTHON_LIBPATH']=python_libpath
1501     context.env['PYTHON_LIB']=python_libs
1502     context.env['PYTHON_CPPPATH']=python_cpppath
1503 johnpye 959 context.env['PYTHON_LINKFLAGS']=python_linkflags
1504 johnpye 957
1505     context.env['LIBS'] = lastLIBS
1506     context.env['LIBPATH'] = lastLIBPATH
1507     context.env['CPPPATH'] = lastCPPPATH
1508 johnpye 959 context.env['LINKFLAGS'] = lastLINKFLAGS
1509 johnpye 957
1510     return result
1511    
1512     #----------------
1513 johnpye 673 # IDA test
1514    
1515 johnpye 913 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 johnpye 673 ida_test_text = """
1529 jpye 1400 #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1530     # include <sundials/sundials_config.h>
1531     # include <sundials/sundials_nvector.h>
1532 jpye 1405 # include <nvector_serial.h>
1533 jpye 1400 # include <ida.h>
1534     # include <ida/ida_spgmr.h>
1535     #else
1536     # include <sundials/sundials_config.h>
1537     # include <nvector/nvector_serial.h>
1538 johnpye 907 # include <ida/ida.h>
1539 jpye 1400 #endif
1540 johnpye 673 int main(){
1541     void *ida_mem;
1542     ida_mem = IDACreate();
1543 johnpye 782 return 0;
1544 johnpye 673 }
1545     """
1546    
1547 johnpye 913 # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1548     # so detect the version and act accordingly.
1549 jpye 1400 def CheckSUNDIALS(context):
1550     keep = KeepContext(context,'SUNDIALS')
1551 jpye 1402 context.Message("Checking for SUNDIALS... ")
1552 johnpye 913 (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1553     keep.restore(context)
1554     if not is_ok:
1555 jpye 1402 context.Result(0)
1556 johnpye 913 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 johnpye 1086 context.Result("%d.%d.%d, good" % (major,minor,patch))
1570 jpye 1400
1571 johnpye 913 return 1
1572    
1573 jpye 1400
1574     def CheckIDA(context):
1575 jpye 1402 context.Message( 'Checking for IDA... ' )
1576 jpye 1400
1577 jpye 1404 keep = KeepContext(context,"SUNDIALS")
1578 jpye 1400
1579     major = context.env['SUNDIALS_VERSION_MAJOR']
1580     minor = context.env['SUNDIALS_VERSION_MINOR']
1581    
1582 jpye 1404 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 jpye 1400 context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1594 jpye 1404 context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1595     context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1596 jpye 1400
1597     is_ok = context.TryLink(ida_test_text,".c")
1598     context.Result(is_ok)
1599    
1600 jpye 1404 if cppdef:
1601     context.env['CPPDEFINES']=cppdef
1602 jpye 1552 else:
1603     del context.env['CPPDEFINES']
1604    
1605 jpye 1400 keep.restore(context)
1606    
1607     return is_ok
1608    
1609    
1610 johnpye 673 #----------------
1611 johnpye 783 # CONOPT test
1612    
1613     conopt_test_text = """
1614 johnpye 800 #if !defined(_WIN32)
1615     # define FNAME_LCASE_DECOR
1616     #endif
1617    
1618 johnpye 783 #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 jpye 1529 # IPOPT test
1643    
1644     ipopt_test_text = """
1645     #if !defined(_WIN32)
1646     # define FNAME_LCASE_DECOR
1647     #endif
1648    
1649 jpye 1770 #include <coin/IpStdCInterface.h>
1650 jpye 1529 int main(){
1651     Number n;
1652 jpye 1546 IpoptProblem nlp = 0;
1653 jpye 1529 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 johnpye 405 # Tcl test
1671 johnpye 404
1672 jpye 1787 # TCL and TK required version 8.1 through 8.5:
1673     tcltk_minor_newest_acceptable = 5
1674 johnpye 561 tcltk_major_required = 8
1675    
1676 johnpye 404 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 johnpye 521 return CheckExtLib(context,'tcl',tcl_check_text,static=env['STATIC_TCLTK'])
1687 johnpye 405
1688     def CheckTclVersion(context):
1689 johnpye 521 keep = KeepContext(context,'TCL',static=env['STATIC_TCLTK'])
1690 johnpye 405 context.Message("Checking Tcl version... ")
1691     (is_ok,output) = context.TryRun(tcl_check_text,'.c')
1692 johnpye 404 keep.restore(context)
1693     if not is_ok:
1694 johnpye 405 context.Result("failed to run check")
1695 johnpye 404 return 0
1696 johnpye 405
1697 wangym 511 major,minor,patch = tuple([int(i) for i in output.split(".")])
1698 johnpye 561 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1699 johnpye 428 context.Result(output+" (bad version)")
1700 johnpye 405 # bad version
1701     return 0
1702    
1703     # good version
1704 johnpye 552 context.Result(output+", good")
1705 johnpye 404 return 1
1706    
1707 johnpye 405 #----------------
1708 johnpye 463 # Tk test
1709 johnpye 405
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 johnpye 673 return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
1720 johnpye 405
1721 johnpye 428
1722 johnpye 405 def CheckTkVersion(context):
1723 johnpye 521 keep = KeepContext(context,'TK',static=context.env['STATIC_TCLTK'])
1724 johnpye 405 context.Message("Checking Tk version... ")
1725 johnpye 521 #print "LINKFLAGS =",context.env['LINKFLAGS']
1726 johnpye 405 (is_ok,output) = context.TryRun(tk_check_text,'.c')
1727 johnpye 404 keep.restore(context)
1728     if not is_ok:
1729     context.Result("failed to run check")
1730     return 0
1731    
1732 wangym 511 major,minor,patch = tuple([int(i) for i in output.split(".")])
1733 johnpye 561 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1734 johnpye 404 # bad version
1735 johnpye 561 context.Result(output+" (bad version)")
1736 johnpye 404 return 0
1737 johnpye 400
1738 johnpye 404 # good version
1739 johnpye 561 context.Result(output+" (good)")
1740 johnpye 404 return 1
1741 johnpye 485
1742     #----------------
1743 johnpye 521 # 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 johnpye 968 # 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 johnpye 953 # 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 johnpye 968 context.Message("Checking C99 FPE behaviour... ")
1841 johnpye 953 (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1842     context.Result(is_ok)
1843     return is_ok
1844    
1845     #----------------
1846 johnpye 968 # 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 johnpye 1002 /* fprintf(stderr,"Raising SIGINT\n"); */
1860 johnpye 968 raise(SIGINT);
1861     }
1862     int main(void){
1863     SigHandlerFn *last,*saved;
1864     saved = signal(SIGINT,&sighandler);
1865     if(saved!=SIG_DFL){
1866 johnpye 1002 fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
1867 johnpye 968 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 johnpye 1002 last = signal(SIGINT,SIG_DFL);
1880 johnpye 968 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 johnpye 1260 return False
1895 johnpye 1002 if int(output)==1:
1896 johnpye 968 context.Result("required");
1897     context.env['ASC_RESETNEEDED'] = True
1898     else:
1899     context.Result("not required");
1900     context.env['ASC_RESETNEEDED'] = False
1901 jpye 1658 return True
1902 johnpye 968
1903     #----------------
1904 jpye 1442 # LyX on this system?
1905    
1906     def CheckLyx(context):
1907     context.Message("Checking for LyX... ")
1908     r = context.env.WhereIs("lyx")
1909 jpye 1469 if r:
1910     context.Result(r)
1911     else:
1912     context.Result(0)
1913 jpye 1442 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 jpye 1701 # 'lmodern' package for LaTeX available?
1929    
1930 jpye 1723 lmodern_test_text = r"""
1931 jpye 1701 \documentclass{article}
1932 jpye 1723 \usepackage{lmodern}
1933 jpye 1701 \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 jpye 1770 b = context.env.get("DVI")
1945     if not b:
1946     context.Result(False)
1947     return False
1948 jpye 1723 is_ok = context.TryBuild(builder=b,text=lmodern_test_text,extension=".tex")
1949 jpye 1701 context.Result(is_ok)
1950     return is_ok
1951    
1952     #----------------
1953 johnpye 485 # GCC Version sniffing
1954    
1955     # TODO FIXME
1956    
1957     gcc_version4 = False
1958    
1959 johnpye 398 #------------------------------------------------------
1960 johnpye 385 # CONFIGURATION
1961    
1962     conf = Configure(env
1963     , custom_tests = {
1964 jpye 1448 'CheckCC' : CheckCC
1965     , 'CheckCXX' : CheckCXX
1966 jpye 1641 , 'CheckF77' : CheckF77
1967 jpye 1448 , 'CheckMath' : CheckMath
1968 jpye 1656 , 'CheckMalloc' : CheckMalloc
1969     , 'CheckDLOpen' : CheckDLOpen
1970 johnpye 673 , 'CheckSwigVersion' : CheckSwigVersion
1971 johnpye 957 , 'CheckPythonLib' : CheckPythonLib
1972 johnpye 400 , 'CheckCUnit' : CheckCUnit
1973 johnpye 938 , 'CheckDMalloc' : CheckDMalloc
1974 jpye 1442 , 'CheckLyx' : CheckLyx
1975     , 'CheckLatex2HTML' : CheckLatex2HTML
1976 jpye 1701 , 'CheckLModern' : CheckLModern
1977 jpye 1678 , 'CheckGraphViz' : CheckGraphViz
1978 jpye 1721 , 'CheckGraphVizBoolean' : CheckGraphVizBoolean
1979 jpye 1326 , 'CheckUFSparse' : CheckUFSparse
1980 johnpye 404 , 'CheckTcl' : CheckTcl
1981     , 'CheckTclVersion' : CheckTclVersion
1982 johnpye 405 , 'CheckTk' : CheckTk
1983     , 'CheckTkVersion' : CheckTkVersion
1984 johnpye 502 , 'CheckGcc' : CheckGcc
1985 johnpye 500 , 'CheckGccVisibility' : CheckGccVisibility
1986 johnpye 502 , 'CheckYacc' : CheckYacc
1987 johnpye 1025 , 'CheckLex' : CheckLex
1988 johnpye 521 , 'CheckTkTable' : CheckTkTable
1989     , 'CheckX11' : CheckX11
1990 johnpye 673 , 'CheckIDA' : CheckIDA
1991 jpye 1400 , 'CheckSUNDIALS' : CheckSUNDIALS
1992 johnpye 783 , 'CheckCONOPT' : CheckCONOPT
1993 jpye 1529 , 'CheckIPOPT' : CheckIPOPT
1994 johnpye 816 , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1995 johnpye 953 , 'CheckFPE' : CheckFPE
1996 johnpye 968 , 'CheckSIGINT' : CheckSIGINT
1997     , 'CheckSigReset' : CheckSigReset
1998 johnpye 400 # , 'CheckIsNan' : CheckIsNan
1999     # , 'CheckCppUnitConfig' : CheckCppUnitConfig
2000 jpye 1691 }
2001 johnpye 459 # , config_h = "config.h"
2002 johnpye 385 )
2003    
2004 jpye 1357 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 jpye 1431 if int(v[1]) >= 97:
2014     return 1
2015 jpye 1357 if v[1] != '96':
2016     return 0
2017     micro = int(v[2])
2018 jpye 1394 if micro == 92 or micro == 93 or micro == 96:
2019 jpye 1357 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 jpye 1448 # check C compiler
2030    
2031 jpye 1654 if conf.CheckCC() is False:
2032 jpye 1448 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 jpye 1654 if conf.CheckCXX() is False:
2037 jpye 1448 print "Failed to build simple test file with your C++ compiler."
2038     print "Check your compiler is installed and running correctly."
2039 jpye 1630 print "You can set your C++ compiler using the CXX scons option."
2040 jpye 1448 Exit(1)
2041    
2042 johnpye 740 # stdio -- just to check that compiler is behaving
2043 johnpye 398
2044 jpye 1654 if conf.CheckHeader('stdio.h') is False:
2045 johnpye 832 print "CPPPATH =",env.get('CPPPATH')
2046 johnpye 740 print "Did not find 'stdio.h'! Check your compiler configuration."
2047 johnpye 1080 print ""
2048     print "You environment is printed here:"
2049     for k,v in os.environ.iteritems():
2050     print "%-30s%s" % ("%s :" % k, v)
2051 johnpye 740 Exit(1)
2052    
2053 jpye 1654 if conf.CheckFunc('snprintf') is False:
2054 johnpye 1228 print "Didn't find snprintf";
2055     exit(1)
2056    
2057 jpye 1678 if conf.CheckFunc('strdup'):
2058     conf.env['HAVE_STRDUP'] = True
2059    
2060 jpye 1720 if platform.system()=="Windows" and env.get('WITH_MSVCR71'):
2061     conf.env.Append(LIBS='msvcr71')
2062    
2063 johnpye 385 # Math library
2064    
2065 johnpye 1262 conf.env['HAVE_IEEE']=True
2066    
2067 jpye 1654 if need_libm and (conf.CheckMath() is False):
2068 johnpye 1232 conf.env['HAVE_IEEE']=False
2069 johnpye 1262 print 'Did not find math library, exiting!'
2070     Exit(1)
2071 johnpye 427
2072 jpye 1656 # 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 jpye 1659 # CURRENTLY BREAKS LATER TEST (libsave?)
2082     #if conf.CheckDLOpen() is False:
2083     # print "Did not find functioning dlopen/LoadLibrary, exiting!"
2084     # Exit(1)
2085 jpye 1656
2086 johnpye 385 # Where is 'isnan'?
2087    
2088 jpye 1654 if conf.CheckFunc('isnan') is False and conf.CheckFunc('_isnan') is False:
2089 johnpye 385 print "Didn't find isnan"
2090 johnpye 414 # Exit(1)
2091 johnpye 385
2092 johnpye 500 # GCC visibility
2093    
2094 johnpye 502 if conf.CheckGcc():
2095     conf.env['HAVE_GCC']=True;
2096 johnpye 526 if env['WITH_GCCVISIBILITY'] and conf.CheckGccVisibility():
2097 johnpye 509 conf.env['HAVE_GCCVISIBILITY']=True;
2098     conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
2099     conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
2100 johnpye 709 conf.env.Append(CCFLAGS=['-Wall'])
2101 johnpye 500
2102 johnpye 968 # Catching SIGINT
2103    
2104 johnpye 1142 if env['WITH_SIGNALS']:
2105 jpye 1655 if not conf.CheckSIGINT():
2106 johnpye 1142 with_signals = False
2107     without_signals_reason = "SIGINT uncatchable"
2108 johnpye 968
2109 johnpye 953 # Catching SIGFPE
2110    
2111     if conf.CheckFPE():
2112 johnpye 968 conf.env['HAVE_C99FPE']=True
2113 johnpye 953 else:
2114 johnpye 968 conf.env['HAVE_C99FPE']=False
2115 johnpye 953
2116 johnpye 968 # Checking for signal reset requirement
2117    
2118 jpye 1654 if conf.CheckSigReset() is False:
2119 johnpye 968 print "Unable to determine if signal reset is required"
2120 johnpye 1260 Exit(1)
2121 johnpye 968
2122 johnpye 502 # YACC
2123    
2124 jpye 1552 if conf.CheckYacc():
2125 johnpye 502 conf.env['HAVE_YACC']=True
2126    
2127 jpye 1552 if conf.CheckLex():
2128 johnpye 1025 conf.env['HAVE_LEX']=True
2129 johnpye 502
2130 johnpye 387 # Tcl/Tk
2131 johnpye 386
2132 johnpye 586 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 johnpye 521 else:
2147 johnpye 586 without_tcltk_reason = "Tk not found."
2148 johnpye 551 with_tcltk = False
2149 johnpye 428 else:
2150 johnpye 586 without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
2151 johnpye 551 with_tcltk = False
2152 johnpye 586
2153 johnpye 428 else:
2154 johnpye 586 without_tcltk_reason = "Tcl not found."
2155 johnpye 551 with_tcltk = False
2156 johnpye 386
2157 johnpye 521 if env['STATIC_TCLTK']:
2158     conf.CheckX11()
2159    
2160 johnpye 395 # 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 jpye 1655 if not conf.CheckPythonLib():
2164 johnpye 957 without_python_reason = 'libpython2.x not found or not linkable'
2165     with_python = False
2166 johnpye 982 env['WITH_PYTHON']=False
2167 johnpye 391
2168 johnpye 395 # SWIG version
2169    
2170 jpye 1656 if with_python and conf.CheckSwigVersion() is False:
2171 johnpye 413 without_python_reason = 'SWIG >= 1.3.24 is required'
2172     with_python = False
2173 johnpye 982 env['WITH_PYTHON']=False
2174 johnpye 413
2175 johnpye 400 # CUnit
2176    
2177 johnpye 593 if with_cunit:
2178 jpye 1655 if not conf.CheckCUnit():
2179 johnpye 427 without_cunit_reason = 'CUnit not found'
2180 johnpye 665 with_cunit = False
2181 johnpye 705 #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
2182 johnpye 427
2183 johnpye 938 # DMALLOC
2184    
2185     if with_dmalloc:
2186 jpye 1655 if not conf.CheckDMalloc():
2187 johnpye 938 without_dmalloc_reason = 'dmalloc not found'
2188     with_dmalloc = False
2189    
2190 jpye 1678 # GRAPHVIZ
2191 johnpye 1109
2192 jpye 1678 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 jpye 1721 env['HAVE_GRAPHVIZ_BOOLEAN'] = conf.CheckGraphVizBoolean()
2198 johnpye 1109
2199 jpye 1326 # UFSPARSE
2200    
2201     if with_ufsparse:
2202 jpye 1655 if not conf.CheckUFSparse():
2203 jpye 1678 without_ufsparse_reason = 'ufsparse not found'
2204 jpye 1326 with_ufsparse = False
2205     env['WITH_UFSPARSE'] = False
2206    
2207 johnpye 673 # IDA
2208    
2209 jpye 1734 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 johnpye 673
2217 johnpye 797 # CONOPT
2218 johnpye 783
2219     if not with_conopt:
2220     without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2221 jpye 1654 elif conf.CheckCONOPT() is False:
2222 jpye 1541 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 johnpye 783
2228 jpye 1529 # IPOPT
2229    
2230     if not with_ipopt:
2231     without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2232 jpye 1657 elif not conf.CheckIPOPT():
2233 jpye 1529 with_ipopt = False
2234     without_ipopt_reason = "IPOPT not found"
2235    
2236 johnpye 427 # BLAS
2237    
2238 johnpye 459 need_blas=False
2239 johnpye 673
2240     if with_lsode:
2241     need_fortran = True
2242 jpye 1641 need_fortran_reasons.append("LSODE")
2243 johnpye 459 need_blas=True
2244 johnpye 673
2245 johnpye 459 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 jpye 1641 need_fortran_reasons.append("BLAS")
2253 johnpye 673 else:
2254     with_local_blas= False;
2255     without_local_blas_reason = "BLAS not required"
2256 johnpye 427
2257     # FORTRAN
2258    
2259     if need_fortran:
2260 johnpye 629 conf.env.Tool('fortran')
2261 jpye 1380 detect_fortran = conf.env.Detect(['gfortran','g77'])
2262 johnpye 427 if detect_fortran:
2263     # For some reason, g77 doesn't get detected properly on MinGW
2264 johnpye 673 if not env.has_key('F77') and not env.has_key('FORTRAN'):
2265 jpye 1357 print "Fixing detection of F77 on MinGW...(?)"
2266 johnpye 427 conf.env.Replace(F77=detect_fortran)
2267     conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
2268     conf.env.Replace(F77FLAGS='')
2269 johnpye 428 #print "F77:",conf.env['F77']
2270     #print "F77COM:",conf.env['F77COM']
2271     #print "F77FLAGS:",conf.env['F77FLAGS']
2272 johnpye 427 fortran_builder = Builder(
2273     action='$F77COM'
2274     , suffix='.o'
2275     , src_suffix='.f'
2276     )
2277     conf.env.Append(BUILDERS={'Fortran':fortran_builder})
2278 johnpye 1284 if platform.system()=="Linux":
2279     conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
2280 johnpye 427 else:
2281 johnpye 673 with_lsode=False;
2282     without_lsode_reason="FORTRAN-77 required but not found"
2283 johnpye 629
2284 jpye 1654 if need_fortran and conf.CheckF77() is False:
2285 jpye 1641 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 johnpye 464 #else:
2293     # print "FORTRAN not required"
2294 johnpye 400
2295 johnpye 673 # F2C
2296    
2297     if need_fortran:
2298     if platform.system()=="Windows":
2299 jpye 1380 pass
2300     #conf.env.Append(LIBPATH='c:\mingw\lib')
2301 johnpye 673
2302 johnpye 816 # scrollkeeper
2303 johnpye 673
2304 johnpye 816 if with_scrollkeeper:
2305 jpye 1654 if conf.CheckScrollkeeperConfig() is False:
2306 johnpye 816 with_scrollkeeper=False
2307     without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2308    
2309 jpye 1442 # lyx
2310    
2311 jpye 1470 if with_doc_build:
2312 jpye 1769 if not conf.CheckLyx():
2313 jpye 1470 with_doc_build = False
2314 jpye 1769 without_doc_build_reason="unable to locate LyX"
2315 jpye 1442
2316 jpye 1769 with_latex2html = conf.CheckLatex2HTML()
2317 jpye 1442
2318 jpye 1723 if conf.CheckLModern() is False:
2319     with_doc_build = False
2320     without_doc_build_reason="'lmodern' is not available"
2321 jpye 1701
2322 johnpye 385 # TODO: -D_HPUX_SOURCE is needed
2323    
2324     # TODO: check size of void*
2325    
2326 johnpye 393 # TODO: detect if dynamic libraries are possible or not
2327    
2328 johnpye 427 if platform.system()=="Windows" and env.has_key('MSVS'):
2329 johnpye 740 _found_windows_h = conf.CheckHeader('Windows.h')
2330    
2331     if not _found_windows_h:
2332 johnpye 741 print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2333 johnpye 740 Exit(1)
2334 johnpye 741
2335 jpye 1654 if with_python and conf.CheckHeader(['basetsd.h','BaseTsd.h']) is False:
2336 johnpye 427 with_python = 0;
2337     without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
2338    
2339 johnpye 395 conf.Finish()
2340    
2341 johnpye 507 #---------------------------------------
2342     # SUBSTITUTION DICTIONARY for .in files
2343    
2344 johnpye 658 release = env.get('RELEASE')
2345     if release=="0.":
2346     release="0"
2347    
2348 johnpye 800 #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
2349    
2350 johnpye 507 subst_dict = {
2351     '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2352 jpye 1519 ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2353 johnpye 507 , '@GLADE_FILE@':'ascend.glade'
2354     , '@HELP_ROOT@':''
2355     , '@ICON_EXTENSION@':icon_extension
2356 johnpye 628 , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
2357 johnpye 507 , '@INSTALL_BIN@':env['INSTALL_BIN']
2358     , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2359 johnpye 683 , '@INSTALL_LIB@':env['INSTALL_LIB']
2360 johnpye 721 , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2361 jpye 1504 , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2362 johnpye 507 , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2363     , '@VERSION@':version
2364 johnpye 658 , '@RELEASE@':release
2365 johnpye 563 , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2366 jpye 1590 , '@WEBHELPROOT@':'http://ascendwiki.cheme.cmu.edu/Category:Documentation'
2367 johnpye 1228 , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2368     , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2369 jpye 1597 , '@EXTLIB_SUFFIX@':env['EXTLIB_SUFFIX']
2370     , '@EXTLIB_PREFIX@':env['EXTLIB_PREFIX']
2371 johnpye 589 , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2372 johnpye 627 , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
2373 johnpye 683 , '@PYTHON@' : python_exe
2374 jpye 1466 , '@PYVERSION@' : pyversion
2375 johnpye 1174 , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2376 jpye 1680 , '@WITH_GRAPHVIZ@': str(int(env.get('WITH_GRAPHVIZ')))
2377 johnpye 507 }
2378    
2379 jpye 1442 if env.get('WITH_DOC'):
2380     print "WITH_DOC:",env['WITH_DOC']
2381     subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2382 johnpye 507
2383 johnpye 597 # bool options...
2384 johnpye 673 for k,v in {
2385 jpye 1747 'ASC_WITH_DMALLOC':with_dmalloc
2386 jpye 1326 ,'ASC_WITH_UFSPARSE':with_ufsparse
2387 johnpye 1142 ,'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 johnpye 1261 ,'HAVE_IEEE':env.get('HAVE_IEEE')
2392 jpye 1412 ,'ASC_ABSOLUTE_PATHS':env.get('ABSOLUTE_PATHS')
2393 johnpye 1142 ,'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 johnpye 594
2399 johnpye 507 if with_python:
2400     subst_dict['@ASCXX_USE_PYTHON@']="1"
2401 johnpye 673 env['WITH_PYTHON']=1;
2402 johnpye 507
2403 jpye 1442 if with_latex2html:
2404     env['WITH_LATEX2HTML']=1
2405    
2406 johnpye 507 if env.has_key('HAVE_GCCVISIBILITY'):
2407     subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2408    
2409     env.Append(SUBST_DICT=subst_dict)
2410    
2411 johnpye 1142 #for k,v in subst_dict.iteritems():
2412     # print "%-50s%s" % ("'%s'"%k,v)
2413 johnpye 829
2414 johnpye 1142 # REMOVED: long command-line support on Win2k
2415 johnpye 829
2416     #------------------------------------------------------
2417 johnpye 558 # 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 johnpye 463 # Recipe for 'CHMOD' ACTION
2432 johnpye 439
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 johnpye 578 SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2448 johnpye 629 SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2449 johnpye 463
2450 johnpye 439 #------------------------------------------------------
2451 johnpye 463 # BUILD...
2452 johnpye 385
2453 johnpye 463 # so that #include <modulename/headername.h> works across all modules...
2454 johnpye 743 env.AppendUnique(CPPPATH=['#base/generic'])
2455 johnpye 385
2456 johnpye 508 if env['DEBUG']:
2457     env.Append(CCFLAGS=['-g'])
2458 jpye 1554 env.Append(LINKFLAGS=['-g'])
2459 johnpye 508
2460 johnpye 591 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 johnpye 673 if with_ida:
2468     env.Append(WITH_IDA=1)
2469    
2470 johnpye 783 if with_conopt:
2471     env.Append(WITH_CONOPT=1)
2472    
2473 jpye 1529 if with_ipopt:
2474     env.Append(WITH_IPOPT=1)
2475    
2476 jpye 1734 if with_dopri5:
2477     env.Append(WITH_DOPRI5=1)
2478    
2479 jpye 1719 if with_graphviz and env.get('GRAPHVIZ_RPATH'):
2480 jpye 1718 env.Append(RPATH=env['GRAPHVIZ_RPATH'])
2481    
2482 johnpye 463 #-------------
2483     # TCL/TK GUI
2484 johnpye 385
2485 johnpye 551 if with_tcltk:
2486 johnpye 569 env.SConscript(['tcltk/generic/interface/SConscript'],'env')
2487 johnpye 391 else:
2488 johnpye 982 print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2489 johnpye 386
2490 johnpye 463 #-------------
2491     # PYTHON INTERFACE
2492    
2493 johnpye 387 if with_python:
2494 johnpye 532 env.SConscript(['pygtk/SConscript'],'env')
2495 johnpye 391 else:
2496 johnpye 982 print "Skipping... Python bindings aren't being built:",without_python_reason
2497 johnpye 400
2498 johnpye 463 #------------
2499     # BASE/GENERIC SUBDIRECTORIES
2500    
2501 jpye 1786 libascend_env = env.Clone()
2502 johnpye 673
2503 johnpye 1316 dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2504 johnpye 463
2505     srcs = []
2506     for d in dirs:
2507 johnpye 673 heresrcs = libascend_env.SConscript('base/generic/'+d+'/SConscript','libascend_env')
2508 johnpye 463 srcs += heresrcs
2509    
2510     #-------------
2511 johnpye 673 # IMPORTED CODE: LSODE, BLAS, etc
2512    
2513 jpye 1509 #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 johnpye 673
2519     if with_local_blas:
2520 jpye 1515 env['blasobjs'] = env.SConscript(['blas/SConscript'],'env')
2521 johnpye 673 else:
2522 jpye 1515 env['blasobjs'] = []
2523 johnpye 673 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 jpye 1734 if not with_dopri5:
2529     print "Skipping... DOPRI5 won't be built:", without_dopri5_reason
2530    
2531 johnpye 993 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 johnpye 673 #-------------
2536 johnpye 463 # LIBASCEND -- all base/generic functionality
2537    
2538 johnpye 938 if with_dmalloc:
2539     libascend_env.Append(LIBS=['dmalloc'])
2540    
2541 jpye 1326 if with_ufsparse:
2542     libascend_env.Append(LIBS=['cxsparse'])
2543    
2544 johnpye 673 libascend = libascend_env.SharedLibrary('ascend',srcs)
2545 johnpye 463
2546 jpye 1510 # for use in declaring dependent shared libraries in SConscript files (eg solvers/*/SConscript)
2547     env['libascend'] = libascend
2548    
2549 johnpye 673 env.Alias('libascend',libascend)
2550    
2551 johnpye 463 #-------------
2552 johnpye 761 # UNIT TESTS (C CODE)
2553 johnpye 463
2554 johnpye 593 if with_cunit:
2555 jpye 1638 testdirs = ['general','solver','utilities','linear','compiler']
2556 johnpye 593 testsrcs = []
2557 johnpye 400 for testdir in testdirs:
2558     path = 'base/generic/'+testdir+'/test/'
2559     env.SConscript([path+'SConscript'],'env')
2560 johnpye 593 testsrcs += [i.path for i in env['TESTSRCS_'+testdir.upper()]]
2561    
2562     #print "TESTSRCS =",testsrcs
2563    
2564 johnpye 400 env.SConscript(['test/SConscript'],'env')
2565     env.SConscript(['base/generic/test/SConscript'],'env')
2566 johnpye 593
2567     env.Alias('test',[env.Dir('test'),env.Dir('base/generic/test')])
2568 johnpye 400
2569     else:
2570 johnpye 427 print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2571 johnpye 400
2572 johnpye 761 #-------------
2573 jpye 1504 # EXTERNAL SOLVERS
2574    
2575     env['extfns']=[]
2576    
2577 jpye 1505 env.SConscript(['solvers/SConscript'],'env')
2578 jpye 1504
2579     #-------------
2580 johnpye 761 # EXTERNAL FUNCTIONS
2581    
2582 johnpye 811 modeldirs = env.SConscript(['models/SConscript'],'env')
2583    
2584     if not with_extfns:
2585 johnpye 761 print "Skipping... External modules aren't being built:",without_extfns_reason
2586    
2587 johnpye 811 env.Alias('extfns',env['extfns'])
2588 johnpye 761
2589 johnpye 463 #------------------------------------------------------
2590 johnpye 683 # CREATE ASCEND-CONFIG scriptlet
2591    
2592     ascendconfig = env.SubstInFile('ascend-config.in')
2593    
2594 jpye 1625
2595 johnpye 683 #------------------------------------------------------
2596 jpye 1625 # CREATE asc4dev scriptlet
2597    
2598     asc4devcmd = env.SubstInFile('tcltk/asc4dev.in')
2599     env.AddPostAction(asc4devcmd, 'chmod 755 $TARGET')
2600     #------------------------------------------------------
2601 johnpye 463 # INSTALLATION
2602 johnpye 427
2603 johnpye 552 if env.get('CAN_INSTALL'):
2604 johnpye 427
2605 jpye 1442 dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC']
2606 jpye 1436 install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2607 jpye 1505 install_dirs += modeldirs + [Dir(env.subst("$INSTALL_ROOT$INSTALL_SOLVERS"))]
2608 johnpye 449
2609 johnpye 463 # TODO: add install options
2610     env.Alias('install',install_dirs)
2611 johnpye 400
2612 jpye 1436 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2613 johnpye 435
2614 jpye 1436 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2615 johnpye 683
2616 johnpye 438 #------------------------------------------------------
2617 johnpye 631 # WINDOWS INSTALLER
2618    
2619 jpye 1551 if not env.get('NSIS'):
2620     with_installer = False
2621     without_installer_reason = "NSIS not found"
2622    
2623 johnpye 631 if with_installer:
2624 jpye 1467 env.Append(NSISDEFINES={
2625     'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2626     ,"VERSION":version
2627     ,'PYVERSION':pyversion
2628     })
2629 jpye 1570 installer = env.Installer('nsis/installer.nsi')
2630 jpye 1465 Depends(installer,["pygtk","tcltk","ascend.dll","models","ascend-config"])
2631     env.Alias('installer',installer)
2632 johnpye 631 else:
2633     print "Skipping... Windows installer isn't being built:",without_installer_reason
2634    
2635 jpye 1465
2636 johnpye 631 #------------------------------------------------------
2637 johnpye 673 # PROJECT FILE for MSVC
2638    
2639     env.SConscript(['base/msvc/SConscript'],['env','libascend']);
2640    
2641     #------------------------------------------------------
2642 johnpye 438 # CREATE the SPEC file for generation of RPM packages
2643    
2644 johnpye 463 if platform.system()=="Linux":
2645     env.SubstInFile('ascend.spec.in')
2646 johnpye 552
2647     #------------------------------------------------------
2648 johnpye 816 # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2649    
2650 jpye 1442 #if with_scrollkeeper:
2651     # #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2652     # #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2653 johnpye 816
2654     #------------------------------------------------------
2655 johnpye 552 # DISTRIBUTION TAR FILE
2656    
2657 johnpye 554 env['DISTTAR_FORMAT']='bz2'
2658 johnpye 556 env.Append(
2659 jpye 1443 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 jpye 1417 , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2661 johnpye 556 )
2662 johnpye 554
2663 johnpye 563 tar = env.DistTar("dist/"+env['DISTTAR_NAME']
2664 johnpye 556 , [env.Dir('#')]
2665 johnpye 554 )
2666    
2667 johnpye 680 env.Depends(tar,'ascend.spec')
2668 jpye 1442 env.Depends(tar,'#doc/book.pdf')
2669 johnpye 680
2670 jpye 1596 #------------------------------------------------------
2671 jpye 1622 # DISTRIBUTION TAR FILE (new style with AccumulateBuilder)
2672    
2673     # ...
2674    
2675     #------------------------------------------------------
2676 jpye 1596 # DEBIAN TARBALL for use with Build Service
2677 johnpye 862
2678 jpye 1596 import glob
2679     deb_manfiles = glob.glob('debian/*.man')
2680    
2681     deb_tar = env.Tar(
2682     'dist/debian.tar.gz'
2683 jpye 1609 ,deb_manfiles + ['debian/compat','debian/copyright','debian/dirs'
2684     ,'debian/postinst','debian/postrm']
2685 jpye 1596 ,TARFLAGS = ['cz']
2686     )
2687    
2688     Alias('dist',[tar,deb_tar])
2689    
2690 johnpye 554 #------------------------------------------------------
2691 jpye 1551 # DOCUMENTATION
2692 johnpye 816
2693 jpye 1769 #print "WITH_DOC_BUILD = ",with_doc_build
2694 johnpye 816