ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / ca / calc / package.nix
blob699f3d25caf74844c95f276a85f84027b7b2848e
1 { lib
2 , stdenv
3 , fetchurl
4 , makeWrapper
5 , ncurses
6 , readline
7 , unixtools
8 , enableReadline ? true
9 }:
11 stdenv.mkDerivation (finalAttrs: {
12   pname = "calc";
13   version = "2.15.0.2";
15   src = fetchurl {
16     urls = [
17       "https://github.com/lcn2/calc/releases/download/v${finalAttrs.version}/calc-${finalAttrs.version}.tar.bz2"
18       "http://www.isthe.com/chongo/src/calc/calc-${finalAttrs.version}.tar.bz2"
19     ];
20     hash = "sha256-dPEj32SiR7RhI9fBa9ny9+EEuuiXS2WswRcDVuOMJXc=";
21   };
23   postPatch = ''
24     substituteInPlace Makefile.target \
25       --replace '-install_name ''${LIBDIR}/libcalc''${LIB_EXT_VERSION}' '-install_name ''${T}''${LIBDIR}/libcalc''${LIB_EXT_VERSION}' \
26       --replace '-install_name ''${LIBDIR}/libcustcalc''${LIB_EXT_VERSION}' '-install_name ''${T}''${LIBDIR}/libcustcalc''${LIB_EXT_VERSION}'
27   '';
29   nativeBuildInputs = [
30     makeWrapper
31     unixtools.col
32   ];
34   buildInputs = lib.optionals enableReadline [
35     ncurses
36     readline
37   ];
39   makeFlags = [
40     "T=$(out)"
41     "INCDIR="
42     "BINDIR=/bin"
43     "LIBDIR=/lib"
44     "CALC_SHAREDIR=/share/calc"
45     "CALC_INCDIR=/include"
46     "MANDIR=/share/man/man1"
48     # Handle LDFLAGS defaults in calc
49     "DEFAULT_LIB_INSTALL_PATH=$(out)/lib"
50   ]
51   ++ lib.optionals enableReadline [
52     "READLINE_LIB=-lreadline"
53     "USE_READLINE=-DUSE_READLINE"
54   ];
56   meta = {
57     homepage = "http://www.isthe.com/chongo/tech/comp/calc/";
58     description = "C-style arbitrary precision calculator";
59     mainProgram = "calc";
60     changelog = "https://github.com/lcn2/calc/blob/v${finalAttrs.version}/CHANGES";
61     # The licensing situation depends on readline (see section 3 of the LGPL)
62     # If linked against readline then GPLv2 otherwise LGPLv2.1
63     license = if enableReadline
64               then lib.licenses.gpl2Only
65               else lib.licenses.lgpl21Only;
66     maintainers = with lib.maintainers; [ matthewbauer ];
67     platforms = lib.platforms.all;
68   };