jack2 codebase
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.

68 lines
2.1KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. import os, sys, imp, types, re
  4. from waflib import Utils, Configure, Options, Logs, Errors
  5. from waflib.Tools import fc
  6. fc_compiler = {
  7. 'win32' : ['gfortran','ifort'],
  8. 'darwin' : ['gfortran', 'g95', 'ifort'],
  9. 'linux' : ['gfortran', 'g95', 'ifort'],
  10. 'java' : ['gfortran', 'g95', 'ifort'],
  11. 'default': ['gfortran'],
  12. 'aix' : ['gfortran']
  13. }
  14. """
  15. Dict mapping the platform names to lists of names of Fortran compilers to try, in order of preference::
  16. from waflib.Tools.compiler_c import c_compiler
  17. c_compiler['linux'] = ['gfortran', 'g95', 'ifort']
  18. """
  19. def default_compilers():
  20. build_platform = Utils.unversioned_sys_platform()
  21. possible_compiler_list = fc_compiler.get(build_platform, fc_compiler['default'])
  22. return ' '.join(possible_compiler_list)
  23. def configure(conf):
  24. """
  25. Try to find a suitable Fortran compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
  26. """
  27. try: test_for_compiler = conf.options.check_fortran_compiler or default_compilers()
  28. except AttributeError: conf.fatal("Add options(opt): opt.load('compiler_fc')")
  29. for compiler in re.split('[ ,]+', test_for_compiler):
  30. conf.env.stash()
  31. conf.start_msg('Checking for %r (Fortran compiler)' % compiler)
  32. try:
  33. conf.load(compiler)
  34. except conf.errors.ConfigurationError as e:
  35. conf.env.revert()
  36. conf.end_msg(False)
  37. Logs.debug('compiler_fortran: %r' % e)
  38. else:
  39. if conf.env['FC']:
  40. conf.end_msg(conf.env.get_flat('FC'))
  41. conf.env.COMPILER_FORTRAN = compiler
  42. break
  43. conf.end_msg(False)
  44. else:
  45. conf.fatal('could not configure a Fortran compiler!')
  46. def options(opt):
  47. """
  48. Restrict the compiler detection from the command-line::
  49. $ waf configure --check-fortran-compiler=ifort
  50. """
  51. test_for_compiler = default_compilers()
  52. opt.load_special_tools('fc_*.py')
  53. fortran_compiler_opts = opt.add_option_group('Configuration options')
  54. fortran_compiler_opts.add_option('--check-fortran-compiler', default=None,
  55. help='list of Fortran compiler to try [%s]' % test_for_compiler,
  56. dest="check_fortran_compiler")
  57. for x in test_for_compiler.split():
  58. opt.load('%s' % x)