-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
161 lines (115 loc) · 3.51 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import os
import distro
AddOption(
'--debug-build',
dest='debug-build',
action='store_true',
help='debug build',
default=False)
env = Environment()
# Check build
DEBUG = GetOption('debug-build')
RELEASE = (not DEBUG)
OS_NAME = distro.name()
OS_VERSION = float(distro.version())
# Assign compilers
if os.environ.get('CC') != None:
env['CC'] = os.environ.get('CC')
else:
env['CC'] = 'gcc'
if os.environ.get('CXX') != None:
env['CXX'] = os.environ.get('CXX')
else:
env['CXX'] = 'g++'
# Includes
includes = []
if os.environ.get('INCLUDE') != None:
includes.append(os.environ.get('INCLUDE').split(":"))
includes.append('include')
includes.append('/usr/include/himan')
includes.append('/usr/include/himan/plugins')
includes.append('/usr/gdal38/include')
env.Append(CPPPATH = includes)
# Library paths
librarypaths = []
if os.environ.get('LIBRARYPATH') != None:
librarypaths.append(os.environ.get('LIBRARYPATH').split(":"))
librarypaths.append('/usr/lib64')
librarypaths.append('/usr/gdal38/lib')
if OS_VERSION < 9:
librarypaths.append('/usr/lib64/boost169')
env.Append(LIBPATH = librarypaths)
# Libraries
libraries = []
libraries.append('himan')
libraries.append('fmidb')
libraries.append('fminc')
libraries.append('pqxx')
libraries.append('odbc')
libraries.append('netcdf_c++')
libraries.append('s3')
libraries.append('fmigrib')
libraries.append('eccodes')
libraries.append('gdal')
libraries.append('fmt')
libraries.append('stdc++fs')
env.Append(LIBS = libraries)
boost_libraries = [ 'boost_program_options', 'boost_iostreams' ]
env.Append(LIBS = boost_libraries)
env.Append(LIBS = ['fmt','dl','rt'])
# CFLAGS
# "Normal" flags
cflags_normal = []
cflags_normal.append('-Wall')
cflags_normal.append('-W')
cflags_normal.append('-Wno-unused-parameter')
#cflags_normal.append('-Werror')
# Extra flags
cflags_extra = []
cflags_extra.append('-Wpointer-arith')
cflags_extra.append('-Wcast-qual')
cflags_extra.append('-Wcast-align')
cflags_extra.append('-Wwrite-strings')
cflags_extra.append('-Wconversion')
cflags_extra.append('-Wnon-virtual-dtor')
cflags_extra.append('-Wno-pmf-conversions')
cflags_extra.append('-Wsign-promo')
cflags_extra.append('-Wchar-subscripts')
cflags_extra.append('-Wold-style-cast')
# Difficult flags
cflags_difficult = []
cflags_difficult.append('-pedantic')
#cflags_difficult.append('-Weffc++')
cflags_difficult.append('-Wredundant-decls')
cflags_difficult.append('-Wshadow')
cflags_difficult.append('-Woverloaded-virtual')
cflags_difficult.append('-Wunreachable-code')
cflags_difficult.append('-Wctor-dtor-privacy')
# Default flags (common for release/debug)
cflags = []
cflags.append('-std=c++17')
env.Append(CCFLAGS = '-fPIC')
env.Append(CCFLAGS = cflags)
env.Append(CCFLAGS = cflags_normal)
env.Append(CCFLAGS = cflags_extra)
env.Append(CCFLAGS = cflags_difficult)
if OS_VERSION < 9:
env.AppendUnique(CCFLAGS=('-isystem', '/usr/include/boost169'))
# Linker flags
env.Append(LINKFLAGS = ['-Wl,--export-dynamic', '-rdynamic', '-Wl,--as-needed', '-Wl,--warn-unresolved-symbols', '-pthread'])
# '-Wl,-rpath,.'
# Defines
env.Append(CPPDEFINES=['UNIX'])
build_dir = ""
if RELEASE:
env.Append(CCFLAGS = ['-O2', '-g'])
env.Append(CPPDEFINES = ['NDEBUG'])
build_dir = "build/release"
if DEBUG:
env.Append(CPPDEFINES = ['DEBUG'])
env.Append(CCFLAGS = ['-O0', '-g'])
env.Append(CCFLAGS = cflags_extra)
env.Append(CCFLAGS = cflags_difficult)
build_dir = "build/debug"
SConscript('SConscript', exports = ['env'], variant_dir=build_dir, duplicate=0)
Clean('.', build_dir)