Skip to content

Commit

Permalink
Remove the configure logic around detecting (n)curses.h.
Browse files Browse the repository at this point in the history
It's complicated (see e.g. PR #21), and we don't actually need it for the
build.
  • Loading branch information
judah committed Apr 21, 2017
1 parent c39f12c commit 02ebf00
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
23 changes: 0 additions & 23 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,44 +1,23 @@
AC_INIT([Haskell terminfo package], [0.2], [judah dot jacobson at gmail dot com], [terminfo])

AC_ARG_WITH([curses-includes],
[AC_HELP_STRING([--with-curses-includes],
[directory containing curses.h])],
[curses_includes=$withval],
[curses_includes=NONE])

AC_ARG_WITH([curses-libraries],
[AC_HELP_STRING([--with-curses-libraries],
[directory containing curses library])],
[curses_libraries=$withval],
[curses_libraries=NONE])


TERMINFO_INCLUDE_DIRS=
TERMINFO_LIB_DIRS=
if test "x$curses_libraries" != "xNONE"; then
LDFLAGS="-L$curses_libraries $LDFLAGS"
TERMINFO_LIB_DIRS=$curses_libraries
fi
if test "x$curses_includes" != "xNONE"; then
CPPFLAGS="-I$curses_includes $CPPFLAGS"
TERMINFO_INCLUDE_DIRS=$curses_includes
fi

AC_ARG_WITH([cc],
[C compiler],
[CC=$withval])
AC_PROG_CC()

AC_CHECK_HEADER(ncurses.h, CursesIncludes='ncurses.h',
[AC_CHECK_HEADER(curses.h, CursesIncludes='curses.h', HaveCursesH=NO)])

# on Solaris, curses.h must be imported before term.h.
if test "x$HaveCursesH" = xNO ; then
AC_MSG_FAILURE([curses headers could not be found, so this package cannot be built])
else
TERMINFO_INCLUDES="$CursesIncludes term.h"
fi

