# -*- python -*-
# Petsc installation file, KSL supercomputing team
from ksl.process.install.installer import *
from copy import copy
from string import Template

base = installer()
variants = []

base.name='petsc'
base.version='dev-aug30'
base.release='1'
base.license='BSD-like'
base.vendor='Argonne National Laboratories - MCS Division'
base.url='http://www.mcs.anl.gov/petsc/petsc-as/'
base.summary='Portable Extensible Toolkit for Scientific Computation'
base.packager='aron'
base.source='petsc-dev-16784.tar.gz'
base.category='math'
base.description=\
"""PETSc, pronounced PET-see (the S is silent), is a suite of data
structures and routines for the scalable (parallel) solution of
scientific applications modeled by partial differential equations.  It
employs the MPI standard for parallelism.    
"""

base.paths    = []
base.binaries = []
base.includes=['./include']
base.libdirs=['./lib'] 

# these libraries all appear to be independent
base.libs=['libpetsc.so']
base.compile_modules=[]
base.required_modules=[]
base.notes=\
"""
Build Notes:
* Parmetis support
* Fortran support
* uses reference BLAS/LAPACK (very slow)
* shared library support
"""

o0 = (unpack_overlay,'petsc-dev-16784-shaheen-gnu-overlay.tar.gz')
s2 = (shell_command, 'export PETSC_DIR=`pwd` && export PETSC_ARCH=bgp-gnu-shared')
s3 = (templated_shell_command,
      Template('./bgp-gnu-shared.py --prefix=$target_dir --CFLAGS="$$CFLAGS" --CXXFLAGS="$$CXXFLAGS" --FFLAGS="$$FFLAGS" --FCFLAGS="$$FCFLAGS" --LDFLAGS="-Wl,-dy" --LIBS="$$LIBS" --CC=$$CC --CXX=$$CXX --FC=$$FC --download-f-blas-lapack=1'))
s4 = make
s5 = make_install 

gnu_install = (o0, s2, s3, s4, s5) 

base.tag = '-bgp_gnu_shared'

ppc450d = copy(base)
ppc450d.build_host = 'ppc64'
ppc450d.compile_modules = ['gnu']
ppc450d.target_arch = 'ppc450d'
ppc450d.install_steps = gnu_install
ppc450d.mod_magic = \
'''
setenv PETSC_DIR "$::env(KSL_PETSC_DIR)"
setenv PETSC_ARCH bgp-gnu-shared
'''
variants.append(ppc450d)


