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