diff --git a/SConstruct b/SConstruct index d2ae17defc06658b029cebbf20506577b5680b66..3e8cce061f8b5c8203e22877550e240b10a0be2d 100644 --- a/SConstruct +++ b/SConstruct @@ -3,12 +3,10 @@ ###### Author: Edward Brash (brash@jlab.org) June 2013 import os -#import sys +import sys #import platform #import commands import SCons -import configure -from rootcint import rootcint import subprocess ####### Check SCons version ################## @@ -16,17 +14,17 @@ print('!!! Building the Hall C analyzer and libraries with SCons requires') print('!!! SCons version 2.5.0 or newer.') EnsureSConsVersion(2,5,0) -baseenv = Environment(ENV = os.environ,tools=["default"],toolpath=['site_scons']) +baseenv = Environment(ENV = os.environ,tools=["default"],toolpath=['podd/site_scons']) ####### Hall A Build Environment ############# # baseenv.Append(HEAD_DIR= Dir('.').abspath) baseenv.Append(HC_DIR= baseenv.subst('$HEAD_DIR')) -baseenv.Append(HC_SRC= baseenv.subst('$HC_DIR')+'/src ') -baseenv.Append(HA_DIR= baseenv.subst('$HC_DIR')+'/podd ') +baseenv.Append(HC_SRC= baseenv.subst('$HC_DIR')+'/src') +baseenv.Append(HA_DIR= baseenv.subst('$HC_DIR')+'/podd') baseenv.Append(MAIN_DIR= baseenv.subst('$HEAD_DIR')) -baseenv.Append(HA_SRC= baseenv.subst('$HA_DIR')+'/src ') -baseenv.Append(HA_DC= baseenv.subst('$HA_DIR')+'/hana_decode ') +baseenv.Append(HA_SRC= baseenv.subst('$HA_DIR')+'/src') +baseenv.Append(HA_DC= baseenv.subst('$HA_DIR')+'/hana_decode') baseenv.Append(MAJORVERSION = '1') baseenv.Append(MINORVERSION = '6') baseenv.Append(PATCH = '0') @@ -42,6 +40,10 @@ ivercode = 65536*int(float(baseenv.subst('$SOVERSION')))+ 256*int(10*(float(base baseenv.Append(VERCODE = ivercode) baseenv.Append(CPPPATH = ['$HC_SRC','$HA_SRC','$HA_DC']) +sys.path.insert(1,baseenv.subst('$HA_DIR'+'/site_scons')) +import configure +from rootcint import rootcint + configure.FindROOT(baseenv) bld = Builder(action=rootcint) diff --git a/site_scons/configure.py b/site_scons/configure.py deleted file mode 100644 index 0225457e2a877a844c7e7bdf0520030f93c4bd3a..0000000000000000000000000000000000000000 --- a/site_scons/configure.py +++ /dev/null @@ -1,111 +0,0 @@ -import sys -import platform -import os -import subprocess - -def config(env,args): - - if env['PLATFORM'] == 'posix': - if (platform.machine() == 'x86_64'): - print "Got a 64-bit processor, I can do a 64-bit build in theory..." - for element in platform.architecture(): - if (element == '32bit'): - print '32-bit Linux build' - env['MEMORYMODEL'] = '32bit' - import linux32 - linux32.config(env, args) - break - elif (element == '64bit'): - print '64-bit Linux build' - env['MEMORYMODEL'] = '64bit' - import linux64 - linux64.config(env, args) - break - else: - print 'Memory model not specified, so I\'m building 32-bit...' - env['MEMORYMODEL'] = '32bit' - import linux32 - linux32.config(env, args) - else: - print '32-bit Linux Build.' - env['MEMORYMODEL'] = '32bit' - import linux32 - linux32.config(env, args) -# elif env['PLATFORM'] == 'win32': -# if (os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64' or (os.environ.has_key('PROCESSOR_ARCHITEW6432') and os.environ['PROCESSOR_ARCHITEW6432'] == 'AMD64')): -# print "Got a 64-bit processor, I can do a 64-bit build in theory..." -# if args.get('32bit', 0): -# print '32-bit Windows build.' -# #import win6432 -# #win6432.config(env, args) -# elif args.get('64bit', 0): -# print '64-bit Windows build.' -# #import win64 -# #win64.config(env, args) -# else: -# print 'Memory model not specified, so I\'m building 32-bit.' -# #import win6432 -# #win6432.config(env, args) -# else: -# print '32-bit Windows build.' -# #import win32 -# #win32.config(env, args) - elif env['PLATFORM'] == 'darwin': - print 'OS X Darwin is a 64-bit build.' - env['MEMORYMODEL'] = '64bit' - import darwin64 - darwin64.config(env, args) - else: - print 'ERROR! unrecognized platform. Twonk.' - -# which() utility -def which(program): - def is_exe(fpath): - return os.path.isfile(fpath) and os.access(fpath, os.X_OK) - - fpath, fname = os.path.split(program) - if fpath: - if is_exe(program): - return program - else: - for path in os.environ["PATH"].split(os.pathsep): - path = path.strip('"') - exe_file = os.path.join(path, program) - if is_exe(exe_file): - return exe_file - return None - -####### ROOT Definitions #################### -def FindROOT(env, need_glibs = True): - root_config = 'root-config' - try: - env.PrependENVPath('PATH',env['ENV']['ROOTSYS'] + '/bin') - except KeyError: - pass # ROOTSYS not defined - - try: - if need_glibs: - env.ParseConfig(root_config + ' --cflags --glibs') - else: - env.ParseConfig(root_config + ' --cflags --libs') - if sys.version_info >= (2, 7): - cmd = root_config + ' --cxx' - env.Replace(CXX = subprocess.check_output(cmd, shell=True).rstrip()) - cmd = root_config + ' --version' - env.Replace(ROOTVERS = subprocess.check_output(cmd, shell=True).rstrip()) - else: - env.Replace(CXX = subprocess.Popen([root_config, '--cxx'],\ - stdout=subprocess.PIPE).communicate()[0].rstrip()) - env.Replace(ROOTVERS = subprocess.Popen([root_config,\ - '--version'],stdout=subprocess.PIPE).communicate()[0].rstrip()) - if platform.system() == 'Darwin': - try: - env.Replace(LINKFLAGS = env['LINKFLAGS'].remove('-pthread')) - except: - pass # '-pthread' was not present in LINKFLAGS - - except OSError: - print('!!! Cannot find ROOT. Check if root-config is in your PATH.') - env.Exit(1) - -#end configure.py diff --git a/site_scons/darwin64.py b/site_scons/darwin64.py deleted file mode 100644 index e56f8de0a01ba7082b6708349d6f4931cb15af85..0000000000000000000000000000000000000000 --- a/site_scons/darwin64.py +++ /dev/null @@ -1,42 +0,0 @@ -import platform -import os - -def config(env,args): - - debug = args.get('debug',0) - standalone = args.get('standalone',0) - cppcheck = args.get('cppcheck',0) - checkheaders = args.get('checkheaders',0) - - if int(debug): - env.Append(CXXFLAGS = '-g -O0') - else: - env.Append(CXXFLAGS = '-O') - env.Append(CPPDEFINES= '-DNDEBUG') - - if int(standalone): - env.Append(STANDALONE= '1') - - if int(cppcheck): - env.Append(CPPCHECK= '1') - - if int(checkheaders): - env.Append(CHECKHEADERS= '1') - - #env.Append(CXXFLAGS = '-Wall -Woverloaded-virtual -pthread -rdynamic') - env.Append(CXXFLAGS = '-Wall -Woverloaded-virtual -pthread') - env.Append(CPPDEFINES = '-DMACVERS') - - cxxversion = env.subst('$CXXVERSION') - -# if float(cxxversion[0:2])>=4.0: -# env.Append(CXXFLAGS = '-Wextra -Wno-missing-field-initializers') - - if float(cxxversion[0:2])>=3.0: - env.Append(CPPDEFINES = '-DHAS_SSTREAM') - - env['SHLINKFLAGS'] = '$LINKFLAGS -shared -Wl,-undefined,dynamic_lookup' - env['SHLIBSUFFIX'] = '.so' - - -#end darwin64.py diff --git a/site_scons/linux32.py b/site_scons/linux32.py deleted file mode 100644 index 283b5607f53516afb3f3f06c9e2913f0f5645a59..0000000000000000000000000000000000000000 --- a/site_scons/linux32.py +++ /dev/null @@ -1,43 +0,0 @@ -import platform -import os - -def config(env,args): - - debug = args.get('debug',0) - standalone = args.get('standalone',0) - cppcheck = args.get('cppcheck',0) - checkheaders = args.get('checkheaders',0) - - if int(debug): - env.Append(CXXFLAGS = '-g -O0') - else: - env.Append(CXXFLAGS = '-O') - env.Append(CPPDEFINES= '-DNDEBUG') - - if int(standalone): - env.Append(STANDALONE= '1') - - if int(cppcheck): - env.Append(CPPCHECK= '1') - - if int(checkheaders): - env.Append(CHECKHEADERS= '1') - - env.Append(CXXFLAGS = '-m32') - env.Append(CXXFLAGS = '-Wall') - env.Append(CXXFLAGS = '-Woverloaded-virtual') - env.Append(CPPDEFINES = '-DLINUXVERS') - - cxxversion = env.subst('$CXXVERSION') - -# if float(cxxversion[0:2])>=4.0: -# env.Append(CXXFLAGS = '-Wextra -Wno-missing-field-initializers') - - if float(cxxversion[0:2])>=3.0: - env.Append(CPPDEFINES = '-DHAS_SSTREAM') - - env['SHLINKFLAGS'] = '$LINKFLAGS -m32 -shared' - env['SHLIBSUFFIX'] = '.so' - - -#end linux32.py diff --git a/site_scons/linux64.py b/site_scons/linux64.py deleted file mode 100644 index 79703f6f1d1747f08782a2ebd5ade12d42017665..0000000000000000000000000000000000000000 --- a/site_scons/linux64.py +++ /dev/null @@ -1,42 +0,0 @@ -import platform -import os - -def config(env,args): - - debug = args.get('debug',0) - standalone = args.get('standalone',0) - cppcheck = args.get('cppcheck',0) - checkheaders = args.get('checkheaders',0) - - if int(debug): - env.Append(CXXFLAGS = '-g -O0') - else: - env.Append(CXXFLAGS = '-O') - env.Append(CPPDEFINES= '-DNDEBUG') - - if int(standalone): - env.Append(STANDALONE= '1') - - if int(cppcheck): - env.Append(CPPCHECK= '1') - - if int(checkheaders): - env.Append(CHECKHEADERS= '1') - - env.Append(CXXFLAGS = '-Wall') - env.Append(CXXFLAGS = '-Woverloaded-virtual') - env.Append(CPPDEFINES = '-DLINUXVERS') - - cxxversion = env.subst('$CXXVERSION') - -# if float(cxxversion[0:2])>=4.0: -# env.Append(CXXFLAGS = '-Wextra -Wno-missing-field-initializers') - - if float(cxxversion[0:2])>=3.0: - env.Append(CPPDEFINES = '-DHAS_SSTREAM') - - env['SHLINKFLAGS'] = '$LINKFLAGS -shared' - env['SHLIBSUFFIX'] = '.so' - - -#end linux6432.py diff --git a/site_scons/rootcint.py b/site_scons/rootcint.py deleted file mode 100644 index 958ad1779de021bf329ea1f2ea335b888ad2e862..0000000000000000000000000000000000000000 --- a/site_scons/rootcint.py +++ /dev/null @@ -1,18 +0,0 @@ -# rootcint.py - -import os - -def rootcint(target,source,env): - """Executes the ROOT dictionary generator over a list of headers.""" - dictname = target[0] - cpppath = env.subst('$_CCCOMCOM') -# ccflags = env.subst('$CCFLAGS') -# print ("Doing rootcint call now ...") - headers = "" - for f in source: - headers += str(f) + " " - command = "rootcint -f %s -c %s %s" % (dictname,cpppath,headers) -# print ('RootCint Command = %s\n' % command) - ok = os.system(command) - return ok -