%define pkg_name    aeson
%define pkg_version 0.9.0.1
%define pkg_release 3%{?_dist_release}

%define ghc_version 7.10.3

Summary: Haskell libraries: %{pkg_name} and dependent libraries
Name:    libghc-%{pkg_name}
Version: %{pkg_version}
Release: %{pkg_release}

License: BSD3
Group:   Applications/Text
URL:     http://hackage.haskell.org

Source0: %{pkg_name}-%{version}.tar.gz
# Source100: packages

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

BuildRequires: ghc haskell-platform-base cabal-install
BuildRequires: libffi-devel gmp-devel zlib-devel
BuildRequires: libghc-dlist

BuildRequires: docbook-utils docbook-utils-pdf docbook-style-xsl
BuildRequires: hscolour

Requires: ghc haskell-platform-base cabal-install
Requires: libghc-dlist

Vendor: Project Vine
Distribution: Vine Linux
Packager: ara_t


%description
Haskell libraries: %{pkg_name}


%prep
%{__rm} -rf ${RPM_BUILD_ROOT}
%setup -q -n %{pkg_name}-%{version}

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

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

cabal configure \
    --prefix=%{_prefix} \
    --libdir=%{_libdir}/ghc-lib/%{pkg_name}-%{version} \
    --libsubdir= \
    --datadir=%{_datadir}/%{pkg_name}-%{version} \
    --datasubdir= \
    --docdir=%{_docdir}/%{pkg_name}-%{version}

cabal build
cabal haddock || : # avoid Error
cabal copy --destdir=${RPM_BUILD_ROOT}
cabal register --inplace
cabal register --gen-pkg-config=${PKG_CONF_DIR}/%{pkg_name}-%{version}.conf

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

%{__cp} changelog.md LICENSE README.markdown \
        ${RPM_BUILD_ROOT}%{_docdir}/%{pkg_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/
%{_datadir}/


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

* Tue Apr 12 2016 Toshiaki Ara <ara_t@384.jp> 0.9.0.1-2
- correct SPEC file

* Tue Mar 01 2016 Toshiaki Ara <ara_t@384.jp> 0.9.0.1-1
- new package
