[commit: ghc] master: Add flag allowing convenient disabling of terminfo support (c686af5)

git at git.haskell.org git at git.haskell.org
Tue Feb 28 15:59:29 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c686af5818686efb55cfd81ac104027c959d6277/ghc

>---------------------------------------------------------------

commit c686af5818686efb55cfd81ac104027c959d6277
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Tue Feb 28 09:27:04 2017 -0500

    Add flag allowing convenient disabling of terminfo support
    
    This is a common thing that users who cross-compile must fight against.
    It turns out that it's pretty straightforward to make is convenient.
    
    Test Plan: Cross compile without a target `ncurses` available
    
    Reviewers: danharaj, hvr, erikd, austin, rwbarton
    
    Subscribers: rwbarton, thomie, snowleopard
    
    Differential Revision: https://phabricator.haskell.org/D3177


>---------------------------------------------------------------

c686af5818686efb55cfd81ac104027c959d6277
 compiler/ghc.mk             |  4 ++++
 ghc.mk                      |  4 +---
 mk/config.mk.in             |  9 +++++++++
 mk/flavours/bench-cross.mk  |  1 +
 mk/flavours/perf-cross.mk   |  1 +
 mk/flavours/quick-cross.mk  |  1 +
 utils/ghc-pkg/Main.hs       | 12 ++++++++++--
 utils/ghc-pkg/ghc-pkg.cabal | 11 +++++++++--
 utils/ghc-pkg/ghc.mk        |  4 ++++
 9 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index ce41eca..36603a4 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -361,6 +361,10 @@ compiler_CONFIGURE_OPTS += --ghc-option=-DNOSMP
 compiler_CONFIGURE_OPTS += --ghc-option=-optc-DNOSMP
 endif
 
+ifeq "$(WITH_TERMINFO)" "NO"
+compiler_stage2_CONFIGURE_OPTS += --flags=-terminfo
+endif
+
 # Careful optimisation of the parser: we don't want to throw everything
 # at it, because that takes too long and doesn't buy much, but we do want
 # to inline certain key external functions, so we instruct GHC not to
diff --git a/ghc.mk b/ghc.mk
index b2888c0..578e031 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -431,9 +431,7 @@ else # CLEANING
 # compiler already has installed (or up-to-date enough).
 
 PACKAGES_STAGE0 = binary Cabal/Cabal hpc ghc-boot-th ghc-boot hoopl transformers template-haskell ghci
-ifeq "$(Windows_Host)" "NO"
 PACKAGES_STAGE0 += terminfo
-endif
 
 PACKAGES_STAGE1 += ghc-prim
 PACKAGES_STAGE1 += $(INTEGER_LIBRARY)
@@ -469,7 +467,7 @@ ifeq "$(HADDOCK_DOCS)" "YES"
 PACKAGES_STAGE1 += xhtml
 endif
 
-ifeq "$(Windows_Target)" "NO"
+ifeq "$(WITH_TERMINFO)" "YES"
 PACKAGES_STAGE1 += terminfo
 endif
 PACKAGES_STAGE1 += haskeline
diff --git a/mk/config.mk.in b/mk/config.mk.in
index b90aca3..0fad90c 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -100,6 +100,15 @@ GhcDynamic=NO
 # GhcProfiled=YES means compile a profiled stage-2 compiler
 GhcProfiled=NO
 
+# WITH_TERMINFO can be used to disable terminfo support throughout the compiler
+# and its tools. This is handy in the case of cross-compilation, where we may
+# not have an ncurses build for the target.
+ifeq "$(Windows_Target)" "NO"
+WITH_TERMINFO=YES
+else
+WITH_TERMINFO=NO
+endif
+
 ifeq "$(findstring $(TargetOS_CPP),linux freebsd dragonfly openbsd netbsd solaris2 kfreebsdgnu haiku linux-android)" ""
 TargetElf = NO
 else
diff --git a/mk/flavours/bench-cross.mk b/mk/flavours/bench-cross.mk
index 15b359e..90344fc 100644
--- a/mk/flavours/bench-cross.mk
+++ b/mk/flavours/bench-cross.mk
@@ -8,6 +8,7 @@ HADDOCK_DOCS       = NO
 BUILD_SPHINX_HTML  = NO
 BUILD_SPHINX_PDF   = NO
 BUILD_MAN          = NO
+WITH_TERMINFO      = NO
 
 INTEGER_LIBRARY      = integer-simple
 Stage1Only           = YES
