Update SConstruct
This commit is contained in:
parent
61202f7a1f
commit
44b3145b65
|
@ -1,7 +1,6 @@
|
||||||
from sysconfig import get_config_var
|
from sysconfig import get_config_var
|
||||||
import os
|
import os
|
||||||
|
|
||||||
SetOption('silent', True)
|
|
||||||
# Define the command line options
|
# Define the command line options
|
||||||
AddOption('--dbg',
|
AddOption('--dbg',
|
||||||
dest='dbg',
|
dest='dbg',
|
||||||
|
@ -13,29 +12,57 @@ AddOption('--verbose',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='add debugging symbols')
|
help='add debugging symbols')
|
||||||
|
|
||||||
|
AddOption('--compiler',
|
||||||
|
dest='compiler',
|
||||||
|
default='gfortran',
|
||||||
|
choices=['gfortran', 'ifort'],
|
||||||
|
help='The Fortran compiler to use')
|
||||||
|
|
||||||
|
def CheckPKGConfig(context, version):
|
||||||
|
context.Message( 'Checking for pkg-config... ' )
|
||||||
|
ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
|
||||||
|
context.Result( ret )
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def CheckPKG(context, name):
|
||||||
|
context.Message( 'Checking for %s... ' % name )
|
||||||
|
ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
|
||||||
|
context.Result( ret )
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# define environments
|
# define environments
|
||||||
COMP_OPTS = ['-O2', '-ffast-math', '-fno-automatic']
|
std = Environment(tools=['default', 'fortran'], F2PY_OPTS=[], FORTRANCOMSTR = "building $TARGET ...")
|
||||||
#std = Environment(tools=['default', 'gfortran'], FORTRAN='gfortran',
|
|
||||||
std = Environment(FORTRAN='gfortran',
|
|
||||||
FORTRANFLAGS=['-fPIC', '-O2', '-ffast-math', '-fno-automatic'],
|
|
||||||
F2PY_OPTS=[],
|
|
||||||
FORTRANCOMSTR = "building $TARGET ...")
|
|
||||||
|
|
||||||
dbg = std.Clone()
|
gfortran_env = std.Clone(tools=['gfortran'])
|
||||||
dbg.Append(FORTRANFLAGS = ['-g', '-Wall', '-Wextra', '-Warray-temporaries', '-Wconversion', '-fbacktrace',
|
gfortran_env.Replace(FORTRANFLAGS=['-fPIC', '-O2', '-ffast-math', '-fno-automatic'])
|
||||||
'-ffree-line-length-0', '-fcheck=all', '-ffpe-trap=zero,overflow,underflow',
|
|
||||||
'-finit-real=nan'])
|
ifort_env = std.Clone(tools=['ifort'])
|
||||||
dbg.Append(F2PY_OPTS = ['--debug-capi', '--debug'])
|
|
||||||
|
# parse options
|
||||||
|
if GetOption('compiler') == 'gfortran':
|
||||||
|
env = gfortran_env
|
||||||
|
elif GetOption('compiler') == 'ifort':
|
||||||
|
env = ifort_env
|
||||||
|
|
||||||
env = std
|
|
||||||
if GetOption('dbg'):
|
if GetOption('dbg'):
|
||||||
env = dbg
|
gfortran_env.Append(FORTRANFLAGS = ['-g', '-Wall', '-Wextra', '-Warray-temporaries', '-Wconversion', '-fbacktrace',
|
||||||
|
'-ffree-line-length-0', '-fcheck=all', '-ffpe-trap=zero,overflow,underflow',
|
||||||
|
'-finit-real=nan'],
|
||||||
|
F2PY_OPTS = ['--debug-capi', '--debug'])
|
||||||
|
|
||||||
if GetOption('verbose'):
|
if GetOption('verbose'):
|
||||||
SetOption('silent', False)
|
env.Replace(FORTRANCOMSTR = "")
|
||||||
#env.Replace(FORTRANCOMSTR = "")
|
|
||||||
|
|
||||||
|
# Configuration:
|
||||||
|
conf = Configure(env, custom_tests = { 'CheckPKG' : CheckPKG})
|
||||||
|
|
||||||
|
if conf.CheckPKG('lapack'):
|
||||||
|
env.ParseConfig("pkg-config lapack --libs")
|
||||||
|
|
||||||
|
conf.Finish()
|
||||||
|
|
||||||
|
|
||||||
suffix = get_config_var('EXT_SUFFIX')
|
suffix = get_config_var('EXT_SUFFIX')
|
||||||
|
@ -52,6 +79,11 @@ sources = {
|
||||||
'eig_mi_src' : Glob('eig/mi/*.f'),
|
'eig_mi_src' : Glob('eig/mi/*.f'),
|
||||||
'eig_pw_src' : Glob('eig/pw/*.f')}
|
'eig_pw_src' : Glob('eig/pw/*.f')}
|
||||||
|
|
||||||
|
if 'lapack' in env['LIBS']:
|
||||||
|
env.Append(F2PY_OPTS = "-llapack")
|
||||||
|
for k,files in sources.items():
|
||||||
|
sources[k] = [_ for _ in files if str(_).find('lapack') == -1]
|
||||||
|
|
||||||
objects = {}
|
objects = {}
|
||||||
for k, v in sources.items():
|
for k, v in sources.items():
|
||||||
objects[k.replace('_src', '_obj')] = env.Object(v)
|
objects[k.replace('_src', '_obj')] = env.Object(v)
|
||||||
|
@ -69,8 +101,11 @@ modules = {}
|
||||||
|
|
||||||
for k, v in shared_objects.items():
|
for k, v in shared_objects.items():
|
||||||
cmd = "f2py3 -I. " + " ".join([str(_) for _ in objects if str(_).endswith('.o')]) + f"$F2PY_OPTS -c -m {k} $SOURCE"
|
cmd = "f2py3 -I. " + " ".join([str(_) for _ in objects if str(_).endswith('.o')]) + f"$F2PY_OPTS -c -m {k} $SOURCE"
|
||||||
cmd += " 1>/dev/null"
|
cmd += "2>/dev/null 1>/dev/null"
|
||||||
modules[k + suffix] = env.Command(k + suffix, v, Action(cmd, 'Building Python module $TARGET'))
|
modules[k + suffix] = env.Command(k + suffix, v, Action(cmd, '$FORTRANCOMSTR'))
|
||||||
Requires(modules[k + suffix], objects.values())
|
Requires(modules[k + suffix], objects.values())
|
||||||
|
|
||||||
|
#for k,v in env.items():
|
||||||
|
# print(k,v)
|
||||||
|
|
||||||
|
#exit()
|
||||||
|
|
Loading…
Reference in New Issue