README.md: improve markdown formatting, update homepage, use https
[pd-aubio.git] / waflib / Tools / gfortran.py
1 #! /usr/bin/env python
2 # encoding: utf-8
3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
4
5 import re
6 from waflib import Utils
7 from waflib.Tools import fc,fc_config,fc_scan,ar
8 from waflib.Configure import conf
9 @conf
10 def find_gfortran(conf):
11         fc=conf.find_program(['gfortran','g77'],var='FC')
12         fc=conf.cmd_to_list(fc)
13         conf.get_gfortran_version(fc)
14         conf.env.FC_NAME='GFORTRAN'
15 @conf
16 def gfortran_flags(conf):
17         v=conf.env
18         v['FCFLAGS_fcshlib']=['-fPIC']
19         v['FORTRANMODFLAG']=['-J','']
20         v['FCFLAGS_DEBUG']=['-Werror']
21 @conf
22 def gfortran_modifier_win32(conf):
23         fc_config.fortran_modifier_win32(conf)
24 @conf
25 def gfortran_modifier_cygwin(conf):
26         fc_config.fortran_modifier_cygwin(conf)
27 @conf
28 def gfortran_modifier_darwin(conf):
29         fc_config.fortran_modifier_darwin(conf)
30 @conf
31 def gfortran_modifier_platform(conf):
32         dest_os=conf.env['DEST_OS']or Utils.unversioned_sys_platform()
33         gfortran_modifier_func=getattr(conf,'gfortran_modifier_'+dest_os,None)
34         if gfortran_modifier_func:
35                 gfortran_modifier_func()
36 @conf
37 def get_gfortran_version(conf,fc):
38         version_re=re.compile(r"GNU\s*Fortran",re.I).search
39         cmd=fc+['--version']
40         out,err=fc_config.getoutput(conf,cmd,stdin=False)
41         if out:match=version_re(out)
42         else:match=version_re(err)
43         if not match:
44                 conf.fatal('Could not determine the compiler type')
45         cmd=fc+['-dM','-E','-']
46         out,err=fc_config.getoutput(conf,cmd,stdin=True)
47         if out.find('__GNUC__')<0:
48                 conf.fatal('Could not determine the compiler type')
49         k={}
50         out=out.split('\n')
51         import shlex
52         for line in out:
53                 lst=shlex.split(line)
54                 if len(lst)>2:
55                         key=lst[1]
56                         val=lst[2]
57                         k[key]=val
58         def isD(var):
59                 return var in k
60         def isT(var):
61                 return var in k and k[var]!='0'
62         conf.env['FC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k['__GNUC_PATCHLEVEL__'])
63 def configure(conf):
64         conf.find_gfortran()
65         conf.find_ar()
66         conf.fc_flags()
67         conf.fc_add_flags()
68         conf.gfortran_flags()
69         conf.gfortran_modifier_platform()