All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH 17/18] libattr: convert to meson
Date: Thu, 17 Dec 2020 10:40:43 +0100	[thread overview]
Message-ID: <20201217094044.46462-18-pbonzini@redhat.com> (raw)
In-Reply-To: <20201217094044.46462-1-pbonzini@redhat.com>

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure         | 45 ++++-----------------------------------------
 meson.build       | 38 +++++++++++++++++++++++++++++++++++---
 meson_options.txt |  2 ++
 3 files changed, 41 insertions(+), 44 deletions(-)

diff --git a/configure b/configure
index faee71612f..420663d69a 100755
--- a/configure
+++ b/configure
@@ -332,8 +332,7 @@ xen_pci_passthrough="auto"
 linux_aio="$default_feature"
 linux_io_uring="$default_feature"
 cap_ng="auto"
-attr="$default_feature"
-libattr="$default_feature"
+attr="auto"
 xfs="$default_feature"
 tcg="enabled"
 membarrier="$default_feature"
@@ -1230,9 +1229,9 @@ for opt do
   ;;
   --enable-linux-io-uring) linux_io_uring="yes"
   ;;
-  --disable-attr) attr="no"
+  --disable-attr) attr="disabled"
   ;;
-  --enable-attr) attr="yes"
+  --enable-attr) attr="enabled"
   ;;
   --disable-membarrier) membarrier="no"
   ;;
@@ -3544,36 +3543,6 @@ elif test "$tpm" = "yes"; then
   fi
 fi
 
-##########################################
-# attr probe
-
-libattr_libs=
-if test "$attr" != "no" ; then
-  cat > $TMPC <<EOF
-#include <stdio.h>
-#include <sys/types.h>
-#ifdef CONFIG_LIBATTR
-#include <attr/xattr.h>
-#else
-#include <sys/xattr.h>
-#endif
-int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
-EOF
-  if compile_prog "" "" ; then
-    attr=yes
-  # Older distros have <attr/xattr.h>, and need -lattr:
-  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
-    attr=yes
-    libattr_libs="-lattr"
-    libattr=yes
-  else
-    if test "$attr" = "yes" ; then
-      feature_not_found "ATTR" "Install libc6 or libattr devel"
-    fi
-    attr=no
-  fi
-fi
-
 ##########################################
 # iovec probe
 cat > $TMPC <<EOF
@@ -5868,13 +5837,6 @@ if test "$linux_io_uring" = "yes" ; then
   echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
   echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
 fi
-if test "$attr" = "yes" ; then
-  echo "CONFIG_ATTR=y" >> $config_host_mak
-  echo "LIBATTR_LIBS=$libattr_libs" >> $config_host_mak
-fi
-if test "$libattr" = "yes" ; then
-  echo "CONFIG_LIBATTR=y" >> $config_host_mak
-fi
 if test "$vhost_scsi" = "yes" ; then
   echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
 fi
@@ -6536,6 +6498,7 @@ NINJA=$ninja $meson setup \
         -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
         -Dlibssh=$libssh -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse \
         -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
+        -Dattr=$attr \
         -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
         -Dvhost_user_blk_server=$vhost_user_blk_server \
         -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek \
diff --git a/meson.build b/meson.build
index 56ab291d87..341eadaa5c 100644
--- a/meson.build
+++ b/meson.build
@@ -324,10 +324,40 @@ if not get_option('libnfs').auto() or have_block
                       required: get_option('libnfs'),
                       method: 'pkg-config', static: enable_static)
 endif
+
+libattr_test = '''
+  #include <stddef.h>
+  #include <sys/types.h>
+  #ifdef CONFIG_LIBATTR
+  #include <attr/xattr.h>
+  #else
+  #include <sys/xattr.h>
+  #endif
+  int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }'''
+
 libattr = not_found
-if 'CONFIG_ATTR' in config_host
-  libattr = declare_dependency(link_args: config_host['LIBATTR_LIBS'].split())
+have_old_libattr = false
+if not get_option('attr').disabled()
+  if cc.links(libattr_test)
+    libattr = declare_dependency()
+  else
+    libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'],
+                              required: get_option('attr'),
+                              static: enable_static)
+    if libattr.found() and not \
+      cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR')
+      libattr = not_found
+      if get_option('attr').enabled()
+        error('could not link libattr')
+      else
+        warning('could not link libattr, disabling')
+      endif
+    else
+      have_old_libattr = libattr.found()
+    endif
+  endif
 endif
