File ghc-prepare-binary-distributions.spec of Package ghc-prepare-binary-distributions

#
# spec file for package ghc-prepare-binary-distributions
#
# Copyright (c) 2023 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


#%global unregisterised_archs s390 s390x riscv64
%ifarch aarch64
%define longarch aarch64
%endif
%ifarch ppc
%define longarch powerpc
%endif
%ifarch ppc64
%define longarch powerpc64
%endif
%ifarch ppc64le
%define longarch powerpc64le
%endif
%ifarch riscv64
%define longarch riscv64
%endif
%ifarch s390
%define longarch s390
%endif
%ifarch s390x
%define longarch s390x
%endif
%ifarch x86_64
%define longarch x86_64
%endif
%ifarch s390 s390x
%define sysname ibm
%else
%define sysname unknown
%endif
%define system_libffi 1
Name:           ghc-prepare-binary-distributions
Version:        9.2.3
Release:        0
Summary:        The Glorious Glasgow Haskell Compiler binary distribution
License:        BSD-3-Clause
Group:          Development/Languages/Other
URL:            https://haskell.org/ghc
Source:         http://haskell.org/ghc/dist/%{version}/ghc-%{version}-src.tar.xz
#%%Source:        ghc-%{version}-src.tar.xz
Source1:        8_10_7_bootstrap_sources.tar.gz
Patch1:         ghc-gen_contents_index-haddock-path.patch
# for unregisterized (s390x)
# https://ghc.haskell.org/trac/ghc/ticket/15689
Patch2:         ghc-Cabal-install-PATH-warning.patch
# PATCH-FIX-UPSTREAM Disable-unboxed-arrays.patch ptrommler@icloud.com -- Do not use unboxed arrays on big-endian platforms. See Haskell Trac #15411.
Patch3:         Disable-unboxed-arrays.patch
# https://phabricator.haskell.org/rGHC4eebc8016f68719e1ccdf460754a97d1f4d6ef05
Patch6:         ghc-8.6.3-sphinx-1.8.patch
# unregisterized
Patch15:        ghc-warnings.mk-CC-Wall.patch
Patch26:        no-missing-haddock-file-warning.patch
# PATCH-FIX-UPSTREAM ghc-pie.patch - set linux as default PIE platform
#Patch35:        ghc-pie.patch
# PATCH-FIX-OPENSUSE ghc-8.0.2-Cabal-dynlibdir.patch -- Fix shared library directory location.
#  Patch100:       ghc-8.0.2-Cabal-dynlibdir.patch
# PATCH-FIX-UPSTREAM buildpath-abi-stability.patch -- debian patch for more stable abi-1
Patch110:       buildpath-abi-stability.patch
Patch120:       libatomic.patch
Patch130:       riscv-tntc.patch
#Patch140:       environ.patch
Patch150:       ghc-hadrian-s390x-rts--qg.patch
BuildRequires:  alex
#%endif
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  binutils-devel
BuildRequires:  ghc-bytestring-devel
#%ifarch riscv64
#BuildRequires:  gcc9
#%else
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  ghc-array-devel
BuildRequires:  ghc-binary-devel
BuildRequires:  ghc-containers-devel
BuildRequires:  ghc-deepseq-devel
BuildRequires:  ghc-directory-devel
BuildRequires:  ghc-filepath-devel
BuildRequires:  ghc-ghc-boot-th-devel
BuildRequires:  ghc-pretty-devel
BuildRequires:  ghc-parsec-devel
BuildRequires:  ghc-Cabal-devel
BuildRequires:  ghc-process-devel
BuildRequires:  ghc-rpm-macros-extra
BuildRequires:  ghc-stm-devel
BuildRequires:  ghc-mtl-devel
BuildRequires:  ghc-template-haskell-devel
BuildRequires:  ghc-text-devel
BuildRequires:  ghc-time-devel
BuildRequires:  ghc-transformers-devel
BuildRequires:  ghc-unix-devel
BuildRequires:  gmp-devel
BuildRequires:  happy
BuildRequires:  libelf-devel
BuildRequires:  libffi-devel
BuildRequires:  lzip
BuildRequires:  make
# for terminfo
# for terminfo
BuildRequires:  ncurses-devel
BuildRequires:  perl
BuildRequires:  pkgconfig
BuildRequires:  python3
# ignore failures with unregisterised compilers (s390x)
#!BuildIgnore:  post-build-checks
ExcludeArch:    %{arm} %{ix86}
%ifarch riscv64 s390x
BuildRequires:  llvm12-devel
%define hadrian_llvm +llvm
%endif
%if 0%{?suse_version} >= 1500
BuildRequires:  memory-constraints
%endif

