summary refs log tree commit diff
path: root/pkgs/development/compilers/gnu-cobol/default.nix
blob: 3f1268a9d65af71ec1d8aa88419cc7a1188a5b0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{ lib
, stdenv
, fetchurl
, autoconf269
, automake
, libtool
# libs
, cjson
, db
, gmp
, libxml2
, ncurses
# docs
, help2man
, texinfo
, texlive
# test
, writeText
}:

stdenv.mkDerivation rec {
  pname = "gnu-cobol";
  version = "3.1.2";

  src = fetchurl {
    url = "mirror://sourceforge/gnucobol/${lib.versions.majorMinor version}/gnucobol-${version}.tar.xz";
    sha256 = "0x15ybfm63g7c9340fc6712h9v59spnbyaz4rf85pmnp3zbhaw2r";
  };

  nativeBuildInputs = [
    autoconf269
    automake
    libtool
    help2man
    texinfo
    texlive.combined.scheme-basic
  ];

  buildInputs = [
    cjson
    db
    gmp
    libxml2
    ncurses
  ];

  outputs = [ "bin" "dev" "lib" "out" ];
  # XXX: Without this, we get a cycle between bin and dev
  propagatedBuildOutputs = [];

  # Skips a broken test
  postPatch = ''
    sed -i '/^AT_CHECK.*crud\.cob/i AT_SKIP_IF([true])' tests/testsuite.src/listings.at
  '';

  preConfigure = ''
    autoconf
    aclocal
    automake
  '';

  enableParallelBuilding = true;

  installFlags = [ "install-pdf" "install-html" "localedir=$out/share/locale" ];

  # Tests must run after install.
  doCheck = false;

  doInstallCheck = true;
  installCheckPhase = ''
    runHook preInstallCheck

    # Run tests
    make -j$NIX_BUILD_CORES check

    # Sanity check
    message="Hello, COBOL!"
    # XXX: Don't for a second think you can just get rid of these spaces, they
    # are load bearing.
    tee hello.cbl <<EOF
           IDENTIFICATION DIVISION.
           PROGRAM-ID. HELLO.

           PROCEDURE DIVISION.
           DISPLAY "$message".
           STOP RUN.
    EOF
    $bin/bin/cobc -x -o hello-cobol "hello.cbl"
    hello="$(./hello-cobol | tee >(cat >&2))"
    [[ "$hello" == "$message" ]] || exit 1

    runHook postInstallCheck
  '';

  meta = with lib; {
    description = "An open-source COBOL compiler";
    homepage = "https://sourceforge.net/projects/gnucobol/";
    license = with licenses; [ gpl3Only lgpl3Only ];
    maintainers = with maintainers; [ ericsagnes lovesegfault ];
    platforms = platforms.all;
  };
}