summary refs log tree commit diff
path: root/pkgs/applications/science/math/content/default.nix
blob: 87c047c299573fefab45d13e992db1ff4e53f1b7 (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
a :  
let 
  fetchurl = a.fetchurl;

  version = "1.5"; 
  buildInputs = with a; [
    mesa lesstif libX11 libXaw xproto libXt libSM libICE 
      libXmu libXext libXcursor
  ];
in
rec {
  srcNcbiStdH = fetchurl {
    url = "http://www.math.uu.nl/people/kuznet/CONTENT/src/unix/ncbistd.h";
    sha256 = "1zi3l53b0a7d3620rhxvh1jn7pz3ihl1mxl9qqw86xkmhm4q7xf3";
  };

  srcVibrant = fetchurl {
    url = "http://www.math.uu.nl/people/kuznet/CONTENT/src/unix/vibrant.tar.gz";
    sha256 = "1s0vsa0np3sm7jh3ps3f1sf4j64v0kw4hqasllpxx5hdgxwd8y25";
  };

  srcContent = fetchurl {
    url = "http://www.math.uu.nl/people/kuznet/CONTENT/src/unix/content_${version}.tar.gz";
    sha256 = "0y0dzr1d3jgbd53729jk6s2wpb5hv54xwbdird4r0s15bznpm6fs";
  };

  inherit buildInputs;
  configureFlags = [];

  /* doConfigure should be removed if not needed */
  phaseNames = ["unpackTarballs" 
    "setPlatform" "extraVars"
    "buildVibrant" "buildContent" 
    "install"];

  unpackTarballs = a.fullDepEntry (''
    mkdir content
    cd content
    mkdir vibrant
    tar -xvf ${srcVibrant} -C vibrant
    tar -xvf ${srcContent} -C .
    sed -e s/SGI=/SGI=no/ -i content/makefile_v
  '') ["minInit"];

  platformTLAContent = if a.stdenv.isLinux then "LIN" else 
    throw "Three-letter code for the platform is not known";

  platformTLAVibrant = if a.stdenv.isLinux then "lnx" else 
    throw "Three-letter code for the platform is not known";

  setPlatform = a.fullDepEntry (''
    sed -e 's/${platformTLAContent}=no/${platformTLAContent}=/' -i content/makefile_v
  '') ["minInit" "unpackTarballs"];

  extraVars = a.noDepEntry ''
    export NIX_LDFLAGS="$NIX_LDFLAGS -lXcursor"
  '';

  buildVibrant = a.fullDepEntry (''
    cd vibrant/build
    
    export LCL=${platformTLAVibrant}
    make copy
    for i in *.c; do gcc $i -c -DWIN_MOTIF -I. -I../include; done
    sh ../make/viball.${platformTLAVibrant}

    cd ../..
  '') ["addInputs" "unpackTarballs"];

  buildContent = a.fullDepEntry (''
    cd content 

    export PATH=$PATH:$PWD/victor:$PWD/yuri
    make -f makefile_v unix
    
    cd ..
  '') ["addInputs" "buildVibrant" "setPlatform"];

  install = a.fullDepEntry (''
    mkdir -p $out/share/${name}/build-snapshot $out/bin $out/lib $out/share/${name}/doc
    find . -name '*.o' -exec cp '{}' $out/lib ';'
    find . -name '*.so' -exec cp '{}' $out/lib ';'
    find . -name '*.txt' -exec cp '{}' $out/share/${name}/doc ';'
    find . -name '*.hlp' -exec cp '{}' $out/share/${name}/doc ';'
    find . -perm +111 -a ! -name '*.*' -exec cp '{}' $out/bin ';'
    cp -r . $out/share/${name}/build-snapshot
  '') ["buildContent" "defEnsureDir" "minInit"];
      
  name = "content-" + version;
  meta = {
    description = "A tool for analysis of dynamical systems";
    maintainers = [
      a.lib.maintainers.raskin
    ];
    platforms = a.lib.platforms.linux;
  };
}