summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-02-28 09:27:04 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-28 10:56:07 -0500
commitc686af5818686efb55cfd81ac104027c959d6277 (patch)
treef30c9924759689db56fc1e7a684392a54fea697f
parentc662d41e2006f5a45619d40d2369b24642348f1a (diff)
downloadhaskell-c686af5818686efb55cfd81ac104027c959d6277.tar.gz
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
-rw-r--r--compiler/ghc.mk4
-rw-r--r--ghc.mk4
-rw-r--r--mk/config.mk.in9
-rw-r--r--mk/flavours/bench-cross.mk1
-rw-r--r--mk/flavours/perf-cross.mk1
-rw-r--r--mk/flavours/quick-cross.mk1
-rw-r--r--utils/ghc-pkg/Main.hs12
-rw-r--r--utils/ghc-pkg/ghc-pkg.cabal11
-rw-r--r--utils/ghc-pkg/ghc.mk4
9 files changed, 40 insertions, 7 deletions
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index ce41eca052..36603a472c 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 b2888c0dac..578e031fed 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 b90aca3ad9..0fad90c32b 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 15b359e259..90344fc3ac 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 669b51a3b1..f202642b7d 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 92347cae4a..b886a8da9f 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 44960ca0b6..dd49180615 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 3511e36691..8776cb955e 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 f7d97debfa..002c8122f2 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)/.