-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
SConstruct
88 lines (75 loc) · 2.55 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import os, sys, re
sys.path.append('../../framework')
import bldutil
# Put your name programs in progs variable
# without 'M' preffix and '.c' extension
progs = '''
crepefandstack crestack cretrajec getcregather getcretimecurve rnip2vrms getcreandstack rnip2vnmo parsmoother
'''
try: # distributed version
Import('env root pkgdir bindir')
env = env.Clone()
except: # local version
env = bldutil.Debug()
cflags = env.get('CFLAGS','')
if isinstance (cflags, str):
env['CFLAGS'] = cflags.replace('-O3','-g').replace('-xHOST','')
env.Prepend(CPPDEFINES=['DEBUG'])
root = None
SConscript('../../api/c/SConstruct')
# Check if the TDD option is set
if ARGUMENTS.get('tdd',0):
print("TDD option is set...")
## Set a c flag to compilation process
## the flag -Wp,-DTDD=1 informs to the preprocessor that TDD=1
env['CFLAGS'] = '-Wp,-DTDD=1'
if sys.platform.startswith('linux'):
env.Prepend(CPPDEFINES=['LINUX'])
src = Glob('[a-z]*.c')
sse = None
#sse = env.get('SSE')
CC = env.get('CC')
if CC.rfind('icc') >= 0:
env.Append(CCFLAGS=['-restrict','-wd188'])
threads = env.get('PTHREADS')
if threads:
env.Prepend(CPPDEFINES=['PTHREADS'])
if sse:
env.Prepend(CPPPATH=['../../include'],
LIBPATH=['../../lib'],
LIBS=[env.get('DYNLIB','')+'rsf'],
CCFLAGS=[sse],CPPDEFINES=['HAVE_SSE'])
else:
env.Prepend(CPPPATH=['../../include'],
LIBPATH=['../../lib'],
LIBS=[env.get('DYNLIB','')+'rsf'])
if env['PLATFORM'] == 'darwin':
# bug in Mac's gcc handling of OpenMP
env.Append(CPPDEFINES=['_FORTIFY_SOURCE=0'],CCFLAGS='-O1')
for source in src:
if source.rstr() == 'einspline.c':
einspl_o = env.StaticObject('einspline.c')
env.Depends(einspl_o,'einspline.h')
else:
inc = env.RSF_Include(source,prefix='')
obj = env.StaticObject(source)
env.Ignore(inc,inc)
env.Depends(obj,inc)
# Regular progams
mains = Split(progs)
for prog in mains:
sources = ['M' + prog]
bldutil.depends(env,sources,'M'+prog)
prog = env.Program(prog,[x + '.c' for x in sources])
if root:
env.Install(bindir,prog)
######################################################################
# SELF-DOCUMENTATION
######################################################################
if root:
user = os.path.basename(os.getcwd())
main = 'sf%s.py' % user
docs = [env.Doc(prog,'M' + prog) for prog in mains]
env.Depends(docs,'#/framework/rsf/doc.py')
doc = env.RSF_Docmerge(main,docs)
env.Install(pkgdir,doc)