@@ -213,6 +213,10 @@ class FCompiler(CCompiler):
213213 # command/{build_ext.py, build_clib.py, config.py} files.
214214 c_compiler = None
215215
216+ # extra_{f77,f90}_compile_args are set by build_ext.build_extension method
217+ extra_f77_compile_args = []
218+ extra_f90_compile_args = []
219+
216220 def __init__ (self , * args , ** kw ):
217221 CCompiler .__init__ (self , * args , ** kw )
218222 self .distutils_vars = self .distutils_vars .clone (self ._environment_hook )
@@ -560,18 +564,21 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
560564 flavor = ':f77'
561565 compiler = self .compiler_f77
562566 src_flags = get_f77flags (src )
567+ extra_compile_args = self .extra_f77_compile_args or []
563568 elif is_free_format (src ):
564569 flavor = ':f90'
565570 compiler = self .compiler_f90
566571 if compiler is None :
567572 raise DistutilsExecError ('f90 not supported by %s needed for %s' \
568573 % (self .__class__ .__name__ ,src ))
574+ extra_compile_args = self .extra_f90_compile_args or []
569575 else :
570576 flavor = ':fix'
571577 compiler = self .compiler_fix
572578 if compiler is None :
573579 raise DistutilsExecError ('f90 (fixed) not supported by %s needed for %s' \
574580 % (self .__class__ .__name__ ,src ))
581+ extra_compile_args = self .extra_f90_compile_args or []
575582 if self .object_switch [- 1 ]== ' ' :
576583 o_args = [self .object_switch .strip (),obj ]
577584 else :
@@ -580,13 +587,17 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
580587 assert self .compile_switch .strip ()
581588 s_args = [self .compile_switch , src ]
582589
590+ if extra_compile_args :
591+ log .info ('extra %s options: %r' \
592+ % (flavor [1 :], ' ' .join (extra_compile_args )))
593+
583594 extra_flags = src_flags .get (self .compiler_type ,[])
584595 if extra_flags :
585596 log .info ('using compile options from source: %r' \
586597 % ' ' .join (extra_flags ))
587598
588599 command = compiler + cc_args + extra_flags + s_args + o_args \
589- + extra_postargs
600+ + extra_postargs + extra_compile_args
590601
591602 display = '%s: %s' % (os .path .basename (compiler [0 ]) + flavor ,
592603 src )
@@ -961,5 +972,7 @@ def get_f77flags(src):
961972 f .close ()
962973 return flags
963974
975+ # TODO: implement get_f90flags and use it in _compile similarly to get_f77flags
976+
964977if __name__ == '__main__' :
965978 show_fcompilers ()
0 commit comments