+
 seccomp = not_found
 if not get_option('libiscsi').auto() or have_system or have_tools
   seccomp = dependency('libseccomp', version: '>=2.3.0',
@@ -1006,6 +1036,7 @@ config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') /
 config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
 config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
 
+config_host_data.set('CONFIG_ATTR', libattr.found())
 config_host_data.set('CONFIG_BRLAPI', brlapi.found())
 config_host_data.set('CONFIG_COCOA', cocoa.found())
 config_host_data.set('CONFIG_LIBUDEV', libudev.found())
@@ -1021,6 +1052,7 @@ config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().version_c
 config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().version_compare('>=6'))
 config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat)
 config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat)
+config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
 config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
 config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
 config_host_data.set('CONFIG_LIBNFS', libnfs.found())
@@ -2343,7 +2375,7 @@ summary_info += {'vde support':       config_host.has_key('CONFIG_VDE')}
 summary_info += {'netmap support':    config_host.has_key('CONFIG_NETMAP')}
 summary_info += {'Linux AIO support': config_host.has_key('CONFIG_LINUX_AIO')}
 summary_info += {'Linux io_uring support': config_host.has_key('CONFIG_LINUX_IO_URING')}
-summary_info += {'ATTR/XATTR support': config_host.has_key('CONFIG_ATTR')}
+summary_info += {'ATTR/XATTR support': libattr.found()}
 summary_info += {'Install blobs':     get_option('install_blobs')}
 summary_info += {'KVM support':       config_all.has_key('CONFIG_KVM')}
 summary_info += {'HAX support':       config_all.has_key('CONFIG_HAX')}
diff --git a/meson_options.txt b/meson_options.txt
index 12a1872f20..8fcec056cd 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -40,6 +40,8 @@ option('cfi', type: 'boolean', value: 'false',
 option('cfi_debug', type: 'boolean', value: 'false',
        description: 'Verbose errors in case of CFI violation')
 
+option('attr', type : 'feature', value : 'auto',
+       description: 'attr/xattr support')
 option('brlapi', type : 'feature', value : 'auto',
        description: 'brlapi character device driver')
 option('bzip2', type : 'feature', value : 'auto',
-- 
2.29.2




  parent reply	other threads:[~2020-12-17  9:53 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17  9:40 [PATCH 00/22] meson: move detection of various libraries to meson.build Paolo Bonzini
2020-12-17  9:40 ` [PATCH 01/18] brlapi: convert to meson Paolo Bonzini
2020-12-17 11:35   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 02/18] curl: remove compatibility code, require 7.29.0 Paolo Bonzini
2020-12-17 10:08   ` Daniel P. Berrangé
2020-12-17 11:48   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 03/18] curl: convert to meson Paolo Bonzini
2020-12-17 10:11   ` Daniel P. Berrangé
2020-12-17 11:59   ` Marc-André Lureau
2020-12-17 12:00     ` Marc-André Lureau
2020-12-17 12:05       ` Paolo Bonzini
2020-12-17  9:40 ` [PATCH 04/18] glusterfs: " Paolo Bonzini
2020-12-17 12:15   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 05/18] bzip2: " Paolo Bonzini
2020-12-17 12:24   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 06/18] libiscsi: " Paolo Bonzini
2020-12-17 12:25   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 07/18] libnfs: " Paolo Bonzini
2020-12-17 12:26   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 08/18] libssh: " Paolo Bonzini
2020-12-17 12:35   ` Marc-André Lureau
2020-12-17 13:09     ` Paolo Bonzini
2020-12-17  9:40 ` [PATCH 09/18] rbd: " Paolo Bonzini
2020-12-17 12:36   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 10/18] lzo: " Paolo Bonzini
2020-12-17 12:42   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 11/18] snappy: " Paolo Bonzini
2020-12-17 12:47   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 12/18] lzfse: " Paolo Bonzini
2020-12-17 13:11   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 13/18] zstd: " Paolo Bonzini
2020-12-17 13:31   ` Marc-André Lureau
2020-12-17 13:32     ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 14/18] seccomp: " Paolo Bonzini
2020-12-17 13:36   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 15/18] virtfs: " Paolo Bonzini
2020-12-17 13:38   ` Marc-André Lureau
2020-12-17  9:40 ` [PATCH 16/18] cap_ng: " Paolo Bonzini
2020-12-17 13:54   ` Marc-André Lureau
2020-12-17  9:40 ` Paolo Bonzini [this message]
2020-12-17 14:05   ` [PATCH 17/18] libattr: " Marc-André Lureau
2020-12-17  9:40 ` [PATCH 18/18] meson.build: convert --with-default-devices " Paolo Bonzini
2020-12-17 14:08   ` Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201217094044.46462-18-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.