diff --git a/mk/flavours/perf-cross.mk b/mk/flavours/perf-cross.mk
index 669b51a..f202642 100644
--- a/mk/flavours/perf-cross.mk
+++ b/mk/flavours/perf-cross.mk
@@ -8,6 +8,7 @@ HADDOCK_DOCS       = NO
 BUILD_SPHINX_HTML  = NO
 BUILD_SPHINX_PDF   = NO
 BUILD_MAN          = NO
+WITH_TERMINFO      = NO
 
 INTEGER_LIBRARY      = integer-simple
 Stage1Only           = YES
diff --git a/mk/flavours/quick-cross.mk b/mk/flavours/quick-cross.mk
index 92347ca..b886a8d 100644
--- a/mk/flavours/quick-cross.mk
+++ b/mk/flavours/quick-cross.mk
@@ -8,6 +8,7 @@ HADDOCK_DOCS       = NO
 BUILD_SPHINX_HTML  = NO
 BUILD_SPHINX_PDF   = NO
 BUILD_MAN          = NO
+WITH_TERMINFO      = NO
 
 INTEGER_LIBRARY      = integer-simple
 Stage1Only           = YES
diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index 44960ca..dd49180 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -9,6 +9,14 @@
 {-# LANGUAGE TupleSections #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# OPTIONS_GHC -fno-warn-orphans #-}
+
+-- We never want to link against terminfo while bootstrapping.
+#ifdef BOOTSTRAPPING
+#ifdef WITH_TERMINFO
+#undef WITH_TERMINFO
+#endif
+#endif
+
 -----------------------------------------------------------------------------
 --
 -- (c) The University of Glasgow 2004-2009.
@@ -80,7 +88,7 @@ import System.Posix hiding (fdToHandle)
 import qualified System.Info(os)
 #endif
 
-#if !defined(mingw32_HOST_OS) && !defined(BOOTSTRAPPING)
+#ifdef WITH_TERMINFO
 import System.Console.Terminfo as Terminfo
 #endif
 
@@ -1429,7 +1437,7 @@ listPackages verbosity my_flags mPackageName mModuleName = do
 
   if simple_output then show_simple stack else do
 
-#if defined(mingw32_HOST_OS) || defined(BOOTSTRAPPING)
+#ifndef WITH_TERMINFO
     mapM_ show_normal stack
 #else
     let
diff --git a/utils/ghc-pkg/ghc-pkg.cabal b/utils/ghc-pkg/ghc-pkg.cabal
index 3511e36..8776cb9 100644
--- a/utils/ghc-pkg/ghc-pkg.cabal
+++ b/utils/ghc-pkg/ghc-pkg.cabal
@@ -15,6 +15,11 @@ Category: Development
 build-type: Simple
 cabal-version: >=1.10
 
+Flag terminfo
+    Description: Build GHC with terminfo support on non-Windows platforms.
+    Default: True
+    Manual: False
+
 Executable ghc-pkg
     Default-Language: Haskell2010
     Main-Is: Main.hs
@@ -30,8 +35,10 @@ Executable ghc-pkg
                    binary,
                    ghc-boot,
                    bytestring
+    if !os(windows) && flag(terminfo)
+        Build-Depends: terminfo
+        Cpp-Options: -DWITH_TERMINFO
     if !os(windows)
-        Build-Depends: unix,
-                       terminfo
+        Build-Depends: unix
     if os(windows)
         c-sources: CRT_noglob.c
diff --git a/utils/ghc-pkg/ghc.mk b/utils/ghc-pkg/ghc.mk
index f7d97de..002c812 100644
--- a/utils/ghc-pkg/ghc.mk
+++ b/utils/ghc-pkg/ghc.mk
@@ -57,6 +57,10 @@ utils/ghc-pkg_dist_INSTALL = YES
 utils/ghc-pkg_dist_INSTALL_SHELL_WRAPPER_NAME = ghc-pkg-$(ProjectVersion)
 endif
 
+ifeq "$(WITH_TERMINFO)" "NO"
+utils/ghc-pkg_dist-install_CONFIGURE_OPTS += -f-terminfo
+endif
+
 $(eval $(call build-prog,utils/ghc-pkg,dist,0))
 
 $(ghc-pkg_INPLACE) : | $(INPLACE_PACKAGE_CONF)/.



More information about the ghc-commits mailing list