import os, sys, glob dirs = ['openmmapi', 'olla', 'libraries/jama', 'libraries/quern', 'libraries/lepton', 'platforms/reference'] def recursive_glob( path, operator ): retVal = [] for val in glob.glob( path + os.sep + '*'): if os.path.isdir( val ): retVal.append( recursive_glob( val, operator ) ) for val in glob.glob( path + os.sep + operator ): retVal.append( val ) return retVal opts = Options() opts.Add( 'release', 'Set to 1 to build release version', 0 ) opts.Add( 'cuda', 'Set to 1 to build cuda libraries', 0 ) opts.Add( 'tests', 'Set to 1 to build test files', 0 ) opts.Add( 'examples', 'Set to 1 to build test files', 0 ) env = Environment( options = opts, ENV = os.environ ) #Configuration if not env.GetOption('clean'): conf = Configure( env ) if not conf.CheckLib( 'dl' ): print "DL Library Missing" sys.exit( 1 ); env = conf.Finish() #Get option values release = int( env.get( 'release', 0 ) ) cuda = int( env.get( 'cuda', 0 ) ) tests = int( env.get( 'tests', 0 ) ) examples = int( env.get( 'examples', 0 ) ) if cuda == 1: dirs.append( 'platforms/cuda' ) env.Tool('nvcc', toolpath='.') env.Append( NVCCFLAGS = ['-maxrregcount=32', '-use_fast_math', '-O0', '--ptxas-options=-v'] ) env.Append( SHNVCCFLAGS = ['-maxrregcount=32', '-use_fast_math', '-O0', '--ptxas-options=-v'] ) env.Append( CPPPATH = ['/usr/local/cuda/include','/Developer/CUDA/sdk/include'] ) src = [] for d in dirs: if cuda == 1: src.append( recursive_glob( d + os.sep + 'src', '*.cu') ) src.append( recursive_glob( d + os.sep + 'src', '*.cpp' ) ) env.Append( CPPPATH = [d + os.sep + 'include'] ) name = 'OpenMM' if cuda == 1: name = name + 'Cuda' extention = '' if release == 1: env.Append( CCFLAGS = '-O3' ) extention = '' else: env.Append( CCFLAGS = '-g -ggdb' ) extention = '_d' shared = env.SharedLibrary( name + extention, src, CPPDEFINES = ['OPENMM_BUILDING_SHARED_LIBRARY','LEPTON_BUILDING_SHARED_LIBRARY'] ) static = env.StaticLibrary( name + '_static' + extention, src, CPPDEFINES = ['OPENMM_USE_STATIC_LIBRARIES', 'OPENMM_BUILDING_STATIC_LIBRARY', 'LEPTON_USE_STATIC_LIBRARIES', 'LEPTON_BUILDING_STATIC_LIBRARY'] ) if tests == 1: print "Building Tests" for src in recursive_glob( 'platforms/reference/tests', '*.cpp' ): env.Program( src[0:len( src ) - 4], src, LIBPATH = ['.'], LIBS = ['OpenMM' + extention] ) if cuda == 1: for src in recursive_glob( 'platforms/cuda/tests', '*.cpp' ): env.Program( src[0:len( src ) - 4], src, LIBPATH = ['.'], LIBS = ['OpenMM' + extention] ) if examples == 1: print "Building Examples" for src in recursive_glob( 'examples', '*.cpp' ): env.Program( src[0:len( src ) - 4], src, LIBPATH = ['.'], LIBS = ['OpenMM' + extention] )