Sophie

Sophie

distrib > Mandriva > 9.0 > i586 > media > contrib-src > by-pkgid > f26eb3a66a2ff33b213bb073ada37a07 > files > 3

petsc-2.1.3-3mdk.src.rpm

%define name	petsc	
%define	version	2.1.3 
%define release	3mdk
%define lib_name_orig lib%{name}
%define lib_major 2
%define lib_name %{lib_name_orig}%{lib_major}
%define buildingdir %{_builddir}/%{name}-%{version}
#%define buildingdir_source %{_builddir}/%{name}-%{version}-source

Summary:	Portable Extensible Toolkit for Scientific Computation
Name:		%{name}
Version:	%{version}
Release:	%{release}
License:	BSD style
Group:		Development/Other
URL:		http://www-fp.mcs.anl.gov/petsc/
Source:		%{name}-%{version}.tar.bz2
Requires:	liblapack
Provides:	%{name}-%{version}
BuildRoot:	%{_tmppath}/%{name}-%{version}
Prefix:		%{_prefix}
BuildRequires:	libmpich0-devel, liblapack3-devel, gcc-g77, binutils, automake, autoconf, texinfo, sed, perl
Patch0:		petsc.install_dir.patch.bz2

%package        -n %{lib_name}-devel
Summary:	PETSC development files (Libraries and headers)
Group:          Development/Other
BuildRoot:      %{_tmppath}/%{name}-%{version}
Prefix:         %{_prefix}
Provides:	%{lib_name_orig}-devel
Requires:	%{lib_name} = %{version}

%package	doc 
Summary:        PETSC documentation
Group:          Development/Other
BuildRoot:      %{_tmppath}/%{name}-%{version}
Prefix:         %{_prefix}

%package	-n %{lib_name}
Summary:	PETSC libraries (Libraries and headers)
Group:          Development/Other
BuildRoot:      %{_tmppath}/%{name}-%{version}
Prefix:         %{_prefix}


%description -n %{lib_name} 
PETSc is a suite of data structures and routines for the scalable (parallel)
solution of scientific applications modeled by partial differential equations.
This version uses the MPI (mpich) library.

%description -n %{lib_name}-devel 
PETSc is a suite of data structures and routines for the scalable (parallel)
solution of scientific applications modeled by partial differential equations.
This version uses the MPI (mpich) library.

%description
PETSC (Development Libraries and headers)

%description doc 
PETSC development files (Libraries and headers) Documentation

%prep
rm -rf %{buildroot}
#rm -rf %{buildingdir_source}
%setup -q
#Making a backup of buildir for later
#cp -a %{_builddir}/%{name}-%{version} %{buildingdir_source}
#cd %{_builddir}/%{name}-%{version}
#%patch0 -p0

%build
#Setting working directory
PETSC_DIR=%{buildingdir}
export PETSC_DIR
PETSC_ARCH=`%{buildingdir}/bin/petscarch | sed -e "s/^linux$/linux-gnu/"`
export PETSC_ARCH

#Execution Environment
NEW_LIB_DIR=%{_libdir}
export NEW_LIB_DIR
NEW_PETSC_DIR=%{_libdir}/%{name}
export NEW_PETSC_DIR

#Preparing make
${PETSC_DIR}/bin/bootstrap 

#Configuring petsc
./configure	--with-mpi=/usr/lib/libmpich.a \
	    	--with-blas=/usr/lib/libblas.a \
		--with-lapack=/usr/lib/liblapack.a \
		--without-mpi-include 
#		--with-gnu-ld

