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