Commit d980b918 authored by Philipp Middendorf's avatar Philipp Middendorf
Browse files

crystfel: review fixes

parent da46337f
Loading
Loading
Loading
Loading
+0 −43
Original line number Diff line number Diff line
Description: Fixing argument mismatches in Fortran code, addressing #957430.
Author: Andrius Merkys <merkys@debian.org>
Forwarded: ccp4-dev@dl.ac.uk
--- a/fortran/pack_f.f
+++ b/fortran/pack_f.f
@@ -106,7 +106,7 @@
          endif
  10   continue
       filnarray(len(filn) + 1) = 0
-      call pack_wordimage_f(data, x, y, filnarray)
+      call pack_longimage_f(data, x, y, filnarray)
       return
       end
 
@@ -138,7 +138,7 @@
          endif
  10   continue
       filnarray(len(filn) + 1) = 0
-      call v2pack_wordimage_f(data, x, y, filnarray)
+      call v2pack_longimage_f(data, x, y, filnarray)
       return
       end
 
--- a/fortran/lgglib.f
+++ b/fortran/lgglib.f
@@ -1236,7 +1236,7 @@
       B3(2) = XYZ(2) * CELL(2)
       B3(3) = XYZ(3) * CELL(3)
 C
-      CALL matmult(3,3,3,1,ORTH,B3,XYZ,B1)
+      CALL matmult(3,3,3,1,ORTH,B3,XYZ)
       END
 c
 c
@@ -1274,7 +1274,7 @@
       B3(1) = XYZ(1)
       B3(2) = XYZ(2)
       B3(3) = XYZ(3)
-      CALL matmult(3,3,3,1,ORTH,B3,XYZ,B1)
+      CALL matmult(3,3,3,1,ORTH,B3,XYZ)
       END
       character*80 function getnam(filnam)
       character*(*) filnam
+0 −116
Original line number Diff line number Diff line
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,
+)
+23 −6
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
, fetchurl
, fetchFromGitHub
, fetchpatch
, fetchzip
, cmake
, lz4
, bzip2
@@ -39,7 +40,7 @@ let
    pname = "libccp4";
    version = "8.0.0";
    src = fetchurl {
      url = "http://ftp.ccp4.ac.uk/opensource/${pname}-${version}.tar.gz";
      url = "https://ftp.ccp4.ac.uk/opensource/${pname}-${version}.tar.gz";
      hash = "sha256-y4E66GYSoIZjKd6rfO6W6sVz2BvlskA0HUD5rVMi/y0=";
    };
    nativeBuildInputs = [ meson ninja ];
@@ -53,10 +54,19 @@ let
    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
    ];

    postPatch =
      let
        mesonPatch = fetchzip {
          url = "https://wrapdb.mesonbuild.com/v2/libccp4c_8.0.0-1/get_patch#somefile.zip";
          hash = "sha256-ohskfKh+972Pl56KtwAeWwHtAaAFNpCzz5vZBAI/vdU=";
        };
      in
      ''
        cp ${mesonPatch}/meson.build .
      '';
  };
  # This is the statically-linked, pre-built binary of mosflm. Compiling it ourselves turns out to be very difficult
  # since the build process is very hard-coded for a specific machine, architecture, and libraries.
@@ -137,12 +147,19 @@ let
    pname = "HDF5-External-Filter-Plugins";
    version = "0.1.0";
    src = fetchFromGitHub {
      owner = "spanezz";
      owner = "nexusformat";
      repo = pname;
      rev = "master";
      hash = "sha256-Lkhhfhs0dIEplTAod1VBeO4vWH5/MIdfRvhAI3bCgD4=";
      hash = "sha256-bEzfWdZuHmb0PDzCqy8Dey4tLtq+4coO0sT0GzqrTYI=";
    };

    patches = [
      (fetchpatch {
        url = "https://github.com/spanezz/HDF5-External-Filter-Plugins/commit/6b337fe36da97a3ef72354393687ce3386c0709d.patch";
        hash = "sha256-wnBEdL/MjEyRHPwaVtuhzY+DW1AFeaUQUmIXh+JaRHo=";
      })
    ];

    nativeBuildInputs = [ cmake ];
    buildInputs = [ hdf5 lz4 bzip2 ];

@@ -219,7 +236,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" "aarch64-linux" "aarch64-darwin" ];
    platforms = platforms.unix;
  };

}