%define pkg_name    xmonad-extras
%define pkg_version 0.12.1
%define pkg_release 5%{?_dist_release}

%define ghc_version 7.10.3

Summary:     Various modules for xmonad
Summary(ja): xmonadのための様々なモジュール
Name:    %{pkg_name}
Version: %{pkg_version}
Release: %{pkg_release}

License: BSD3
Group:   User Interface/Desktops
URL:     http://hackage.haskell.org

Source0: %{name}-%{version}.tar.gz
Source1: ghc-mtl-1.2.1.0.tar.gz
Source2: ghc-paths-0.1.0.9.tar.gz
Source3: hint-0.4.2.3.tar.gz

Source100: packages

BuildRoot: %{_tmppath}/%{name}-%{version}-root

BuildRequires: ghc haskell-platform-base cabal-install
BuildRequires: xmonad xmonad-contrib
BuildRequires: libffi-devel gmp-devel zlib-devel
BuildRequires: xorg-x11-devel
BuildRequires: docbook-utils docbook-utils-pdf docbook-style-xsl
BuildRequires: hscolour

Requires: xmonad xmonad-contrib

Vendor: Project Vine
Distribution: Vine Linux
Packager: ara_t

%description
Various modules for xmonad that cannot be added to xmonad-contrib
 because of additional dependencies.

%description -l ja
サードパーティーによるxmonad拡張であり、依存パッケージの追加のために
xmonad-contribに含まれなかったモジュールを含みます。


%prep
%{__rm} -rf ${RPM_BUILD_ROOT}
%setup -q

# Initialise the package db
ghc-pkg init %{_builddir}/package.conf

%build
PKG_CONF_DIR=${RPM_BUILD_ROOT}%{_libdir}/ghc-%{ghc_version}/package.conf.d
%{__mkdir_p} ${PKG_CONF_DIR}

# install dependent packages
cd %{_builddir}
for pkg in `cat %{SOURCE100}`; do
  %{__tar} xzf %{_sourcedir}/${pkg}.tar.gz
  cd ${pkg}
  cabal configure \
    --prefix=%{_prefix} \
    --libdir=%{_libdir}/ghc-lib/%{name}/${pkg} \
    --libsubdir= \
    --datadir=%{_datadir}/%{name}/${pkg} \
    --datasubdir= \
    --docdir=%{_docdir}/%{name}/${pkg}

  cabal build
  cabal haddock
  cabal copy --destdir=${RPM_BUILD_ROOT}
  cabal register --inplace
  cabal register --gen-pkg-config=${PKG_CONF_DIR}/%{name}_${pkg}.conf
  cd ..
done

# build xmonad-extras
cd %{_builddir}/%{name}-%{version}
cabal configure \
    --prefix=%{_prefix} \
    --libdir=%{_libdir}/ghc-lib/%{name}/%{name}-%{version} \
    --libsubdir= \
    --datadir=%{_datadir}/%{name}/%{name}-%{version} \
    --datasubdir= \
    --docdir=%{_docdir}/%{name}/%{name}-%{version}

cabal build
cabal haddock
cabal copy --destdir=${RPM_BUILD_ROOT}
cabal register --inplace
cabal register --gen-pkg-config=${PKG_CONF_DIR}/%{name}-%{version}.conf

# %install
# %{__cp} LICENSE ${RPM_BUILD_ROOT}%{_docdir}/%{name}/%{name}-%{version}

%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%post
ghc-pkg recache

%postun
ghc-pkg recache


%files
%defattr(-, root, root)
%{_libdir}/ghc-%{ghc_version}/
%{_libdir}/ghc-lib/
%{_docdir}/%{name}/


%changelog
* Wed May 04 2016 Toshiaki Ara <ara_t@384.jp> 0.12.1-5
- rebuilt

* Tue Apr 12 2016 Toshiaki Ara <ara_t@384.jp> 0.12.1-4
- rebuild under xmonad-0.12-3 and xmonad-contrib-0.12-4
- correct SPEC file

* Tue Mar 01 2016 Toshiaki Ara <ara_t@384.jp> 0.12.1-3
- rebuild under xmonad-0.12-2 and xmonad-contrib-0.12-3

* Sat Feb 27 2016 Toshiaki Ara <ara_t@384.jp> 0.12.1-2
- recompile

* Sat Feb 27 2016 Toshiaki Ara <ara_t@384.jp> 0.12.1-1
- new package
