mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-22 20:14:37 +00:00
crystfel: enable aarch64-* and external filter plugins on Darwin
This commit is contained in:
parent
fca0501c76
commit
da46337f0e
116
pkgs/applications/science/physics/crystfel/add-meson-build.patch
Normal file
116
pkgs/applications/science/physics/crystfel/add-meson-build.patch
Normal file
@ -0,0 +1,116 @@
|
||||
diff --git a/meson.build b/meson.build
|
||||
new file mode 100644
|
||||
index 0000000..8fc0631
|
||||
--- /dev/null
|
||||
+++ b/meson.build
|
||||
@@ -0,0 +1,110 @@
|
||||
+# Meson file for libccp4c (CCP4 core libraries, C part only)
|
||||
+project('libccp4c', 'c', version: '8.0.0', meson_version: '>=0.49.0', license: 'LGPL-3.0-or-later')
|
||||
+
|
||||
+cc = meson.get_compiler('c')
|
||||
+mdep = cc.find_library('m', required: false)
|
||||
+
|
||||
+# Note that the source code assumes that datadir='share'.
|
||||
+# If it is not, programs using the library will not be able
|
||||
+# to find 'environ.def'.
|
||||
+datadir = get_option('datadir') / 'ccp4'
|
||||
+
|
||||
+add_project_arguments('-DPACKAGE_ROOT="@0@"'.format(get_option('prefix')), language: 'c')
|
||||
+add_project_arguments(
|
||||
+ cc.get_supported_arguments(
|
||||
+ '-Wno-uninitialized',
|
||||
+ '-Wno-unused-function',
|
||||
+ '-Wno-stringop-truncation',
|
||||
+ '-Wno-stringop-overflow',
|
||||
+ '-Wno-format-overflow',
|
||||
+ '-Wno-misleading-indentation',
|
||||
+ '-Wno-pointer-compare',
|
||||
+ ),
|
||||
+ language: 'c',
|
||||
+)
|
||||
+
|
||||
+# C library
|
||||
+libccp4c = library(
|
||||
+ 'ccp4c',
|
||||
+ 'ccp4/ccp4_array.c',
|
||||
+ 'ccp4/cmap_accessor.c',
|
||||
+ 'ccp4/cmap_open.c',
|
||||
+ 'ccp4/csymlib.c',
|
||||
+ 'ccp4/pack_c.c',
|
||||
+ 'ccp4/ccp4_general.c',
|
||||
+ 'ccp4/cmap_close.c',
|
||||
+ 'ccp4/cmap_skew.c',
|
||||
+ 'ccp4/cvecmat.c',
|
||||
+ 'ccp4/ccp4_parser.c',
|
||||
+ 'ccp4/cmap_data.c',
|
||||
+ 'ccp4/cmap_stats.c',
|
||||
+ 'ccp4/library_err.c',
|
||||
+ 'ccp4/ccp4_program.c',
|
||||
+ 'ccp4/cmap_header.c',
|
||||
+ 'ccp4/cmap_symop.c',
|
||||
+ 'ccp4/library_file.c',
|
||||
+ 'ccp4/ccp4_unitcell.c',
|
||||
+ 'ccp4/cmap_labels.c',
|
||||
+ 'ccp4/cmtzlib.c',
|
||||
+ 'ccp4/library_utils.c',
|
||||
+ dependencies: mdep,
|
||||
+ install: true,
|
||||
+)
|
||||
+
|
||||
+# CCP4 headers are included with prefix: <ccp4/header.h>
|
||||
+incdir = include_directories('.')
|
||||
+
|
||||
+install_headers(
|
||||
+ 'ccp4/ccp4_file_err.h',
|
||||
+ 'ccp4/ccp4_program.h',
|
||||
+ 'ccp4/ccp4_unitcell.h',
|
||||
+ 'ccp4/cmap_errno.h',
|
||||
+ 'ccp4/cmap_stats.h',
|
||||
+ 'ccp4/csymlib.h',
|
||||
+ 'ccp4/library_file.h',
|
||||
+ 'ccp4/ccp4_fortran.h',
|
||||
+ 'ccp4/ccp4_spg.h',
|
||||
+ 'ccp4/ccp4_utils.h',
|
||||
+ 'ccp4/cmap_header.h',
|
||||
+ 'ccp4/cmaplib.h',
|
||||
+ 'ccp4/cvecmat.h',
|
||||
+ 'ccp4/mtzdata.h',
|
||||
+ 'ccp4/ccp4_array.h',
|
||||
+ 'ccp4/ccp4_general.h',
|
||||
+ 'ccp4/ccp4_sysdep.h',
|
||||
+ 'ccp4/ccp4_vars.h',
|
||||
+ 'ccp4/cmap_labels.h',
|
||||
+ 'ccp4/cmaplib_f.h',
|
||||
+ 'ccp4/overview.h',
|
||||
+ 'ccp4/ccp4_errno.h',
|
||||
+ 'ccp4/ccp4_parser.h',
|
||||
+ 'ccp4/ccp4_types.h',
|
||||
+ 'ccp4/cmap_data.h',
|
||||
+ 'ccp4/cmap_skew.h',
|
||||
+ 'ccp4/cmtzlib.h',
|
||||
+ 'ccp4/pack_c.h',
|
||||
+ subdir: 'ccp4',
|
||||
+)
|
||||
+
|
||||
+# Data files
|
||||
+install_data(
|
||||
+ 'data/atomsf_electron.lib',
|
||||
+ 'data/atomsf.lib',
|
||||
+ 'data/atomsf_neutron.lib',
|
||||
+ 'data/syminfo.lib',
|
||||
+ 'data/symop.lib',
|
||||
+ install_dir: datadir,
|
||||
+)
|
||||
+
|
||||
+# pkg-config file
|
||||
+pkg = import('pkgconfig')
|
||||
+pkg.generate(
|
||||
+ libccp4c,
|
||||
+ filebase: 'libccp4c',
|
||||
+ description: 'CCP4 core C libraries',
|
||||
+)
|
||||
+
|
||||
+libccp4c_dep = declare_dependency(
|
||||
+ include_directories: incdir,
|
||||
+ link_with: libccp4c,
|
||||
+)
|
@ -6,7 +6,6 @@
|
||||
, cmake
|
||||
, lz4
|
||||
, bzip2
|
||||
, gfortran
|
||||
, m4
|
||||
, hdf5
|
||||
, gsl
|
||||
@ -38,14 +37,12 @@
|
||||
let
|
||||
libccp4 = stdenv.mkDerivation rec {
|
||||
pname = "libccp4";
|
||||
version = "6.5.1";
|
||||
version = "8.0.0";
|
||||
src = fetchurl {
|
||||
# Original mirror, now times out
|
||||
# url = "ftp://ftp.ccp4.ac.uk/opensource/${pname}-${version}.tar.gz";
|
||||
url = "https://deb.debian.org/debian/pool/main/libc/${pname}/${pname}_${version}.orig.tar.gz";
|
||||
sha256 = "1rfvjliny29vy5bdi6rrjaw9hhhhh72pw536xwvqipqcjlylf2r8";
|
||||
url = "http://ftp.ccp4.ac.uk/opensource/${pname}-${version}.tar.gz";
|
||||
hash = "sha256-y4E66GYSoIZjKd6rfO6W6sVz2BvlskA0HUD5rVMi/y0=";
|
||||
};
|
||||
nativeBuildInputs = [ gfortran m4 ];
|
||||
nativeBuildInputs = [ meson ninja ];
|
||||
buildInputs = [ hdf5 gsl ];
|
||||
|
||||
configureFlags = [ "FFLAGS=-fallow-argument-mismatch" ];
|
||||
@ -53,15 +50,12 @@ let
|
||||
# libccp4 tries to read syminfo.lib by looking at an environment variable, which hinders reproducibility.
|
||||
# We hard-code this by providing a little patch and then passing the absolute path to syminfo.lib as a
|
||||
# preprocessor flag.
|
||||
preBuild = ''
|
||||
makeFlagsArray+=(CFLAGS='-DNIX_PROVIDED_SYMOP_FILE=\"${placeholder "out"}/share/syminfo.lib\"')
|
||||
export NIX_LDFLAGS="-L${gfortran.cc}/lib64 -L${gfortran.cc}/lib $NIX_LDFLAGS";
|
||||
'';
|
||||
makeFlags = [ "CFLAGS='-DNIX_PROVIDED_SYMOP_FILE=\"${placeholder "out"}/share/syminfo.lib\"" ];
|
||||
env.NIX_CFLAGS_COMPILE = "-DNIX_PROVIDED_SYMOP_FILE=\"${placeholder "out"}/share/ccp4/syminfo.lib\"";
|
||||
|
||||
patches = [
|
||||
# This circumvents the original autoconf/CMake based build and uses meson instead
|
||||
./add-meson-build.patch
|
||||
./libccp4-use-hardcoded-syminfo-lib.patch
|
||||
./0002-fix-ftbfs-with-gcc-10.patch
|
||||
];
|
||||
};
|
||||
# This is the statically-linked, pre-built binary of mosflm. Compiling it ourselves turns out to be very difficult
|
||||
@ -143,10 +137,10 @@ let
|
||||
pname = "HDF5-External-Filter-Plugins";
|
||||
version = "0.1.0";
|
||||
src = fetchFromGitHub {
|
||||
owner = "nexusformat";
|
||||
owner = "spanezz";
|
||||
repo = pname;
|
||||
rev = "d469f175e5273c1d488e71a6134f84088f57d39c";
|
||||
sha256 = "1jrzzh75i68ad1yrim7s1nx9wy0s49ghkziahs71mm5azprm6gh9";
|
||||
rev = "master";
|
||||
hash = "sha256-Lkhhfhs0dIEplTAod1VBeO4vWH5/MIdfRvhAI3bCgD4=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
@ -184,13 +178,14 @@ stdenv.mkDerivation rec {
|
||||
] ++ lib.optionals withGui [ gtk3 gdk-pixbuf ]
|
||||
++ lib.optionals stdenv.isDarwin [
|
||||
argp-standalone
|
||||
] ++ lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [
|
||||
memorymappingHook
|
||||
]
|
||||
# hdf5-external-filter-plugins doesn't link on Darwin
|
||||
++ lib.optionals (withBitshuffle && !stdenv.isDarwin) [ hdf5-external-filter-plugins ];
|
||||
++ lib.optionals withBitshuffle [ hdf5-external-filter-plugins ];
|
||||
|
||||
patches = [
|
||||
./link-to-argp-standalone-if-needed.patch
|
||||
./disable-fmemopen-on-aarch64-darwin.patch
|
||||
(fetchpatch {
|
||||
url = "https://gitlab.desy.de/thomas.white/crystfel/-/commit/3c54d59e1c13aaae716845fed2585770c3ca9d14.diff";
|
||||
hash = "sha256-oaJNBQQn0c+z4p1pnW4osRJA2KdKiz4hWu7uzoKY7wc=";
|
||||
@ -204,7 +199,7 @@ stdenv.mkDerivation rec {
|
||||
sed -i -e 's#execlp("mosflm"#execl("${mosflm}/bin/mosflm"#' libcrystfel/src/indexers/mosflm.c;
|
||||
'';
|
||||
|
||||
postInstall = lib.optionalString (withBitshuffle && !stdenv.isDarwin) ''
|
||||
postInstall = lib.optionalString withBitshuffle ''
|
||||
for file in $out/bin/*; do
|
||||
wrapProgram $file --set HDF5_PLUGIN_PATH ${hdf5-external-filter-plugins}/lib/plugins
|
||||
done
|
||||
@ -224,7 +219,7 @@ stdenv.mkDerivation rec {
|
||||
downloadPage = "https://www.desy.de/~twhite/crystfel/download.html";
|
||||
license = licenses.gpl3Plus;
|
||||
maintainers = with maintainers; [ pmiddend ];
|
||||
platforms = [ "x86_64-linux" "x86_64-darwin" ];
|
||||
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
diff --git a/libcrystfel/src/image-cbf.c b/libcrystfel/src/image-cbf.c
|
||||
index b8f09a1f..f8a15c1b 100644
|
||||
--- a/libcrystfel/src/image-cbf.c
|
||||
+++ b/libcrystfel/src/image-cbf.c
|
||||
@@ -287,7 +287,7 @@ static float *read_cbf_data(const char *filename, int gz, int *w, int *h)
|
||||
|
||||
} else {
|
||||
|
||||
- #ifdef HAVE_ZLIB
|
||||
+ #if defined(HAVE_ZLIB) && !(defined(__aarch64__) && defined(__APPLE__))
|
||||
gzFile gzfh;
|
||||
int len_read;
|
||||
size_t len;
|
Loading…
Reference in New Issue
Block a user