Changeset 323


Ignore:
Timestamp:
Jun 30, 2011 11:07:49 AM (10 years ago)
Author:
toby
Message:

incorporate linux changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fsource/SConstruct

    r322 r323  
     1# this is a build script that is intended to be run from scons (it will not work in python)
     2# it compiles the Fortran files needed to be used as Python packages for GSAS-II
     3#
     4# if the default options need to be overridden for this to work on your system, please let me
     5# know the details of what OS, compiler and python you are using as well as the command-line
     6# options you need.
    17import platform
    28import sys
     
    99105LDFLAGS='string'   -- string of options to be used for f2py during link step
    100106
    101 Note that at present, only 32-bit python is supported and python 3.x is
    102 not supported.
     107Note that at present, this has been tested with 32-bit python on windows and
     108Mac & 64 bit on linux. Python 3.x is not supported in GSAS-II yet.
    103109
    104110examples:
     
    143149#  find the python location. Note that on Windows it may be in the parent of the f2py location
    144150# then run it to get info about the verision and the number of bits
     151pythonpath = ''
    145152for program in ['python','../python']:
    146153    if sys.platform == "win32" and os.path.splitext(program)[1].lower() != '.exe':
    147154        program = program + '.exe'
    148155    pythonprogram = os.path.normpath(os.path.join(F2PYpath,program))
    149     if is_exe(pythonprogram): break
     156    if is_exe(pythonprogram):
     157        pythonpath = os.path.split(program)[0]
     158        break
    150159else:
    151160    print 'python not found'
     
    189198f2py = Builder(generator = generate_f2py)
    190199env.Append(BUILDERS = {'f2py' : f2py},)
    191 
    192 #if ARGUMENTS.get('FCompiler', None) is not None or env.get('FORTRAN') is None:
    193 if True:
    194     # create a builder for the fortran compiler for library compilation, if needed
    195     def generate_obj(source, target, env, for_signature):
    196         dir = os.path.split(str(source[0]))[0]
    197         obj = os.path.splitext(str(source[0]))[0]+'.o'
    198         return os.path.join(FORTpath,FCompiler)  + ' -c $SOURCE ' + FORTflags + ' -I' + dir + ' -o' + obj
    199     fort = Builder(generator = generate_obj, suffix = '.o',
    200                    src_suffix = '.for')
    201     env.Append(BUILDERS = {'fort' : fort},)
    202     FortranCompile = env.fort
    203     print 'Defining a FORTRAN builder'
    204 #else:
    205 #    FortranCompile = Object
    206 #    env['FORTRANFLAGS'] = FORTflags
    207 
     200# create a builder for the fortran compiler for library compilation so we can control how it is done
     201def generate_obj(source, target, env, for_signature):
     202    dir = os.path.split(str(source[0]))[0]
     203    obj = os.path.splitext(str(source[0]))[0]+'.o'
     204    return os.path.join(FORTpath,FCompiler)  + ' -c $SOURCE ' + FORTflags + ' -I' + dir + ' -o' + obj
     205fort = Builder(generator = generate_obj, suffix = '.o',
     206               src_suffix = '.for')
     207env.Append(BUILDERS = {'fort' : fort},)
     208
     209#==========================================================================================
    208210# Setup build Environment
     211#    add compiler, f2py & python to path
    209212if FORTpath != "":  env.PrependENVPath('PATH', FORTpath)
    210213if F2PYpath != "":  env.PrependENVPath('PATH', F2PYpath)
    211 #var = 'LDFLAGS'
    212 #env['ENV'][var] = eval(var)
    213 
    214 # find libraries to build (subdirectories named *subs)
     214if pythonpath != "" and pythonpath != F2PYpath: env.PrependENVPath('PATH', pythonpath)
     215#   add other needed environment variables
     216var = 'LDFLAGS'
     217if eval(var) != "": env['ENV'][var] = eval(var)
     218
     219#==========================================================================================
     220# finally ready to build something!
     221# locate libraries to be built (subdirectories named *subs)
    215222for sub in glob.glob('*subs'):
    216223    filelist = []
    217224    for file in glob.glob(os.path.join(sub,'*.for')):
    218225        #target = os.path.splitext(file)[0]+'.o'
    219         target = FortranCompile(file) # connect .o files to .for files
     226        target = env.fort(file) # connect .o files to .for files
    220227        #print 'Compile: ',file, target
    221228        filelist.append(target)
     
    234241    env.Install(InstallLoc, out[0].name)
    235242    #break # bail out early for testing
     243#==========================================================================================
     244# all done with setup, show the user the options and let scons do the work
    236245print 80*'='
    237246for var in ['FCompiler','FORTpath','FORTflags','F2PYflags','F2PYpath','F2PYsuffix','LDFLAGS']:
Note: See TracChangeset for help on using the changeset viewer.