From 47fc293b36ff4975baac089920874de154c5f418 Mon Sep 17 00:00:00 2001
From: Jens Petersen <petersen@redhat.com>
Date: Tue, 18 Nov 2014 11:12:49 +0900
Subject: [PATCH] backport more changes from 7.8.3 spec to 7.6.3 spec

- remove the build hack to switch from llvm to llvm34 (#1161049)
- use rpm internal dependency generator with ghc.attr on F21+
- fix bash-ism in ghc-doc-index (#1146733)
- do "quick" build when bootstrapping
- setup LDFLAGS
---
 ghc           |  3 ---
 ghc-doc-index |  2 +-
 ghc-pkg       |  3 ---
 ghc.spec      | 29 ++++++++++++++++++++---------
 4 files changed, 21 insertions(+), 16 deletions(-)
 delete mode 100755 ghc
 delete mode 100755 ghc-pkg

diff --git a/ghc b/ghc
deleted file mode 100755
index aa61e6a..0000000
--- a/ghc
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-/usr/bin/ghc -pgmlc llc-3.4 -pgmlo opt-3.4 $*
diff --git a/ghc-doc-index b/ghc-doc-index
index 6105d7e..a0223fa 100755
--- a/ghc-doc-index
+++ b/ghc-doc-index
@@ -34,5 +34,5 @@ if [ -x "gen_contents_index" -a ! -r "$PKGDIRCACHE.new" -o -n "$DIR_DIFF" ]; the
 fi
 
 if [ -f $PKGDIRCACHE.new ]; then
-  mv -f $PKGDIRCACHE{.new,}
+  mv -f $PKGDIRCACHE.new $PKGDIRCACHE
 fi
diff --git a/ghc-pkg b/ghc-pkg
deleted file mode 100755
index 14e0395..0000000
--- a/ghc-pkg
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-/usr/bin/ghc-pkg $*
diff --git a/ghc.spec b/ghc.spec
index 6807eca..774380c 100644
--- a/ghc.spec
+++ b/ghc.spec
@@ -22,7 +22,7 @@ Version: 7.6.3
 # - release can only be reset if *all* library versions get bumped simultaneously
 #   (sometimes after a major release)
 # - minor release numbers for a branch should be incremented monotonically
-Release: 27%{?dist}
+Release: 28%{?dist}
 Summary: Glasgow Haskell Compiler
 
 License: %BSDHaskellReport
@@ -33,8 +33,6 @@ Source2: http://www.haskell.org/ghc/dist/%{version}/ghc-%{version}-testsuite.tar
 %endif
 Source3: ghc-doc-index.cron
 Source4: ghc-doc-index
-Source5: ghc
-Source6: ghc-pkg
 # absolute haddock path (was for html/libraries -> libraries)
 Patch1:  ghc-gen_contents_index-haddock-path.patch
 # fedora does not allow copy libraries
@@ -105,7 +103,7 @@ Obsoletes: ghc-feldspar-language < 0.4, ghc-feldspar-language-devel < 0.4, ghc-f
 %if %{undefined ghc_bootstrapping}
 BuildRequires: ghc-compiler = %{version}
 %endif
-%if 0%{?fedora} >= 20
+%if 0%{?fedora} >= 19 || 0%{?rhel} >= 7
 BuildRequires: ghc-rpm-macros-extra
 %else
 BuildRequires: ghc-rpm-macros
@@ -198,11 +196,13 @@ documention.
 
 %global ghc_version_override %{version}
 
+# currently only F21+ ghc-rpm-macros has ghc.attr
+%if 0%{?fedora} < 21
 # needs ghc_version_override for bootstrapping
 %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}
-
+%endif
 
 %global ghc_pkg_c_deps ghc-compiler = %{ghc_version_override}-%{release}
 
@@ -328,6 +328,12 @@ BuildFlavour = perf
 %else
 BuildFlavour = perf-llvm
 %endif
+%else
+%ifnarch armv7hl armv5tel
+BuildFlavour = quick-llvm
+%else
+BuildFlavour = quick
+%endif
 %endif
 GhcLibWays = v %{!?ghc_without_shared:dyn} %{!?without_prof:p}
 %if %{defined without_haddock}
@@ -343,7 +349,6 @@ BUILD_DOCBOOK_HTML = NO
 #EXTRA_HC_OPTS=-debug
 EOF
 
-export CFLAGS="${CFLAGS:-%optflags}"
 # note %%configure induces cross-build due to different target/host/build platform names
 # --with-gcc=%{_bindir}/gcc is to avoid ccache hardcoding problem when bootstrapping 
 %ifarch ppc64le aarch64 armv7hl
@@ -352,9 +357,8 @@ for i in $(find . -name config.guess -o -name config.sub) ; do
 done
 autoreconf
 %endif
-%ifarch armv7hl armv5tel
-export GHC=%SOURCE5
-%endif
+export CFLAGS="${CFLAGS:-%optflags}"
+export LDFLAGS="${LDFLAGS:-%__global_ldflags}"
 ./configure --prefix=%{_prefix} --exec-prefix=%{_exec_prefix} \
   --bindir=%{_bindir} --sbindir=%{_sbindir} --sysconfdir=%{_sysconfdir} \
   --datadir=%{_datadir} --includedir=%{_includedir} --libdir=%{_libdir} \
@@ -556,6 +560,13 @@ fi
 
 
 %changelog
+* Mon Nov 17 2014 Jens Petersen <petersen@redhat.com> - 7.6.3-28
+- remove the build hack to switch from llvm to llvm34 (#1161049)
+- use rpm internal dependency generator with ghc.attr on F21+
+- fix bash-ism in ghc-doc-index (#1146733)
+- do "quick" build when bootstrapping
+- setup LDFLAGS
+
 * Mon Nov 17 2014 Jens Petersen <petersen@redhat.com> - 7.6.3-27
 - use llvm34 instead of llvm-3.5 for arm (#1161049)