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