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