%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/>.

%prep
%setup -q -n ghc-%{version}
# workaround bogus gcc warning that causes unregistered builds to be rejected
# by OBS - rpmlint filters do not work with OBS checks
%patch1 -p1
%patch2 -p1
%patch6 -p1
%ifarch ppc64 s390 s390x
%patch3 -p1
%endif
%ifarch s390 s390x riscv64
%patch15 -p1
%endif
#%patch35 -p1
# %%patch100 -p1
%patch120 -p1
%patch130 -p1
#%patch140 -p1
#%%patch110 -p1
%ifarch s390x riscv64
%patch150 -p1
%endif

rm libffi-tarballs/libffi-*.tar.gz
sed -i -e '/SRC_CC_OPTS/s/$/ -Wno-return-type/' mk/warnings.mk

%build
autoupdate
./boot
%if 0%{?qemu_user_space_build}
%limit_build -m 15000
%endif
cp %{SOURCE1} ./
hadrian/bootstrap/bootstrap.py --bootstrap-sources 8_10_7_bootstrap_sources.tar.gz

%global hadrian _build/bin/hadrian



#cat > mk/build.mk <<EOF
#%ifnarch %{unregisterised_archs}
#%ifarch aarch64 %{arm}
#BuildFlavour = quick-llvm
#%else
#BuildFlavour = quick
#%endif
#%endif
#GhcLibWays = v
#DYNAMIC_GHC_PROGRAMS = NO
#%ifarch %{unregistered_archs}
#GhcUnregisterised=YES
#GhcUnregisterised    = YES
#GhcWithNativeCodeGen = NO
#SRC_HC_OPTS          = -O -H64m
#GhcStage1HcOpts      = -O
#GhcStage2HcOpts      = -O
#GhcHcOpts            = -Rghc-timing
#GhcLibHcOpts         = -O
#SRC_HC_OPTS         += -optc-fno-builtin -optc-Wno-return-type
#SRC_CC_OPTS         += -fno-builtin -Wno-return-type
#%endif
#HSCOLOUR_SRCS = NO
#HADDOCK_DOCS = NO
#EOF

# macro ...
%{ghc_set_gcc_flags}

export LANG=C.utf8
export CFLAGS="${CFLAGS:-%{optflags}}"

# FIXME: you should use the %%configure macro
./configure --with-system-libffi \
%ifarch %{ghc_unregisterized_arches}
  --enable-unregisterised \
%endif
%{nil}


#%%ifarch %{unregisterised_archs}
#%%if 0%{?qemu_user_space_build}
#%%limit_build -m 15000
#%%else
#%%limit_build -m 8000
#%%endif
#%%else
#%%limit_build -m 2000
#%%endif
#make -j 2
#make binary-dist

%{hadrian} --docs=none --flavour=quick%{?hadrian_llvm} binary-dist-xz

%install
mkdir -p %{buildroot}%{_datadir}/ghc
cp _build/bindist/ghc-%{version}-%{longarch}-%{sysname}-linux.tar.xz %{buildroot}%{_datadir}/ghc

%check
#cd /tmp
#tar -Jxvf %{buildroot}%{_datadir}/ghc/ghc-%{version}-%{longarch}-%{sysname}-linux.tar.xz
#cd ghc-%{version}
#./configure --prefix=/tmp/disttest
#%make_build install

%files
%dir %{_datadir}/ghc
%{_datadir}/ghc/ghc-%{version}-%{longarch}-%{sysname}-linux.tar.xz

%changelog
openSUSE Build Service is sponsored by