/[escript]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1149 by gross, Thu May 17 00:30:15 2007 UTC revision 1235 by phornby, Mon Aug 13 00:25:29 2007 UTC
# Line 22  if sys.path.count('scons')==0: sys.path. Line 22  if sys.path.count('scons')==0: sys.path.
22  import scons_extensions  import scons_extensions
23    
24  #===============================================================  #===============================================================
 #   check on windows or linux platform  
 #  
 IS_WINDOWS_PLATFORM = (os.name== "nt")  
25    
26  if IS_WINDOWS_PLATFORM:  tools_prefix="/usr"
    tools_prefix="C:\\Program Files\\"  
 else:  
    tools_prefix="/usr"  
27    
28  #==============================================================================================      #==============================================================================================    
29  #      #    
30  #    get the iinstallation prefix  #    get the installation prefix
31  #  #
32  prefix = ARGUMENTS.get('prefix', Dir('#.').abspath)  prefix = ARGUMENTS.get('prefix', Dir('#.').abspath)
33    
34    # We may also need to know where python's site-packages subdirectory lives
35    python_version = 'python%s.%s'%(sys.version_info[0],sys.version_info[1])
36    
37    if prefix == "/usr":
38       # Install as a standard python package in /usr/lib64 if available, else in /usr/lib
39       if os.path.isdir(  prefix+"/lib64/"+python_version+"/site-packages"):
40          dir_packages =  prefix+"/lib64/"+python_version+"/site-packages"
41          dir_libraries = prefix+"/lib64"
42       elif os.path.isdir(prefix+"/lib/"+python_version+"/site-packages"):
43          dir_packages =  prefix+"/lib/"+python_version+"/site-packages"
44          dir_libraries = prefix+"/lib"
45       else:
46          print "Install prefix is /usr but couldn't find python package directory in either"
47          print "/usr/lib64/"+python_version+"/site-packages or /usr/lib/"+python_version+"/site-packages"
48          sys.exit(1)
49       dir_examples = prefix+"/share/doc/esys"
50    else:
51       # Install using the usual escript directory structure
52       dir_packages = prefix
53       dir_libraries = prefix+"/lib"
54       dir_examples = prefix
55    dir_packages += "/esys"
56    dir_examples += "/examples"
57    
58  print "Install prefix is: ", prefix  print "Install prefix is: ", prefix
59    print " python packages will be installed in:   ", dir_packages
60    print " libraries will be installed in:     ", dir_libraries
61    print " examples will be installed in:      ", dir_examples
62    
63    #==============================================================================================    
64    
65  # Default options and options help text  # Default options and options help text
66  # These are defaults and can be overridden using command line arguments or an options file.  # These are defaults and can be overridden using command line arguments or an options file.
# Line 96  else: Line 120  else:
120  #  #
121  #    python installation:  #    python installation:
122  #  #
123  if IS_WINDOWS_PLATFORM:  python_path_default=os.path.join(tools_prefix,'include','python%s.%s'%(sys.version_info[0],sys.version_info[1]))
124     python_path_default=os.path.join(tools_prefix,'python%s%s'%(sys.version_info[0],sys.version_info[1]),"include")  python_lib_path_default=os.path.join(tools_prefix,'lib')
125     python_lib_path_default=os.path.join(tools_prefix,'python%s%s'%(sys.version_info[0],sys.version_info[1])+"libs")  python_lib_default="python%s.%s"%(sys.version_info[0],sys.version_info[1])
    python_libs_default=["python%s%s"%(sys.version_info[0],sys.version_info[1])]  
 else:  
    python_path_default=os.path.join(tools_prefix,'include','python%s.%s'%(sys.version_info[0],sys.version_info[1]))  
    python_lib_path_default=os.path.join(tools_prefix,'lib')  
    python_libs_default=["python%s.%s"%(sys.version_info[0],sys.version_info[1])]  
126    
127  #==========================================================================  #==========================================================================
128  #  #
129  #    boost installation:  #    boost installation:
130  #  #
131  if IS_WINDOWS_PLATFORM:  boost_path_default=os.path.join(tools_prefix,'include')
132     boost_libs_path_default=os.path.join(tools_prefix,'boost','lib')  boost_lib_path_default=os.path.join(tools_prefix,'lib')
133     boost_libs_default=None  boost_lib_default=['boost_python']
    for i in os.listdir(boost_libs_path_default):  
       name=os.path.splitext(i)  
       if name[1] == ".dll" and name[0].startswith("boost_python"):  
           if boost_libs_default == None:  
          boost_libs_default= [ name[0] ]  
       else:  
          if not name[0].find("-gd-"): boost_libs_default=[ name[0] ]  
    boost_path_default=os.path.join(tools_prefix,'boost','include','boost-%s'%(boost_libs_default[0].split("-")[-1],))  
 else:  
    boost_path_default=os.path.join(tools_prefix,'include')  
    boost_libs_path_default=os.path.join(tools_prefix,'lib')  
    boost_libs_default=['boost_python']  
