File mpich2.spec of Package mpich2

#
# spec file for package mpich2
#
# Copyright (c) 2008 Kurt Garloff, Vasil Yordanov, Deji Akingunola.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
# File based on excellent work by Deji Akingunola
# ftp://czar.eas.yorku.ca/pub/mpich2/mpich2.spec
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%define javadev java-sdk
%define fortran gcc-gfortran
%if 0%{?fedora_version} >= 7
%define javadev java-1.5.0-gcj-devel
%endif
%if 0%{?rhel_version} >= 5
%define javadev java-devel
%endif
%if 0%{?mandriva_version}
%define javadev java-devel
%endif
%if 0%{?suse_version}
%define fortran gcc-fortran
%if 0%{?suse_version} == 1020
%define javadev java-1_4_2-gcj-compat-devel
%define need_jni_detect 1
%endif
%if 0%{?suse_version} == 1030
# /etc/alternatives/java_djk/include/jni.h is not found with gcc-java/libgcj-devel :-(
%define need_jni_detect 1
%endif
%if 0%{?suse_version} < 1000
%define javadev java-devel
%define fortran gcc-g77
%endif
%endif
# norootforbuild


Summary:	High-performance implementation of MPI-1 and MPI-2
Name:		mpich2
Version:	1.2.1p1
# Release:	2%{?dist}
Release:        0
License:	Freely redistributable without restriction
Group:		Development/Libraries
URL:		http://www.mcs.anl.gov/mpi/mpich2
Source:		ftp://ftp.mcs.anl.gov/pub/mpi/%{name}-%{version}.tar.bz2
Source1:	mpich2.module.in
Patch1:         obs-shmget.diff
Patch2:         detect_jni.diff
Patch3:		mpe2-install.diff
BuildRoot:	%{_tmppath}/%{name}-%{version}-build
BuildRequires:	e2fsprogs-devel python %{javadev} %{fortran}
%if 0%{?fedora_version}
BuildRequires:  emacs-common libXt-devel gcc-c++
%endif
%if 0%{?rhel_version}
BuildRequires:  emacs-common libXt-devel gcc-c++
%endif
%if 0%{?mandriva_version}
BuildRequires: emacs-common libXt-devel gcc-c++
%endif
%if 0%{?suse_version}
BuildRequires:	emacs-nox xorg-x11-devel gcc-c++ unzip update-alternatives
BuildRequires:  ElectricFence psmisc
%endif
Requires:	%{name}-libs = %{version}-%{release}
Requires:	python
%if 0%{?fedora_version}
Requires(post):	/usr/sbin/alternatives
Requires(preun):/usr/sbin/alternatives
%endif

%description
MPICH2 is implemented by Argonne National Laboratory.

The goals of MPICH2 are:
1. to provide an MPI implementation that efficiently supports different
 computation and communication platforms including commodity clusters (desktop
 systems, shared-memory systems, multicore architectures), high-speed networks
 (10Gigabit Ethernet, Inifinband, Myrinet, Quadrics) and proprietary high-end
 computing systems (Blue Gene, Cray, SiCortex).
2. to enable cutting-edge research in MPI through an easy-to-extend modular
 framework for other derived implemenations.

%package devel
Summary:	Development files for mpich2
Group:		Development/Libraries
Requires:	%{name} = %{version}-%{release}
Requires:	pkgconfig
Requires:	%{fortran}
%if 0%{?fedora_version}
Requires(post):	/usr/sbin/alternatives
Requires(preun):/usr/sbin/alternatives
%endif

%description devel
Contains development headers and libraries for mpich2

%package libs
Summary:	Libraries and configuration files for mpich2
Group:		Development/Libraries

%description libs
Contains the arch dependent libraries and their build configuration for mpich2

%package doc
Summary:	Documentation files for mpich2
Group:		Development/Documentation
Requires:	%{name} = %{version}-%{release}

%description doc
Contains the documentation for mpich2.

%if 0
# TO BE DONE
%if 0%{?suse_version} > 0
%ifarch x86_64
%package libs-32bit
Summary:        32bit libraries for mpich2
Group:          Development/Libraries

%description 32bit
Contains the 32bit versions of the libraries
%endif
%endif
%endif

# We only compile with gcc, but other people may want other compilers.
# Set the compiler here.
%ifarch %{ix86} ppc
%define mode 32
%define priority 40
%else
%define mode 64
%define priority 41
%endif

%prep
%define opt_cc gcc
%define opt_fc gfortran
# Optional CFLAGS to use with the specific compiler...gcc doesn't need any,
# so uncomment and undefine to NOT use
%if 0%{?suse_version} > 0
RPM_OPT_FLAGS=$(echo $RPM_OPT_FLAGS | sed 's/\-fstack\-protector//')
%else
RPM_OPT_FLAGS="%{optflags}"
%endif

