You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
5.0 KiB
156 lines
5.0 KiB
# RPM Macros for packaging Haskell cabalized packages -*-rpm-spec-*-
|
|
# see https://fedoraproject.org/wiki/Packaging:Haskell for more details
|
|
|
|
# "cabal"
|
|
%cabal [ -x Setup ] || ghc --make %{!?ghc_user_conf:-no-user-package-db} %{!?ghc_without_dynamic:-dynamic} Setup\
|
|
./Setup
|
|
|
|
# check ghc version was rebuilt against self
|
|
%ghc_check_bootstrap\
|
|
if [ ! "$(ghc --info | grep \\"Booter\\ version\\",\\"%{ghc_version}\\")" ]; then\
|
|
echo "Warning: this ghc build is not self-bootstrapped."\
|
|
%if %{undefined ghc_bootstrapping}\
|
|
echo "The ghc package should be rebuilt against its current version before\
|
|
proceeding, to avoid dependency ABI breakage from a future ghc rebuild."\
|
|
echo "To override set ghc_bootstrapping."\
|
|
echo "Aborting."\
|
|
exit 1\
|
|
%endif\
|
|
fi
|
|
|
|
# configure
|
|
%cabal_configure\
|
|
%ghc_check_bootstrap\
|
|
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{?_pkgdocdir}%{!?_pkgdocdir:%{_docdir}/%{name}-%{version}} --libsubdir='$compiler/$pkgid' --datasubdir='$pkgid' --ghc %{!?ghc_without_dynamic:--enable-executable-dynamic} --ghc-option=-O2 %{?with_tests:--enable-tests} %{?cabal_configure_options} $cabal_configure_extra_options
|
|
|
|
# install
|
|
%cabal_install %cabal copy --destdir=%{buildroot} -v
|
|
|
|
# root dir for ghc docs
|
|
%ghcdocbasedir %{_docdir}/ghc/html
|
|
# libraries doc dir
|
|
%ghclibdocdir %{ghcdocbasedir}/libraries
|
|
# pkg doc dir
|
|
%ghcpkgdocdir %{ghcdocbasedir}/libraries/%{pkg_name}
|
|
# top library dir
|
|
%ghclibdir %{_libdir}/ghc-%{ghc_version}
|
|
|
|
# ghc_gen_filelists [name] [version]
|
|
%ghc_gen_filelists()\
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
%define pkgnamever %{pkgname}-%{pkgver}\
|
|
%define basepkg ghc-%{pkgname}\
|
|
%define pkgdir %{ghclibdir}/%{pkgnamever}\
|
|
%define docdir %{ghclibdocdir}/%{pkgname}\
|
|
rm -f %{basepkg}.files %{basepkg}-devel.files\
|
|
if [ -d "%{buildroot}%{pkgdir}" ]; then\
|
|
echo "%dir %{pkgdir}" >> %{basepkg}.files\
|
|
%if %{undefined ghc_without_shared}\
|
|
echo "%attr(755,root,root) %{pkgdir}/libHS%{pkgnamever}-ghc%{ghc_version}.so" >> %{basepkg}.files\
|
|
%endif\
|
|
fi\
|
|
echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf" >> %{basepkg}-devel.files\
|
|
if [ -d "%{buildroot}%{pkgdir}" ]; then\
|
|
find %{buildroot}%{pkgdir} -mindepth 1 -type d | sed "s/^/%dir /" >> %{basepkg}-devel.files\
|
|
find %{buildroot}%{pkgdir} ! \\( -type d -o -name "libHS*.so" \\) >> %{basepkg}-devel.files\
|
|
fi\
|
|
if [ -d "%{buildroot}%{docdir}" ]; then\
|
|
echo "%{docdir}" >> %{basepkg}-devel.files\
|
|
fi\
|
|
for i in %{basepkg}.files %{basepkg}-devel.files; do\
|
|
if [ -f "$i" ]; then\
|
|
sed -i -e "s!%{buildroot}!!g" $i\
|
|
fi\
|
|
done\
|
|
%{nil}
|
|
|
|
# compiler version
|
|
%ghc_version %{!?ghc_version_override:%(ghc --numeric-version)}%{?ghc_version_override}
|
|
|
|
# create and install package.conf file
|
|
# cabal_pkg_conf [name] [version]
|
|
%cabal_pkg_conf()\
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
%define pkgnamever %{pkgname}-%{pkgver}\
|
|
%cabal register --gen-pkg-config\
|
|
install -D --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf.d/%{pkgnamever}.conf\
|
|
%{nil}
|
|
|
|
# ghc_bin_build
|
|
%ghc_bin_build\
|
|
%global debug_package %{nil}\
|
|
%cabal_configure\
|
|
%cabal build
|
|
|
|
# ghc_lib_build_without_haddock [name] [version]
|
|
%ghc_lib_build_without_haddock()\
|
|
%global debug_package %{nil}\
|
|
%cabal_configure %{!?without_prof:-p} %{!?ghc_without_shared:--enable-shared} %{?pkg_name:--htmldir=%{ghclibdocdir}/%{pkg_name}} %{?1:--docdir=%{_docdir}/ghc-%1%{!?fedora:-%2} --htmldir=%{ghclibdocdir}/%1} %{!?1:--global} %{?ghc_with_lib_for_ghci:--enable-library-for-ghci}\
|
|
%cabal build\
|
|
%{nil}
|
|
|
|
# ghc_lib_build [name] [version]
|
|
%ghc_lib_build()\
|
|
%ghc_lib_build_without_haddock\
|
|
%if %{undefined without_haddock}\
|
|
%cabal haddock --html %{!?without_hscolour:%(if [ -x %{_bindir}/HsColour ]; then echo --hyperlink-source; fi)} --hoogle\
|
|
%endif\
|
|
%{nil}
|
|
|
|
# ghc_strip_dynlinked
|
|
%ghc_strip_dynlinked\
|
|
%if %{undefined __debug_package}\
|
|
find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \\; -exec strip "{}" \\;\
|
|
%endif
|
|
|
|
# install bin package
|
|
%ghc_bin_install()\
|
|
%cabal_install\
|
|
%{!?1:%ghc_strip_dynlinked}\
|
|
%{nil}
|
|
|
|
# ghc_lib_install [name] [version]
|
|
%ghc_lib_install()\
|
|
%cabal_install\
|
|
%cabal_pkg_conf\
|
|
%ghc_gen_filelists\
|
|
%{!?1:%ghc_strip_dynlinked}\
|
|
%{nil}
|
|
|
|
# ghc_fix_dynamic_rpath prog ...
|
|
# (assumes cwd = pkg_name !)
|
|
%ghc_fix_dynamic_rpath()\
|
|
%if %{undefined ghc_without_dynamic}\
|
|
if ! type chrpath > /dev/null; then exit 1; fi\
|
|
PDIR=$(cd ..; pwd)\
|
|
for i in %*; do\
|
|
PROG=%{buildroot}%{_bindir}/$i\
|
|
if [ -x "$PROG" ]; then\
|
|
RPATH=$(chrpath $PROG | sed -e "s@^$PROG: RPATH=@@")\
|
|
case $RPATH in\
|
|
*$PDIR*)\
|
|
NEWRPATH=$(echo $RPATH | sed -e "s@$PDIR@%{ghclibdir}@g" -e "s@/dist/build@@g")\
|
|
chrpath -r $NEWRPATH $PROG\
|
|
;;\
|
|
esac\
|
|
else\
|
|
echo "%%ghc_fix_dynamic_rpath: no such file $PROG"\
|
|
exit 1\
|
|
fi\
|
|
done\
|
|
%endif\
|
|
%{nil}
|
|
|
|
%ghc_pkg_recache %{_bindir}/ghc-pkg recache --no-user-package-db || :
|
|
|
|
# - without_hscolour, without_testsuite, and ghc_bootstrapping
|
|
# need to be set locally in the spec file
|
|
|
|
# skip prof libs and documentation
|
|
%ghc_bootstrap\
|
|
%global without_prof 1\
|
|
%global without_haddock 1\
|
|
%global without_manual 1
|