#Fixing wrong static hardlink !
echo "Looking for hardlinked librairies, please wait"
for file in $(grep -ri "\-DPETSC_LIB_DIR" src/* | grep -v html | cut -d ":" -f 1); do
echo "Patching $file"
perl -pi -e 's|DPETSC_LIB_DIR=\x27\x22\${PETSC_LIB_DIR}\x22\x27|DPETSC_LIB_DIR=\x27\x22\${NEW_LIB_DIR}\x22\x27|g' "$file"
perl -pi -e 's|DPETSC_DIR=\x27\x22\${PETSC_DIR}\x22\x27|DPETSC_DIR=\x27\x22\${NEW_PETSC_DIR}\x22\x27|g' "$file"
done

# make all BOPT=g
make BOPT=g

%install
PETSC_DIR=%{buildingdir}
export PETSC_DIR
REAL_PETSC_ARCH=$(%{buildingdir}/bin/petscarch)
PETSC_ARCH=`%{buildingdir}/bin/petscarch| sed -e "s/^linux$/linux-gnu/"`
export REAL_PETSC_ARCH PETSC_ARCH

#Creating dirs
mkdir -p %{buildroot}/%{_libdir}/%{name}/bmake
mkdir -p %{buildroot}/%{_libdir}/%{name}/common

#Installing headers
for i in $(find %{buildingdir}/bmake -type f -maxdepth 1); do
cp $i %{buildroot}/%{_libdir}/%{name}/bmake
done

#cp -a %{buildingdir_source}/bmake/${PETSC_ARCH} %{buildroot}/%{_libdir}/%{name}/bmake

#Changing default settings for enable building
perl -pi -e 's|\${PETSC\_DIR}\/lib\/lib\$\{BOPT\}\/\$\{PETSC\_ARCH\}|\/usr\/lib|g' "%{buildingdir}/bmake/common/variables"
perl -pi -e 's|BLASLAPACK_LIB = \-L\/home\/petsc\/software\/mkl\_linux\/LIB \-lmkl32\_lapack \-lmkl32\_def \-lpthread|BLASLAPACK_LIB = \-L\/usr\/lib  \-llapack \-lblas |g' "%{buildingdir}/bmake/linux/packages"
perl -e 'open (DF,"+< %{buildingdir}/bmake/common/variables")	 or die "ouverture :$!";
	 @T = <DF>; 
	 seek (DF,0,0)                   or die "seek :$!"; 
	 print DF "PETSC_DIR=/usr/lib/petsc\n"; 
	 print DF @T                     or die "print:$!"; 
	 truncate (DF,tell(DF))          or die "trunc :$!"; 
	 close(DF)    			 or die "close :$!";'
	 
cp -a %{buildingdir}/bmake/${REAL_PETSC_ARCH} %{buildroot}/%{_libdir}/%{name}/bmake
cp -a %{buildingdir}/bmake/common %{buildroot}/%{_libdir}/%{name}/bmake

find %{buildingdir}/include | grep "\.html" | xargs rm -rf
cp -a %{buildingdir}/include %{buildroot}/%{_libdir}/%{name}

#Installing Libs
cp %{buildingdir}/lib/libg/${PETSC_ARCH}/* %{buildroot}/%{_libdir}/%{name}

#Renaming and Linking libs
rm -rf $RPM_BUILD_ROOT/%{_libdir}/%{name}/*so.0*
cd $RPM_BUILD_ROOT/%{_libdir}/%{name}
for i in $(ls *.so); do
 mv $i ../$i.%{version}
 ln -sf ../$i.%{version} $i
done

#Patching .la files
for file in $(ls %{buildroot}/%{_libdir}/%{name}/*.la); do
perl -pi -e "s|%{buildingdir}/lib/libg/${PETSC_ARCH}|%{_libdir}/%{name}|g" "$file"
perl -pi -e 's|0\.0\.0|%{version}|g' "$file"
done

%clean
rm -fr %{buildroot}

%post -n %{lib_name}
/sbin/ldconfig

%postun -n %{lib_name}
/sbin/ldconfig

%files -n %{lib_name}
%defattr(-,root,root) 
%{_libdir}/*.so.*

%files -n %{lib_name}-devel
%defattr(-,root,root) 
%doc readme.html docs/copyright.html
%{_libdir}/%{name}/*.a
%{_libdir}/%{name}/*.la
%{_libdir}/%{name}/*.so
%{_libdir}/%{name}/include/*
%{_libdir}/%{name}/bmake/*

%files doc
%defattr(-,root,root)
%doc docs/* readme.html

%changelog
* Fri Jun 14 2002 Erwan Velu <erwan@mandrakesoft.com> 2.1.3-3mdk
- Fixing wrong devel environment (thx to bruno raffin)

* Fri Jun 14 2002 Erwan Velu <erwan@mandrakesoft.com> 2.1.3-2mdk
- Fixing errors with dynamic librairies loading (thx to bruno raffin)

* Mon Jun 10 2002 Erwan Velu <erwan@mandrakesoft.com> 2.1.3-1mdk
- New version
- Fixing missing severals building requires
- Fixing static home dir depenencies
- Removing configure patch (Fixed by --with-mpi-include)
- Adding package libpetsc
- Fixing content of libpetsc-devel
- Fixing lib localisation and name
- Adding missing headers files to the devel lib
- Fixing *.la libdir path and lib version

* Mon May 27 2002 Antoine Ginies <aginies@mandrakesoft.com> 2.1.2-1mdk
- version 2.1.2 with patch for 2.1.2 05/22/2002
- first release for Mandrakesoft