From 4f05eadcb6f94b24099e04b1bdfb2912be10c446 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 3 Sep 2021 16:40:47 +0200 Subject: Meson: Add libccp4c as a wrapped subproject --- INSTALL.md | 6 ++ libcrystfel/meson.build | 4 +- meson.build | 2 +- subprojects/libccp4c.wrap | 10 +++ subprojects/packagefiles/libccp4c/meson.build | 97 +++++++++++++++++++++++++++ 5 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 subprojects/libccp4c.wrap create mode 100644 subprojects/packagefiles/libccp4c/meson.build diff --git a/INSTALL.md b/INSTALL.md index dd2f2b5d..8cba45b9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -56,6 +56,12 @@ to download and install any of them separately from source. In particular, we emphatically recommend against trying to install GTK, Cairo, Pango or gdk-pixbuf from source. +If libccp4 is not available on the system and you compile using Meson, then +libccp4 will be downloaded and compiled automatically. If you don't want this, +add option `--wrap-mode=nofallback` when invoking Meson. See the Meson manual +for other possibilities, such as using locally-provided files instead of +downloading them. + We also do not recommend using dependencies from Conda/Anaconda. Do not activate any Conda environment before compiling CrystFEL, not even the "base" environment. Don't even "source" the Conda setup file before installing diff --git a/libcrystfel/meson.build b/libcrystfel/meson.build index 429a78c9..026f2c8a 100644 --- a/libcrystfel/meson.build +++ b/libcrystfel/meson.build @@ -32,7 +32,9 @@ if fdipdep.found() conf_data.set10('HAVE_FDIP', 1) endif -ccp4dep = dependency('libccp4c', required: false) +ccp4dep = dependency('libccp4c', + required: false, + fallback: ['libccp4c', 'libccp4c_dep']) if ccp4dep.found() conf_data.set10('HAVE_LIBCCP4', 1) endif diff --git a/meson.build b/meson.build index 841e65cd..6e92d430 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project('crystfel', 'c', version: '0.10.0', license: 'GPL3+', - meson_version: '>=0.50.0', + meson_version: '>=0.55.0', default_options: ['buildtype=debugoptimized']) libcrystfel_api_version = 14 diff --git a/subprojects/libccp4c.wrap b/subprojects/libccp4c.wrap new file mode 100644 index 00000000..21e89f3b --- /dev/null +++ b/subprojects/libccp4c.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory = libccp4-6.5.1 +source_url = ftp://ftp.ccp4.ac.uk/opensource/libccp4-6.5.1.tar.gz +source_fallback_url = https://www.desy.de/~twhite/crystfel/libccp4-6.5.1.tar.gz +source_filename = libccp4-6.5.1.tar.gz +source_hash = 280b473d950cdf8837ef66147ec581104298b892399bd856f13b096f2395dbe5 +patch_directory = libccp4c + +[provide] +libccp4c = libccp4c_dep diff --git a/subprojects/packagefiles/libccp4c/meson.build b/subprojects/packagefiles/libccp4c/meson.build new file mode 100644 index 00000000..b7b976ba --- /dev/null +++ b/subprojects/packagefiles/libccp4c/meson.build @@ -0,0 +1,97 @@ +# Meson file for libccp4c (CCP4 core libraries, C part only) +project('libccp4c', ['c'], + version: '6.5.1', + meson_version: '>=0.49.0', + license: 'LGPL3') + + +cc = meson.get_compiler('c') +mdep = cc.find_library('m', required: true) + + +# 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="' + get_option('prefix') + '"', + 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: +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) -- cgit v1.2.3