@@ -8,9 +8,6 @@ Import('env')
88flagnames = 'CFLAGS CXXFLAGS LDFLAGS' .split ()
99env .MergeFlags ([os .environ .get (n , '' ) for n in flagnames ])
1010
11- # The directory of this SConscript should be searched first for any headers.
12- env .PrependUnique (CPPPATH = Dir ('.' ))
13-
1411# Insert LIBRARY_PATH explicitly because some compilers
1512# ignore it in the system environment.
1613env .PrependUnique (LIBPATH = env ['ENV' ].get ('LIBRARY_PATH' , '' ).split (':' ))
@@ -24,11 +21,6 @@ if env['tool'] == 'intelc':
2421 Exit (1 )
2522 env .Tool ('intelc' , topdir = icpc [:icpc .rfind ('/bin' )])
2623
27- # Declare external libraries.
28- env .ParseConfig ("gsl-config --cflags --libs" )
29- # dladdr in runtimepath.cpp requires the dl library.
30- env .AppendUnique (LIBS = ['dl' ])
31-
3224fast_linkflags = ['-s' ]
3325
3426# Platform specific intricacies.
@@ -38,15 +30,6 @@ if env['PLATFORM'] == 'darwin':
3830 env .AppendUnique (SHLINKFLAGS = '-headerpad_max_install_names' )
3931 fast_linkflags [:] = []
4032
41- # configure version specific options.
42- skip_configure = (GetOption ('clean' ) or GetOption ('help' ) or
43- (['sdist' ] == list (COMMAND_LINE_TARGETS )))
44- if not skip_configure :
45- SConscript ('SConscript.configure' )
46- elif GetOption ('clean' ):
47- # make sure ObjCryst files will be also cleaned
48- env ['has_objcryst' ] = True
49-
5033# Compiler specific options
5134if icpc :
5235 # options for Intel C++ compiler on hpc dev-intel07
@@ -74,22 +57,41 @@ if env['coverage']:
7457 env .Append (CCFLAGS = ['--coverage' , '-O0' ])
7558 env .Append (LINKFLAGS = '--coverage' )
7659
60+ # configure boost and ObjCryst libraries unless non-relevant.
61+ skip_configure = (GetOption ('clean' ) or GetOption ('help' ) or
62+ (['sdist' ] == list (COMMAND_LINE_TARGETS )))
63+ if not skip_configure :
64+ SConscript ('SConscript.configure' )
65+
66+ # when cleaning make sure to also purge ObjCryst files
67+ if GetOption ('clean' ):
68+ env ['has_objcryst' ] = True
69+
7770# Define lists for storing library source and include files.
7871env ['lib_includes' ] = []
7972env ['lib_sources' ] = []
8073env ['lib_datafiles' ] = []
8174
8275# Subsidiary SConscripts -----------------------------------------------------
8376
84- # Determine if unit tests need to be built .
85- build_tests = set (('test' , 'alltests' )). intersection ( COMMAND_LINE_TARGETS )
77+ # The targets that concern unit tests .
78+ targets_that_test = set (('test' , 'alltests' ))
8679
8780# Short circuit if we test an already installed library. Do not define
8881# any further targets as they may conflict with the installed files.
89- if build_tests and env ['test_installed' ]:
82+ if env ['test_installed' ]:
9083 SConscript ('tests/SConscript' )
84+ if not targets_that_test .issuperset (COMMAND_LINE_TARGETS ):
85+ print ('Warning: only test targets are available when '
86+ '"test_installed=True".' )
9187 Return ()
9288
89+ assert not env ['test_installed' ]
90+
91+ # Here we do not test the installed library. Any diffpy headers
92+ # should thus be looked up from our source tree.
93+ env .PrependUnique (CPPPATH = Dir ('.' ))
94+
9395# Load the version script first to resolve the majorminor tuple
9496SConscript ('diffpy/SConscript.version' )
9597
@@ -110,15 +112,22 @@ if 'sdist' in COMMAND_LINE_TARGETS:
110112# Top Level Targets ----------------------------------------------------------
111113
112114# lib -- shared library object
113- libdiffpy = env .SharedLibrary ('diffpy' , env ['lib_sources' ])
115+
116+ # use new environment with extra libraries needed for libdiffpy.
117+ env_lib = env .Clone ()
118+ # Setup GSL, the GNU Scientific library.
119+ env_lib .ParseConfig ("gsl-config --cflags --libs" )
120+ # The dladdr call in runtimepath.cpp requires the dl library.
121+ env_lib .AppendUnique (LIBS = ['dl' ])
122+
123+ libdiffpy = env_lib .SharedLibrary ('diffpy' , env ['lib_sources' ])
114124Export ('libdiffpy' )
115125lib = Alias ('lib' , [libdiffpy , env ['lib_includes' ]])
116126Default (lib )
117127
118128# Define targets related to testing. Do so only when testing is requested.
119129# This enables library build on machines without cxxtest.
120- if build_tests :
121- assert not env ['test_installed' ]
130+ if targets_that_test .intersection (COMMAND_LINE_TARGETS ):
122131 SConscript ('tests/SConscript' )
123132
124133# Installation targets.
0 commit comments