Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cernlib: 2006 -> 2024.06.12.0 #336597

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

126 changes: 49 additions & 77 deletions pkgs/development/libraries/physics/cernlib/default.nix
Original file line number Diff line number Diff line change
@@ -1,102 +1,74 @@
{ lib, stdenv, fetchurl, gfortran, imake, makedepend, motif, xorg, libxcrypt }:
{
lib,
stdenv,
fetchpatch,
fetchurl,
cmake,
freetype,
gfortran,
gnused,
openssl,
libnsl,
motif,
xorg,
libxcrypt,
}:

stdenv.mkDerivation rec {
version = "2006";
version = "2024.06.12.0";
pname = "cernlib";
year = lib.versions.major version;

src = fetchurl {
urls = [
"https://ftp.riken.jp/cernlib/download/${version}_source/tar/${version}_src.tar.gz"
"https://cernlib.web.cern.ch/cernlib/download/${version}_source/tar/${version}_src.tar.gz"
"https://ftp.riken.jp/cernlib/download/${year}_source/tar/cernlib-cernlib-${version}-free.tar.gz"
"https://cernlib.web.cern.ch/download/${year}_source/tar/cernlib-cernlib-${version}-free.tar.gz"
];
sha256 = "0awla1rl96z82br7slcmg8ks1d2a7slk6dj79ywb871j2ksi3fky";
hash = "sha256-SEFgQjPBkmRoaMD/7yXiXO9DZNrRhqZ01kptSDQur84=";
};

buildInputs = with xorg; [ gfortran motif libX11 libXft libXt libxcrypt ];
nativeBuildInputs = [ imake makedepend ];
sourceRoot = ".";

patches = [ ./patch.patch ./0001-Use-strerror-rather-than-sys_errlist-to-fix-compilat.patch ];
patches = [
(fetchpatch {
url = "https://github.com/user-attachments/files/16832928/geant321-fix-weak-alias-on-darwin.patch";
hash = "sha256-YzaUh4rJBszGdp5s/HDQMI5qQhCGrTt9P6XCgZOFn1I=";
})
];

postPatch = ''
echo 'InstallBinSubdirs(packlib scripts)' >> 2006/src/Imakefile
substituteInPlace 2006/src/config/site.def \
--replace "# define MakeCmd gmake" "# define MakeCmd make"
substituteInPlace 2006/src/config/lnxLib.rules \
--replace "# lib" "// lib"

substituteInPlace 2006/src/config/linux.cf \
--replace "# ifdef Hasgfortran" "# if 1" \
--replace "# define CcCmd gcc4" "# define CcCmd gcc"
substituteInPlace 2006/src/scripts/cernlib \
--replace "-lnsl" ""

# binutils 2.37 fix
substituteInPlace 2006/src/config/Imake.tmpl --replace "clq" "cq"
substituteInPlace CMakeLists.txt \
--replace-fail "find_program ( SED NAMES gsed" "find_program ( SED NAMES sed"
'';

# gfortran warning's on iframework messes with CMake's check_fortran_compiler_flag
# see also https://github.com/NixOS/nixpkgs/issues/27218
preConfigure = ''
export CERN=`pwd`
export CERN_LEVEL=${version}
export CERN_ROOT=$CERN/$CERN_LEVEL
export CVSCOSRC=`pwd`/$CERN_LEVEL/src
export PATH=$PATH:$CERN_ROOT/bin
export NIX_CFLAGS_COMPILE="$(echo $NIX_CFLAGS_COMPILE | sed 's|-iframework [^ ]*||g')"
'';

FFLAGS = lib.optionals (lib.versionAtLeast gfortran.version "10.0.0") [
# Fix https://github.com/vmc-project/geant3/issues/17
"-fallow-invalid-boz"

# Fix for gfortran 10
"-fallow-argument-mismatch"
];

NIX_CFLAGS = [ "-Wno-return-type" ];

# Workaround build failure on -fno-common toolchains:
# ld: libpacklib.a(kedit.o):kuip/klink1.h:11: multiple definition of `klnkaddr';
# libzftplib.a(zftpcdf.o):zftp/zftpcdf.c:155: first defined here
env.NIX_CFLAGS_COMPILE = "-fcommon";

makeFlags = [
"FORTRANOPTIONS=$(FFLAGS)"
"CCOPTIONS=$(NIX_CFLAGS)"
];

configurePhase = ''
runHook preConfigure

cd $CERN_ROOT
mkdir -p build
cd $CERN_ROOT/build
$CVSCOSRC/config/imake_boot

runHook postConfigure
'';

preBuild = ''
make -j $NIX_BUILD_CORES $makeFlags bin/kuipc
make -j $NIX_BUILD_CORES $makeFlags scripts/Makefile
pushd scripts
make -j $NIX_BUILD_CORES $makeFlags bin/cernlib
popd
'';

installTargets = [ "install.bin" "install.lib" "install.include" ];
installFlags = [
"CERN_BINDIR=${placeholder "out"}/bin"
"CERN_INCLUDEDIR=${placeholder "out"}/include"
"CERN_LIBDIR=${placeholder "out"}/lib"
"CERN_SHLIBDIR=${placeholder "out"}/libexec"
];
nativeBuildInputs = [ cmake ];
buildInputs = with xorg; [
freetype
gfortran
openssl
libX11
libXaw
libXft
libXt
libxcrypt
motif
] ++ lib.optional stdenv.isLinux libnsl;

setupHook = ./setup-hook.sh;

meta = {
homepage = "http://cernlib.web.cern.ch";
description = "Legacy collection of libraries and modules for data analysis in high energy physics";
broken = stdenv.isDarwin;
platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
platforms = [
"aarch64-linux"
"i686-linux"
"x86_64-linux"
"x86_64-darwin"
];
maintainers = with lib.maintainers; [ veprbl ];
license = lib.licenses.gpl2;
};
Expand Down
Loading