import os import sys import subprocess import glob # Add SBMS directory to PYTHONPATH sbmsdir = "%s/SBMS" % (os.getcwd()) sys.path.append(sbmsdir) import sbms # Get command-line options SHOWBUILD = ARGUMENTS.get('SHOWBUILD', 0) OPTIMIZATION = ARGUMENTS.get('OPTIMIZATION', 3) DEBUG = ARGUMENTS.get('DEBUG', 1) # Get platform-specific name osname = os.getenv('BMS_OSNAME', subprocess.Popen(["%s/osrelease.pl" % sbmsdir], stdout=subprocess.PIPE).communicate()[0].strip()) # Get architecture name arch = ROOT_CFLAGS = subprocess.Popen(["uname"], stdout=subprocess.PIPE).communicate()[0].strip() # Setup initial environment installdir = "#%s" %(osname) ginstalldir = "#../../%s" % (osname) include = "%s/include" % (installdir) bin = "%s/bin" % (installdir) lib = "%s/lib" % (installdir) plugins = "%s/plugins" % (installdir) examples = "%s/examples" % (installdir) env = Environment( ENV = os.environ, # Bring in full environement, including PATH CPPPATH = [include], LIBPATH = [lib], variant_dir = "src/.%s" % (osname)) # These are SBMS-specific variables (i.e. not default scons ones) env.Replace(INSTALLDIR = installdir, GINSTALLDIR = ginstalldir, OSNAME = osname, INCDIR = include, BINDIR = bin, LIBDIR = lib, PLUGINSDIR = plugins, ALL_SOURCES = [], # used so we can add generated sources MISC_OBJS = [], # used so we can add explicit static libraries SHOWBUILD = SHOWBUILD, OPTIMIZATION = OPTIMIZATION, DEBUG = DEBUG, COMMAND_LINE_TARGETS = COMMAND_LINE_TARGETS) # Use terse output unless otherwise specified if SHOWBUILD==0: env.Replace(CCCOMSTR = "Compiling [$SOURCE]", CXXCOMSTR = "Compiling [$SOURCE]", FORTRANPPCOMSTR = "Compiling [$SOURCE]", FORTRANCOMSTR = "Compiling [$SOURCE]", SHCCCOMSTR = "Compiling [$SOURCE]", SHCXXCOMSTR = "Compiling [$SOURCE]", LINKCOMSTR = "Linking [$TARGET]", SHLINKCOMSTR = "Linking [$TARGET]", INSTALLSTR = "Installing [$TARGET]", ARCOMSTR = "Archiving [$TARGET]", RANLIBCOMSTR = "Ranlib [$TARGET]") # Get compiler from environment variables (if set) env.Replace( CXX = os.getenv('CXX', 'g++'), CC = os.getenv('CC' , 'gcc'), FC = os.getenv('FC' , 'gfortran') ) # Add libraries and libraries/include to include search path env.PrependUnique(CPPPATH = ['#', '#src/libRootSpy', '#src/libRootSpy-client']) # Standard flags (optimization level and warnings) env.PrependUnique( CFLAGS = ['-O%s' % OPTIMIZATION, '-fPIC', '-Wall']) env.PrependUnique( CXXFLAGS = ['-O%s' % OPTIMIZATION, '-fPIC', '-Wall']) env.PrependUnique(FORTRANFLAGS = ['-O%s' % OPTIMIZATION, '-fPIC', '-Wall']) # Turn on debug symbols unless user told us not to if not DEBUG=='0': env.PrependUnique( CFLAGS = ['-g']) env.PrependUnique( CXXFLAGS = ['-g']) env.PrependUnique(FORTRANFLAGS = ['-g']) # xMsg requires C++14 features. ROOT uses C++11. # Let ROOT add the -std=c++11 flag and then xMsg # will add the -std=c++14 flag after it to superceed # it. No need to further complicate things here. # Enable some C++11 features available in gcc4.9.2 # env.AppendUnique(CXXFLAGS=['-std=c++11']) # The following offensive setting is needed to force # the compiler NOT to include __cxx11 in the namespace # for std::basic_string<... This seems to be included # in RootSpy objects, but not in the CODA installed cMsg # library. Oddly, I compiled a private version of cMsg # with the -std=c++11 flag and it did NOT add the namespace. # I fully expect this line will cause me grief at some # point in the future. (Sorry future Dave!) #env.AppendUnique(CXXFLAGS=['-D_GLIBCXX_USE_CXX11_ABI=0']) # Apply any platform/architecture specific settings sbms.ApplyPlatformSpecificSettings(env, arch) sbms.ApplyPlatformSpecificSettings(env, osname) # Include SConscript in src SConscript('src/SConscript', variant_dir="src/.%s" % (osname), exports='env osname', duplicate=0) # Make install target env.Alias('install', installdir) env.Alias('ginstall', ginstalldir) # Create setenv if user explicitly specified "install" target #build_targets = map(str,BUILD_TARGETS) #if len(build_targets)>0: # if 'install' in build_targets: # import sbms_setenv # sbms_setenv.mk_setenv(env)