%define pkg_name    build-pandoc
%define pkg_version 1.17.0.3
%define pkg_release 1%{?_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: JuicyPixels-3.2.7.tar.gz
Source1: SHA-1.6.4.2.tar.gz
Source2: blaze-markup-0.7.0.3.tar.gz
Source3: blaze-html-0.8.1.1.tar.gz
Source4: cmark-0.5.2.tar.gz
Source5: digest-0.0.1.2.tar.gz
Source6: extensible-exceptions-0.1.1.4.tar.gz
Source7: haddock-library-1.2.1.tar.gz
Source8: hslua-0.4.1.tar.gz
Source9: pandoc-types-1.16.1.tar.gz
Source10: regex-pcre-builtin-0.94.4.8.8.35.tar.gz
Source11: tagsoup-0.13.9.tar.gz
Source12: temporary-1.2.0.4.tar.gz
Source13: unix-compat-0.4.1.4.tar.gz
Source14: filemanip-0.3.6.3.tar.gz
Source15: utf8-string-1.0.1.1.tar.gz
Source16: highlighting-kate-0.6.2.tar.gz
Source17: xml-1.3.14.tar.gz
Source18: texmath-0.8.6.2.tar.gz
Source19: zip-archive-0.3.0.2.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-data-default-class
BuildRequires: libghc-dlist
BuildRequires: libghc-data-default
BuildRequires: libghc-aeson
BuildRequires: libghc-http-client-tls
BuildRequires: yaml

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

Requires: ghc haskell-platform-base cabal-install
Requires: libghc-data-default-class
Requires: libghc-dlist
Requires: libghc-data-default
Requires: libghc-aeson
Requires: libghc-http-client-tls
Requires: yaml

Vendor: Project Vine
Distribution: Vine Linux
Packager: ara_t


%description
Haskell libraries: %{pkg_name}


%prep
%{__rm} -rf ${RPM_BUILD_ROOT}
%setup -q -T -c %{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}

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 || : # aviod Error
  cabal copy --destdir=${RPM_BUILD_ROOT}
  cabal register --inplace
  cabal register --gen-pkg-config=${PKG_CONF_DIR}/%{pkg_name}_${pkg}.conf
  cd ..
done

%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
* Fri May 06 2016 Toshiaki Ara <ara_t@384.jp> 1.17.0.3-1
- new package
