/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22