wscript 8.41 KB
Newer Older
Maude Le Jeune's avatar
Maude Le Jeune committed
1
APPNAME='spherelib'
Maude Le Jeune's avatar
Maude Le Jeune committed
2
VERSION='1.1'
Maude Le Jeune's avatar
Maude Le Jeune committed
3 4 5 6

top = '.'
out = 'build'

Maude Martin's avatar
Maude Martin committed
7

8 9

def options(ctx):
10 11 12 13 14 15 16
   ctx.add_option('--cfitsio_prefix', action='store', default='/usr', help='cfitsio location')
   ctx.add_option('--healpix_prefix', action='store', default='/usr/local', help='healpix location')
   ctx.add_option('--with_gsl', action='store', default='/usr', help='location of gsl')
   ctx.add_option('--with_fftw3', action='store', default='/usr', help='location of fftw3')
   ctx.add_option('--with_numpy_core', action='store', default='/usr/lib64/python2.6/site-packages/numpy/core', help='location of numpy core headers')
   ctx.tool_options('compiler_cxx')
   ctx.tool_options('python')   
Maude Le Jeune's avatar
Maude Le Jeune committed
17

Maude Le Jeune's avatar
Maude Le Jeune committed
18

Maude Le Jeune's avatar
Maude Le Jeune committed
19
def configure(ctx):
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
   print('→ configuring spherelib')
   import Options
   ctx.env['CXXFLAGS'] = ['-O2'] 
   ctx.find_program(['swig'], mandatory=True)
   ctx.check_tool('g++ python')
   ctx.check_tool( 'python' )
   ctx.check_python_headers() 
   ctx.check_tool('swig')
   ctx.check_tool('compiler_cxx')

   print('→ find healpix from healpix_prefix')
   ctx.env["HEALPIX_EXT_PREFIX"] = str(Options.options.healpix_prefix)   
   ctx.env["HEALPIX_EXT_LIB"] = ctx.env["HEALPIX_EXT_PREFIX"]+'/lib'
   ctx.env["HEALPIX_EXT_INC"] = ctx.env["HEALPIX_EXT_PREFIX"]+'/include'   
   ctx.env['CXXFLAGS'].append("-I"+ctx.env["HEALPIX_EXT_INC"]) 
   ctx.check(header_name=['alm.h'],compile_mode='cxx', mandatory=True)    
   ctx.check_cxx(lib=['cxxsupport',  'fftpack', 'healpix_cxx','sharp','c_utils'],libpath=ctx.env["HEALPIX_EXT_LIB"], uselib_store='healpix',mandatory=True)

   print('→ find cfitsio from cfitsio_prefix')
   ctx.env["CFITSIO_PREFIX"] = str(Options.options.cfitsio_prefix)   
   ctx.env["CFITSIO_EXT_LIB"] = ctx.env["CFITSIO_PREFIX"]+'/lib'
   ctx.env["CFITSIO_EXT_INC"] = ctx.env["CFITSIO_PREFIX"]+'/include/cfitsio'   
   ctx.env['CXXFLAGS'].append("-I"+ctx.env["CFITSIO_EXT_INC"]) 
   ctx.check(header_name=['fitsio.h'],compile_mode='cxx', mandatory=True)    
   ctx.check_cxx(lib=['cfitsio'], libpath=ctx.env["CFITSIO_EXT_LIB"], uselib_store='cfitsio', mandatory=True)
   
   ctx.env['CXXFLAGS'].append("-I"+str(Options.options.with_gsl)+"/include")
   ctx.env['CXXFLAGS'].append("-I"+str(Options.options.with_fftw3)+"/include")
   ctx.env['CXXFLAGS'].append("-I"+str(Options.options.with_numpy_core)+"/include")   
   ctx.env['CXXFLAGS'].append('-fPIC')
   ctx.env['CXXFLAGS'].append('-fopenmp')
51
   #ctx.env['CXXFLAGS'].append('-fpermissive')
52 53 54 55 56 57
   #ctx.check_fortran()
   ctx.check(header_name=['gsl/gsl_rng.h', 'gsl/gsl_sort_double.h'],compile_mode='cxx', mandatory=True) 
   ctx.check(header_name=['fftw3.h'],compile_mode='cxx', mandatory=True) 
   ctx.check_cxx(lib=['gsl', 'gslcblas'], libpath=str(Options.options.with_gsl)+"/lib", uselib_store='gsl', mandatory=True)
   ctx.check_cxx(lib=['fftw3'],  libpath=str(Options.options.with_fftw3)+"/lib", uselib_store='fftw3', mandatory=True)
   ctx.check_python_module('healpy')
58

59 60
   ctx.env['STLIB_MARKER'] = ['-Wl,--start-group', '-Wl,-Bstatic']
   ctx.env['SHLIB_MARKER'] = ['-Wl,--end-group', '-Wl,-Bdynamic']
Maude Le Jeune's avatar
Maude Le Jeune committed
61 62

def get_version():
63
   return VERSION
Maude Le Jeune's avatar
Maude Le Jeune committed
64

65 66


Maude Le Jeune's avatar
Maude Le Jeune committed
67
def build(bld):
68 69 70 71 72 73 74 75
    print('→ building spherelib')
    hp_data = 'HEALPIXDATA="'+bld.env["HEALPIX_EXT_PREFIX"]+'/data"'
    libs = ['cfitsio', 'gsl', 'gslcblas']
    stlibs = ['cxxsupport', 'fftpack', 'healpix_cxx','sharp','c_utils']
    import Options
    import os
    libs.append('gomp' )
    libs.append('pthread')
