%global alphatag @alphatag@
%global numcomm @numcomm@

Name:           dlm
Version:        @relver@
Release:        1%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dist}
License:        GPLv2 and GPLv2+ and LGPLv2+
# For a breakdown of the licensing, see README.license
Summary:        dlm control daemon and tool
URL:            https://pagure.io/dlm
BuildRequires:  gcc
%if 0%{?suse_version}
BuildRequires:  linux-kernel-headers
%else
BuildRequires:  glibc-kernheaders
%endif
BuildRequires:  corosynclib-devel >= 3.1.0
%if 0%{?suse_version}
%if 0%{?suse_version} > 1500
BuildRequires:  libpacemaker3-devel >= 1.1.7
%else
BuildRequires:  libpacemaker-devel >= 1.1.7
%endif
%else
BuildRequires:  pacemaker-libs-devel >= 1.1.7
%endif
BuildRequires:  systemd-devel
BuildRequires:  make
Source0:	https://releases.pagure.org/dlm/%{name}-%{version}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}.tar.gz

Requires:       %{name}-lib = %{version}-%{release}
Requires:       corosync >= 3.1.0
%{?fedora:Requires: kernel-modules-extra}
%{?suse_version:Requires: dlm-kmp}
%if %{defined systemd_requires}
%systemd_requires
%endif

%description
The kernel dlm requires a user daemon to control membership.

%prep
%setup -q

%build
# upstream does not require configure
# upstream does not support parallel builds
%set_build_flags
%make_build -j1

%install
%make_install LIBDIR=%{_libdir}

install -Dm 0644 init/dlm.service %{buildroot}%{_unitdir}/dlm.service
install -Dm 0644 init/dlm.sysconfig %{buildroot}/etc/sysconfig/dlm

%post
%systemd_post dlm.service

%preun
%systemd_preun dlm.service

%postun
%systemd_postun_with_restart dlm.service

%files
%doc README.license
%{_unitdir}/dlm.service
%{_sbindir}/dlm_controld
%{_sbindir}/dlm_tool
%{_sbindir}/dlm_stonith
%{_mandir}/man8/dlm*
%{_mandir}/man5/dlm*
%{_mandir}/man3/*dlm*
%config(noreplace) %{_sysconfdir}/sysconfig/dlm

%package        lib
Summary:        Library for %{name}

%description    lib
The %{name}-lib package contains the libraries needed to use the dlm
from userland applications.

%ldconfig_scriptlets lib

%files          lib
/usr/lib/udev/rules.d/*-dlm.rules
%{_libdir}/libdlm*.so.*

%package        devel
Summary:        Development files for %{name}
Requires:       %{name}-lib = %{version}-%{release}

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%files          devel
%{_libdir}/libdlm*.so
%{_includedir}/libdlm*.h
%{_libdir}/pkgconfig/*.pc

%changelog
* @rpmdate@ Autogenerated version <nobody@nowhere.org> - @relver@-1%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}
- Autogenerated spec file