134  #==========================================================================  #==========================================================================
135  #  #
136  #    check if netCDF is installed on the system:  #    check if netCDF is installed on the system:
137  #  #
138  if IS_WINDOWS_PLATFORM:  netCDF_path_default=os.path.join(tools_prefix,'include','netcdf-3')
139      netcdf_dir=os.path.join(tools_prefix,'netcdf')  netCDF_lib_path_default=os.path.join(tools_prefix,'lib','netcdf-3')
     netCDF_path_default=os.path.join(netcdf_dir,'include')  
     netCDF_lib_path_default=os.path.join(netcdf_dir,'lib')  
 else:  
     netCDF_path_default=os.path.join(tools_prefix,'include','netcdf-3')  
     netCDF_lib_path_default=os.path.join(tools_prefix,'lib','netcdf-3')  
140    
141  if os.path.isdir(netCDF_path_default) and os.path.isdir(netCDF_lib_path_default):  if os.path.isdir(netCDF_path_default) and os.path.isdir(netCDF_lib_path_default):
142       useNetCDF_default='yes'       useNetCDF_default='yes'
# Line 145  else: Line 147  else:
147       netCDF_lib_path_default=None       netCDF_lib_path_default=None
148       netCDF_libs_default=None       netCDF_libs_default=None
149    
 if IS_WINDOWS_PLATFORM:  
         useNetCDF_default='no' # be default netcdf is not supported on windows.  
150  #==========================================================================  #==========================================================================
151  #  #
152  #    compile:  #    compile:
153  #  #
154  if IS_WINDOWS_PLATFORM:  cc_flags_default='-O3 -std=c99 -ffast-math -fpic -Wno-unknown-pragmas -ansi -pedantic-errors'
155      # cc_flags_default  = '/GR /EHsc /MD /Qc99 /Qopenmp /Qopenmp-report1 /O3 /G7 /Qprec /Qpar-report1 /QxP /QaxP'  cc_flags_debug_default='-g -O0 -ffast-math -std=c99 -fpic -Wno-unknown-pragmas -ansi -pedantic-errors'
156      # cc_flags_debug_default  = '/Od /MDd /RTC1 /GR /EHsc /Qc99 /Qopenmp /Qopenmp-report1 /Qprec'  cxx_flags_default='--no-warn -ansi'
157      cc_flags_default  = '/nologo /EHsc /GR  /wd4068 /O2 /Op /MT /W3 /Ob0 /Z7'  cxx_flags_debug_default='--no-warn -ansi -DDOASSERT'
     cc_flags_debug_default  ='/nologo /EHsc /GR  /wd4068 /Od /RTC1 /MTd /ZI /Ob0 /Z7'  
       
     cc_flags_default  = '/nologo /EHsc /GR  /O2 /MT /W3 /Ob0 /Z7 /wd4068'  
     cc_flags_debug_default  ='/nologo /EHsc /GR /Od /RTC1 /MTd /W3 /Ob0 /Z7/wd4068'  
     cxx_flags_default = ''  
     cxx_flags_debug_default = ''  
     cc_common_flags = '/FD /EHsc /GR /wd4068 '  
 else:  
    cc_flags_default='-O3 -std=c99 -ffast-math -fpic -Wno-unknown-pragmas -ansi -pedantic-errors'  
    cc_flags_debug_default='-g -O0 -ffast-math -std=c99 -fpic -Wno-unknown-pragmas -ansi -pedantic-errors'  
    cxx_flags_default='--no-warn -ansi'  
    cxx_flags_debug_default='--no-warn -ansi -DDOASSERT'  
