ghc/ghc.spec

319 lines
10 KiB
RPMSpec
Raw Normal View History

#
# spec file for package ghc
# based on fedora package
#
# Copyright (c) 2012 Peter Trommler peter.trommler@ohm-hochschule.de
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# To bootstrap a new version of ghc, uncomment the following:
#%%global ghc_bootstrapping 1
#%%{?ghc_bootstrap}
%global without_hscolour 1
%global debug_package %{nil}
Name: ghc
Version: 7.0.4
Release: 1
Group: Development/Languages/Other
License: BSD
Url: http://haskell.org/ghc/dist/%{version}/%{name}-%{version}-src.tar.bz2
Summary: The Glorious Glasgow Haskell Compiler
%if %{defined ghc_bootstrapping}
BuildRequires: ghc >= 6.10
%else
BuildRequires: ghc = %version
%endif
BuildRequires: ghc-directory-devel ghc-process-devel ghc-pretty-devel
BuildRequires: ghc-containers-devel ghc-haskell98-devel ghc-bytestring-devel
BuildRequires: ghc-rpm-macros >= 0.14
# up to ghc-time-devel should be Required by ghc, remove after fix!
BuildRequires: ghc-base-devel ghc-filepath-devel ghc-unix-devel
BuildRequires: ghc-array-devel ghc-old-locale-devel ghc-old-time-devel
BuildRequires: ghc-random-devel
BuildRequires: ghc-time-devel
BuildRequires: gcc pkg-config autoconf
BuildRequires: glibc-devel
BuildRequires: ncurses-devel
BuildRequires: gmp-devel libffi-devel
%if %{undefined without_manual}
BuildRequires: libxslt docbook-xsl-stylesheets docbook-utils
%endif
# FIXME: containers, array and base not pulled in by OBS
%if %{undefined without_haddock} && %{undefined without_hscolour}
BuildRequires: hscolour ghc-containers ghc-base ghc-array
BuildRequires: ghc-haskell98 ghc-random ghc-time ghc-process
BuildRequires: ghc-directory ghc-unix ghc-old-time ghc-old-locale
BuildRequires: ghc-filepath
%endif
BuildRequires: fdupes
PreReq: update-alternatives
Requires: gcc gmp-devel ghc-base-devel
# Fedora put compiler into ghc-compiler and left ghc empty?!
Provides: ghc-compiler = %{version}
Source: %{name}-%{version}-src.tar.bz2
#Patch5 on Fedora
Patch: Cabal-option-executable-dynamic.patch
#Patch4 on Fedora
Patch1: ghc-use-system-libffi.patch
#Patch1 on Fedora
Patch2: ghc-6.12.1-gen_contents_index-haddock-path.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Haskell is the standard purely functional programming language; the
current language version is Haskell 98, agreed in December 1998.
GHC is a state-of-the-art programming suite for Haskell. Included is
an optimising compiler generating good code for a variety of
platforms, together with an interactive system for convenient, quick
development. The distribution includes space and time profiling
facilities, a large collection of libraries, and support for various
language extensions, including concurrency, exceptions, and foreign
language interfaces (C, C++, etc).
A wide variety of Haskell related resources (tutorials, libraries,
specifications, documentation, compilers, interprbeters, references,
contact information, links to research groups) are available from the
Haskell home page at <http://www.haskell.org/>.
%global ghc_version_override %{version}
# SLE does not define _rpmconfigdir (yet)
%if %{defined sles_version}
%global _rpmconfigdir %{_prefix}/lib/rpm
%endif
%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}
%global ghc_pkg_c_deps ghc = %{ghc_version_override}-%{release}
%if %{defined ghclibdir}
%ghc_binlib_package Cabal 1.10.2.0
%ghc_binlib_package array 0.3.0.2
%ghc_binlib_package -c gmp-devel,libffi-devel base 4.3.1.0
%ghc_binlib_package bytestring 0.9.1.10
%ghc_binlib_package containers 0.4.0.0
%ghc_binlib_package directory 1.1.0.0
%ghc_binlib_package extensible-exceptions 0.1.1.2
%ghc_binlib_package filepath 1.2.0.0
%define ghc_pkg_obsoletes ghc-bin-package-db-devel < 0.0.0.0-%{release}
%ghc_binlib_package ghc %{ghc_version_override}
%undefine ghc_pkg_obsoletes
%ghc_binlib_package haskell2010 1.0.0.0
%ghc_binlib_package haskell98 1.1.0.1
%ghc_binlib_package hpc 0.5.0.6
%ghc_binlib_package old-locale 1.0.0.2
%ghc_binlib_package old-time 1.0.0.6
%ghc_binlib_package pretty 1.0.1.2
%ghc_binlib_package process 1.0.1.5
%ghc_binlib_package random 1.0.0.3
%ghc_binlib_package template-haskell 2.5.0.0
%ghc_binlib_package time 1.2.0.3
%ghc_binlib_package unix 2.4.2.0
%endif
%global version %{ghc_version_override}
%prep
%setup -q
rm -r ghc-tarballs/{mingw,perl}
%patch -p1 -b .orig
%if 0%{?suse_version} > 1140
%patch1 -p1 -b .libffi
%endif
#%%patch2 -p1 -b .orig
%build
autoreconf --force --install
# http://hackage.haskell.org/trac/ghc/wiki/Platforms
# cf https://github.com/gentoo-haskell/gentoo-haskell/tree/master/dev-lang/ghc
cat > mk/build.mk << EOF
GhcLibWays = v %{!?ghc_without_shared:dyn} %{!?without_prof:p}
%if %{defined without_haddock}
HADDOCK_DOCS = NO
%endif
%if %{defined without_manual}
BUILD_DOCBOOK_HTML = NO
%endif
%if %{defined without_hscolour}
HSCOLOUR_SRCS = NO
%endif
%ifarch %{unregisterised_archs}
GhcUnregisterised=YES
%endif
%ifarch ppc64
GhcNotThreaded=YES
SRC_HC_OPTS+=-optc-mminimal-toc -optl-pthread
SRC_CC_OPTS+=-mminimal-toc -pthread -Wa,--noexecstack
%endif
EOF
export SUSE_ASNEEDED=0
export CFLAGS="${CFLAGS:-%optflags}"
./configure --prefix=%{_prefix} --exec-prefix=%{_exec_prefix} --bindir=%{_bindir} \
--sbindir=%{_sbindir} --sysconfdir=%{_sysconfdir} --datadir=%{_datadir} \
--includedir=%{_includedir} --libdir=%{_libdir} --libexecdir=%{_libexecdir} \
--localstatedir=%{_localstatedir} --sharedstatedir=%{_sharedstatedir} \
--mandir=%{_mandir} --docdir=%{ghcdocroot} \
%{?with_shared:--enable-shared}
make %{?_smp_mflags}
%install
%makeinstall
for i in %{ghc_packages_list}; do
name=$(echo $i | sed -e "s/\(.*\)-.*/\1/")
ver=$(echo $i | sed -e "s/.*-\(.*\)/\1/")
%ghc_gen_filelists $name $ver
echo "%doc libraries/$name/LICENSE" >> ghc-$name%{?ghc_without_shared:-devel}.files
done
%ghc_gen_filelists bin-package-db 0.0.0.0
%ghc_gen_filelists ghc %{ghc_version_override}
%ghc_gen_filelists ghc-binary 0.5.0.2
%ghc_gen_filelists ghc-prim 0.2.0.0
%ghc_gen_filelists integer-gmp 0.2.0.3
%define merge_filelist()\
%if %{undefined ghc_without_shared}\
cat ghc-%1.files >> ghc-%2.files\
%endif\
cat ghc-%1-devel.files >> ghc-%2-devel.files\
cp -p libraries/%1/LICENSE libraries/LICENSE.%1\
echo "%doc libraries/LICENSE.%1" >> ghc-%2.files
%merge_filelist integer-gmp base
%merge_filelist ghc-prim base
%merge_filelist ghc-binary ghc
%merge_filelist bin-package-db ghc
%if %{undefined ghc_without_shared}
ls $RPM_BUILD_ROOT%{ghclibdir}/libHS*.so >> ghc-base.files
sed -i -e "s|^$RPM_BUILD_ROOT||g" ghc-base.files
%endif
ls -d $RPM_BUILD_ROOT%{ghclibdir}/libHS*.a $RPM_BUILD_ROOT%{ghclibdir}/package.conf.d/builtin_*.conf $RPM_BUILD_ROOT%{ghclibdir}/include >> ghc-base-devel.files
%if 0%{?suse_version} <= 1140
echo $RPM_BUILD_ROOT%{ghclibdir}/HSffi.o >> ghc-base-devel.files
%endif
sed -i -e "s|^$RPM_BUILD_ROOT||g" ghc-base-devel.files
# these are handled as alternatives
for i in hsc2hs runhaskell; do
if [ -x ${RPM_BUILD_ROOT}%{_bindir}/$i-ghc ]; then
rm ${RPM_BUILD_ROOT}%{_bindir}/$i
else
mv ${RPM_BUILD_ROOT}%{_bindir}/$i{,-ghc}
fi
touch ${RPM_BUILD_ROOT}%{_bindir}/$i
done
%ghc_strip_dynlinked
%if 0%{?suse_version} > 1020
%fdupes -s %{buildroot}
%endif
%post
%ghc_pkg_recache
# Alas, GHC, Hugs and nhc all come with different set of tools in addition to
# a runFOO:
#
# * GHC: hsc2hs
# * Hugs: hsc2hs, cpphs
# * nhc: cpphs
#
# Therefore it is currently not possible to use --slave below to form link
# groups under a single name 'runhaskell'. Either these tools should be
# disentangled from the Haskell implementations or all implementations should
# have the same set of tools. *sigh*
update-alternatives --install %{_bindir}/runhaskell runhaskell %{_bindir}/runghc 500
update-alternatives --install %{_bindir}/hsc2hs hsc2hs %{_bindir}/hsc2hs-ghc 500
%preun
if test "$1" = 0; then
update-alternatives --remove runhaskell %{_bindir}/runghc
update-alternatives --remove hsc2hs %{_bindir}/hsc2hs-ghc
fi
%files
%defattr(-,root,root,-)
%doc ANNOUNCE HACKING LICENSE README
%{_bindir}/ghc
%{_bindir}/ghc-%{version}
%{_bindir}/ghc-pkg
%{_bindir}/ghc-pkg-%{version}
%{_bindir}/ghci
%{_bindir}/ghci-%{version}
%{_bindir}/hp2ps
%{_bindir}/hpc
%ghost %attr(755,root,root) %{_bindir}/hsc2hs
%{_bindir}/hsc2hs-ghc
%{_bindir}/runghc
%ghost %attr(755,root,root) %{_bindir}/runhaskell
%{_bindir}/runhaskell-ghc
%dir %{ghclibdir}
%{ghclibdir}/extra-gcc-opts
%{ghclibdir}/ghc
%{ghclibdir}/ghc-pkg
%ifnarch %{unregisterised_archs}
%{ghclibdir}/ghc-asm
%{ghclibdir}/ghc-split
%endif
%{ghclibdir}/ghc-usage.txt
%{ghclibdir}/ghci-usage.txt
%{ghclibdir}/hsc2hs
%dir %{ghclibdir}/package.conf.d
%ghost %{ghclibdir}/package.conf.d/package.cache
%{ghclibdir}/runghc
%{ghclibdir}/template-hsc.h
%{ghclibdir}/unlit
%{_mandir}/man1/ghc.*
%dir %{ghcdocroot}
%dir %{ghcdocbasedir}
%dir %{ghcdocbasedir}/libraries
%if %{undefined without_haddock}
%{_bindir}/haddock
%{_bindir}/haddock-ghc-%{version}
%{ghclibdir}/html
%{ghclibdir}/latex
%{ghclibdir}/haddock
%{ghcdocbasedir}/html
%if %{undefined without_manual}
%{ghcdocbasedir}/Cabal
%{ghcdocbasedir}/haddock
%{ghcdocbasedir}/users_guide
%endif
%{ghcdocbasedir}/libraries/frames.html
%{ghcdocbasedir}/libraries/gen_contents_index
%{ghcdocbasedir}/libraries/hscolour.css
%{ghcdocbasedir}/libraries/ocean.css
%{ghcdocbasedir}/libraries/prologue.txt
%{ghcdocbasedir}/index.html
%ghost %{ghcdocbasedir}/libraries/doc-index*.html
%ghost %{ghcdocbasedir}/libraries/haddock-util.js
%ghost %{ghcdocbasedir}/libraries/index*.html
%ghost %{ghcdocbasedir}/libraries/minus.gif
%ghost %{ghcdocbasedir}/libraries/plus.gif
%endif
%changelog