Maude Le Jeune's avatar
Maude Le Jeune committed
76

77 78 79
    target=bld.env["HEALPIX_TARGET"]
    abspath = bld.root.abspath()
    cxx_spherelib = bld(features     = ['cxx', 'cshlib'],
80 81 82 83 84
                        source       = ['../lib/src/MapExt.cpp', '../lib/src/AlmExt.cpp', '../lib/src/Bin.cpp', '../lib/src/PowSpecExt.cpp', '../lib/src/CovMat.cpp'],
                        target       = 'spherelib', 
                        vnum         = get_version(), 
                        includes     = ['../lib/src', bld.env["HEALPIX_EXT_INC"]], 
                        defines      = [hp_data],
85
                        cflags       = bld.env['CXXFLAGS'],
86 87
                        linkflags    = ['-shared'],
                        lib          = libs,
88 89
                        libpath      = [bld.env["CFITSIO_EXT_LIB"]],
                        stlib    = stlibs,
90 91 92
                        stlibpath    =[bld.env["HEALPIX_EXT_LIB"]],
                        name         = 'spherelib'
                        )
93
    cxx_spherelib.install_path = '${PREFIX}/lib'
94

95
    cxx_atlas = bld(features     = ['cxx', 'cshlib'],
96 97 98 99 100
                    source       = ['../lib/atlas/catalog.cpp', '../lib/atlas/profile.cpp', '../lib/atlas/tangentPlane.cpp', '../lib/atlas/maptools.cpp', '../lib/atlas/atlasmanager.cpp'],
                    target       = 'libatlas', 
                    vnum         = get_version(), 
                    includes     = ['../lib/atlas',  bld.env["HEALPIX_EXT_INC"]], 
                    defines      = [hp_data],
101
                    cflags       = bld.env['CXXFLAGS'],
102 103
                    linkflags    = ['-shared'],
                    lib          = libs+['fftw3', 'm'],
104 105
                    libpath      = [bld.env["CFITSIO_EXT_LIB"]],
                    stlib    = stlibs,
106 107 108
                    stlibpath    =[bld.env["HEALPIX_EXT_LIB"]],
                    name         = 'libatlas'
                    )
109
    cxx_atlas.install_path = '${PREFIX}/lib'
110

111
    swig_spherelib_map = bld(features = 'cxx cshlib pyext',
112 113 114 115 116
                            includes = ['../lib/atlas','../lib/src',bld.env["HEALPIX_EXT_INC"],'spherelib', 
                                        '../include', '../lib/src', bld.env["CFITSIO_EXT_INC"] ],
                            source = ['spherelib/spherelib_map.i','spherelib/spherelib_map.cpp'],
                            target = '_spherelib_map',
                            swig_flags = '-c++ -python -Wall',
117
                            cflags      = bld.env['CXXFLAGS'],
118 119 120
                            linkflags    = ['-shared'],
                            defines      = [hp_data],
                            lib          = libs,
121 122
                            libpath      = [bld.env["CFITSIO_EXT_LIB"]],
                            stlib    = stlibs,
123
                            stlibpath    =[bld.env["HEALPIX_EXT_LIB"]],
124
                            use = ['spherelib', 'libatlas']
125
                            )
126
    swig_spherelib_alm = bld(features = 'cxx cshlib pyext',
127 128 129 130 131
                            includes = ['../lib/src', bld.env["HEALPIX_EXT_INC"],'spherelib', 
                                         '../include', '../lib/src' ],
                            source = ['spherelib/spherelib_alm.i','spherelib/spherelib_alm.cpp'],
                            target = '_spherelib_alm',
                            swig_flags = '-c++ -python -Wall',
132 133
                            cflags      = bld.env['CXXFLAGS'],
                            linkflags    = ['-shared'], 
134 135
                            defines      = [hp_data],
                            lib          = libs,
136 137
                            libpath      = [bld.env["CFITSIO_EXT_LIB"]],
                            stlib    = stlibs,
138
                            stlibpath    =[bld.env["HEALPIX_EXT_LIB"]],
139
                            use = ['spherelib'])
140
   
141
    swig_spherelib_bin = bld(features = 'cxx cshlib pyext',
142 143 144 145 146
                             includes = ['../lib/src', bld.env["HEALPIX_EXT_INC"],'spherelib', 
                                         '../include', '../lib/src'],
                            source = ['spherelib/spherelib_bin.i','spherelib/spherelib_bin.cpp'],
                            target = '_spherelib_bin',
                            swig_flags = '-c++ -python -Wall',
147 148
                            cflags      = bld.env['CXXFLAGS'],
                            linkflags    = ['-shared'], 
149 150
                            defines      = [hp_data],
                            lib          = libs,
151 152
                            libpath      = [bld.env["CFITSIO_EXT_LIB"]],
                            stlib    = stlibs,
153
                            stlibpath    =[bld.env["HEALPIX_EXT_LIB"]],
154 155 156 157 158 159 160 161
                            use = ['spherelib'])

    swig_spherelib_map.install_path = '${PYTHONDIR}/spherelib'
    swig_spherelib_alm.install_path = '${PYTHONDIR}/spherelib'
    swig_spherelib_bin.install_path = '${PYTHONDIR}/spherelib'
    source_files = bld.path.ant_glob('spherelib/*.py')
    obj = bld(features = 'py', source=source_files)
    obj.install_path = '${PYTHONDIR}/spherelib'
162 163 164
   
   #print('→ building icosahedron')   
   #os.system("gfortran ../include/icosahedron.f -o "+'${PREFIX}'+"/bin/icosahedron")
165 166