AC_CHECK_LIB(tinfo, setupterm, HaveLibCurses=YES; LibCurses=tinfo,
[AC_CHECK_LIB(ncursesw, setupterm, HaveLibCurses=YES; LibCurses=ncursesw,
[AC_CHECK_LIB(ncurses, setupterm, HaveLibCurses=YES; LibCurses=ncurses,
Expand All @@ -52,8 +31,6 @@ else
fi


AC_SUBST(TERMINFO_INCLUDES)
AC_SUBST(TERMINFO_INCLUDE_DIRS)
AC_SUBST(TERMINFO_LIB_DIRS)
AC_SUBST(TERMINFO_LIB)

Expand Down
2 changes: 0 additions & 2 deletions terminfo.buildinfo.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
includes: @TERMINFO_INCLUDES@
include-dirs: @TERMINFO_INCLUDE_DIRS@
extra-lib-dirs: @TERMINFO_LIB_DIRS@
extra-libraries: @TERMINFO_LIB@

7 comments on commit 02ebf00

@fmthoma
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@judah This should fix #15, right? This deserves a release!

@judah
Copy link
Collaborator Author

@judah judah commented on 02ebf00 Apr 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change has already been released on Hackage in terminfo-0.4.1.0.

I'm not sure if it'll fix that problem. Although we no longer need the headers, we still require the library itself (for example: lib(n)curses.a) which is also not listed explicitly in terminfo.cabal.

@fmthoma
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this makes matters even worse for me: While I could work around the issue by adding ncurses to Stack's Nix environment until terminfo-0.4.0.2, this does not work for terminfo-0.4.1.0, and I haven't yet figured a way to get it to work.
Related issues are commercialhaskell/stack#3233 and NixOS/nixpkgs#15995.

@judah
Copy link
Collaborator Author

@judah judah commented on 02ebf00 Jul 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I recall correctly, this PR should have been a no-op to the behavior of terminfo, no matter the platform. It only changes the includes and include-dirs parameters, but those shouldn't actually affect the link-time behavior of this package.

Are you able to give me concrete steps (e.g. via a stack package that uses nix) to help me verify that this change made things worse for you?

@fmthoma
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building terminfo in a new Stack project:

> stack new tmp
Downloading template "new-template" to create project "tmp" in tmp/ ...

Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- tmp/tmp.cabal

Selecting the best among 10 snapshots...

* Matches lts-8.23

Selected resolver: lts-8.23
Initialising configuration using resolver: lts-8.23
Total number of user packages considered: 1
Writing configuration to file: tmp/stack.yaml
All done.
> cd tmp
> stack build terminfo
terminfo-0.4.1.0: configure

--  While building package terminfo-0.4.1.0 using:
      /run/user/1000/stack4013/terminfo-0.4.1.0/.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/setup/setup --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0 configure --with-ghc=/nix/store/hg0ppf88q1rw0q7x3zqhlxbnviq0ddcg-ghc-8.0.2/bin/ghc --with-ghc-pkg=/nix/store/hg0ppf88q1rw0q7x3zqhlxbnviq0ddcg-ghc-8.0.2/bin/ghc-pkg --user --package-db=clear --package-db=global --package-db=/home/fthoma/config-files/.stack/snapshots/x86_64-linux-nix/lts-8.23/8.0.2/pkgdb --libdir=/home/fthoma/config-files/.stack/snapshots/x86_64-linux-nix/lts-8.23/8.0.2/lib --bindir=/home/fthoma/config-files/.stack/snapshots/x86_64-linux-nix/lts-8.23/8.0.2/bin --datadir=/home/fthoma/config-files/.stack/snapshots/x86_64-linux-nix/lts-8.23/8.0.2/share --libexecdir=/home/fthoma/config-files/.stack/snapshots/x86_64-linux-nix/lts-8.23/8.0.2/libexec --sysconfdir=/home/fthoma/config-files/.stack/snapshots/x86_64-linux-nix/lts-8.23/8.0.2/etc --docdir=/home/fthoma/config-files/.stack/snapshots/x86_64-linux-nix/lts-8.23/8.0.2/doc/terminfo-0.4.1.0 --htmldir=/home/fthoma/config-files/.stack/snapshots/x86_64-linux-nix/lts-8.23/8.0.2/doc/terminfo-0.4.1.0 --haddockdir=/home/fthoma/config-files/.stack/snapshots/x86_64-linux-nix/lts-8.23/8.0.2/doc/terminfo-0.4.1.0 --dependency=base=base-4.9.1.0 --extra-include-dirs=/nix/store/4dkz4b4fnajwkl95dd8yxl8h0bks167b-stack-1.3.2/include --extra-include-dirs=/nix/store/6dg8dn31lvl4xzphbf2lip00xmdjv0hy-ncurses-6.0-dev/include --extra-include-dirs=/nix/store/bjcvlgchajkdr8xjdai6hdqnm6h3502p-zsh-5.3.1/include --extra-include-dirs=/nix/store/g5zfd7s7y4xn5yz5ghslynw7mq2zcs73-ncurses-5.9-dev/include --extra-include-dirs=/nix/store/gsymmqfflvim6bpf8yjws9jd5jc3hc0g-zlib-1.2.11-dev/include --extra-include-dirs=/nix/store/hg0ppf88q1rw0q7x3zqhlxbnviq0ddcg-ghc-8.0.2/include --extra-include-dirs=/nix/store/jc0bsmb633wnxd62h0l5nx6msfab8v6z-less-481/include --extra-include-dirs=/nix/store/jkh5n5f7fw64rfkbb28nr82klpvjl9zp-emacs-25.1/include --extra-lib-dirs=/nix/store/4dkz4b4fnajwkl95dd8yxl8h0bks167b-stack-1.3.2/lib --extra-lib-dirs=/nix/store/6dg8dn31lvl4xzphbf2lip00xmdjv0hy-ncurses-6.0-dev/lib --extra-lib-dirs=/nix/store/bjcvlgchajkdr8xjdai6hdqnm6h3502p-zsh-5.3.1/lib --extra-lib-dirs=/nix/store/g5zfd7s7y4xn5yz5ghslynw7mq2zcs73-ncurses-5.9-dev/lib --extra-lib-dirs=/nix/store/gi5vvbjawzw1bakiksazbd50bvfmpmmc-ncurses-6.0/lib --extra-lib-dirs=/nix/store/h1pk8l728c40z6sg3wnsf7p5hk2qrwjv-zlib-1.2.11/lib --extra-lib-dirs=/nix/store/hg0ppf88q1rw0q7x3zqhlxbnviq0ddcg-ghc-8.0.2/lib --extra-lib-dirs=/nix/store/jc0bsmb633wnxd62h0l5nx6msfab8v6z-less-481/lib --extra-lib-dirs=/nix/store/jkh5n5f7fw64rfkbb28nr82klpvjl9zp-emacs-25.1/lib --extra-lib-dirs=/nix/store/rk17yqh4ryvnyc912ljr3jnj163r2kip-ncurses-5.9/lib
    Process exited with code: ExitFailure 1
    Logs have been written to: /home/fthoma/tmp/tmp/.stack-work/logs/terminfo-0.4.1.0.log

    [1 of 2] Compiling Main             ( /run/user/1000/stack4013/terminfo-0.4.1.0/Setup.lhs, /run/user/1000/stack4013/terminfo-0.4.1.0/.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/setup/Main.o )
    [2 of 2] Compiling StackSetupShim   ( /home/fthoma/config-files/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /run/user/1000/stack4013/terminfo-0.4.1.0/.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/setup/StackSetupShim.o )
    Linking /run/user/1000/stack4013/terminfo-0.4.1.0/.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/setup/setup ...
    Configuring terminfo-0.4.1.0...
    configure: WARNING: unrecognized options: --with-compiler
    checking for gcc... /nix/store/r54jv402shjggj3fn2dy895iycy3afxi-gcc-wrapper-5.4.0/bin/cc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether /nix/store/r54jv402shjggj3fn2dy895iycy3afxi-gcc-wrapper-5.4.0/bin/cc accepts -g... yes
    checking for /nix/store/r54jv402shjggj3fn2dy895iycy3afxi-gcc-wrapper-5.4.0/bin/cc option to accept ISO C89... none needed
    checking for setupterm in -ltinfo... no
    checking for setupterm in -lncursesw... no
    checking for setupterm in -lncurses... no
    checking for setupterm in -lcurses... no
    configure: error: in `/run/user/1000/stack4013/terminfo-0.4.1.0':
    configure: error: curses library not found, so this package cannot be built
    See `config.log' for more details

NixOS version: 17.03.981.a7ebf59aa7 (Gorilla)
Nix version: nix-env (Nix) 1.11.8
Stack version: Version 1.3.2 x86_64

Here ist my ~/.stack/config.yaml

nix:
  enable: true
  packages: [
              ncurses.dev
            , ncurses.out
            , ncurses
            ]

Earlier, nix.enable.packages = [ncurses] was already sufficient to build terminfo, I added the others hoping that one of them might provide the necessary dependency.

I also had a look at the possibility that this breakage might have been caused by a NixOS/nixpkgs upgrade; however, I haven't found anything suspicious in the commit history for pkgs/development/libraries/ncurses.

@judah
Copy link
Collaborator Author

@judah judah commented on 02ebf00 Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed instructions; I was able to reproduce your issue.

I was able to fix it on my machine by adding gcc to the list of packages, so that my ~/.stack/config.yaml contains:

nix:
  enable: true
  packages: [gcc, ncurses]

Does that work for you? If so, it sounds like perhaps an issue either with the ncurses Nix package or a regression in how Stack interacts with Nix (i.e., the shell it builds ought to have gcc)?

@fmthoma
Copy link

@fmthoma fmthoma commented on 02ebf00 Jul 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, adding gcc to the nix.packages works for me, too. Thanks!

Please sign in to comment.