2c0b10d
# RPM Macros for packaging Haskell cabalized packages  -*-rpm-spec-*-
1f4312a
# see https://fedoraproject.org/wiki/PackagingDrafts/Haskell for more details
1f4312a
a0e7ada
# "cabal"
2c0b10d
%cabal [ -x Setup ] || ghc --make %{!?ghc_without_shared:%{!?ghc_without_dynamic:-dynamic}} Setup\
a1abcaa
./Setup
Yaakov Meir Nemoy b640c1a
a0e7ada
# configure
086f1bc
%cabal_configure\
cd30bb3
%if %{undefined ghc_bootstrap}\
78a6eab
if [ ! "$(ghc --info | grep \\"Booter\\ version\\",\\"%{ghc_version}\\")" ]; then\
15b76d9
  echo "Aborting since this ghc build is not self-bootstrapped.\
cd30bb3
The ghc package should be rebuilt against its current version first\
15b76d9
to prevent dependency ABI breakage from a future ghc rebuild.\
15b76d9
(This can be overridden understanding this risk, by defining ghc_bootstrap.)"\
cd30bb3
  exit 1\
cd30bb3
fi\
cd30bb3
%endif\
8af86b7
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_docdir}/%{name}-%{version} %{?pkg_name:--htmldir=%{ghclibdocdir}/%{pkg_name}-%{version}} --libsubdir='$compiler/$pkgid' --ghc %{!?ghc_without_shared:--enable-shared} %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?cabal_configure_options}
dffc2c5
a0e7ada
# install
086f1bc
%cabal_install %cabal copy --destdir=%{buildroot} -v
Yaakov Meir Nemoy b640c1a
a0e7ada
# root dir for ghc docs
c97ee70
%ghcdocbasedir %{_docdir}/ghc/html
b13abae
# libraries doc dir
b13abae
%ghclibdocdir %{ghcdocbasedir}/libraries
a0e7ada
# top library dir
086f1bc
%ghclibdir %{_libdir}/ghc-%{ghc_version}
c6c20a5
086f1bc
# ghc_gen_filelists [name] [version]
c6c20a5
%ghc_gen_filelists()\
086f1bc
%define pkgname %{?1}%{!?1:%{pkg_name}}\
086f1bc
%define pkgver %{?2}%{!?2:%{version}}\
086f1bc
%define pkgnamever %{pkgname}-%{pkgver}\
086f1bc
%define basepkg ghc-%{pkgname}\
086f1bc
%define pkgdir %{ghclibdir}/%{pkgnamever}\
b13abae
%define docdir %{ghclibdocdir}/%{pkgnamever}\
1bc67af
rm -f %{basepkg}.files %{basepkg}-devel.files\
2c0b10d
%if %{undefined ghc_without_shared}\
086f1bc
echo "%defattr(-,root,root,-)" > %{basepkg}.files\
086f1bc
if [ -d "%{buildroot}%{pkgdir}" ]; then\
086f1bc
echo "%dir %{pkgdir}" >> %{basepkg}.files\
086f1bc
echo "%attr(755,root,root) %{pkgdir}/libHS%{pkgnamever}-ghc%{ghc_version}.so" >> %{basepkg}.files\
086f1bc
fi\
086f1bc
%endif\
086f1bc
echo "%defattr(-,root,root,-)" > %{basepkg}-devel.files\
876ea62
%if 0%{!?1:1}\
876ea62
if [ -d "%{buildroot}%{_docdir}/%{name}-%{version}" ]; then\
2c0b10d
  echo "%{_docdir}/%{name}-%{version}" >> %{basepkg}%{?ghc_without_shared:-devel}.files\
4d6720d
fi\
876ea62
%endif\
30ceea2
%if 0%{?1:1}\
30ceea2
if [ -d "%{buildroot}%{_docdir}/ghc-%{pkgnamever}" ]; then\
30ceea2
  echo "%{_docdir}/ghc-%{pkgnamever}" >> %{basepkg}%{?ghc_without_shared:-devel}.files\
