1{ stdenv, fetchurl, gfortran, gnumake, imake, makedepend, motif, xorg }:
2
3stdenv.mkDerivation rec {
4 version = "2006";
5 name = "cernlib-${version}";
6
7 src = fetchurl {
8 url = "https://cernlib.web.cern.ch/cernlib/download/${version}_source/tar/${version}_src.tar.gz";
9 sha256 = "0awla1rl96z82br7slcmg8ks1d2a7slk6dj79ywb871j2ksi3fky";
10 };
11
12 buildInputs = with xorg; [ gfortran motif libX11 libXft libXt ];
13 nativeBuildInputs = [ gnumake imake makedepend ];
14 sourceRoot = ".";
15
16 patches = [ ./patch ];
17
18 postPatch = ''
19 substituteInPlace 2006/src/config/site.def \
20 --replace "# define MakeCmd gmake" "# define MakeCmd make"
21 substituteInPlace 2006/src/config/lnxLib.rules \
22 --replace "# lib" "// lib"
23 '';
24
25 configurePhase = ''
26 export CERN=`pwd`
27 export CERN_LEVEL=${version}
28 export CERN_ROOT=$CERN/$CERN_LEVEL
29 export CVSCOSRC=`pwd`/$CERN_LEVEL/src
30 export PATH=$PATH:$CERN_ROOT/bin
31 '';
32
33 buildPhase = ''
34 cd $CERN_ROOT
35 mkdir -p build bin lib
36
37 cd $CERN_ROOT/build
38 $CVSCOSRC/config/imake_boot
39 make bin/kuipc
40 make scripts/Makefile
41 pushd scripts
42 make install.bin
43 popd
44 make
45 '';
46
47 installPhase = ''
48 mkdir "$out"
49 cp -r "$CERN_ROOT/bin" "$out"
50 cp -r "$CERN_ROOT/lib" "$out"
51 mkdir "$out/$CERN_LEVEL"
52 ln -s "$out/bin" "$out/$CERN_LEVEL/bin"
53 ln -s "$out/lib" "$out/$CERN_LEVEL/lib"
54 '';
55
56 setupHook = ./setup-hook.sh;
57
58 meta = {
59 homepage = http://cernlib.web.cern.ch;
60 description = "Legacy collection of libraries and modules for data analysis in high energy physics";
61 broken = stdenv.isDarwin;
62 platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
63 maintainers = with stdenv.lib.maintainers; [ veprbl ];
64 license = stdenv.lib.licenses.gpl2;
65 };
66}