This repository has been archived by the owner on Oct 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
290 lines (257 loc) · 8.47 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
from glob import glob
from string import find
# CONFIGURATION TEST SUBROUTINES
def CheckCXX( context, src ):
context.Message( ' Compile: ' )
ret = context.TryCompile( src, '.cpp' )
context.Result( ret )
return ret
def CheckLNK( context, src ):
context.Message( ' Link: ' )
ret = context.TryLink( src, '.cpp' )
context.Result( ret )
return ret
# TEST PROGRAMS
checkfftw = """
#include <fftw.h>
int main(int argc, char **argv) {
fftw_real *fftwp = 0;
float *fftp = 0;
fftw_plan plan;
fftp = fftwp;
plan = fftw_create_plan(16, FFTW_FORWARD, 0);
return 0;
}
"""
checkmmdb = """
#include "mmdb_manager.h"
int main(int argc, char **argv) {
CMMDBManager mmdb;
mmdb.ReadPDBASCII( argv[1] );
return 0;
}
"""
checkcctbx = """
#include "cctbx/miller.h"
int main(int argc, char **argv) {
cctbx::Miller::Index x;
return 0;
}
"""
checkccp4 = """
#include "cmtzlib.h"
int main(int argc, char **argv) {
CMtz::MTZ* mtz;
mtz = CMtz::MtzGet( "dummy.mtz", 0 );
return 0;
}
"""
checkmccp4 = """
#include "mmtzlib.h"
int main(int argc, char **argv) {
mmtz_io::mmtzfile mtz;
mtz = mmtz_io::mmtz_open( "dummy.mtz", "r" );
return 0;
}
"""
# ---------- MAIN BUILD SECTION STARTS HERE ----------
# Help info
Help( """
Typical usage:
scons with-fftw=$PWD/fftw-2.1.5 with-ccp4=$PWD/ccp4
Options:
TARGETS: (omit to build everything)
clipper (builds the libraries)
install (installs the libraries and headers)
examples (builds the examples)
BUILD DIRECTORIES:
prefix=PATH
- define path for final lib/ and include/ directories. Defaults to
current workign directory.
e.g. prefix=/usr/local/
DEPENDENCIES:
with-fftw=PATH
with-ccp4=PATH (this also provides mmdb)
with-mmdb=PATH (only use this option if you don't have CCP4)
with-mccp4=PATH
with-cctbx=PATH
with-boost=PATH
- define paths for dependencies
e.g. with-fftw=/usr/local/fftw
PLATFORMS:
unix-gcc=[PATH/]gcc (use GNU gcc, with optional compiler path)
sun-CC=[PATH/]CC (use Sun CC, with optional compiler path)
sgi-CC=[PATH/]CC (use SGI CC, with optional compiler path)
tru-cxx=[PATH/]cxx (use Tru64 cxx, with optional compiler path)
- if no platform is specified, unix-gcc is assumed (may work on
Windows/MinGW too).
OPTIMISATION:
opt=FLAGS (use -g for debug, "-O2 -fno-default-inline" on gcc 3.2)
LIBRARIES:
objs=[static,shared]
- default is both
PACKAGES:
pkglist=PACKAGES
- define a comma-separated list of packages to be built. If this
option is not specified, then all packages for which dependencies
are found will be built. The core package is always built. Possible
packages include:
core,contrib,phs,mmdb,minimol,mmdbold,cif,ccp4,mccp4,cctbx
e.g. packages=core,contrib,phs
""" )
# read command line
prefix = ARGUMENTS.get( 'prefix', '#' )
withfftw = ARGUMENTS.get( 'with-fftw', '-' )
withmmdb = ARGUMENTS.get( 'with-mmdb', '-' )
withccp4 = ARGUMENTS.get( 'with-ccp4', '-' )
withmccp4 = ARGUMENTS.get( 'with-mccp4', '-' )
withcctbx = ARGUMENTS.get( 'with-cctbx', '-' )
withboost = ARGUMENTS.get( 'with-boost', '-' )
ccgcc = ARGUMENTS.get( 'unix-gcc', '-' )
ccsun = ARGUMENTS.get( 'sun-CC', '-' )
ccsgi = ARGUMENTS.get( 'sgi-CC', '-' )
cctru = ARGUMENTS.get( 'tru-cxx', '-' )
objs = ARGUMENTS.get( 'objs', 'static,shared' )
opt = ARGUMENTS.get( 'opt', '-' )
debug = ARGUMENTS.get( 'debug', '-' )
pkglist = ARGUMENTS.get( 'packages', '-' )
libvers = '0.0.0'
# basic environment
env = Environment( CPPPATH = [], LIBPATH = [], LIBS = [ 'rfftw', 'fftw', 'm' ] )
if withfftw != '-':
env.Append( CPPPATH = [ withfftw + '/include' ] )
env.Append( LIBPATH = [ withfftw + '/lib' ] )
if withmmdb != '-':
env.Append( CPPPATH = [ withmmdb + '/src' ] )
env.Append( LIBPATH = [ withmmdb + '' ] )
if withccp4 != '-':
env.Append( CPPPATH = [ withccp4 + '/lib/src', withccp4 + '/lib/src/mmdb' ] )
env.Append( LIBPATH = [ withccp4 + '/lib' ] )
if withmccp4 != '-':
env.Append( CPPPATH = [ withmccp4 + '/include' ] )
env.Append( LIBPATH = [ withmccp4 + '/lib' ] )
if withcctbx != '-':
env.Append( CPPPATH = [ withcctbx + '' ] )
env.Append( LIBPATH = [ withcctbx + '/lib' ] )
if withboost != '-':
env.Append( CPPPATH = [ withboost + '' ] )
env.Append( LIBPATH = [ withboost + '/lib' ] )
# platform options
if ccgcc != '-':
env.Replace( CXX = ccgcc )
env.Replace( SHLINK = ccgcc )
if ccsun != '-':
env.Replace( CXX = ccsun )
env.Replace( SHLINK = ccsun )
env.Replace( LINK = ccsun )
env.Replace( ARCOM = ccsun + ' -xar -o $TARGET $SOURCES' )
env.Replace( SHCXXFLAGS = '-KPIC' )
env.Append( LINKFLAGS = '-G' )
if ccsgi != '-':
env.Replace( CXX = ccsgi )
env.Replace( SHLINK = ccsgi )
env.Replace( LINK = ccsgi )
env.Append( CXXFLAGS = [ '-LANG:std', '-ptused' ] )
if cctru != '-':
env.Replace( CXX = cctru )
env.Replace( SHLINK = cctru )
env.Replace( LINK = cctru )
env.Replace( SHCXXFLAGS = [ '-ieee', '-std', 'strict_ansi', '-alternative_tokens', '-timplicit_local', '-no_implicit_include' ] )
env.Append( CXXFLAGS = [ '-ieee', '-std', 'strict_ansi', '-alternative_tokens', '-timplicit_local', '-no_implicit_include' ] )
# optimisation options
if opt == '-':
opt = '-O1'
if debug != '-':
opt = '-g'
env.Append( CXXFLAGS = opt )
# Dependency checks:
cxx_fftw = cxx_mmdb = cxx_ccp4 = cxx_mccp4 = cxx_cctbx = 1
lnk_fftw = lnk_mmdb = lnk_ccp4 = lnk_mccp4 = lnk_cctbx = 1
if not GetOption( 'clean' ):
conf = Configure( env, custom_tests = { 'CheckCXX' : CheckCXX,
'CheckLNK' : CheckLNK } )
print "Checking for fftw:"
cxx_fftw = conf.CheckCXX( checkfftw )
lnk_fftw = conf.CheckLNK( checkfftw )
print "Checking for mmdb:"
cxx_mmdb = conf.CheckCXX( checkmmdb )
if cxx_mmdb:
env.Append( LIBS = [ 'mmdb' ] )
lnk_mmdb = conf.CheckLNK( checkmmdb )
print "Checking for ccp4:"
cxx_ccp4 = conf.CheckCXX( checkccp4 )
if cxx_ccp4:
env.Append( LIBS = [ 'ccp4c' ] )
lnk_ccp4 = conf.CheckLNK( checkccp4 )
print "Checking for mccp4:"
cxx_mccp4 = conf.CheckCXX( checkmccp4 )
if cxx_mccp4:
env.Append( LIBS = [ 'mccp4' ] )
lnk_mccp4 = conf.CheckLNK( checkmccp4 )
print "Checking for cctbx:"
cxx_cctbx = conf.CheckCXX( checkcctbx )
if cxx_cctbx:
env.Append( LIBS = [ 'uctbx', 'sgtbx' ] )
lnk_cctbx = conf.CheckLNK( checkcctbx )
env = conf.Finish()
if not cxx_fftw:
print 'Need fftw compiled with --enable-float'
Exit(1)
# default package selection
packages = [ 'core', 'contrib', 'phs' ]
if cxx_mmdb:
packages = packages + [ 'mmdb', 'minimol', 'mmdbold', 'cif' ]
if cxx_ccp4:
packages = packages + [ 'ccp4' ]
if cxx_mccp4:
packages = packages + [ 'mtz' ]
if cxx_cctbx:
packages = packages + [ 'cctbx' ]
# package selection override
if pkglist != '-':
packages = pkglist.split(',')
# add clipper libraries to link path
clipperlibs = []
for pkg in packages:
clipperlibs = [ 'clipper-'+pkg ] + clipperlibs
# install
libdir = prefix+'/lib/'
incdir = prefix+'/include/clipper/'
env.Alias( 'install', [ libdir, incdir ] )
env.Install( incdir, glob( 'clipper/*.h' ) )
for pkg in packages:
env.Alias( 'install', incdir+pkg )
env.Install( incdir+pkg, glob( 'clipper/'+pkg+'/*.h' ) )
if find( objs, 'static' ) >= 0:
env.InstallAs( libdir+'/libclipper-'+pkg+'.a',
'clipper/'+pkg+'/libclipper-'+pkg+'.a' )
if find( objs, 'shared' ) >= 0:
env.InstallAs( libdir+'/libclipper-'+pkg+'.so.'+libvers,
'clipper/'+pkg+'/libclipper-'+pkg+'.so' )
env.Command( libdir+'/libclipper-'+pkg+'.so.'+libvers.split('.')[0],
libdir+'/libclipper-'+pkg+'.so.'+libvers,
'ln -s libclipper-'+pkg+'.so.'+libvers+' $TARGET' )
env.Command( libdir+'/libclipper-'+pkg+'.so',
libdir+'/libclipper-'+pkg+'.so.'+libvers,
'ln -s libclipper-'+pkg+'.so.'+libvers+' $TARGET' )
# make examples build options
env_examples = env.Copy()
env_examples.Append( CPPPATH = prefix+'/include' )
env_examples.Append( LIBPATH = prefix+'/lib' )
env_examples.Prepend( LIBS = clipperlibs )
# build libs and examples
Export( 'env' )
Export( 'packages' )
Export( 'objs' )
SConscript( 'clipper/SConstruct' )
Export( 'env_examples' )
SConscript( 'examples/SConstruct' )
# set default build order
Default( [ 'clipper', incdir, libdir, 'examples' ] )
# diagnostics
print '------------------------------------------------------------'
print 'CPPPATH: ', env['CPPPATH']
print 'LIBPATH: ', env['LIBPATH']
print 'LIBS: ', env['LIBS']
print 'NEWLIBS: ', clipperlibs
print '------------------------------------------------------------'