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 = "http://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 '';
22
23 configurePhase = ''
24 export CERN=`pwd`
25 export CERN_LEVEL=${version}
26 export CERN_ROOT=$CERN/$CERN_LEVEL
27 export CVSCOSRC=`pwd`/$CERN_LEVEL/src
28 export PATH=$PATH:$CERN_ROOT/bin
29 '';
30
31 buildPhase = ''
32 cd $CERN_ROOT
33 mkdir -p build bin lib
34
35 cd $CERN_ROOT/build
36 $CVSCOSRC/config/imake_boot
37 make bin/kuipc
38 make scripts/Makefile
39 pushd scripts
40 make install.bin
41 popd
42 make
43 '';
44
45 installPhase = ''
46 mkdir "$out"
47 cp -r "$CERN_ROOT/bin" "$out"
48 cp -r "$CERN_ROOT/lib" "$out"
49 mkdir "$out/$CERN_LEVEL"
50 ln -s "$out/bin" "$out/$CERN_LEVEL/bin"
51 ln -s "$out/lib" "$out/$CERN_LEVEL/lib"
52 '';
53
54 setupHook = ./setup-hook.sh;
55
56 meta = {
57 homepage = http://cernlib.web.cern.ch;
58 description = "Legacy collection of libraries and modules for data analysis in high energy physics";
59 platforms = stdenv.lib.platforms.unix;
60 maintainers = with stdenv.lib.maintainers; [ veprbl ];
61 license = stdenv.lib.licenses.gpl2;
62 };
63}