[PATCH 10/34] meson, configure: move usbfs test to meson

Paolo Bonzini posted 34 patches 3 years, 9 months ago
Maintainers: Yuval Shaia <yuval.shaia.ml@gmail.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Jason Wang <jasowang@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>, Stefano Stabellini <sstabellini@kernel.org>, Anthony Perard <anthony.perard@citrix.com>, Paul Durrant <paul@xen.org>, "Michael S. Tsirkin" <mst@redhat.com>, Juan Quintela <quintela@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Michael Roth <michael.roth@amd.com>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>, Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>
There is a newer version of this series
[PATCH 10/34] meson, configure: move usbfs test to meson
Posted by Paolo Bonzini 3 years, 9 months ago
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure   | 28 ----------------------------
 meson.build | 13 +++++++++++++
 2 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/configure b/configure
index 1c74d2c5f2..d4d7c001f6 100755
--- a/configure
+++ b/configure
@@ -2160,31 +2160,6 @@ case "$fdt" in
     ;;
 esac
 
-##########################################
-# check for usbfs
-have_usbfs=no
-if test "$linux_user" = "yes"; then
-  cat > $TMPC << EOF
-#include <linux/usbdevice_fs.h>
-
-#ifndef USBDEVFS_GET_CAPABILITIES
-#error "USBDEVFS_GET_CAPABILITIES undefined"
-#endif
-
-#ifndef USBDEVFS_DISCONNECT_CLAIM
-#error "USBDEVFS_DISCONNECT_CLAIM undefined"
-#endif
-
-int main(void)
-{
-    return 0;
-}
-EOF
-  if compile_prog "" ""; then
-    have_usbfs=yes
-  fi
-fi
-
 ##########################################
 # capstone
 
@@ -2641,9 +2616,6 @@ fi
 if test "$module_upgrades" = "yes"; then
   echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
 fi
-if test "$have_usbfs" = "yes" ; then
-  echo "CONFIG_USBFS=y" >> $config_host_mak
-fi
 if test "$gio" = "yes" ; then
     echo "CONFIG_GIO=y" >> $config_host_mak
     echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
diff --git a/meson.build b/meson.build
index 066bb69174..c0b2838d2e 100644
--- a/meson.build
+++ b/meson.build
@@ -1938,6 +1938,19 @@ config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + '''
     return getauxval(AT_HWCAP) == 0;
   }'''))
 
+config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles('''
+  #include <linux/usbdevice_fs.h>
+
+  #ifndef USBDEVFS_GET_CAPABILITIES
+  #error "USBDEVFS_GET_CAPABILITIES undefined"
+  #endif
+
+  #ifndef USBDEVFS_DISCONNECT_CLAIM
+  #error "USBDEVFS_DISCONNECT_CLAIM undefined"
+  #endif
+
+  int main(void) { return 0; }'''))
+
 have_keyring = get_option('keyring') \
   .require(targetos == 'linux', error_message: 'keyring is only available on Linux') \
   .require(cc.compiles('''
-- 
2.35.1
Re: [PATCH 10/34] meson, configure: move usbfs test to meson
Posted by Marc-André Lureau 3 years, 9 months ago
On Wed, Apr 20, 2022 at 7:46 PM Paolo Bonzini <pbonzini@redhat.com> wrote:

> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  configure   | 28 ----------------------------
>  meson.build | 13 +++++++++++++
>  2 files changed, 13 insertions(+), 28 deletions(-)
>
> diff --git a/configure b/configure
> index 1c74d2c5f2..d4d7c001f6 100755
> --- a/configure
> +++ b/configure
> @@ -2160,31 +2160,6 @@ case "$fdt" in
>      ;;
>  esac
>
> -##########################################
> -# check for usbfs
> -have_usbfs=no
> -if test "$linux_user" = "yes"; then
> -  cat > $TMPC << EOF
> -#include <linux/usbdevice_fs.h>
> -
> -#ifndef USBDEVFS_GET_CAPABILITIES
> -#error "USBDEVFS_GET_CAPABILITIES undefined"
> -#endif
> -
> -#ifndef USBDEVFS_DISCONNECT_CLAIM
> -#error "USBDEVFS_DISCONNECT_CLAIM undefined"
> -#endif
> -
> -int main(void)
> -{
> -    return 0;
> -}
> -EOF
> -  if compile_prog "" ""; then
> -    have_usbfs=yes
> -  fi
> -fi
> -
>  ##########################################
>  # capstone
>
> @@ -2641,9 +2616,6 @@ fi
>  if test "$module_upgrades" = "yes"; then
>    echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
>  fi
> -if test "$have_usbfs" = "yes" ; then
> -  echo "CONFIG_USBFS=y" >> $config_host_mak
> -fi
>  if test "$gio" = "yes" ; then
>      echo "CONFIG_GIO=y" >> $config_host_mak
>      echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
> diff --git a/meson.build b/meson.build
> index 066bb69174..c0b2838d2e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1938,6 +1938,19 @@ config_host_data.set('CONFIG_GETAUXVAL',
> cc.links(gnu_source_prefix + '''
>      return getauxval(AT_HWCAP) == 0;
>    }'''))
>
> +config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles('''
> +  #include <linux/usbdevice_fs.h>
> +
> +  #ifndef USBDEVFS_GET_CAPABILITIES
> +  #error "USBDEVFS_GET_CAPABILITIES undefined"
> +  #endif
> +
> +  #ifndef USBDEVFS_DISCONNECT_CLAIM
> +  #error "USBDEVFS_DISCONNECT_CLAIM undefined"
> +  #endif
> +
> +  int main(void) { return 0; }'''))
>


We could use cc.has_header_symbol(). Alternatively, drop the symbol checks?
They were added in Linux 3.6... (commit
0837e7e5270bd5547ba5763f11611dc43f677b3d &
19181bc50e1b8e92a7a3b3d78637c6dc5c0b5a1b)


> +
>  have_keyring = get_option('keyring') \
>    .require(targetos == 'linux', error_message: 'keyring is only available
> on Linux') \
>    .require(cc.compiles('''
> --
> 2.35.1
>
>
>
>

-- 
Marc-André Lureau