30ceea2
fi\
30ceea2
%endif\
086f1bc
echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf" >> %{basepkg}-devel.files\
086f1bc
if [ -d "%{buildroot}%{pkgdir}" ]; then\
086f1bc
find %{buildroot}%{pkgdir} -type d | sed "s/^/%dir /" >> %{basepkg}-devel.files\
1bc67af
find %{buildroot}%{pkgdir} ! \\( -type d -o -name "libHS*.so" \\) >> %{basepkg}-devel.files\
086f1bc
fi\
086f1bc
if [ -d "%{buildroot}%{docdir}" ]; then\
086f1bc
echo "%{docdir}" >> %{basepkg}-devel.files\
086f1bc
fi\
1bc67af
sed -i -e "s!%{buildroot}!!g" %{!?ghc_without_shared:%{basepkg}.files} %{basepkg}-devel.files\
Yaakov Meir Nemoy b640c1a
%{nil}
Yaakov Meir Nemoy b640c1a
a0e7ada
# compiler version
8b0ec9d
%ghc_version %{!?ghc_version_override:%(ghc --numeric-version)}%{?ghc_version_override}
5edaabc
a0e7ada
# create and install package.conf file
086f1bc
# cabal_pkg_conf [name] [version]
c6c20a5
%cabal_pkg_conf()\
086f1bc
%define pkgname %{?1}%{!?1:%{pkg_name}}\
086f1bc
%define pkgver %{?2}%{!?2:%{version}}\
086f1bc
%define pkgnamever %{pkgname}-%{pkgver}\
086f1bc
%cabal register --gen-pkg-config\
b13abae
mkdir -p %{buildroot}%{ghclibdir}/package.conf.d\
b13abae
install --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf.d\
c6c20a5
%{nil}
d9a9b5f
a0e7ada
# devel pkg basic requires
b13abae
%ghc_devel_requires Requires:       ghc = %{ghc_version}\
85779fa
Requires(post): ghc = %{ghc_version}\
3ca7af7
Requires(postun): ghc = %{ghc_version}\
2c0b10d
%if %{undefined ghc_without_shared}\
086f1bc
Requires:       ghc-%{?pkg_name}%{!?pkg_name:%{pkgname}} = %{?pkgver}%{!?pkgver:%{version}}-%{release}\
3ca7af7
%endif
dffc2c5
086f1bc
# ghc_lib_package [-c cdepslist] [-h pkgdepslist]
086f1bc
%ghc_lib_package(c:h:)\
086f1bc
%define pkgname %{?1}%{!?1:%{pkg_name}}\
086f1bc
%define pkgver %{?2}%{!?2:%{version}}\
086f1bc
%define pkgnamever %{pkgname}-%{pkgver}\
086f1bc
%define basepkg ghc-%{pkgname}\
2c0b10d
%if %{undefined ghc_without_shared}\
086f1bc
%files -n %{basepkg} -f %{basepkg}.files\
23340a3
%defattr(-,root,root,-)\
23340a3
%endif\
23340a3
\
23340a3
%ghc_package_devel\
d9a9b5f
%{nil}
23340a3
4d6720d
# ghc_binlib_package [-c cdepslist] [-h pkgdepslist] [-l licensetag] [-x] [name] [version]
4d6720d
%ghc_binlib_package(c:h:l:x)\
086f1bc
%define pkgname %{?1}%{!?1:%{pkg_name}}\
086f1bc
%define pkgver %{?2}%{!?2:%{version}}\
086f1bc
%define pkgnamever %{pkgname}-%{pkgver}\
4d6720d
%{!-x:%{?1:%global ghc_packages_list %{?ghc_packages_list} %{pkgnamever}}}\
086f1bc
%define basepkg ghc-%{pkgname}\
086f1bc
%package -n %{basepkg}\
086f1bc
Summary:        %{?common_summary}%{!?common_summary:Haskell %{pkgname} library}\
23340a3
Group:          System Environment/Libraries\
086f1bc
%{?1:Version:        %{pkgver}}\
23340a3
%{-l:License:        %{-l*}}\
82b34c5
%{?ghc_pkg_obsoletes:Obsoletes:      %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1/g")}\
23340a3
\
086f1bc
%description -n %{basepkg}\
086f1bc
%{?common_description}%{!?common_description:Haskell %{pkgname} library.}\
2c0b10d
%if %{defined ghc_version} && %{undefined ghc_without_shared}\
23340a3
This package provides the shared library.\
086f1bc
%endif\
23340a3
\
23340a3
%ghc_lib_package\
d9a9b5f
%{nil}
23340a3
d9a9b5f
%ghc_pkg_recache %{_bindir}/ghc-pkg recache --no-user-package-conf || :
23340a3
cd30bb3
# (deprecated) for docs post and postun
cd30bb3
%ghc_reindex_haddock :
4e21230
086f1bc
# ghc_package_devel [-c cdepslist] [-h pkgdepslist] [-l licensetag] [name] [version]
086f1bc
%ghc_package_devel(c:h:l:)\
086f1bc
%define pkgname %{?1}%{!?1:%{pkg_name}}\
086f1bc
%define pkgver %{?2}%{!?2:%{version}}\
086f1bc
%define pkgnamever %{pkgname}-%{pkgver}\
086f1bc
%define basepkg ghc-%{pkgname}\
742ca58
%global _use_internal_dependency_generator 0\
a1abcaa
%global __find_provides %{_rpmconfigdir}/ghc-deps.sh --provides %{buildroot}%{ghclibdir}\
a1abcaa
%global __find_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\
086f1bc
%package -n %{basepkg}-devel\
232d016
Summary:        %{?common_summary}%{!?common_summary:Haskell %{pkgname} library} development files\
23340a3
Group:          Development/Libraries\
086f1bc
%{?1:Version:        %{pkgver}}\
23340a3
%{-l:License:        %{-l*}}\
7232a81
%{?ghc_devel_requires}\
23340a3
%{-h:Requires:       %{-h*}}\
eab5583
%{?ghc_pkg_c_deps:Requires:       %{ghc_pkg_c_deps}}\
23340a3
%{-c:Requires:       %{-c*}}\
742ca58
%{?ghc_pkg_obsoletes:Obsoletes:      %{ghc_pkg_obsoletes}}\
742ca58
%{?ghc_pkg_obsoletes:Obsoletes:      %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-doc/g")}\
086f1bc
Obsoletes:      %{basepkg}-doc < %{version}-%{release}\
cbf3d70
Provides:       %{basepkg}-doc = %{version}-%{release}\
1bc67af
Obsoletes:      %{basepkg}-prof < %{version}-%{release}\
1bc67af
Provides:       %{basepkg}-prof = %{version}-%{release}\
23340a3
\
086f1bc
%description -n %{basepkg}-devel\
086f1bc
%{?common_description}%{!?common_description:Haskell %{pkgname} library.}\
23340a3
\
23340a3
This package contains the development files.\
23340a3
\
086f1bc
%post -n %{basepkg}-devel\
d9a9b5f
%ghc_pkg_recache\
23340a3
\
086f1bc
%postun -n %{basepkg}-devel\
d9a9b5f
%ghc_pkg_recache\
23340a3
\
086f1bc
%files -n %{basepkg}-devel -f %{basepkg}-devel.files\
23340a3
%defattr(-,root,root,-)\
d9a9b5f
%{nil}
eaf2421
07f858e
# ghc_strip_dynlinked
4e07127
%ghc_strip_dynlinked\
2c0b10d
%if %{undefined __debug_package}\
b13abae
find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \\; -exec strip "{}" \\;\
4e07127
%endif
28ead10
28ead10
# ghc_bin_build
28ead10
%ghc_bin_build\
2c0b10d
%global debug_package %{nil}\
c6c20a5
%cabal_configure\
28ead10
%cabal build
28ead10
086f1bc
# ghc_lib_build [name] [version]
c6c20a5
%ghc_lib_build()\
2c0b10d
%global debug_package %{nil}\
086f1bc
%{?1:cd %1-%2}\
b13abae
%cabal_configure %{!?without_prof:-p} %{?1:--docdir=%{_docdir}/ghc-%1-%2 --htmldir=%{ghclibdocdir}/%1-%2}\
28ead10
%cabal build\
b13abae
%{!?without_haddock:%cabal haddock %{!?without_hscolour:--hyperlink-source}}\
c6c20a5
%{?1:cd -}\
c6c20a5
%{nil}
28ead10
c6c20a5
# install bin package
28ead10
%ghc_bin_install\
a1abcaa
%global _use_internal_dependency_generator 0\
a1abcaa
%global __find_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\
28ead10
%cabal_install\
28ead10
%ghc_strip_dynlinked
28ead10
086f1bc
# ghc_lib_install [name] [version]
c6c20a5
%ghc_lib_install()\
086f1bc
%{?1:cd %1-%2}\
28ead10
%cabal_install\
28ead10
%cabal_pkg_conf\
c6c20a5
%{?1:cd -}\
28ead10
%ghc_gen_filelists\
c6c20a5
%{!?1:%ghc_strip_dynlinked}\
c6c20a5
%{nil}