73b0bd1
# RPM Macros for packaging Haskell packages with multiple libs  -*-rpm-spec-*-
73b0bd1
338a2e1
# ghc_lib_subpackage [-c cdepslist] [-d] [-l licensetag] [-m] [-x] [name-version]
ebdd006
# for backward compat also support: ghc_lib_subpackage name version
338a2e1
%ghc_lib_subpackage(c:dl:mx)\
ebdd006
%define pkgname %{?2:%{1}}%{!?2:%{lua:\
8539a71
local pv = rpm.expand("%1")\
09527a5
local _, _, name = string.find(pv, "^([%a%d-]+)-")\
8539a71
print(name)\
ebdd006
}}\
ebdd006
%define pkgver %{?2}%{!?2:%{lua:\
8539a71
local pv = rpm.expand("%1")\
8539a71
print(string.sub(pv, string.find(pv, "[%d.]+$")))\
ebdd006
}}\
34a2770
%global ghc_subpackages_list %{?ghc_subpackages_list} %{pkgname}-%{pkgver}\
7a5198b
%{!-x:%{?1:%global ghc_packages_list %{?ghc_packages_list} %{pkgname}-%{pkgver}}}\
fb48383
%define ghc_prefix %{?ghc_name}%{!?ghc_name:ghc}\
f0f6b55
%define basepkg %{ghc_prefix}-%{pkgname}\
338a2e1
%if 0%{!-m:1}\
73b0bd1
%package -n %{basepkg}\
6dad230
Summary:        Haskell %{pkgname} library\
73b0bd1
%{?1:Version:        %{pkgver}}\
73b0bd1
%{-l:License:        %{-l*}}\
0b9d47c
Url:            https://hackage.haskell.org/package/%{pkgname}\
f0f6b55
%{?ghc_pkg_obsoletes:Obsoletes:      %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(%{ghc_prefix}-[^, ]*\\)-devel/\\1/g")}\
73b0bd1
\
ecaa014
%description -n %{basepkg}\
6dad230
This package provides the Haskell %{pkgname} library.\
73b0bd1
\
338a2e1
%endif\
73b0bd1
%package -n %{basepkg}-devel\
6dad230
Summary:        Haskell %{pkgname} library development files\
73b0bd1
%{?1:Version:        %{pkgver}}\
73b0bd1
%{-l:License:        %{-l*}}\
1d408a6
Provides:       %{basepkg}-static = %{pkgver}-%{release}\
c041659
Provides:       %{basepkg}-static%{?_isa} = %{pkgver}-%{release}\
1d408a6
Requires:       %{ghc_prefix}-compiler = %{ghc_version}%{?ghc_version_override:-%{release}}\
338a2e1
%if 0%{!-m:1}\
f0f6b55
Requires:       %{ghc_prefix}-%{pkgname}%{?_isa} = %{pkgver}-%{release}\
338a2e1
%endif\
73b0bd1
%{?ghc_pkg_c_deps:Requires:       %{ghc_pkg_c_deps}}\
73b0bd1
%{-c:Requires:       %{-c*}}\
73b0bd1
%{?ghc_pkg_obsoletes:Obsoletes:      %{ghc_pkg_obsoletes}}\
ecaa014
\
73b0bd1
%description -n %{basepkg}-devel\
6dad230
This package provides the Haskell %{pkgname} library development files.\
73b0bd1
\
338a2e1
%if 0%{!-m:1}\
35cd9d0
%if %{with haddock}\
7c7ff55
%package -n %{basepkg}-doc\
7c7ff55
Summary:        Haskell %{pkgname} library documentation\
7c7ff55
%{?1:Version:        %{pkgver}}\
7c7ff55
%{-l:License:        %{-l*}}\
2e40c5d
BuildArch:      noarch\
708a38b
Requires:       ghc-filesystem\
7c7ff55
Supplements:    (%{basepkg}-devel and ghc-doc)\
7c7ff55
\
7c7ff55
%description -n %{basepkg}-doc\
7c7ff55
This package provides the Haskell %{pkgname} library documentation.\
7c7ff55
%endif\
7c7ff55
\
35cd9d0
%if %{with ghc_prof}\
7c7ff55
%package -n %{basepkg}-prof\
7c7ff55
Summary:        Haskell %{pkgname} profiling library\
7c7ff55
%{?1:Version:        %{pkgver}}\
7c7ff55
%{-l:License:        %{-l*}}\
7c7ff55
Requires:       %{ghc_prefix}-%{pkgname}-devel%{?_isa} = %{pkgver}-%{release}\
7c7ff55
Supplements:    (%{basepkg}-devel and ghc-prof)\
7c7ff55
\
7c7ff55
%description -n %{basepkg}-prof\
7c7ff55
This package provides the Haskell %{pkgname} profiling library.\
7e15be0
%endif\
7c7ff55
\
7c7ff55
%files -n %{basepkg} -f %{!-d:%{pkgname}-%{pkgver}/}%{basepkg}.files\
6dad230
\
338a2e1
%endif\
f1517cd
%files -n %{basepkg}-devel -f %{!-d:%{pkgname}-%{pkgver}/}%{basepkg}-devel.files\
338a2e1
%if 0%{!-m:1}\
7c7ff55
\
35cd9d0
%if %{with haddock}\
a848de7
%files -n %{basepkg}-doc -f %{!-d:%{pkgname}-%{pkgver}/}%{basepkg}-doc.files\
7c7ff55
%endif\
7c7ff55
\
35cd9d0
%if %{with ghc_prof}\
7c7ff55
%files -n %{basepkg}-prof -f %{!-d:%{pkgname}-%{pkgver}/}%{basepkg}-prof.files\
7e15be0
%endif\
338a2e1
%endif\
73b0bd1
%{nil}
986f88a
ad5af67
# ghc_libs_build [name-version] ...
40e1493
%ghc_libs_build()\
986f88a
HOME=$PWD\
89fc885
%global ghc_subpackaging 1\
986f88a
for i in %*; do\
96d4e68
name=$(echo $i | sed -e "s/\\(.*\\)-.*/\\1/")\
96d4e68
ver=$(echo $i | sed -e "s/.*-\\(.*\\)/\\1/")\
986f88a
cd $name-$ver\
986f88a
case $name in\
986f88a
haskell-platform)\
986f88a
%ghc_lib_build_without_haddock $name $ver\
986f88a
;;\
986f88a
*)\
986f88a
%ghc_lib_build $name $ver\
986f88a
./Setup register --inplace\
986f88a
;;\
986f88a
esac\
986f88a
cd ..\
986f88a
done\
986f88a
%{nil}
986f88a
ad5af67
# ghc_libs_install [name-version] ...
40e1493
%ghc_libs_install()\
986f88a
HOME=$PWD\
411d61d
args="%*"\
411d61d
for i in $args; do\
411d61d
cd $i\
96d4e68
name=$(echo $i | sed -e "s/\\(.*\\)-.*/\\1/")\
96d4e68
ver=$(echo $i | sed -e "s/.*-\\(.*\\)/\\1/")\
986f88a
%ghc_lib_install $name $ver\
986f88a
cd ..\
986f88a
done\
986f88a
%{nil}