calc: cleanup expression

Fixes #39321

(Still needs testing on Linux)
This commit is contained in:
Matthew Bauer 2018-04-22 18:43:40 -05:00
parent e3239a266d
commit 63507ada7d

View File

@ -1,47 +1,49 @@
{ stdenv, fetchurl, makeWrapper, glibc, readline, ncurses, utillinux }: { stdenv, lib, fetchurl, utillinux, makeWrapper
, enableReadline ? true, readline, ncurses }:
with stdenv.lib;
let
makeFlags = ''
INCDIR=${glibc.dev}/include \
BINDIR=$out/bin LIBDIR=$out/lib CALC_INCDIR=$out/include/calc CALC_SHAREDIR=$out/share/calc MANDIR=$out/share/man/man1 \
USE_READLINE=-DUSE_READLINE READLINE_LIB=-lreadline READLINE_EXTRAS='-lhistory -lncurses' \
TERMCONTROL=-DUSE_TERMIOS \
'';
in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "calc-${version}"; name = "calc-${version}";
version = "2.12.6.6"; version = "2.12.6.6";
src = fetchurl { src = fetchurl {
url = "https://github.com/lcn2/calc/releases/download/${version}/${name}.tar.bz2"; urls = [
"https://github.com/lcn2/calc/releases/download/${version}/${name}.tar.bz2"
"http://www.isthe.com/chongo/src/calc/${name}.tar.bz2"
];
sha256 = "03sg1xhin6qsrz82scf96mmzw8lz1yj68rhj4p4npp4s0fawc9d5"; sha256 = "03sg1xhin6qsrz82scf96mmzw8lz1yj68rhj4p4npp4s0fawc9d5";
}; };
buildInputs = [ makeWrapper readline ncurses utillinux ]; patchPhase = ''
substituteInPlace Makefile \
configurePhase = '' --replace 'all: check_include' 'all:' \
sed -i 's/all: check_include/all:/' Makefile --replace '-install_name ''${LIBDIR}/libcalc''${LIB_EXT_VERSION}' '-install_name ''${T}''${LIBDIR}/libcalc''${LIB_EXT_VERSION}' \
--replace '-install_name ''${LIBDIR}/libcustcalc''${LIB_EXT_VERSION}' '-install_name ''${T}''${LIBDIR}/libcustcalc''${LIB_EXT_VERSION}'
''; '';
buildPhase = '' buildInputs = [ utillinux makeWrapper ]
make ${makeFlags} ++ lib.optionals enableReadline [ readline ncurses ];
'';
installPhase = '' makeFlags = [
make install ${makeFlags} "T=$(out)"
wrapProgram $out/bin/calc --prefix LD_LIBRARY_PATH : $out/lib "INCDIR=${lib.getDev stdenv.cc.libc}/include"
''; "BINDIR=/bin"
"LIBDIR=/lib"
"CALC_SHAREDIR=/share/calc"
"CALC_INCDIR=/include"
"MANDIR=/share/man/man1"
# Hack to avoid TMPDIR in RPATHs. # Handle LDFLAGS defaults in calc
preFixup = ''rm -rf "$(pwd)" ''; "DEFAULT_LIB_INSTALL_PATH=$(out)/lib"
] ++ lib.optionals enableReadline [
"READLINE_LIB=-lreadline"
"USE_READLINE=-DUSE_READLINE"
];
meta = { meta = with lib; {
description = "C-style arbitrary precision calculator"; description = "C-style arbitrary precision calculator";
homepage = http://www.isthe.com/chongo/tech/comp/calc/; homepage = http://www.isthe.com/chongo/tech/comp/calc/;
license = licenses.lgpl21; license = licenses.lgpl21;
maintainers = [ ]; maintainers = with maintainers; [ matthewbauer ];
platforms = platforms.all; platforms = platforms.all;
}; };
} }