%define ver @VERSION@

%{!?configure_options: %define configure_options %{nil}}
%{!?_with_valgrind: %define _with_valgrind 0}
%{!?_disable_valgrind: %define _disable_valgrind 0}

%if 0%{?rhel} != 0
%if 0%{_disable_valgrind} == 0
%define _with_valgrind 1
%endif
%endif

Name: librdmacm
Version: 1.1.0mlnx
Release: 1%{?dist}
Summary: Userspace RDMA Connection Manager

Group: System Environment/Libraries
License: GPLv2 or BSD
Url: http://www.openfabrics.org/
Source: http://www.openfabrics.org/downloads/rdmacm/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: libibverbs-devel >= 1.1-1
%if %{_with_valgrind}
BuildRequires: valgrind-devel
%endif

%description
librdmacm provides a userspace RDMA Communication Managment API.

%package devel
Summary: Development files for the librdmacm library
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release} %{_includedir}/infiniband/verbs.h

%description devel
Development files for the librdmacm library.

%package utils
Summary: Examples for the librdmacm library
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}

%description utils
Example test programs for the librdmacm library.

%prep
%setup -q -n %{name}-%{ver}

%build
%if %{_with_valgrind}
%configure %{configure_options} --libdir=%{_libdir}/mlnx_ofed/valgrind --with-valgrind
make %{?_smp_mflags}
make DESTDIR=$RPM_BUILD_DIR/%{name}-%{version}/valgrind install
rm -f $RPM_BUILD_DIR/%{name}-%{version}/valgrind/%{_libdir}/mlnx_ofed/valgrind/*.*a
rm -f $RPM_BUILD_DIR/%{name}-%{version}/valgrind/%{_libdir}/mlnx_ofed/valgrind/rsocket/*.*a
make clean
%endif

%configure %{configure_options}
make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
%makeinstall
%if %{_with_valgrind}
mkdir -p %{buildroot}/%{_libdir}/mlnx_ofed
cp -a $RPM_BUILD_DIR/%{name}-%{version}/valgrind/%{_libdir}/mlnx_ofed/valgrind %{buildroot}/%{_libdir}/mlnx_ofed
%endif
# remove unpackaged files from the buildroot
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/rsocket/*.la

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%{_libdir}/lib*.so.*
%{_libdir}/rsocket/lib*.so.*
%if %{_with_valgrind}
%{_libdir}/mlnx_ofed/valgrind/lib*.so.*
%{_libdir}/mlnx_ofed/valgrind/rsocket/lib*.so.*
%endif
%doc AUTHORS COPYING README

%files devel
%defattr(-,root,root)
%{_libdir}/librdmacm*.so
%{_libdir}/rsocket/librspreload*.so
%{_libdir}/*.a
%{_libdir}/rsocket/*.a
%if %{_with_valgrind}
%{_libdir}/mlnx_ofed/valgrind/lib*.so
%{_libdir}/mlnx_ofed/valgrind/rsocket/lib*.so
%endif
%{_includedir}/*
%{_mandir}/man3/*
%{_mandir}/man7/*

%files utils
%defattr(-,root,root,-)
%{_bindir}/*
%{_mandir}/man1/*

%changelog

* Fri Feb 15 2008 Roland Dreier <rdreier@cisco.com> - 1.0.6-1
- Initial Fedora spec file
