nixpkgs/pkgs/development/libraries/ncurses/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

176 lines
6.2 KiB
Nix
Raw Normal View History

{ lib
, stdenv
, fetchurl
, buildPackages
, pkg-config
, abiVersion ? "6"
, enableStatic ? stdenv.hostPlatform.isStatic
, withCxx ? !stdenv.hostPlatform.useAndroidPrebuilt
, mouseSupport ? false, gpm
, unicodeSupport ? true
2015-05-01 01:04:37 +00:00
}:
2015-06-19 03:00:18 +00:00
stdenv.mkDerivation rec {
# Note the revision needs to be adjusted.
version = "6.3";
2022-02-10 12:58:01 +00:00
pname = "ncurses" + lib.optionalString (abiVersion == "5") "-abi5-compat";
# We cannot use fetchFromGitHub (which calls fetchzip)
# because we need to be able to use fetchurlBoot.
src = let
# Note the version needs to be adjusted.
rev = "v${version}";
in fetchurl {
url = "https://github.com/mirror/ncurses/archive/${rev}.tar.gz";
sha256 = "1mawdjhzl2na2j0dylwc37f5w95rhgyvlwnfhww5rz2r7fgkvayv";
};
outputs = [ "out" "dev" "man" ];
setOutputFlags = false; # some aren't supported
2015-06-20 20:59:11 +00:00
configureFlags = [
(lib.withFeature (!enableStatic) "shared")
2015-06-20 20:59:11 +00:00
"--without-debug"
"--enable-pc-files"
"--enable-symlinks"
"--with-manpage-format=normal"
"--disable-stripping"
2022-01-17 17:36:23 +00:00
"--with-versioned-syms"
] ++ lib.optional unicodeSupport "--enable-widec"
++ lib.optional (!withCxx) "--without-cxx"
++ lib.optional (abiVersion == "5") "--with-abi-version=5"
ncurses: fix build on NetBSD Only tested cross-compiling, but is probably necessary for native too. Fixes errors like this: linking ../lib/libncursesw.so x86_64-unknown-netbsd-gcc --param max-inline-insns-single=1200 -Wl,-shared -Wl,-Bshareable -o ../lib/libncursesw.so ../obj_s/hardscroll.o ../obj_s/hashmap.o ../obj_s/lib_addch.o ../obj_s/lib_addstr.o ../obj_s/lib_beep.o ../obj_s/lib_bkgd.o ../obj_s/lib_box.o ../obj_s/lib_chgat.o ../obj_s/lib_clear.o ../obj_s/lib_clearok.o ../obj_s/lib_clrbot.o ../obj_s/lib_clreol.o ../obj_s/lib_color.o ../obj_s/lib_colorset.o ../obj_s/lib_delch.o ../obj_s/lib_delwin.o ../obj_s/lib_echo.o ../obj_s/lib_endwin.o ../obj_s/lib_erase.o ../obj_s/lib_flash.o ../obj_s/lib_gen.o ../obj_s/lib_getch.o ../obj_s/lib_getstr.o ../obj_s/lib_hline.o ../obj_s/lib_immedok.o ../obj_s/lib_inchstr.o ../obj_s/lib_initscr.o ../obj_s/lib_insch.o ../obj_s/lib_insdel.o ../obj_s/lib_insnstr.o ../obj_s/lib_instr.o ../obj_s/lib_isendwin.o ../obj_s/lib_leaveok.o ../obj_s/lib_mouse.o ../obj_s/lib_move.o ../obj_s/lib_mvcur.o ../obj_s/lib_mvwin.o ../obj_s/lib_newterm.o ../obj_s/lib_newwin.o ../obj_s/lib_nl.o ../obj_s/lib_overlay.o ../obj_s/lib_pad.o ../obj_s/lib_printw.o ../obj_s/lib_redrawln.o ../obj_s/lib_refresh.o ../obj_s/lib_restart.o ../obj_s/lib_scanw.o ../obj_s/lib_screen.o ../obj_s/lib_scroll.o ../obj_s/lib_scrollok.o ../obj_s/lib_scrreg.o ../obj_s/lib_set_term.o ../obj_s/lib_slk.o ../obj_s/lib_slkatr_set.o ../obj_s/lib_slkatrof.o ../obj_s/lib_slkatron.o ../obj_s/lib_slkatrset.o ../obj_s/lib_slkattr.o ../obj_s/lib_slkclear.o ../obj_s/lib_slkcolor.o ../obj_s/lib_slkinit.o ../obj_s/lib_slklab.o ../obj_s/lib_slkrefr.o ../obj_s/lib_slkset.o ../obj_s/lib_slktouch.o ../obj_s/lib_touch.o ../obj_s/lib_tstp.o ../obj_s/lib_ungetch.o ../obj_s/lib_vidattr.o ../obj_s/lib_vline.o ../obj_s/lib_wattroff.o ../obj_s/lib_wattron.o ../obj_s/lib_winch.o ../obj_s/lib_window.o ../obj_s/nc_panel.o ../obj_s/safe_sprintf.o ../obj_s/tty_update.o ../obj_s/varargs.o ../obj_s/vsscanf.o ../obj_s/lib_freeall.o ../obj_s/charable.o ../obj_s/lib_add_wch.o ../obj_s/lib_box_set.o ../obj_s/lib_cchar.o ../obj_s/lib_erasewchar.o ../obj_s/lib_get_wch.o ../obj_s/lib_get_wstr.o ../obj_s/lib_hline_set.o ../obj_s/lib_in_wch.o ../obj_s/lib_in_wchnstr.o ../obj_s/lib_ins_wch.o ../obj_s/lib_inwstr.o ../obj_s/lib_key_name.o ../obj_s/lib_pecho_wchar.o ../obj_s/lib_slk_wset.o ../obj_s/lib_unget_wch.o ../obj_s/lib_vid_attr.o ../obj_s/lib_vline_set.o ../obj_s/lib_wacs.o ../obj_s/lib_wunctrl.o ../obj_s/expanded.o ../obj_s/legacy_coding.o ../obj_s/lib_dft_fgbg.o ../obj_s/lib_print.o ../obj_s/new_pair.o ../obj_s/resizeterm.o ../obj_s/use_screen.o ../obj_s/use_window.o ../obj_s/wresize.o ../obj_s/access.o ../obj_s/add_tries.o ../obj_s/alloc_ttype.o ../obj_s/codes.o ../obj_s/comp_captab.o ../obj_s/comp_error.o ../obj_s/comp_hash.o ../obj_s/comp_userdefs.o ../obj_s/db_iterator.o ../obj_s/doalloc.o ../obj_s/entries.o ../obj_s/fallback.o ../obj_s/free_ttype.o ../obj_s/getenv_num.o ../obj_s/home_terminfo.o ../obj_s/init_keytry.o ../obj_s/lib_acs.o ../obj_s/lib_baudrate.o ../obj_s/lib_cur_term.o ../obj_s/lib_data.o ../obj_s/lib_has_cap.o ../obj_s/lib_kernel.o ../obj_s/lib_keyname.o ../obj_s/lib_longname.o ../obj_s/lib_napms.o ../obj_s/lib_options.o ../obj_s/lib_raw.o ../obj_s/lib_setup.o ../obj_s/lib_termcap.o ../obj_s/lib_termname.o ../obj_s/lib_tgoto.o ../obj_s/lib_ti.o ../obj_s/lib_tparm.o ../obj_s/lib_tputs.o ../obj_s/lib_trace.o ../obj_s/lib_ttyflags.o ../obj_s/lib_twait.o ../obj_s/name_match.o ../obj_s/names.o ../obj_s/obsolete.o ../obj_s/read_entry.o ../obj_s/read_termcap.o ../obj_s/strings.o ../obj_s/tries.o ../obj_s/trim_sgr0.o ../obj_s/unctrl.o ../obj_s/visbuf.o ../obj_s/alloc_entry.o ../obj_s/captoinfo.o ../obj_s/comp_expand.o ../obj_s/comp_parse.o ../obj_s/comp_scan.o ../obj_s/parse_entry.o ../obj_s/write_entry.o ../obj_s/define_key.o ../obj_s/hashed_db.o ../obj_s/key_defined.o ../obj_s/keybound.o ../obj_s/keyok.o ../obj_s/version.o -L../lib /nix/store/6h96vn8vpm01sn0r5shdl48nw94kzls6-x86_64-unknown-netbsd-binutils-2.35.1/bin/x86_64-unknown-netbsd-ld: /nix/store/dy4bg91z7g0p8k3cdq8rbmzj27lsmx5k-libc-netbsd-9.1-x86_64-unknown-netbsd/lib/crt0.o: in function `__start': (.text+0x31): undefined reference to `__fini_array_start' /nix/store/6h96vn8vpm01sn0r5shdl48nw94kzls6-x86_64-unknown-netbsd-binutils-2.35.1/bin/x86_64-unknown-netbsd-ld: /nix/store/dy4bg91z7g0p8k3cdq8rbmzj27lsmx5k-libc-netbsd-9.1-x86_64-unknown-netbsd/lib/crt0.o: relocation R_X86_64_PC32 against undefined hidden symbol `__fini_array_start' can not be used when making a shared object /nix/store/6h96vn8vpm01sn0r5shdl48nw94kzls6-x86_64-unknown-netbsd-binutils-2.35.1/bin/x86_64-unknown-netbsd-ld: final link failed: bad value collect2: error: ld returned 1 exit status
2021-06-06 18:03:08 +00:00
++ lib.optional stdenv.hostPlatform.isNetBSD "--enable-rpath"
++ lib.optionals stdenv.hostPlatform.isWindows [
"--enable-sp-funcs"
"--enable-term-driver"
];
# Only the C compiler, and explicitly not C++ compiler needs this flag on solaris:
CFLAGS = lib.optionalString stdenv.isSunOS "-D_XOPEN_SOURCE_EXTENDED";
depsBuildBuild = [
buildPackages.stdenv.cc
];
2017-04-26 03:52:29 +00:00
nativeBuildInputs = [
pkg-config
] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
buildPackages.ncurses
2017-04-26 03:52:29 +00:00
];
buildInputs = lib.optional (mouseSupport && stdenv.isLinux) gpm;
preConfigure = ''
export PKG_CONFIG_LIBDIR="$dev/lib/pkgconfig"
mkdir -p "$PKG_CONFIG_LIBDIR"
configureFlagsArray+=(
"--libdir=$out/lib"
"--includedir=$dev/include"
"--bindir=$dev/bin"
"--mandir=$man/share/man"
"--with-pkg-config-libdir=$PKG_CONFIG_LIBDIR"
)
''
+ lib.optionalString stdenv.isSunOS ''
sed -i -e '/-D__EXTENSIONS__/ s/-D_XOPEN_SOURCE=\$cf_XOPEN_SOURCE//' \
-e '/CPPFLAGS="$CPPFLAGS/s/ -D_XOPEN_SOURCE_EXTENDED//' \
configure
CFLAGS=-D_XOPEN_SOURCE_EXTENDED
'';
2013-02-28 15:20:03 +00:00
enableParallelBuilding = true;
2015-05-01 01:04:37 +00:00
doCheck = false;
# When building a wide-character (Unicode) build, create backward
# compatibility links from the the "normal" libraries to the
# wide-character libraries (e.g. libncurses.so to libncursesw.so).
postFixup = let
abiVersion-extension = if stdenv.isDarwin then "${abiVersion}.$dylibtype" else "$dylibtype.${abiVersion}"; in
''
2015-06-19 03:00:18 +00:00
# Determine what suffixes our libraries have
suffix="$(awk -F': ' 'f{print $3; f=0} /default library suffix/{f=1}' config.log)"
libs="$(ls $dev/lib/pkgconfig | tr ' ' '\n' | sed "s,\(.*\)$suffix\.pc,\1,g")"
2015-06-19 03:00:18 +00:00
suffixes="$(echo "$suffix" | awk '{for (i=1; i < length($0); i++) {x=substr($0, i+1, length($0)-i); print x}}')"
2015-05-01 01:04:37 +00:00
2015-06-19 03:00:18 +00:00
# Get the path to the config util
cfg=$(basename $dev/bin/ncurses*-config)
2015-05-01 01:04:37 +00:00
# symlink the full suffixed include directory
ln -svf . $dev/include/ncurses$suffix
2015-06-19 03:00:18 +00:00
for newsuffix in $suffixes ""; do
# Create a non-abi versioned config util links
ln -svf $cfg $dev/bin/ncurses$newsuffix-config
2015-06-19 03:00:18 +00:00
# Allow for end users who #include <ncurses?w/*.h>
ln -svf . $dev/include/ncurses$newsuffix
2015-06-19 03:00:18 +00:00
for library in $libs; do
2015-06-19 03:00:18 +00:00
for dylibtype in so dll dylib; do
if [ -e "$out/lib/lib''${library}$suffix.$dylibtype" ]; then
ln -svf lib''${library}$suffix.$dylibtype $out/lib/lib$library$newsuffix.$dylibtype
ln -svf lib''${library}$suffix.${abiVersion-extension} $out/lib/lib$library$newsuffix.${abiVersion-extension}
if [ "ncurses" = "$library" ]
then
# make libtinfo symlinks
ln -svf lib''${library}$suffix.$dylibtype $out/lib/libtinfo$newsuffix.$dylibtype
ln -svf lib''${library}$suffix.${abiVersion-extension} $out/lib/libtinfo$newsuffix.${abiVersion-extension}
fi
2015-06-19 03:00:18 +00:00
fi
done
for statictype in a dll.a la; do
if [ -e "$out/lib/lib''${library}$suffix.$statictype" ]; then
ln -svf lib''${library}$suffix.$statictype $out/lib/lib$library$newsuffix.$statictype
2018-07-14 12:38:39 +00:00
if [ "ncurses" = "$library" ]
then
# make libtinfo symlinks
ln -svf lib''${library}$suffix.$statictype $out/lib/libtinfo$newsuffix.$statictype
fi
2015-06-19 03:00:18 +00:00
fi
done
ln -svf ''${library}$suffix.pc $dev/lib/pkgconfig/$library$newsuffix.pc
2015-06-19 03:00:18 +00:00
done
done
# move some utilities to $bin
# these programs are used at runtime and don't really belong in $dev
moveToOutput "bin/clear" "$out"
moveToOutput "bin/reset" "$out"
moveToOutput "bin/tabs" "$out"
2017-08-13 05:13:04 +00:00
moveToOutput "bin/tic" "$out"
moveToOutput "bin/tput" "$out"
moveToOutput "bin/tset" "$out"
moveToOutput "bin/captoinfo" "$out"
moveToOutput "bin/infotocap" "$out"
2019-10-28 02:16:43 +00:00
moveToOutput "bin/infocmp" "$out"
2015-05-01 01:04:37 +00:00
'';
2014-08-08 17:28:24 +00:00
preFixup = lib.optionalString (!stdenv.hostPlatform.isCygwin && !enableStatic) ''
rm "$out"/lib/*.a
'';
meta = with lib; {
homepage = "https://www.gnu.org/software/ncurses/";
description = "Free software emulation of curses in SVR4 and more";
longDescription = ''
The Ncurses (new curses) library is a free software emulation of curses in
System V Release 4.0, and more. It uses Terminfo format, supports pads and
color and multiple highlights and forms characters and function-key
mapping, and has all the other SYSV-curses enhancements over BSD Curses.
The ncurses code was developed under GNU/Linux. It has been in use for
some time with OpenBSD as the system curses library, and on FreeBSD and
NetBSD as an external package. It should port easily to any
ANSI/POSIX-conforming UNIX. It has even been ported to OS/2 Warp!
'';
license = licenses.mit;
platforms = platforms.all;
};
2015-05-01 01:04:37 +00:00
passthru = {
ldflags = "-lncurses";
inherit unicodeSupport abiVersion;
};
2014-08-08 17:28:24 +00:00
}