%ifarch %{ix86} x86_64
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -ftree-vectorize -fprefetch-loop-arrays -momit-leaf-frame-pointer"
%else
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -ftree-vectorize -fprefetch-loop-arrays"
%endif
%ifarch %{ix86}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -msse"
%endif

# % define opt_fc_fflags %{opt_cc_flags} 

%setup -q -b0

%patch1 -p1 -b .shmget
%if 0%{?need_jni_detect} > 0
%patch2 -p1 -b .jni
%endif
%patch3 -p1 -b .mpe2
%if 0%{?suse_verion} > 1100
autoreconf -fi
%endif
#aclocal
#autoheader
#autoconf

%configure	\
	--enable-f90 --enable-sharedlibs=gcc			\
	--sysconfdir=%{_sysconfdir}/%{name}-%{mode}		\
	--includedir=%{_includedir}/%{name}			\
	--libdir=%{_libdir}/%{name}				\
	--datadir=%{_datadir}/%{name}				\
	--htmldir=%{_docdir}/%{name}-%{version}/www		\
	--docdir=%{_docdir}/%{name}-%{version}			\
	--with-java=%{_sysconfdir}/alternatives/java_sdk	\
	--with-device=ch3:dllchan:sock,shm,ssm			\
	--with-thread-package=pthreads --enable-mpe		\
	F90=%{opt_fc} 						\
	F77=%{opt_fc}						\
	CFLAGS="$RPM_OPT_FLAGS"					\
	CXXFLAGS="$RPM_OPT_FLAGS"				\
	F90FLAGS="$RPM_OPT_FLAGS"				\
	FFLAGS="$RPM_OPT_FLAGS"					\
	LDFLAGS='-Wl,-z,noexecstack'

%build
#make %{?_smp_mflags} doesn't work
#make %{?jobs:-j%jobs}
make

%install
#rm -rf %{buildroot}
make DESTDIR=%{buildroot} install # PACKAGE=mpich2-%{version}

## Resolve clashes with LAM/OPENMP: mpicxx mpicc mpif77 mpif90 mpiexec mpirun
rm -f %{buildroot}%{_bindir}/{mpiexec,mpirun,mpdrun}
mv %{buildroot}%{_mandir}/man1/{,mp-}mpiexec.1
pushd  %{buildroot}%{_bindir}/
ln -s mpiexec.py mpdrun
popd
mkdir -p %{buildroot}%{_datadir}/%{name}/bin%{mode}
for b in mpicxx mpicc mpif77 mpif90; do 
  mv %{buildroot}%{_bindir}/$b %{buildroot}%{_bindir}/mp%{mode}-$b;
  mv %{buildroot}%{_mandir}/man1/$b.1 %{buildroot}%{_mandir}/man1/mp-$b.1;
  ln -s %{_bindir}/mp%{mode}-$b %{buildroot}%{_datadir}/%{name}/bin%{mode}/$b
done

