Blob Blame History Raw
%cabal %{_bindir}/runghc Setup

%cabal_configure \
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_docdir}/%{name}-%{version} --htmldir=%{ghcdocdir} --libsubdir='$compiler/$pkgid' %{?with_shared:--enable-shared} %{?with_dynamic:--ghc-option=-dynamic}

%cabal_makefile \
%cabal makefile -f cabal-rpm.mk \
make -f cabal-rpm.mk %{_smp_mflags} \
%{nil}

%cabal_install %cabal copy --destdir=${RPM_BUILD_ROOT} -v

%ghcdocbasedir %{_docdir}/ghc/html
%ghcdocdir() %{ghcdocbasedir}/libraries/%{?1}%{!?1:%{pkg_name}}-%{?2}%{!?2:%{version}}
%ghcpkgdir() %{_libdir}/ghc-%{ghc_version}/%{?1}%{!?1:%{pkg_name}}-%{?2}%{!?2:%{version}}

%ghc_gen_filelists() \
basepkg=%{?1}%{!?1:%{pkg_name}} \
basefile=ghc-${basepkg} \
version=%{?2}%{!?2:%{version}} \
rm -f ${basefile}.files ${basefile}-devel.files ${basefile}-prof.files ${basefile}-doc.files \
echo "%defattr(-,root,root,-)" > ${basefile}.files \
if [ -d "${RPM_BUILD_ROOT}%{_docdir}/%{name}-%{version}" ]; then \
  %{!?1:echo "%{_docdir}/%{name}-%{version}" >> ${basefile}%{!?with_shared:-devel}.files} %{?1::} \
fi \
echo "%dir %{ghcpkgdir}" >> ${basefile}.files \
echo "%attr(755,root,root) %{ghcpkgdir}/libHS${basepkg}-${version}-ghc%{ghc_version}.so" >> ${basefile}.files \
echo "%defattr(-,root,root,-)" > ${basefile}-devel.files \
echo "%{_libdir}/ghc-%{ghc_version}/package.conf.d/${basepkg}-${version}*.conf" >> ${basefile}-devel.files \
find ${RPM_BUILD_ROOT}%{ghcpkgdir} -type d | sed "s/^/%dir /" >> ${basefile}-devel.files \
find ${RPM_BUILD_ROOT}%{ghcpkgdir} ! \\( -type d -o -name "*_p.a" -o -name "*.p_hi" -o -name "libHS*.so" \\) >> ${basefile}-devel.files \
echo "%defattr(-,root,root,-)" > ${basefile}-prof.files \
find ${RPM_BUILD_ROOT}%{ghcpkgdir} \\( -name "*_p.a" -o -name "*.p_hi" \\) >> ${basefile}-prof.files \
sed -i -e "s!${RPM_BUILD_ROOT}!!g" ${basefile}.files ${basefile}-devel.files ${basefile}-prof.files \
echo "%defattr(-,root,root,-)" > ${basefile}-doc.files \
echo "%{ghcdocdir}" >> ${basefile}-doc.files \
%{nil}

%ghc_reindex_haddock ( cd %{ghcdocbasedir}/libraries && [ -x "./gen_contents_index" ] && ./gen_contents_index ) || :

%ghc_version %{!?ghc_version_override:%(ghc --numeric-version)}%{?ghc_version_override}

%ghc_pkg_ver() %(ghc-pkg list --global --simple-output %1|sed -e "s/.*%1-//")

%cabal_pkg_conf \
%cabal register --gen-pkg-config \
mkdir -p $RPM_BUILD_ROOT%{_libdir}/ghc-%(ghc --numeric-version)/package.conf.d \
install --mode=0644 %{pkg_name}-%{version}.conf $RPM_BUILD_ROOT%{_libdir}/ghc-%{ghc_version}/package.conf.d
 
%ghc_requires Requires:       ghc = %{ghc_version}\
Requires(post): ghc = %{ghc_version}\
Requires(postun): ghc = %{ghc_version}\
%if %{with shared}\
Requires:       ghc-%{-n:%{-n*}}%{!-n:%{pkg_name}} = %{version}-%{release}\
%endif

%ghc_doc_requires Requires:       ghc-doc = %{ghc_version}\
Requires(post): ghc-doc = %{ghc_version}\
Requires(postun): ghc-doc = %{ghc_version}

%ghc_prof_requires Requires:       ghc-prof = %{ghc_version}\
Requires:       ghc-%{-n:%{-n*}}%{!-n:%{pkg_name}}-devel = %{version}-%{release}

%ghc_lib_package(n:c:h:)\
%define ghc_pkg_name %{-n:ghc-%{-n*}}%{!-n:ghc-%{pkg_name}}\
%if %{with shared}\
%files -n %{ghc_pkg_name} -f %{ghc_pkg_name}.files\
%defattr(-,root,root,-)\
%endif\
\
%ghc_package_devel\
\
%ghc_package_doc\
\
%ghc_package_prof\


%ghc_binlib_package(n:c:h:l:v:s:d:)\
%define local_pkg_name %{-n:%{-n*}}%{!-n:%{pkg_name}}\
%define ghc_pkg_name ghc-%{local_pkg_name}\
%package -n %{ghc_pkg_name}\
Summary:        %{-s:%{-s*}}%{!-s:%{?common_summary}%{!?common_summary:%{local_pkg_name}}}\
Group:          System Environment/Libraries\
%{-v:Version:        %{-v*}}\
%{-l:License:        %{-l*}}\
\
%description -n %{ghc_pkg_name}\
%{-d:%{-d*}}%{!-d:%{?common_description}%{!?common_description:Haskell %{local_pkg_name} library.}}\
\
This package provides the shared library.\
\
%ghc_lib_package\


%ghc_package_devel(n:c:h:l:v:s:d:)\
%define local_pkg_name %{-n:%{-n*}}%{!-n:%{pkg_name}}\
%define ghc_pkg_name ghc-%{local_pkg_name}\
%package -n %{ghc_pkg_name}-devel\
Summary:        %{-s:%{-s*}}%{!-s:%{?common_summary}%{!?common_summary:%{local_pkg_name}}} development files\
Group:          Development/Libraries\
%{-v:Version:        %{-v*}}\
%{-l:License:        %{-l*}}\
%{?ghc_requires}\
%{!-h:%{?ghc_pkg_deps:Requires:       %{ghc_pkg_deps}}}\
%{-h:Requires:       %{-h*}}\
%{!-c:%{?ghc_pkg_c_deps:Requires:       %{ghc_pkg_c_deps}}}\
%{-c:Requires:       %{-c*}}\
\
%description -n %{ghc_pkg_name}-devel\
%{-d:%{-d*}}%{!-d:%{?common_description}%{!?common_description:Haskell %{local_pkg_name} library.}}\
\
This package contains the development files.\
\
%post -n %{ghc_pkg_name}-devel\
ghc-pkg recache\
\
%postun -n %{ghc_pkg_name}-devel\
ghc-pkg recache\
\
%files -n %{ghc_pkg_name}-devel -f %{ghc_pkg_name}-devel.files\
%defattr(-,root,root,-)\

%ghc_package_doc(n:h:l:v:s:d:)\
%define local_pkg_name %{-n:%{-n*}}%{!-n:%{pkg_name}}\
%define ghc_pkg_name ghc-%{local_pkg_name}\
%package -n %{ghc_pkg_name}-doc\
Summary:        Documentation for %{-s:%{-s*}}%{!-s:%{?common_summary}%{!?common_summary:%{local_pkg_name}}}\
Group:          Development/Libraries\
%{-v:Version:        %{-v*}}\
%{-l:License:        %{-l*}}\
%{?ghc_doc_requires}\
%{!-h:%{?ghc_pkg_deps:Requires:       %(echo %{ghc_pkg_deps} | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-doc/g")}}\
%{-h:Requires:       %(echo %{-h*} | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-doc/g")}\
\
%description -n %{ghc_pkg_name}-doc\
%{-d:%{-d*}}%{!-d:%{?common_description}%{!?common_description:Haskell %{local_pkg_name} library.}}\
\
This package contains development documentation files.\
\
%post -n %{ghc_pkg_name}-doc\
%ghc_reindex_haddock\
\
%postun -n %{ghc_pkg_name}-doc\
if [ "$1" -eq 0 ] ; then\
  %ghc_reindex_haddock\
fi\
\
%files -n %{ghc_pkg_name}-doc -f %{ghc_pkg_name}-doc.files\
%defattr(-,root,root,-)\

%ghc_package_prof(n:h:l:v:s:d:)\
%define local_pkg_name %{-n:%{-n*}}%{!-n:%{pkg_name}}\
%define ghc_pkg_name ghc-%{local_pkg_name}\
%package -n %{ghc_pkg_name}-prof\
Summary:        Profiling libraries for %{-s:%{-s*}}%{!-s:%{?common_summary}%{!?common_summary:%{local_pkg_name}}}\
Group:          Development/Libraries\
%{-v:Version:        %{-v*}}\
%{-l:License:        %{-l*}}\
%{?ghc_prof_requires}\
%{!-h:%{?ghc_pkg_deps:Requires:       %(echo %{ghc_pkg_deps} | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-prof/g")}}\
%{-h:Requires:       %(echo %{-h*} | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-prof/g")}\
\
%description -n %{ghc_pkg_name}-prof\
%{-d:%{-d*}}%{!-d:%{?common_description}%{!?common_description:Haskell %{local_pkg_name} library.}}\
\
This package contains the profiling library.\
\
%files -n %{ghc_pkg_name}-prof -f %{ghc_pkg_name}-prof.files\
%defattr(-,root,root,-)\