2011-02-12 15:07:05 +00:00
|
|
|
# RPM Macros for packaging Haskell cabalized packages -*-rpm-spec-*-
|
2013-04-23 09:12:25 +00:00
|
|
|
# see https://fedoraproject.org/wiki/Packaging:Haskell for more details
|
2011-02-10 12:11:02 +00:00
|
|
|
|
2010-06-20 12:10:25 +00:00
|
|
|
# "cabal"
|
2013-04-24 07:08:41 +00:00
|
|
|
%cabal [ -x Setup ] || ghc --make %{!?ghc_user_conf:-no-user-package-db} %{!?ghc_without_dynamic:-dynamic} Setup\
|
2011-01-23 05:05:38 +00:00
|
|
|
./Setup
|
2009-05-13 07:37:39 +00:00
|
|
|
|
2011-06-17 03:29:21 +00:00
|
|
|
# check ghc version was rebuilt against self
|
|
|
|
%ghc_check_bootstrap\
|
2011-03-28 07:45:18 +00:00
|
|
|
if [ ! "$(ghc --info | grep \\"Booter\\ version\\",\\"%{ghc_version}\\")" ]; then\
|
2011-06-17 08:00:17 +00:00
|
|
|
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."\
|
2011-06-17 08:11:17 +00:00
|
|
|
echo "To override set ghc_bootstrapping."\
|
2011-06-17 03:29:21 +00:00
|
|
|
echo "Aborting."\
|
2011-03-28 06:57:59 +00:00
|
|
|
exit 1\
|
|
|
|
%endif\
|
2011-06-17 03:29:21 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# configure
|
|
|
|
%cabal_configure\
|
|
|
|
%ghc_check_bootstrap\
|
2014-02-10 09:36:05 +00:00
|
|
|
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_pkgdocdir} --libsubdir='$compiler/$pkgid' --datasubdir='$pkgid' --ghc %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?cabal_configure_options} $cabal_configure_extra_options
|
2009-12-23 14:42:16 +00:00
|
|
|
|
2010-06-20 12:10:25 +00:00
|
|
|
# install
|
2011-01-03 11:37:32 +00:00
|
|
|
%cabal_install %cabal copy --destdir=%{buildroot} -v
|
2009-05-13 07:37:39 +00:00
|
|
|
|
2010-06-20 12:10:25 +00:00
|
|
|
# root dir for ghc docs
|
2010-01-10 14:59:10 +00:00
|
|
|
%ghcdocbasedir %{_docdir}/ghc/html
|
2011-01-22 12:48:18 +00:00
|
|
|
# libraries doc dir
|
|
|
|
%ghclibdocdir %{ghcdocbasedir}/libraries
|
2013-10-15 09:08:08 +00:00
|
|
|
# pkg doc dir
|
|
|
|
%ghcpkgdocdir %{ghcdocbasedir}/libraries/%{pkg_name}
|
2010-06-20 12:10:25 +00:00
|
|
|
# top library dir
|
2011-01-03 11:37:32 +00:00
|
|
|
%ghclibdir %{_libdir}/ghc-%{ghc_version}
|
2010-12-30 12:19:29 +00:00
|
|
|
|
2011-01-03 11:37:32 +00:00
|
|
|
# ghc_gen_filelists [name] [version]
|
2010-12-30 12:19:29 +00:00
|
|
|
%ghc_gen_filelists()\
|
2011-01-03 11:37:32 +00:00
|
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
|
|
%define pkgnamever %{pkgname}-%{pkgver}\
|
|
|
|
%define basepkg ghc-%{pkgname}\
|
|
|
|
%define pkgdir %{ghclibdir}/%{pkgnamever}\
|
2013-08-27 10:31:45 +00:00
|
|
|
%define docdir %{ghclibdocdir}/%{pkgname}\
|
2011-05-16 01:58:56 +00:00
|
|
|
rm -f %{basepkg}.files %{basepkg}-devel.files\
|
2013-02-26 17:32:00 +00:00
|
|
|
if [ -d "%{buildroot}%{pkgdir}" ]; then\
|
2013-04-23 09:12:25 +00:00
|
|
|
echo "%dir %{pkgdir}" >> %{basepkg}.files\
|
2011-02-12 15:07:05 +00:00
|
|
|
%if %{undefined ghc_without_shared}\
|
2011-01-03 11:37:32 +00:00
|
|
|
echo "%attr(755,root,root) %{pkgdir}/libHS%{pkgnamever}-ghc%{ghc_version}.so" >> %{basepkg}.files\
|
|
|
|
%endif\
|
2013-02-26 17:32:00 +00:00
|
|
|
fi\
|
2011-01-03 11:37:32 +00:00
|
|
|
echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf" >> %{basepkg}-devel.files\
|
|
|
|
if [ -d "%{buildroot}%{pkgdir}" ]; then\
|
2013-01-18 09:52:08 +00:00
|
|
|
find %{buildroot}%{pkgdir} -mindepth 1 -type d | sed "s/^/%dir /" >> %{basepkg}-devel.files\
|
2011-05-16 01:58:56 +00:00
|
|
|
find %{buildroot}%{pkgdir} ! \\( -type d -o -name "libHS*.so" \\) >> %{basepkg}-devel.files\
|
2011-01-03 11:37:32 +00:00
|
|
|
fi\
|
|
|
|
if [ -d "%{buildroot}%{docdir}" ]; then\
|
|
|
|
echo "%{docdir}" >> %{basepkg}-devel.files\
|
|
|
|
fi\
|
2013-04-23 09:12:25 +00:00
|
|
|
for i in %{basepkg}.files %{basepkg}-devel.files; do\
|
2012-05-25 14:52:09 +00:00
|
|
|
if [ -f "$i" ]; then\
|
2012-05-25 13:10:06 +00:00
|
|
|
sed -i -e "s!%{buildroot}!!g" $i\
|
|
|
|
fi\
|
|
|
|
done\
|
2009-05-13 07:37:39 +00:00
|
|
|
%{nil}
|
|
|
|
|
2010-06-20 12:10:25 +00:00
|
|
|
# compiler version
|
2009-12-15 21:50:31 +00:00
|
|
|
%ghc_version %{!?ghc_version_override:%(ghc --numeric-version)}%{?ghc_version_override}
|
2009-11-16 07:45:33 +00:00
|
|
|
|
2010-06-20 12:10:25 +00:00
|
|
|
# create and install package.conf file
|
2011-01-03 11:37:32 +00:00
|
|
|
# cabal_pkg_conf [name] [version]
|
2010-12-30 12:19:29 +00:00
|
|
|
%cabal_pkg_conf()\
|
2011-01-03 11:37:32 +00:00
|
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
|
|
%define pkgnamever %{pkgname}-%{pkgver}\
|
|
|
|
%cabal register --gen-pkg-config\
|
2013-10-15 09:08:08 +00:00
|
|
|
install -D --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf.d/%{pkgnamever}.conf\
|
2010-12-30 12:19:29 +00:00
|
|
|
%{nil}
|
2010-04-12 14:52:34 +00:00
|
|
|
|
2010-06-26 08:53:39 +00:00
|
|
|
# ghc_bin_build
|
|
|
|
%ghc_bin_build\
|
2011-02-12 15:07:05 +00:00
|
|
|
%global debug_package %{nil}\
|
2010-12-30 12:19:29 +00:00
|
|
|
%cabal_configure\
|
2010-06-26 08:53:39 +00:00
|
|
|
%cabal build
|
|
|
|
|
2012-06-05 02:40:54 +00:00
|
|
|
# ghc_lib_build_without_haddock [name] [version]
|
|
|
|
%ghc_lib_build_without_haddock()\
|
2011-02-12 15:07:05 +00:00
|
|
|
%global debug_package %{nil}\
|
2013-08-27 10:31:45 +00:00
|
|
|
%cabal_configure %{!?without_prof:-p} %{!?ghc_without_shared:--enable-shared} %{?pkg_name:--htmldir=%{ghclibdocdir}/%{pkg_name}} %{?1:--docdir=%{_docdir}/ghc-%1 --htmldir=%{ghclibdocdir}/%1} %{!?1:--global} %{?ghc_with_lib_for_ghci:--enable-library-for-ghci} --ghc-option=-O2\
|
2010-06-26 08:53:39 +00:00
|
|
|
%cabal build\
|
2012-06-05 02:40:54 +00:00
|
|
|
%{nil}
|
|
|
|
|
|
|
|
# ghc_lib_build [name] [version]
|
|
|
|
%ghc_lib_build()\
|
2012-06-05 10:16:29 +00:00
|
|
|
%ghc_lib_build_without_haddock\
|
2011-11-17 05:36:50 +00:00
|
|
|
%if %{undefined without_haddock}\
|
2012-10-09 03:25:41 +00:00
|
|
|
%cabal haddock --html %{!?without_hscolour:%(if [ -x %{_bindir}/HsColour ]; then echo --hyperlink-source; fi)} --hoogle\
|
2011-11-17 05:36:50 +00:00
|
|
|
%endif\
|
2010-12-30 12:19:29 +00:00
|
|
|
%{nil}
|
2010-06-26 08:53:39 +00:00
|
|
|
|
2013-07-10 07:32:39 +00:00
|
|
|
# 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
|
|
|
|
|
|
|
|
# ghc_clear_execstack
|
|
|
|
%ghc_clear_execstack\
|
2013-07-11 01:41:16 +00:00
|
|
|
if [ -d "%{buildroot}%{_bindir}" ]; then\
|
|
|
|
find %{buildroot}%{_bindir} -type f -exec sh -c "file {} | grep -q ' ELF '" \\; -exec execstack -c "{}" \\;\
|
|
|
|
fi
|
2013-07-10 07:32:39 +00:00
|
|
|
|
2010-12-30 12:19:29 +00:00
|
|
|
# install bin package
|
2012-06-07 11:14:06 +00:00
|
|
|
%ghc_bin_install()\
|
2011-01-23 05:05:38 +00:00
|
|
|
%global _use_internal_dependency_generator 0\
|
|
|
|
%global __find_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\
|
2010-06-26 08:53:39 +00:00
|
|
|
%cabal_install\
|
2012-06-07 11:14:06 +00:00
|
|
|
%{!?1:%ghc_strip_dynlinked}\
|
2013-07-10 07:32:39 +00:00
|
|
|
%{!?1:%ghc_clear_execstack}\
|
2012-06-07 11:14:06 +00:00
|
|
|
%{nil}
|
2010-06-26 08:53:39 +00:00
|
|
|
|
2011-01-03 11:37:32 +00:00
|
|
|
# ghc_lib_install [name] [version]
|
2010-12-30 12:19:29 +00:00
|
|
|
%ghc_lib_install()\
|
2011-07-01 04:54:49 +00:00
|
|
|
%global _use_internal_dependency_generator 0\
|
|
|
|
%global __find_provides %{_rpmconfigdir}/ghc-deps.sh --provides %{buildroot}%{ghclibdir}\
|
|
|
|
%global __find_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\
|
2010-06-26 08:53:39 +00:00
|
|
|
%cabal_install\
|
|
|
|
%cabal_pkg_conf\
|
|
|
|
%ghc_gen_filelists\
|
2010-12-30 12:19:29 +00:00
|
|
|
%{!?1:%ghc_strip_dynlinked}\
|
2013-07-10 07:32:39 +00:00
|
|
|
%{!?1:%ghc_clear_execstack}\
|
2010-12-30 12:19:29 +00:00
|
|
|
%{nil}
|
2011-06-17 08:00:17 +00:00
|
|
|
|
2013-01-22 02:31:08 +00:00
|
|
|
# ghc_fix_dynamic_rpath prog ...
|
|
|
|
%ghc_fix_dynamic_rpath()\
|
|
|
|
%if %{undefined ghc_without_dynamic}\
|
|
|
|
PDIR=$(cd ..; pwd)\
|
|
|
|
for i in %*; do\
|
|
|
|
PROG=%{buildroot}%{_bindir}/$i\
|
2014-01-10 01:54:19 +00:00
|
|
|
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\
|
2014-01-10 02:48:58 +00:00
|
|
|
echo "%%ghc_fix_dynamic_rpath: no such file $PROG"\
|
2014-01-10 01:54:19 +00:00
|
|
|
exit 1\
|
|
|
|
fi\
|
2013-01-22 02:31:08 +00:00
|
|
|
done\
|
|
|
|
%endif\
|
|
|
|
%{nil}
|
|
|
|
|
2013-05-04 14:34:41 +00:00
|
|
|
%ghc_pkg_recache %{_bindir}/ghc-pkg recache --no-user-package-db || :
|
|
|
|
|
2012-02-23 09:10:50 +00:00
|
|
|
# - without_hscolour, without_testsuite, and ghc_bootstrapping
|
|
|
|
# need to be set locally in the spec file
|
2011-09-13 01:14:17 +00:00
|
|
|
|
|
|
|
# skip prof libs, and documentation
|
|
|
|
%ghc_test\
|
|
|
|
%global without_prof 1\
|
|
|
|
%global without_haddock 1\
|
|
|
|
%global without_manual 1
|
2012-02-23 09:10:50 +00:00
|
|
|
|
|
|
|
# skip shared and prof libs, documentation, and testsuite
|
|
|
|
%ghc_bootstrap\
|
|
|
|
%global ghc_without_shared 1\
|
|
|
|
%global ghc_without_dynamic 1\
|
|
|
|
%ghc_test
|