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\
|
2015-05-07 10:14:08 +00:00
|
|
|
LANG=en_US.utf8\
|
2011-01-23 05:05:38 +00:00
|
|
|
./Setup
|
2009-05-13 07:37:39 +00:00
|
|
|
|
2017-02-08 06:26:07 +00:00
|
|
|
# compiler version
|
|
|
|
%ghc_version %{!?ghc_version_override:%(ghc --numeric-version)}%{?ghc_version_override}
|
|
|
|
|
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
|
|
|
|
|
2017-12-04 12:24:21 +00:00
|
|
|
%ghc_set_cflags\
|
2017-11-10 02:49:21 +00:00
|
|
|
# -Wunused-label is extremely noisy\
|
|
|
|
%ifarch aarch64 s390x\
|
2017-11-10 03:12:46 +00:00
|
|
|
CFLAGS="${CFLAGS:-$(echo %optflags | sed -e 's/-Wall -Werror=format-security //')}"\
|
2017-11-10 02:49:21 +00:00
|
|
|
%else\
|
|
|
|
CFLAGS="${CFLAGS:-%optflags}"\
|
|
|
|
%endif\
|
|
|
|
export CFLAGS\
|
2017-12-04 12:24:21 +00:00
|
|
|
%{nil}
|
|
|
|
|
|
|
|
# configure
|
|
|
|
%cabal_configure\
|
|
|
|
%ghc_check_bootstrap\
|
|
|
|
%ghc_set_cflags\
|
|
|
|
%global _hardened_ldflags %{nil}\
|
2018-01-25 06:23:26 +00:00
|
|
|
LDFLAGS="${LDFLAGS:-$(echo %{?__global_ldflags} | sed -e 's/-Wl,-z,defs//')}"; export LDFLAGS\
|
2017-03-26 10:57:33 +00:00
|
|
|
%cabal --version\
|
2018-01-22 08:03:51 +00:00
|
|
|
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_ghcdocdir} --libsubdir='$compiler/$pkgkey' --datasubdir='$pkgid' --ghc --dynlibdir=%{_ghcdynlibdir} %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?with_tests:--enable-tests} %{?ghc_subpackaging:--user}%{!?ghc_subpackaging:--global} --ghc-options="${CFLAGS:+$(echo ' '$CFLAGS | sed -e 's/ / -optc/g')} ${LDFLAGS:+$(echo ' '$LDFLAGS | sed -e 's/ / -optl/g')}" %{?cabal_configure_options} $cabal_configure_extra_options
|
2009-12-23 14:42:16 +00:00
|
|
|
|
2010-06-20 12:10:25 +00:00
|
|
|
# install
|
2017-02-08 06:26:07 +00:00
|
|
|
%cabal_install %cabal copy --destdir=%{buildroot} %{?cabal_install_options}
|
2009-05-13 07:37:39 +00:00
|
|
|
|
2015-10-08 10:20:20 +00:00
|
|
|
# tests
|
2015-01-31 20:22:21 +00:00
|
|
|
%cabal_test\
|
|
|
|
%if %{with tests}\
|
2017-02-08 06:26:07 +00:00
|
|
|
%cabal test %{?cabal_test_options}\
|
2015-01-31 20:22:21 +00:00
|
|
|
%endif
|
|
|
|
|
2015-03-20 08:39:03 +00:00
|
|
|
# no _pkgdocdir in EPEL <= 7
|
|
|
|
%ghc_pkgdocdir %{?_pkgdocdir}%{!?_pkgdocdir:%{_docdir}/%{name}-%{version}}
|
|
|
|
|
2015-01-22 04:46:10 +00:00
|
|
|
# root dir for ghc docs (used by ghc.spec)
|
2016-06-03 04:16:35 +00:00
|
|
|
%ghc_html_dir %{_docdir}/ghc/html
|
2015-01-22 04:46:10 +00:00
|
|
|
# deprecates
|
2015-05-09 02:55:12 +00:00
|
|
|
%ghcdocbasedir %ghc_html_dir
|
2015-01-22 04:46:10 +00:00
|
|
|
|
|
|
|
# libraries doc dir (internal)
|
|
|
|
%ghc_html_libraries_dir %{ghc_html_dir}/libraries
|
|
|
|
# deprecates
|
2015-05-09 02:55:12 +00:00
|
|
|
%ghclibdocdir %ghc_html_libraries_dir
|
2015-01-22 04:46:10 +00:00
|
|
|
|
2013-10-15 09:08:08 +00:00
|
|
|
# pkg doc dir
|
2015-01-22 04:46:10 +00:00
|
|
|
%ghc_html_pkg_dir %{ghc_html_libraries_dir}/%{pkg_name}-%{version}
|
|
|
|
# deprecates
|
2015-05-09 02:55:12 +00:00
|
|
|
%ghcpkgdocdir %ghc_html_pkg_dir
|
2015-01-22 04:46:10 +00:00
|
|
|
|
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
|
|
|
|
2017-07-30 20:05:03 +00:00
|
|
|
%_ghclicensedir %{?_defaultlicensedir}%{!?_defaultlicensedir:%_docdir}
|
|
|
|
|
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}\
|
2015-03-07 13:38:07 +00:00
|
|
|
%define basepkg %{?ghc_name}%{!?ghc_name:ghc}-%{pkgname}\
|
2015-01-17 09:38:55 +00:00
|
|
|
%define docdir %{ghclibdocdir}/%{pkgnamever}\
|
2017-09-13 10:17:01 +00:00
|
|
|
if [ ! -f %{buildroot}%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf ]; then\
|
|
|
|
echo "%{buildroot}%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf not found"\
|
2017-08-02 10:00:01 +00:00
|
|
|
exit 1\
|
|
|
|
fi\
|
2017-03-03 01:04:39 +00:00
|
|
|
pkgconf=$(echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf")\
|
|
|
|
key=$(grep "key: " %{buildroot}${pkgconf} | sed -e "s/key: //")\
|
|
|
|
pkgdir="%{ghclibdir}/${key}"\
|
2011-05-16 01:58:56 +00:00
|
|
|
rm -f %{basepkg}.files %{basepkg}-devel.files\
|
2015-01-31 18:14:30 +00:00
|
|
|
touch %{basepkg}.files %{basepkg}-devel.files\
|
2017-03-03 01:04:39 +00:00
|
|
|
echo ${pkgconf} >> %{basepkg}-devel.files\
|
2016-06-03 04:16:35 +00:00
|
|
|
if [ -d "%{buildroot}${pkgdir}" ]; then\
|
2018-01-22 08:03:51 +00:00
|
|
|
echo "%%attr(755,root,root) %{_ghcdynlibdir}/libHS%{pkgnamever}-*ghc%{ghc_version}.so" >> %{basepkg}.files\
|
|
|
|
echo "${pkgdir}" >> %{basepkg}-devel.files\
|
2011-01-03 11:37:32 +00:00
|
|
|
fi\
|
|
|
|
if [ -d "%{buildroot}%{docdir}" ]; then\
|
|
|
|
echo "%{docdir}" >> %{basepkg}-devel.files\
|
|
|
|
fi\
|
2017-02-08 06:26:07 +00:00
|
|
|
%if 0%{?1:1}\
|
2017-07-30 20:05:03 +00:00
|
|
|
for i in $(ls %{buildroot}%{_ghclicensedir}/%{!?1:%{name}}%{?1:%{basepkg}}); do\
|
2017-02-09 01:51:32 +00:00
|
|
|
echo "%%license %{?1:%{pkgnamever}/}$i" >> %{basepkg}.files\
|
2016-08-26 12:21:24 +00:00
|
|
|
done\
|
2017-02-08 06:26:07 +00:00
|
|
|
%endif\
|
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
|
|
|
# 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\
|
2016-06-06 08:22:42 +00:00
|
|
|
%global debug_package %{nil}\
|
2010-12-30 12:19:29 +00:00
|
|
|
%cabal_configure\
|
2017-07-30 20:05:03 +00:00
|
|
|
%cabal build %{?ghc_smp_mflags} %{?cabal_build_options}
|
2010-06-26 08:53:39 +00:00
|
|
|
|
2012-06-05 02:40:54 +00:00
|
|
|
# ghc_lib_build_without_haddock [name] [version]
|
|
|
|
%ghc_lib_build_without_haddock()\
|
2016-06-06 08:22:42 +00:00
|
|
|
%global debug_package %{nil}\
|
2017-11-14 10:22:31 +00:00
|
|
|
%if 0%{?rhel} && 0%{?rhel} < 8\
|
2017-11-15 02:25:18 +00:00
|
|
|
licensedirversion=%{?2:-%2}\
|
2017-11-14 10:22:31 +00:00
|
|
|
%endif\
|
2018-01-22 08:03:51 +00:00
|
|
|
%cabal_configure %{!?without_prof:-p} --enable-shared %{?pkg_name:--htmldir=%{ghclibdocdir}/%{pkg_name}-%{version}} %{?1:--docdir=%{_ghclicensedir}/ghc-%1${licensedirversion} --htmldir=%{ghclibdocdir}/%1-%2} %{?ghc_subpackaging:--user}%{!?ghc_subpackaging:--global} %{?ghc_with_lib_for_ghci:--enable-library-for-ghci}\
|
2017-07-30 20:05:03 +00:00
|
|
|
%cabal build %{?ghc_smp_mflags} %{?cabal_build_options}\
|
2012-06-05 02:40:54 +00:00
|
|
|
%{nil}
|
|
|
|
|
|
|
|
# ghc_lib_build [name] [version]
|
|
|
|
%ghc_lib_build()\
|
2017-09-13 09:36:31 +00:00
|
|
|
%ghc_lib_build_without_haddock %{?1} %{?2}\
|
2011-11-17 05:36:50 +00:00
|
|
|
%if %{undefined without_haddock}\
|
2015-01-31 18:03:52 +00:00
|
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
2017-03-24 09:17:14 +00:00
|
|
|
if [ -n dist/build/libHS%{pkgname}-%{pkgver}*.so ]; then\
|
2017-02-08 06:26:07 +00:00
|
|
|
%cabal haddock --html %{!?without_hscolour:%(if [ -x %{_bindir}/HsColour ]; then echo --hyperlink-source; fi)} --hoogle %{?cabal_haddock_options}\
|
2015-01-31 18:03:52 +00:00
|
|
|
fi\
|
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
|
|
|
|
|
2010-12-30 12:19:29 +00:00
|
|
|
# install bin package
|
2012-06-07 11:14:06 +00:00
|
|
|
%ghc_bin_install()\
|
2016-06-03 04:16:35 +00:00
|
|
|
%{!?_fileattrsdir:%global _use_internal_dependency_generator 0}\
|
|
|
|
%{!?_fileattrsdir:%global __find_requires %{_rpmconfigdir}/ghc-deps.sh %{buildroot}%{ghclibdir}}\
|
2010-06-26 08:53:39 +00:00
|
|
|
%cabal_install\
|
2012-06-07 11:14:06 +00:00
|
|
|
%{!?1:%ghc_strip_dynlinked}\
|
2017-03-03 02:00:57 +00:00
|
|
|
%{?ghc_subpackaging:%ghc_fix_rpath %{subpkgs}}\
|
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()\
|
2016-06-03 04:16:35 +00:00
|
|
|
%{!?_fileattrsdir:%global _use_internal_dependency_generator 0}\
|
|
|
|
%{!?_fileattrsdir:%global __find_provides %{_rpmconfigdir}/rpmdeps --provides}\
|
|
|
|
%{!?_fileattrsdir:%global __find_requires %{_rpmconfigdir}/ghc-deps.sh %{buildroot}%{ghclibdir}}\
|
2010-06-26 08:53:39 +00:00
|
|
|
%cabal_install\
|
2017-09-13 09:36:31 +00:00
|
|
|
%cabal_pkg_conf %{?1} %{?2}\
|
|
|
|
%ghc_gen_filelists %{?1} %{?2}\
|
2010-12-30 12:19:29 +00:00
|
|
|
%{!?1:%ghc_strip_dynlinked}\
|
2017-03-03 02:00:57 +00:00
|
|
|
%{?ghc_subpackaging:%ghc_fix_rpath %{subpkgs}}\
|
2010-12-30 12:19:29 +00:00
|
|
|
%{nil}
|
2011-06-17 08:00:17 +00:00
|
|
|
|
2016-09-27 05:30:59 +00:00
|
|
|
# ghc_fix_rpath lib-ver ...
|
|
|
|
%ghc_fix_rpath()\
|
|
|
|
%if %{undefined ghc_without_dynamic}\
|
|
|
|
if ! type chrpath > /dev/null; then exit 1; fi\
|
|
|
|
for i in $(find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \\; -print); do\
|
2017-02-22 05:28:31 +00:00
|
|
|
for lib in %*; do\
|
2016-09-27 05:30:59 +00:00
|
|
|
if [ -x "$i" ]; then\
|
2017-02-08 06:26:07 +00:00
|
|
|
rpath=$(chrpath $i | sed -e "s@^$i: R.*PATH=@@")\
|
|
|
|
case $rpath in\
|
2017-02-22 05:28:31 +00:00
|
|
|
*$PWD/$lib/dist/build*)\
|
2017-04-07 10:09:23 +00:00
|
|
|
case %{ghc_version} in\
|
|
|
|
7.10.*)\
|
|
|
|
pkgid=$(cd %{buildroot}%{ghclibdir}/package.conf.d; ls ${lib}* | sed -e "s/.conf$//")\
|
|
|
|
syspath=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} --package-db=%{buildroot}%{ghclibdir}/package.conf.d field $pkgid library-dirs) ;;\
|
2018-01-22 08:03:51 +00:00
|
|
|
8.0)\
|
2017-04-07 10:09:23 +00:00
|
|
|
pkgid=$(cd %{buildroot}%{ghclibdir}; echo ${lib}*)\
|
|
|
|
syspath=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} --package-db=%{buildroot}%{ghclibdir}/package.conf.d field $lib library-dirs | grep $pkgid) ;;\
|
2018-01-22 08:03:51 +00:00
|
|
|
*)\
|
|
|
|
syspath="" ;;\
|
2017-04-07 10:09:23 +00:00
|
|
|
esac\
|
2018-01-23 14:24:11 +00:00
|
|
|
newrpath=$(echo $rpath | sed -e "s@$PWD/$lib/dist/build@${syspath}@g" -e "s/::/:/" -e "s/^://" -e "s/:$//")\
|
2017-02-08 06:26:07 +00:00
|
|
|
chrpath -r $newrpath $i\
|
2016-09-27 05:30:59 +00:00
|
|
|
;;\
|
|
|
|
esac\
|
|
|
|
else\
|
|
|
|
echo "%%ghc_fix_rpath: no $i executable"\
|
|
|
|
exit 1\
|
|
|
|
fi\
|
|
|
|
done\
|
|
|
|
done\
|
|
|
|
%endif\
|
|
|
|
%{nil}
|
|
|
|
|
|
|
|
# Deprecated by ghc_fix_rpath:
|
2013-01-22 02:31:08 +00:00
|
|
|
# ghc_fix_dynamic_rpath prog ...
|
|
|
|
%ghc_fix_dynamic_rpath()\
|
|
|
|
%if %{undefined ghc_without_dynamic}\
|
2014-03-17 03:24:45 +00:00
|
|
|
if ! type chrpath > /dev/null; then exit 1; fi\
|
2017-02-08 06:26:07 +00:00
|
|
|
pdir=$(pwd)\
|
2013-01-22 02:31:08 +00:00
|
|
|
for i in %*; do\
|
2015-01-31 09:40:55 +00:00
|
|
|
case $i in\
|
2017-02-08 06:26:07 +00:00
|
|
|
/*) prog=%{buildroot}$i ;;\
|
|
|
|
*) prog=%{buildroot}%{_bindir}/$i ;;\
|
2015-01-31 09:40:55 +00:00
|
|
|
esac\
|
2017-02-08 06:26:07 +00:00
|
|
|
if [ -x "$prog" ]; then\
|
2017-03-16 04:14:51 +00:00
|
|
|
rpath=$(chrpath $prog | sed -e "s@^$prog: R.*PATH=@@")\
|
2017-02-08 06:26:07 +00:00
|
|
|
case $rpath in\
|
|
|
|
*$pdir*)\
|
|
|
|
newrpath=$(echo $rpath | sed -e "s@$pdir/dist/build@%{ghclibdir}/%{pkg_name}-%{version}@g")\
|
|
|
|
chrpath -r $newrpath $prog\
|
2014-01-10 01:54:19 +00:00
|
|
|
;;\
|
|
|
|
esac\
|
|
|
|
else\
|
2017-02-08 06:26:07 +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}
|
|
|
|
|
2015-03-08 05:41:30 +00:00
|
|
|
%ghc_pkg_recache %{_bindir}/ghc-pkg-%{ghc_version} recache --no-user-package-db || :
|
2013-05-04 14:34:41 +00:00
|
|
|
|
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
|
|
|
|
2014-08-03 14:29:14 +00:00
|
|
|
# skip prof libs and documentation
|
|
|
|
%ghc_bootstrap\
|
2011-09-13 01:14:17 +00:00
|
|
|
%global without_prof 1\
|
|
|
|
%global without_haddock 1\
|
|
|
|
%global without_manual 1
|