fork
Configure Feed
Select the types of activity you want to include in your feed.
lol
fork
Configure Feed
Select the types of activity you want to include in your feed.
1{ lib, stdenv, fetchurl, pkgconfig
2
3, abiVersion
4, mouseSupport ? false
5, unicode ? true
6
7, gpm
8
9, buildPlatform, hostPlatform
10, buildPackages
11}:
12
13stdenv.mkDerivation rec {
14 version = if abiVersion == "5" then "5.9" else "6.0-20170729";
15 name = "ncurses-${version}";
16
17 src = fetchurl (if abiVersion == "5" then {
18 url = "mirror://gnu/ncurses/${name}.tar.gz";
19 sha256 = "0fsn7xis81za62afan0vvm38bvgzg5wfmv1m86flqcj0nj7jjilh";
20 } else {
21 url = "ftp://ftp.invisible-island.net/ncurses/current/${name}.tgz";
22 sha256 = "1cfdpl2gnj8szw28jmzrw47va0yqn16g03ywyzz3bjmaqxxmmwga";
23 });
24
25 patches = [ ./clang.patch ] ++ lib.optional (abiVersion == "5" && stdenv.cc.isGNU) ./gcc-5.patch;
26
27 outputs = [ "out" "dev" "man" ];
28 setOutputFlags = false; # some aren't supported
29
30 configureFlags = [
31 "--with-shared"
32 "--without-debug"
33 "--enable-pc-files"
34 "--enable-symlinks"
35 ] ++ lib.optional unicode "--enable-widec";
36
37 # Only the C compiler, and explicitly not C++ compiler needs this flag on solaris:
38 CFLAGS = lib.optionalString stdenv.isSunOS "-D_XOPEN_SOURCE_EXTENDED";
39
40 nativeBuildInputs = [
41 pkgconfig
42 ] ++ lib.optionals (buildPlatform != hostPlatform) [
43 buildPackages.ncurses buildPackages.stdenv.cc
44 ];
45 buildInputs = lib.optional (mouseSupport && stdenv.isLinux) gpm;
46
47 preConfigure = ''
48 export PKG_CONFIG_LIBDIR="$dev/lib/pkgconfig"
49 mkdir -p "$PKG_CONFIG_LIBDIR"
50 configureFlagsArray+=(
51 "--libdir=$out/lib"
52 "--includedir=$dev/include"
53 "--bindir=$dev/bin"
54 "--mandir=$man/share/man"
55 "--with-pkg-config-libdir=$PKG_CONFIG_LIBDIR"
56 )
57 ''
58 + lib.optionalString stdenv.isSunOS ''
59 sed -i -e '/-D__EXTENSIONS__/ s/-D_XOPEN_SOURCE=\$cf_XOPEN_SOURCE//' \
60 -e '/CPPFLAGS="$CPPFLAGS/s/ -D_XOPEN_SOURCE_EXTENDED//' \
61 configure
62 CFLAGS=-D_XOPEN_SOURCE_EXTENDED
63 '';
64
65 enableParallelBuilding = true;
66
67 doCheck = false;
68
69 # When building a wide-character (Unicode) build, create backward
70 # compatibility links from the the "normal" libraries to the
71 # wide-character libraries (e.g. libncurses.so to libncursesw.so).
72 postFixup = ''
73 # Determine what suffixes our libraries have
74 suffix="$(awk -F': ' 'f{print $3; f=0} /default library suffix/{f=1}' config.log)"
75 libs="$(ls $dev/lib/pkgconfig | tr ' ' '\n' | sed "s,\(.*\)$suffix\.pc,\1,g")"
76 suffixes="$(echo "$suffix" | awk '{for (i=1; i < length($0); i++) {x=substr($0, i+1, length($0)-i); print x}}')"
77
78 # Get the path to the config util
79 cfg=$(basename $dev/bin/ncurses*-config)
80
81 # symlink the full suffixed include directory
82 ln -svf . $dev/include/ncurses$suffix
83
84 for newsuffix in $suffixes ""; do
85 # Create a non-abi versioned config util links
86 ln -svf $cfg $dev/bin/ncurses$newsuffix-config
87
88 # Allow for end users who #include <ncurses?w/*.h>
89 ln -svf . $dev/include/ncurses$newsuffix
90
91 for library in $libs; do
92 for dylibtype in so dll dylib; do
93 if [ -e "$out/lib/lib''${library}$suffix.$dylibtype" ]; then
94 ln -svf lib''${library}$suffix.$dylibtype $out/lib/lib$library$newsuffix.$dylibtype
95 ln -svf lib''${library}$suffix.$dylibtype.${abiVersion} $out/lib/lib$library$newsuffix.$dylibtype.${abiVersion}
96 if [ "ncurses" = "$library" ]
97 then
98 # make libtinfo symlinks
99 ln -svf lib''${library}$suffix.$dylibtype $out/lib/libtinfo$newsuffix.$dylibtype
100 ln -svf lib''${library}$suffix.$dylibtype.${abiVersion} $out/lib/libtinfo$newsuffix.$dylibtype.${abiVersion}
101 fi
102 fi
103 done
104 for statictype in a dll.a la; do
105 if [ -e "$out/lib/lib''${library}$suffix.$statictype" ]; then
106 ln -svf lib''${library}$suffix.$statictype $out/lib/lib$library$newsuffix.$statictype
107 fi
108 done
109 ln -svf ''${library}$suffix.pc $dev/lib/pkgconfig/$library$newsuffix.pc
110 done
111 done
112
113 # move some utilities to $bin
114 # these programs are used at runtime and don't really belong in $dev
115 moveToOutput "bin/clear" "$out"
116 moveToOutput "bin/reset" "$out"
117 moveToOutput "bin/tabs" "$out"
118 moveToOutput "bin/tput" "$out"
119 moveToOutput "bin/tset" "$out"
120 '';
121
122 preFixup = lib.optionalString (!hostPlatform.isCygwin) ''
123 rm "$out"/lib/*.a
124 '';
125
126 meta = {
127 description = "Free software emulation of curses in SVR4 and more";
128
129 longDescription = ''
130 The Ncurses (new curses) library is a free software emulation of
131 curses in System V Release 4.0, and more. It uses Terminfo
132 format, supports pads and color and multiple highlights and
133 forms characters and function-key mapping, and has all the other
134 SYSV-curses enhancements over BSD Curses.
135
136 The ncurses code was developed under GNU/Linux. It has been in
137 use for some time with OpenBSD as the system curses library, and
138 on FreeBSD and NetBSD as an external package. It should port
139 easily to any ANSI/POSIX-conforming UNIX. It has even been
140 ported to OS/2 Warp!
141 '';
142
143 homepage = http://www.gnu.org/software/ncurses/;
144
145 license = lib.licenses.mit;
146 platforms = lib.platforms.all;
147 maintainers = [ lib.maintainers.wkennington ];
148 };
149
150 passthru = {
151 ldflags = "-lncurses";
152 inherit unicode abiVersion;
153 };
154}