158  #==============================================================================================      #==============================================================================================    
159  # Default options and options help text  # Default options and options help text
160  # These are defaults and can be overridden using command line arguments or an options file.  # These are defaults and can be overridden using command line arguments or an options file.
# Line 174  else: Line 162  else:
162  # DO NOT CHANGE THEM HERE  # DO NOT CHANGE THEM HERE
163  opts.AddOptions(  opts.AddOptions(
164  # Where to install esys stuff  # Where to install esys stuff
165    ('incinstall', 'where the esys headers will be installed', prefix+'/include'),    ('incinstall', 'where the esys headers will be installed',             Dir('#.').abspath+'/include'),
166    ('libinstall', 'where the esys libraries will be installed', prefix+'/lib'),    ('libinstall', 'where the esys libraries will be installed',           dir_libraries),
167    ('pyinstall', 'where the esys python modules will be installed', prefix),    ('pyinstall', 'where the esys python modules will be installed',       dir_packages),
168    ('src_zipfile', 'the source zip file will be installed.', prefix+"/release/escript_src.zip"),    ('exinstall', 'where the esys examples will be installed',             dir_examples),
169    ('test_zipfile', 'the test zip file will be installed.', prefix+"/release/escript_tests.zip"),    ('src_zipfile', 'the source zip file will be installed.',              Dir('#.').abspath+"/release/escript_src.zip"),
170    ('src_tarfile', 'the source tar file will be installed.', prefix+"/release/escript_src.tar.gz"),    ('test_zipfile', 'the test zip file will be installed.',               Dir('#.').abspath+"/release/escript_tests.zip"),
171    ('test_tarfile', 'the test tar file will be installed.', prefix+"/release/escript_tests.tar.gz"),    ('src_tarfile', 'the source tar file will be installed.',              Dir('#.').abspath+"/release/escript_src.tar.gz"),
172    ('examples_tarfile', 'the examples tar file will be installed.', prefix+"/release/doc/escript_examples.tar.gz"),    ('test_tarfile', 'the test tar file will be installed.',               Dir('#.').abspath+"/release/escript_tests.tar.gz"),
173    ('examples_zipfile', 'the examples zip file will be installed.', prefix+"/release/doc/escript_examples.zip"),    ('examples_tarfile', 'the examples tar file will be installed.',       Dir('#.').abspath+"/release/doc/escript_examples.tar.gz"),
174    ('guide_pdf', 'name of the user guide in pdf format', prefix+"/release/doc/user/guide.pdf"),    ('examples_zipfile', 'the examples zip file will be installed.',       Dir('#.').abspath+"/release/doc/escript_examples.zip"),
175    ('api_epydoc', 'name of the epydoc api docs directory',prefix+"/release/doc/epydoc"),    ('guide_pdf', 'name of the user guide in pdf format',                  Dir('#.').abspath+"/release/doc/user/guide.pdf"),
176    ('guide_html', 'name of the directory for user guide in html format', prefix+"/release/doc/user/html"),    ('api_epydoc', 'name of the epydoc api docs directory',                Dir('#.').abspath+"/release/doc/epydoc"),
177      ('guide_html', 'name of the directory for user guide in html format',  Dir('#.').abspath+"/release/doc/user/html"),
178      ('api_doxygen', 'name of the doxygen api docs directory',prefix+"/release/doc/doxygen"),
179  # Compilation options  # Compilation options
180    BoolOption('dodebug', 'Do you want a debug build?', 'no'),    BoolOption('dodebug', 'Do you want a debug build?', 'no'),
181    ('options_file', "Optional file containing preferred options. Ignored if it doesn't exist (default: scons/<hostname>_options.py)", options_file),    ('options_file', "Optional file containing preferred options. Ignored if it doesn't exist (default: scons/<hostname>_options.py)", options_file),
# Line 228  opts.AddOptions( Line 218  opts.AddOptions(
218  # locations of include files for python  # locations of include files for python
219    PathOption('python_path', 'Path to Python includes', python_path_default),    PathOption('python_path', 'Path to Python includes', python_path_default),
220    PathOption('python_lib_path', 'Path to Python libs', python_lib_path_default),    PathOption('python_lib_path', 'Path to Python libs', python_lib_path_default),
221    ('python_libs', 'Python libraries to link with', python_libs_default),    ('python_lib', 'Python libraries to link with', python_lib_default),
222  # Boost  # Boost
223    PathOption('boost_path', 'Path to Boost includes', boost_path_default),    PathOption('boost_path', 'Path to Boost includes', boost_path_default),
224    PathOption('boost_libs_path', 'Path to Boost libs', boost_libs_path_default),    PathOption('boost_lib_path', 'Path to Boost libs', boost_lib_path_default),
225    ('boost_libs', 'Boost libraries to link with', boost_libs_default),    ('boost_lib', 'Boost libraries to link with', boost_lib_default),
226  # Doc building  # Doc building
227  #  PathOption('doxygen_path', 'Path to Doxygen executable', None),  #  PathOption('doxygen_path', 'Path to Doxygen executable', None),
228  #  PathOption('epydoc_path', 'Path to Epydoc executable', None),  #  PathOption('epydoc_path', 'Path to Epydoc executable', None),
# Line 253  opts.AddOptions( Line 243  opts.AddOptions(
243  #   This doesn't impact linux and windows which will use the default compiler (g++ or msvc, or the intel compiler if it is installed on both platforms)  #   This doesn't impact linux and windows which will use the default compiler (g++ or msvc, or the intel compiler if it is installed on both platforms)
244  #   FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix  #   FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix
245  #  #
246    IS_WINDOWS_PLATFORM = (os.name== "nt")
247    
248  if IS_WINDOWS_PLATFORM:  if IS_WINDOWS_PLATFORM:
249        env = Environment(tools = ['default', 'msvc'], options = opts)        env = Environment(tools = ['default', 'msvc'], options = opts)
250  else:  else:
# Line 263  else: Line 255  else:
255     else:     else:
256        env = Environment(tools = ['default'], options = opts)        env = Environment(tools = ['default'], options = opts)
257  Help(opts.GenerateHelpText(env))  Help(opts.GenerateHelpText(env))
258    
259  #=================================================================================================  #=================================================================================================
260  #  #
261  #     Initialise Scons Build Environment  #     Initialise Scons Build Environment
# Line 274  except KeyError: Line 267  except KeyError:
267     python_path = ''     python_path = ''
268    
269  try:  try:
270       omp_num_threads = os.environ['OMP_NUM_THREADS']
271    except KeyError:
272       omp_num_threads = 1
273    env['ENV']['OMP_NUM_THREADS'] = omp_num_threads
274    
275    try:
276       env['ENV']['DISPLAY'] = os.environ['DISPLAY']
277       env['ENV']['XAUTHORITY'] = os.environ['XAUTHORITY']
278    except KeyError:
279       pass
280    
281    try:
282     path = os.environ['PATH']     path = os.environ['PATH']
283     env['ENV']['PATH'] = path     env['ENV']['PATH'] = path
284  except KeyError:  except KeyError:
# Line 290  except KeyError: Line 295  except KeyError:
295  py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)  py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
296  env.Append(BUILDERS = {'PyCompile' : py_builder});  env.Append(BUILDERS = {'PyCompile' : py_builder});
297    
298    # TODO: use the inbuilt scons suffix variable.
299  if IS_WINDOWS_PLATFORM:  if IS_WINDOWS_PLATFORM:
300     runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True)     runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True)
301  else:  else:
# Line 307  except KeyError: Line 313  except KeyError:
313     incinstall = None     incinstall = None
314  try:  try:
315     libinstall = env['libinstall']     libinstall = env['libinstall']
316     env.Append(LIBPATH = [libinstall,]) # ksteube adds -L for building of libescript.so libfinley.so escriptcpp.so finleycpp.so     env.Append(LIBPATH = [libinstall,]) # Adds -L for building of libescript.so libfinley.so escriptcpp.so finleycpp.so
317     env.PrependENVPath('LD_LIBRARY_PATH', libinstall)     env.PrependENVPath('LD_LIBRARY_PATH', libinstall)
318     if env['PLATFORM'] == "win32":     if env['PLATFORM'] == "win32":
319        env.PrependENVPath('PATH', libinstall)        env.PrependENVPath('PATH', libinstall)
320        env.PrependENVPath('PATH', env['boost_libs_path'])        env.PrependENVPath('PATH', env['boost_lib_path'])
321  except KeyError:  except KeyError:
322     libinstall = None     libinstall = None
323  try:  try:
324     pyinstall = env['pyinstall']+'/esys' # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc     pyinstall = env['pyinstall'] # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc
325     env.PrependENVPath('PYTHONPATH', env['pyinstall'])     env.PrependENVPath('PYTHONPATH', env['pyinstall'])
326  except KeyError:  except KeyError:
327     pyinstall = None     pyinstall = None
328  try:  try:
329       exinstall = env['exinstall']
330    except KeyError:
331       exinstall = None
332    try:
333     dodebug = env['dodebug']     dodebug = env['dodebug']
334  except KeyError:  except KeyError:
335     dodebug = None     dodebug = None
# Line 543  try: Line 553  try:
553  except KeyError:  except KeyError:
554     pass     pass
555  try:  try:
556     lib_path = env['boost_libs_path']     lib_path = env['boost_lib_path']
557     env.Append(LIBPATH = [lib_path,])     env.Append(LIBPATH = [lib_path,])
558  except KeyError:  except KeyError:
559     pass     pass
560  try:  try:
561     boost_libs = env['boost_libs']     boost_lib = env['boost_lib']
562  except KeyError:  except KeyError:
563     boost_libs = None     boost_lib = None
564  try:  try:
565     includes = env['python_path']     includes = env['python_path']
566     env.Append(CPPPATH = [includes,])     env.Append(CPPPATH = [includes,])
# Line 562  try: Line 572  try:
572  except KeyError:  except KeyError:
573     pass     pass
574  try:  try:
575     python_libs = env['python_libs']     python_lib = env['python_lib']
576  except KeyError:  except KeyError:
577     python_libs = None     python_lib = None
578  try:  try:
579     doxygen_path = env['doxygen_path']     doxygen_path = env['doxygen_path']
580  except KeyError:  except KeyError:
# Line 630  try: Line 640  try:
640  except KeyError:  except KeyError:
641     api_epydoc = None     api_epydoc = None
642    
643    try:
644       api_doxygen = env.Dir(env['api_doxygen'])
645    except KeyError:
646       api_doxygen = None
647    
648  # Zipgets  # Zipgets
649  env.Default(libinstall)  env.Default(libinstall)
650  env.Default(incinstall)  env.Default(incinstall)
651  env.Default(pyinstall)  env.Default(pyinstall)
652    ### env.Default(exinstall) # ksteube this causes dependency error
653  env.Alias('release_src',[ src_zipfile, src_tarfile ])  env.Alias('release_src',[ src_zipfile, src_tarfile ])
654  env.Alias('release_tests',[ test_zipfile, test_tarfile])  env.Alias('release_tests',[ test_zipfile, test_tarfile])
655  env.Alias('release_examples',[ examples_zipfile, examples_tarfile])  env.Alias('release_examples',[ examples_zipfile, examples_tarfile])
656    env.Alias('examples_zipfile',examples_zipfile)
657    env.Alias('examples_tarfile',examples_tarfile)
658  env.Alias('api_epydoc',api_epydoc)  env.Alias('api_epydoc',api_epydoc)
659    env.Alias('api_doxygen',api_doxygen)
660    env.Alias('guide_html_index',guide_html_index)
661  env.Alias('guide_pdf', guide_pdf)  env.Alias('guide_pdf', guide_pdf)
662  env.Alias('docs',[ 'release_examples', 'guide_pdf', guide_html_index, api_epydoc])  env.Alias('docs',[ 'release_examples', 'guide_pdf', api_epydoc, api_doxygen, guide_html_index])
663  env.Alias('release', ['release_src', 'release_tests', 'docs'])  env.Alias('release', ['release_src', 'release_tests', 'docs'])
664  env.Alias('build_tests')    # target to build all C++ tests  env.Alias('build_tests')    # target to build all C++ tests
665  env.Alias('build_py_tests') # target to build all python tests  env.Alias('build_py_tests') # target to build all python tests
# Line 653  init_target = env.Command(pyinstall+'/__ Line 673  init_target = env.Command(pyinstall+'/__
673  env.Alias(init_target)  env.Alias(init_target)
674    
675  # Allow sconscripts to see the env  # Allow sconscripts to see the env
676  Export(["IS_WINDOWS_PLATFORM", "env", "incinstall", "libinstall", "pyinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs", "amd_libs", "blas_libs", "netCDF_libs", "useNetCDF",  Export(["IS_WINDOWS_PLATFORM", "env", "incinstall", "libinstall", "pyinstall", "exinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs", "amd_libs", "blas_libs", "netCDF_libs", "useNetCDF",
677      "boost_libs", "python_libs", "doxygen_path", "epydoc_path", "papi_libs",      "boost_lib", "python_lib", "doxygen_path", "epydoc_path", "papi_libs",
678          "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile", "src_tarfile", "examples_tarfile", "examples_zipfile",          "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile", "src_tarfile", "examples_tarfile", "examples_zipfile",
679          "guide_pdf", "guide_html_index", "api_epydoc", "useMPI" ])          "guide_pdf", "guide_html_index", "api_epydoc", "api_doxygen", "useMPI" ])
680    
681  # End initialisation section  # End initialisation section
682  # Begin configuration section  # Begin configuration section

Legend:
Removed from v.1149  
changed lines
  Added in v.1235

  ViewVC Help
Powered by ViewVC 1.1.26