%define pkg_name    xmobar
%define pkg_version 0.23.1
%define pkg_release 6%{?_dist_release}

%define ghc_version 7.10.3

Summary:     a minimalistic text based status bar
Summary(ja): テキストを基礎とした最小のステータスバー
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: cereal-0.5.1.0.tar.gz
Source2: hinotify-0.3.8.1.tar.gz
Source3: libmpd-0.9.0.4.tar.gz
Source4: timezone-series-0.1.5.1.tar.gz
Source5: timezone-olson-0.1.7.tar.gz

Source100: packages

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

BuildRequires: ghc haskell-platform-base cabal-install
BuildRequires: xmonad-contrib
BuildRequires: libffi-devel gmp-devel zlib-devel
BuildRequires: xorg-x11-devel
BuildRequires: libXpm-devel

Requires: xmonad-contrib
Requires: libXpm

Vendor: Project Vine
Distribution: Vine Linux
Packager: ara_t

%description
Xmobar is a minimalistic text based status bar.

Inspired by the Ion3 status bar, it supports similar features,
like dynamic color management, output templates, and extensibility
through plugins.

%description -l ja
Xmobarはテキストを基礎とした最小のステータスバーです。


%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 xmobar
cd %{_builddir}/%{name}-%{version}
cabal configure \
    --prefix=%{_prefix} \
    --libdir=%{_libdir}/ghc-lib/%{name}-%{version} \
    --libsubdir= \
    --datadir=%{_datadir}/%{name}-%{version} \
    --datasubdir= \
    --docdir=%{_docdir}/%{name}/%{name}-%{version} \
    --flags="with_utf8" --flags="with_xft" \
    --flags="with_threaded" --flags="with_inotify" \
    --flags="with_datazone" --flags="with_xpm"

cabal build

%install
cabal copy --destdir=${RPM_BUILD_ROOT}

%{__cp} license news.md readme.md \
 ${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)
%{_bindir}/
%{_libdir}/ghc-%{ghc_version}/
%{_libdir}/ghc-lib/
%{_docdir}/%{name}/


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

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

* Sun Mar 06 2016 Toshiaki Ara <ara_t@384.jp> 0.23.1-4
- correct SPEC file

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

* Sun Feb 28 2016 Toshiaki Ara <ara_t@384.jp> 0.23.1-2
- add configure option and required libraries

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