mv %{buildroot}%{_libdir}/%{name}/pkgconfig %{buildroot}%{_libdir}/
chmod -x %{buildroot}%{_libdir}/pkgconfig/*.pc

## Create modules file
sed 's#@DATADIR@#'%{_datadir}/%{name}'#;s#@LIBDIR@#'%{_libdir}/%{name}'#;s#@INCLUDEDIR@#'%{_includedir}/%{name}'#;s#@MODE@#'%{mode}'#' < %SOURCE1 > %{buildroot}%{_datadir}/%{name}/%{name}.module
#:;

# Manually copy doc file here instead of the %files section to prevent the rpm
#build script from throwing the other things in there out
mkdir -p %{buildroot}%{_docdir}/%{name}-%{version}
cp -pr CHANGES COPYRIGHT README RELEASE_NOTES %{buildroot}%{_docdir}/%{name}-%{version}/
cp -pr src/mpe2/README %{buildroot}%{_docdir}/%{name}-%{version}/README.mpe

#mv %{buildroot}/%{_datadir}/%{name}/doc %{buildroot}%{_docdir}/%{name}-%{version}
ln -s %{_docdir}/%{name}-%{version} %{buildroot}/%{_datadir}/%{name}/doc

# Silence rpmlint
sed -i '/^#! \//,1 d' %{buildroot}%{_sysconfdir}/%{name}-%{mode}/mp*.conf

#Rename the MPI routine manpages, to avoid conflict with openmpi
for man in %{buildroot}%{_mandir}/man3/*; do
  manf=`basename $man .3`
  mv %{buildroot}%{_mandir}/man3/$manf.3 %{buildroot}%{_mandir}/man4/$manf.4
  sed s/3/4/1 -i %{buildroot}%{_mandir}/man4/$manf.4
done
mv  %{buildroot}%{_mandir}/man4/MPE*.*  %{buildroot}%{_mandir}/man3/

# The uninstall script that is installed in this directory is not needed in rpm
# packaging 
rm -rf %{buildroot}%{_sbindir}/mpe*

find %{buildroot} -type f -name "*.la" -exec rm -f {} ';'


%clean
rm -rf %{buildroot}

%if 0%{?fedora_version}
%post
/usr/sbin/alternatives	\
	--install %{_bindir}/mpirun mpi-run %{_bindir}/mpiexec.py 41	\
	--slave	%{_bindir}/mpiexec mpi-exec %{_bindir}/mpiexec.py	\
	--slave	%{_mandir}/man1/mpiexec.1.gz mpi-exec-man		\
			%{_mandir}/man1/mp-mpiexec.1.gz		\
	--slave	%{_mandir}/man1/mpif90.1.gz mpif90-man		\
			%{_mandir}/man1/mp-mpif90.1.gz		\
	--slave	%{_mandir}/man1/mpif77.1.gz mpif77-man		\
			%{_mandir}/man1/mp-mpif77.1.gz		\
	--slave	%{_mandir}/man1/mpicc.1.gz mpicc-man		\
			%{_mandir}/man1/mp-mpicc.1.gz		\
	--slave	%{_mandir}/man1/mpic++.1.gz mpic++-man		\
			%{_mandir}/man1/mp-mpicxx.1.gz
%endif

%if 0%{?fedora_version}
%preun
/usr/sbin/alternatives --remove mpi-run %{_bindir}/mpiexec.py
%endif

%if 0%{?fedora_version}
%post devel
/usr/sbin/alternatives	\
	--install %{_bindir}/mpicc mpicc %{_bindir}/mp%{mode}-mpicc %{priority}\
	--slave	%{_bindir}/mpicxx  mpicxx  %{_bindir}/mp%{mode}-mpicxx	\
	--slave	%{_bindir}/mpif90  mpif90  %{_bindir}/mp%{mode}-mpif90	\
	--slave	%{_bindir}/mpif77  mpif77  %{_bindir}/mp%{mode}-mpif77
%endif

%if 0%{?fedora_version} > 0
%preun devel
/usr/sbin/alternatives --remove mpicc %{_bindir}/mp%{mode}-mpicc
%endif

%files
%defattr(-,root,root,-)
%{_bindir}/*
#%exclude %{_bindir}/mp*.pyc
#%exclude %{_bindir}/mp*.pyo
%exclude %{_bindir}/mp%{mode}-mpicc
%exclude %{_bindir}/mp%{mode}-mpicxx
%exclude %{_bindir}/mp%{mode}-mpif90
%exclude %{_bindir}/mp%{mode}-mpif77
%{_mandir}/man1/*
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/logfiles
%{_datadir}/%{name}/doc
#%dir %{_datadir}/%{name}/%{name}-%{version}
#%{_datadir}/%{name}/*
%dir %{_docdir}/%{name}-%{version}
%doc %{_docdir}/%{name}-%{version}/READM*
%doc %{_docdir}/%{name}-%{version}/CHANGE*
%doc %{_docdir}/%{name}-%{version}/COPYR*
%doc %{_docdir}/%{name}-%{version}/RELEASE*

%files doc
%defattr(-,root,root,-)
%dir %{_docdir}/%{name}-%{version}
%doc %{_docdir}/%{name}-%{version}/*.pdf
%doc %{_docdir}/%{name}-%{version}/jumpshot*
%doc %{_docdir}/%{name}-%{version}/www

%files libs
%defattr(-,root,root,-)
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/*.jar
%{_libdir}/%{name}/mpe*.o
%{_libdir}/%{name}/*.so.*
%config %{_sysconfdir}/%{name}-%{mode}/

%files devel
%defattr(-,root,root,-)
%{_bindir}/mp%{mode}-mpicc
%{_bindir}/mp%{mode}-mpicxx
%{_bindir}/mp%{mode}-mpif90
%{_bindir}/mp%{mode}-mpif77
%{_includedir}/*
%{_libdir}/%{name}/*.a
%{_libdir}/%{name}/*.so
%dir %{_libdir}/%{name}/trace_rlog
%{_libdir}/%{name}/trace_rlog/libTraceInput.so
%{_libdir}/pkgconfig/%{name}-ch3.pc
%{_libdir}/pkgconfig/openpa.pc
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/bin%{mode}/
%{_datadir}/%{name}/%{name}.module
%{_datadir}/%{name}/examples*
%{_mandir}/man3/*.gz
%{_mandir}/man4/*.gz
#%doc README.testing README.romio README.developer

%changelog
* Sun Aug 15 2010 Kurt Garloff <kurt@garloff.de>
- Update to mpi2ch2-1.2.1p1:
  * Minor bug fixes (PowerPC, IOAT, mpdboot)

* Mon Nov 23 2009 Kurt Garloff <kurt@garloff.de>
- Update to mpich2-1.2.1:
  * Bug fixes with MX and Hydra
  * support hwloc process binding library
  * add valgrind support for debug builds
- Update to MPICH2-1.2:
  * MPI-2.2 support
  * Several bug fixes and code cleanup

* Fri Jul 10 2009 Kurt Garloff <kurt@garloff.de>
- Update to mpich2-1.1:
  * Hydra Process Management support
  * Shared-memory Collectives
  * Nemesis Communication Channel
  * Many fixes and performance improvements

* Fri Feb 13 2009 Kurt Garloff <kurt@garloff.de>
- Split off -doc subpackage.

* Thu Feb 12 2009 Kurt Garloff <kurt@garloff.de>
- Update to mpich2-1.0.8:
  * Added support for MPI 2.1
  * Added support for MPI_Type_create_resized and MPI_Type_create_indexed_block datatypes in ROMIO.
  * Many other bug fixes, memory leak fixes and code cleanup.

* Tue Jun 17 2008 Kurt Garloff <kurt@garloff.de>
- Update to mpich2-1.0.7

* Thu Feb 14 2008 Kurt Garloff <kurt@garloff.de>
- Handle fortran variaton also in Requires: of -devel package

* Tue Feb 12 2008 Kurt Garloff <garloff@opensuse.org>
- Make build in openSUSE Build Service for various distributions
- Optimization flags

* Mon Oct 15 2007 Deji Akingunola <dakingun@gmail.com> - 1.0.6p1-1
- Update to 1.0.6p1

* Mon Oct 15 2007 Deji Akingunola <dakingun@gmail.com> - 1.0.6-1
- New version upgrade

* Mon Jul 31 2007 Deji Akingunola <dakingun@gmail.com> - 1.0.5p4-4
- Create a -mpi-manpages subpackage for the MPI routines manuals

* Fri Jul 27 2007 Deji Akingunola <dakingun@gmail.com> - 1.0.5p4-3
- Fix java-gcj-compat BR
- Handle upgrades in the post scripts

* Mon Jun 12 2007 Deji Akingunola <dakingun@gmail.com> - 1.0.5p4-2
- Fix typos and make other adjustments arising from Fedora package reviews

* Mon Jun 12 2007 Deji Akingunola <dakingun@gmail.com> - 1.0.5p4-1
- Patch #4 release

* Mon Feb 12 2007 Deji Akingunola <dakingun@gmail.com> - 1.0.5p2-1
- Patch #2 release

* Tue Jan 09 2007 Deji Akingunola <dakingun@gmail.com> - 1.0.5p1-1
- New release with manpages
- Create a -libs subpackage as it's done in Fedora's openmpi to help with
  multi-libs packaging
- Disable modules support (until I can properly figure it out)

* Wed Dec 27 2006 Deji Akingunola <dakingun@gmail.com> - 1.0.5-1
- New release

* Sat Nov 18 2006 Deji Akingunola <dakingun@gmail.com> - 1.0.4p1-2
- Set the java_sdk directory so all java bit work  

* Sat Sep 02 2006 Deji Akingunola <dakingun@gmail.com> - 1.0.4p1-1
- Update to version 1.0.4p1
- Cleanup up spec file to use alternatives similarly to FC's openmpi

* Wed Aug 02 2006 Deji Akingunola <dakingun@gmail.com> - 1.0.4-1
- Update to version 1.0.4

* Thu May 18 2006 Deji Akingunola <dakingun@gmail.com> - 1.0.3-3
- Add missing BRs (Orion Polawski)

* Mon Apr 10 2006 Deji Akingunola <dakingun@gmail.com> - 1.0.3-2
- Rewrite the spec, borrowing extensively from openmpi's spec by Jason Vas Dias
- Allows use of environment modules and alternatives

* Fri Nov 25 2005 Deji Akingunola <dakingun@gmail.com> - 1.0.3-1
- Update to new version

* Sat Oct 15 2005 Deji Akingunola <deji.aking@gmail.com> - 1.0.2p1-1
- Initial package

openSUSE Build Service is sponsored by