You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.3 KiB

6 years ago
  1. """SCons.Tool.ifort
  2. Tool-specific initialization for newer versions of the Intel Fortran Compiler
  3. for Linux/Windows (and possibly Mac OS X).
  4. There normally shouldn't be any need to import this module directly.
  5. It will usually be imported through the generic SCons.Tool.Tool()
  6. selection method.
  7. """
  8. #
  9. # Copyright (c) 2001 - 2017 The SCons Foundation
  10. #
  11. # Permission is hereby granted, free of charge, to any person obtaining
  12. # a copy of this software and associated documentation files (the
  13. # "Software"), to deal in the Software without restriction, including
  14. # without limitation the rights to use, copy, modify, merge, publish,
  15. # distribute, sublicense, and/or sell copies of the Software, and to
  16. # permit persons to whom the Software is furnished to do so, subject to
  17. # the following conditions:
  18. #
  19. # The above copyright notice and this permission notice shall be included
  20. # in all copies or substantial portions of the Software.
  21. #
  22. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  23. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  24. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. #
  30. __revision__ = "src/engine/SCons/Tool/ifort.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
  31. import SCons.Defaults
  32. from SCons.Scanner.Fortran import FortranScan
  33. from .FortranCommon import add_all_to_env
  34. def generate(env):
  35. """Add Builders and construction variables for ifort to an Environment."""
  36. # ifort supports Fortran 90 and Fortran 95
  37. # Additionally, ifort recognizes more file extensions.
  38. fscan = FortranScan("FORTRANPATH")
  39. SCons.Tool.SourceFileScanner.add_scanner('.i', fscan)
  40. SCons.Tool.SourceFileScanner.add_scanner('.i90', fscan)
  41. if 'FORTRANFILESUFFIXES' not in env:
  42. env['FORTRANFILESUFFIXES'] = ['.i']
  43. else:
  44. env['FORTRANFILESUFFIXES'].append('.i')
  45. if 'F90FILESUFFIXES' not in env:
  46. env['F90FILESUFFIXES'] = ['.i90']
  47. else:
  48. env['F90FILESUFFIXES'].append('.i90')
  49. add_all_to_env(env)
  50. fc = 'ifort'
  51. for dialect in ['F77', 'F90', 'FORTRAN', 'F95']:
  52. env['%s' % dialect] = fc
  53. env['SH%s' % dialect] = '$%s' % dialect
  54. if env['PLATFORM'] == 'posix':
  55. env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS -fPIC' % dialect)
  56. if env['PLATFORM'] == 'win32':
  57. # On Windows, the ifort compiler specifies the object on the
  58. # command line with -object:, not -o. Massage the necessary
  59. # command-line construction variables.
  60. for dialect in ['F77', 'F90', 'FORTRAN', 'F95']:
  61. for var in ['%sCOM' % dialect, '%sPPCOM' % dialect,
  62. 'SH%sCOM' % dialect, 'SH%sPPCOM' % dialect]:
  63. env[var] = env[var].replace('-o $TARGET', '-object:$TARGET')
  64. env['FORTRANMODDIRPREFIX'] = "/module:"
  65. else:
  66. env['FORTRANMODDIRPREFIX'] = "-module "
  67. def exists(env):
  68. return env.Detect('ifort')
  69. # Local Variables:
  70. # tab-width:4
  71. # indent-tabs-mode:nil
  72. # End:
  73. # vim: set expandtab tabstop=4 shiftwidth=4: