Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates > by-pkgid > c0af98b61b3b5c8bf0772124ad980843 > files > 1

ghc-rpm-macros-0.7.5-1.fc13.i686.rpm

# RPM Macros for packaging Haskell cabalized packages  -*-rpm-spec-*-
# see https://fedoraproject.org/wiki/PackagingDrafts/Haskell for more details

# "cabal"
%cabal %{_bindir}/runghc Setup

# configure
%cabal_configure \
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_docdir}/%{name}-%{version} --htmldir=%{ghcdocdir} --libsubdir='$compiler/$pkgid' --ghc %{!?ghc_without_shared:--enable-shared} %{?cabal_configure_options}

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

# root dir for ghc docs
%ghcdocbasedir %{_docdir}/ghc/html
# ghcdocdir [pkgname]
%ghcdocdir() %{ghcdocbasedir}/libraries/%{?1}%{!?1:%{pkg_name}}-%{version}
# top library dir
%ghcpkgbasedir %{_libdir}/ghc-%{ghc_version}
# ghcpkgdir [pkgname]
%ghcpkgdir() %{ghcpkgbasedir}/%{?1}%{!?1:%{pkg_name}}-%{version}

# ghc_gen_filelists [pkgname]
%ghc_gen_filelists() \
pkgname=%{?1}%{!?1:%{pkg_name}} \
basefile=ghc-${pkgname} \
pkgnamever=${pkgname}-%{version} \
rm -f ${basefile}.files ${basefile}-devel.files ${basefile}-prof.files ${basefile}-doc.files \
%if %{undefined ghc_without_shared}\
echo "%defattr(-,root,root,-)" > ${basefile}.files \
if [ -d "${RPM_BUILD_ROOT}%{ghcpkgdir}" ]; then \
echo "%dir %{ghcpkgdir}" >> ${basefile}.files \
echo "%attr(755,root,root) %{ghcpkgdir}/libHS${pkgnamever}-ghc%{ghc_version}.so" >> ${basefile}.files \
fi \
%endif \
echo "%defattr(-,root,root,-)" > ${basefile}-devel.files \
if [ -d "${RPM_BUILD_ROOT}%{_docdir}/%{name}-%{version}" ]; then \
  %{!?1:echo "%{_docdir}/%{name}-%{version}" >> ${basefile}%{?ghc_without_shared:-devel}.files} %{?1::} \
fi \
echo "%{ghcpkgbasedir}/package.conf.d/${pkgnamever}*.conf" >> ${basefile}-devel.files \
if [ -d "${RPM_BUILD_ROOT}%{ghcpkgdir}" ]; then \
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 \
fi \
echo "%defattr(-,root,root,-)" > ${basefile}-prof.files \
if [ -d "${RPM_BUILD_ROOT}%{ghcpkgdir}" ]; then \
find ${RPM_BUILD_ROOT}%{ghcpkgdir} \\( -name "*_p.a" -o -name "*.p_hi" \\) >> ${basefile}-prof.files \
fi \
echo "%defattr(-,root,root,-)" > ${basefile}-doc.files \
if [ -d "${RPM_BUILD_ROOT}%{ghcdocdir}" ]; then \
echo "%{ghcdocdir}" >> ${basefile}-doc.files \
fi \
sed -i -e "s!${RPM_BUILD_ROOT}!!g" %{!?ghc_without_shared:${basefile}.files} ${basefile}-devel.files ${basefile}-prof.files \
%{nil}

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

# create and install package.conf file
# cabal_pkg_conf [pkgname]
%cabal_pkg_conf \
%cabal register --gen-pkg-config \
mkdir -p $RPM_BUILD_ROOT%{ghcpkgbasedir}/package.conf.d \
install --mode=0644 %{?1}%{!?1:%{pkg_name}}-%{version}.conf $RPM_BUILD_ROOT%{ghcpkgbasedir}/package.conf.d

# devel pkg basic requires
%ghc_requires Requires:       ghc = %{ghc_version}\
Requires(post): ghc = %{ghc_version}\
Requires(postun): ghc = %{ghc_version}\
%if %{undefined ghc_without_shared}\
Requires:       ghc-%{-n:%{-n*}}%{!-n:%{pkg_name}} = %{-v:%{-v*}}%{!-v:%{version}}-%{release}\
%endif

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

# prof pkg basic requires
%ghc_prof_requires Requires:       ghc-prof = %{ghc_version}\
Requires:       ghc-%{-n:%{-n*}}%{!-n:%{pkg_name}}-devel = %{-v:%{-v*}}%{!-v:%{version}}-%{release}

# ghc_lib_package [-n pkgname] [-c cdepslist] [-h pkgdepslist]
%ghc_lib_package(n:c:h:)\
%define ghc_pkg_name ghc-%{-n:%{-n*}}%{!-n:%{pkg_name}}\
%if %{undefined ghc_without_shared}\
%files -n %{ghc_pkg_name} -f %{ghc_pkg_name}.files\
%defattr(-,root,root,-)\
%endif\
\
%ghc_package_devel\
\
%ghc_package_doc\
\
%ghc_package_prof\
%{nil}

# ghc_binlib_package [-n pkgname] [-c cdepslist] [-h pkgdepslist] [-l licensetag] [-v version]
%ghc_binlib_package(n:c:h:l:v:)\
%define local_pkg_name %{-n:%{-n*}}%{!-n:%{pkg_name}}\
%define ghc_pkg_name ghc-%{local_pkg_name}\
%package -n %{ghc_pkg_name}\
Summary:        %{?common_summary}%{!?common_summary:%{local_pkg_name} library}\
Group:          System Environment/Libraries\
%{-v:Version:        %{-v*}}\
%{-l:License:        %{-l*}}\
%{?ghc_pkg_obsoletes:Obsoletes:      %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1/g")}\
\
%description -n %{ghc_pkg_name}\
%{?common_description}%{!?common_description:Haskell %{local_pkg_name} library.}\
\
%if %{defined ghc_version} && %{undefined ghc_without_shared}\
This package provides the shared library.\
%endif\
\
%ghc_lib_package\
%{nil}

%ghc_pkg_recache %{_bindir}/ghc-pkg recache --no-user-package-conf || :

# ghc_package_devel [-n pkgname] [-c cdepslist] [-h pkgdepslist] [-l licensetag] [-v version]
%ghc_package_devel(n:c:h:l:v:)\
%define local_pkg_name %{-n:%{-n*}}%{!-n:%{pkg_name}}\
%define ghc_pkg_name ghc-%{local_pkg_name}\
%package -n %{ghc_pkg_name}-devel\
Summary:        %{?common_summary}%{!?common_summary:%{local_pkg_name} library} 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*}}\
%{?ghc_pkg_obsoletes:Obsoletes:      %{ghc_pkg_obsoletes}}\
\
%description -n %{ghc_pkg_name}-devel\
%{?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,-)\
%{nil}

# for docs post and postun
# re-index haddock
%ghc_reindex_haddock ( cd %{ghcdocbasedir}/libraries && [ -x "./gen_contents_index" ] && ./gen_contents_index ) || :

# ghc_package_doc [-n pkgname] [-h pkgdepslist] [-l licensetag] [-v version]
%ghc_package_doc(n:h:l:v:)\
%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 %{?common_summary}%{!?common_summary:%{local_pkg_name} library}\
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")}\
%{?ghc_pkg_obsoletes:Obsoletes:      %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-doc/g")}\
\
%description -n %{ghc_pkg_name}-doc\
%{?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,-)\
%{nil}

# ghc_package_prof [-n pkgname] [-c cdepslist] [-h pkgdepslist] [-l licensetag] [-v version]
%ghc_package_prof(n:h:l:v:)\
%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 %{?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")}\
%{?ghc_pkg_obsoletes:Obsoletes:      %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-prof/g")}\
\
%description -n %{ghc_pkg_name}-prof\
%{?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,-)\
%{nil}

# ghc_strip_dynlinked
%ghc_strip_dynlinked\
%if %{undefined __debug_package}\
find $RPM_BUILD_ROOT -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \\; -exec strip "{}" \\;\
%endif

# ghc_bin_build
%ghc_bin_build\
%global debug_package %{nil}\
%cabal_configure %{!?ghc_without_dynamic:--ghc-option=-dynamic}\
%cabal build

# ghc_lib_build
%ghc_lib_build\
%global debug_package %{nil}\
%cabal_configure %{!?without_prof:-p}\
%cabal build\
%{!?without_haddock:%cabal haddock %{?with_hscolour:--hyperlink-source}}\
%{nil}

# install bin package
%ghc_bin_install\
%cabal_install\
%ghc_strip_dynlinked

# install lib package
%ghc_lib_install\
%cabal_install\
%cabal_pkg_conf\
%ghc_gen_filelists\
%ghc_strip_dynlinked