Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchurl, gfortran, imake, makedepend, motif, xorg, libxcrypt }: 2 3stdenv.mkDerivation rec { 4 version = "2006"; 5 pname = "cernlib"; 6 7 src = fetchurl { 8 urls = [ 9 "https://ftp.riken.jp/cernlib/download/${version}_source/tar/${version}_src.tar.gz" 10 "https://cernlib.web.cern.ch/cernlib/download/${version}_source/tar/${version}_src.tar.gz" 11 ]; 12 sha256 = "0awla1rl96z82br7slcmg8ks1d2a7slk6dj79ywb871j2ksi3fky"; 13 }; 14 15 buildInputs = with xorg; [ gfortran motif libX11 libXft libXt libxcrypt ]; 16 nativeBuildInputs = [ imake makedepend ]; 17 sourceRoot = "."; 18 19 patches = [ ./patch.patch ./0001-Use-strerror-rather-than-sys_errlist-to-fix-compilat.patch ]; 20 21 postPatch = '' 22 echo 'InstallBinSubdirs(packlib scripts)' >> 2006/src/Imakefile 23 substituteInPlace 2006/src/config/site.def \ 24 --replace "# define MakeCmd gmake" "# define MakeCmd make" 25 substituteInPlace 2006/src/config/lnxLib.rules \ 26 --replace "# lib" "// lib" 27 28 substituteInPlace 2006/src/config/linux.cf \ 29 --replace "# ifdef Hasgfortran" "# if 1" \ 30 --replace "# define CcCmd gcc4" "# define CcCmd gcc" 31 substituteInPlace 2006/src/scripts/cernlib \ 32 --replace "-lnsl" "" 33 34 # binutils 2.37 fix 35 substituteInPlace 2006/src/config/Imake.tmpl --replace "clq" "cq" 36 ''; 37 38 preConfigure = '' 39 export CERN=`pwd` 40 export CERN_LEVEL=${version} 41 export CERN_ROOT=$CERN/$CERN_LEVEL 42 export CVSCOSRC=`pwd`/$CERN_LEVEL/src 43 export PATH=$PATH:$CERN_ROOT/bin 44 ''; 45 46 FFLAGS = lib.optionals (lib.versionAtLeast gfortran.version "10.0.0") [ 47 # Fix https://github.com/vmc-project/geant3/issues/17 48 "-fallow-invalid-boz" 49 50 # Fix for gfortran 10 51 "-fallow-argument-mismatch" 52 ]; 53 54 NIX_CFLAGS = [ "-Wno-return-type" ]; 55 56 # Workaround build failure on -fno-common toolchains: 57 # ld: libpacklib.a(kedit.o):kuip/klink1.h:11: multiple definition of `klnkaddr'; 58 # libzftplib.a(zftpcdf.o):zftp/zftpcdf.c:155: first defined here 59 env.NIX_CFLAGS_COMPILE = "-fcommon"; 60 61 makeFlags = [ 62 "FORTRANOPTIONS=$(FFLAGS)" 63 "CCOPTIONS=$(NIX_CFLAGS)" 64 ]; 65 66 configurePhase = '' 67 runHook preConfigure 68 69 cd $CERN_ROOT 70 mkdir -p build 71 cd $CERN_ROOT/build 72 $CVSCOSRC/config/imake_boot 73 74 runHook postConfigure 75 ''; 76 77 preBuild = '' 78 make -j $NIX_BUILD_CORES $makeFlags bin/kuipc 79 make -j $NIX_BUILD_CORES $makeFlags scripts/Makefile 80 pushd scripts 81 make -j $NIX_BUILD_CORES $makeFlags bin/cernlib 82 popd 83 ''; 84 85 installTargets = [ "install.bin" "install.lib" "install.include" ]; 86 installFlags = [ 87 "CERN_BINDIR=${placeholder "out"}/bin" 88 "CERN_INCLUDEDIR=${placeholder "out"}/include" 89 "CERN_LIBDIR=${placeholder "out"}/lib" 90 "CERN_SHLIBDIR=${placeholder "out"}/libexec" 91 ]; 92 93 setupHook = ./setup-hook.sh; 94 95 meta = { 96 homepage = "http://cernlib.web.cern.ch"; 97 description = "Legacy collection of libraries and modules for data analysis in high energy physics"; 98 broken = stdenv.isDarwin; 99 platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ]; 100 maintainers = with lib.maintainers; [ veprbl ]; 101 license = lib.licenses.gpl2; 102 }; 103}