diff mbox series

[v2,01/20] configure: Detect libfuse

Message ID 20200922104932.46384-2-mreitz@redhat.com
State New
Headers show
Series block/export: Allow exporting BDSs via FUSE | expand

Commit Message

Max Reitz Sept. 22, 2020, 10:49 a.m. UTC
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 configure   | 34 ++++++++++++++++++++++++++++++++++
 meson.build |  6 ++++++
 2 files changed, 40 insertions(+)

Comments

Thomas Huth Sept. 22, 2020, 11:14 a.m. UTC | #1
On 22/09/2020 12.49, Max Reitz wrote:
> Signed-off-by: Max Reitz <mreitz@redhat.com>

> ---

>  configure   | 34 ++++++++++++++++++++++++++++++++++

>  meson.build |  6 ++++++

>  2 files changed, 40 insertions(+)

> 

> diff --git a/configure b/configure

> index ce27eafb0a..21c31e4694 100755

> --- a/configure

> +++ b/configure

> @@ -538,6 +538,7 @@ meson=""

>  ninja=""

>  skip_meson=no

>  gettext=""

> +fuse=""

>  

>  bogus_os="no"

>  malloc_trim=""

> @@ -1621,6 +1622,10 @@ for opt do

>    ;;

>    --disable-libdaxctl) libdaxctl=no

>    ;;

> +  --enable-fuse) fuse=yes

> +  ;;

> +  --disable-fuse) fuse=no

> +  ;;

>    *)

>        echo "ERROR: unknown option $opt"

>        echo "Try '$0 --help' for more information"

> @@ -1945,6 +1950,7 @@ disabled with --disable-FEATURE, default is enabled if available:

>    xkbcommon       xkbcommon support

>    rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()

>    libdaxctl       libdaxctl support

> +  fuse            fuse block device export

>  

>  NOTE: The object files are built at the place where configure is launched

>  EOF

> @@ -6206,6 +6212,28 @@ but not implemented on your system"

>      fi

>  fi

>  

> +##########################################

> +# FUSE support

> +

> +if test "$fuse" != "no"; then

> +  cat > $TMPC <<EOF

> +#define FUSE_USE_VERSION 31

> +#include <fuse.h>

> +#include <fuse_lowlevel.h>

> +int main(void) { return 0; }

> +EOF

> +  fuse_cflags=$(pkg-config --cflags fuse3)

> +  fuse_libs=$(pkg-config --libs fuse3)

> +  if compile_prog "$fuse_cflags" "$fuse_libs"; then

> +    fuse=yes

> +  else

> +    if test "$fuse" = "yes"; then

> +      feature_not_found "fuse"

> +    fi

> +    fuse=no

> +  fi

> +fi


Could you turn this immediately into a meson test instead? See e.g.
https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg07112.html as
an example for how to do this.

 Thomas
Paolo Bonzini Sept. 22, 2020, 11:21 a.m. UTC | #2
On 22/09/20 13:14, Thomas Huth wrote:
> On 22/09/2020 12.49, Max Reitz wrote:

>> Signed-off-by: Max Reitz <mreitz@redhat.com>

>> ---

>>  configure   | 34 ++++++++++++++++++++++++++++++++++

>>  meson.build |  6 ++++++

>>  2 files changed, 40 insertions(+)

>>

>> diff --git a/configure b/configure

>> index ce27eafb0a..21c31e4694 100755

>> --- a/configure

>> +++ b/configure

>> @@ -538,6 +538,7 @@ meson=""

>>  ninja=""

>>  skip_meson=no

>>  gettext=""

>> +fuse=""

>>  

>>  bogus_os="no"

>>  malloc_trim=""

>> @@ -1621,6 +1622,10 @@ for opt do

>>    ;;

>>    --disable-libdaxctl) libdaxctl=no

>>    ;;

>> +  --enable-fuse) fuse=yes

>> +  ;;

>> +  --disable-fuse) fuse=no

>> +  ;;

>>    *)

>>        echo "ERROR: unknown option $opt"

>>        echo "Try '$0 --help' for more information"

>> @@ -1945,6 +1950,7 @@ disabled with --disable-FEATURE, default is enabled if available:

>>    xkbcommon       xkbcommon support

>>    rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()

>>    libdaxctl       libdaxctl support

>> +  fuse            fuse block device export

>>  

>>  NOTE: The object files are built at the place where configure is launched

>>  EOF

>> @@ -6206,6 +6212,28 @@ but not implemented on your system"

>>      fi

>>  fi

>>  

>> +##########################################

>> +# FUSE support

>> +

>> +if test "$fuse" != "no"; then

>> +  cat > $TMPC <<EOF

>> +#define FUSE_USE_VERSION 31

>> +#include <fuse.h>

>> +#include <fuse_lowlevel.h>

>> +int main(void) { return 0; }

>> +EOF

>> +  fuse_cflags=$(pkg-config --cflags fuse3)

>> +  fuse_libs=$(pkg-config --libs fuse3)

>> +  if compile_prog "$fuse_cflags" "$fuse_libs"; then

>> +    fuse=yes

>> +  else

>> +    if test "$fuse" = "yes"; then

>> +      feature_not_found "fuse"

>> +    fi

>> +    fuse=no

>> +  fi

>> +fi

> 

> Could you turn this immediately into a meson test instead? See e.g.

> https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg07112.html as

> an example for how to do this.


For pkg-config in fact it's even simpler and documented in
docs/devel/build-system.rst.

Paolo
Max Reitz Sept. 22, 2020, 11:46 a.m. UTC | #3
On 22.09.20 13:14, Thomas Huth wrote:

[...]

> Could you turn this immediately into a meson test instead? See e.g.

> https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg07112.html as

> an example for how to do this.


Sure!

Max
Max Reitz Sept. 22, 2020, 3:37 p.m. UTC | #4
On 22.09.20 13:14, Thomas Huth wrote:

[...]

> Could you turn this immediately into a meson test instead? See e.g.

> https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg07112.html as

> an example for how to do this.


Done (I think).  Until I send v3, the updated version lives here:

https://git.xanclic.moe/XanClic/qemu/commits/branch/fuse-exports-next
https://github.com/XanClic/qemu/commits/fuse-exports-next

I’ve replaced the compile checks (on test programs) by simpler version
checks (>=3.1 for libfuse itself, >=3.8 for fuse-lseek).

Max
Paolo Bonzini Sept. 22, 2020, 3:45 p.m. UTC | #5
On 22/09/20 17:37, Max Reitz wrote:
> On 22.09.20 13:14, Thomas Huth wrote:

> 

> [...]

> 

>> Could you turn this immediately into a meson test instead? See e.g.

>> https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg07112.html as

>> an example for how to do this.

> 

> Done (I think).  Until I send v3, the updated version lives here:

> 

> https://git.xanclic.moe/XanClic/qemu/commits/branch/fuse-exports-next

> https://github.com/XanClic/qemu/commits/fuse-exports-next


Looks good.

Paolo
diff mbox series

Patch

diff --git a/configure b/configure
index ce27eafb0a..21c31e4694 100755
--- a/configure
+++ b/configure
@@ -538,6 +538,7 @@  meson=""
 ninja=""
 skip_meson=no
 gettext=""
+fuse=""
 
 bogus_os="no"
 malloc_trim=""
@@ -1621,6 +1622,10 @@  for opt do
   ;;
   --disable-libdaxctl) libdaxctl=no
   ;;
+  --enable-fuse) fuse=yes
+  ;;
+  --disable-fuse) fuse=no
+  ;;
   *)
       echo "ERROR: unknown option $opt"
       echo "Try '$0 --help' for more information"
@@ -1945,6 +1950,7 @@  disabled with --disable-FEATURE, default is enabled if available:
   xkbcommon       xkbcommon support
   rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
   libdaxctl       libdaxctl support
+  fuse            fuse block device export
 
 NOTE: The object files are built at the place where configure is launched
 EOF
@@ -6206,6 +6212,28 @@  but not implemented on your system"
     fi
 fi
 
+##########################################
+# FUSE support
+
+if test "$fuse" != "no"; then
+  cat > $TMPC <<EOF
+#define FUSE_USE_VERSION 31
+#include <fuse.h>
+#include <fuse_lowlevel.h>
+int main(void) { return 0; }
+EOF
+  fuse_cflags=$(pkg-config --cflags fuse3)
+  fuse_libs=$(pkg-config --libs fuse3)
+  if compile_prog "$fuse_cflags" "$fuse_libs"; then
+    fuse=yes
+  else
+    if test "$fuse" = "yes"; then
+      feature_not_found "fuse"
+    fi
+    fuse=no
+  fi
+fi
+
 ##########################################
 # End of CC checks
 # After here, no more $cc or $ld runs
@@ -7393,6 +7421,12 @@  if test "$secret_keyring" = "yes" ; then
   echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
 fi
 
+if test "$fuse" = "yes"; then
+  echo "CONFIG_FUSE=y" >> $config_host_mak
+  echo "FUSE_CFLAGS=$fuse_cflags" >> $config_host_mak
+  echo "FUSE_LIBS=$fuse_libs" >> $config_host_mak
+fi
+
 if test "$tcg_interpreter" = "yes"; then
   QEMU_INCLUDES="-iquote ${source_path}/tcg/tci $QEMU_INCLUDES"
 elif test "$ARCH" = "sparc64" ; then
diff --git a/meson.build b/meson.build
index 86e1cca0ad..85addd8562 100644
--- a/meson.build
+++ b/meson.build
@@ -436,6 +436,11 @@  if 'CONFIG_TASN1' in config_host
 endif
 keyutils = dependency('libkeyutils', required: false,
                       method: 'pkg-config', static: enable_static)
+libfuse = not_found
+if 'CONFIG_FUSE' in config_host
+  libfuse = declare_dependency(compile_args: config_host['FUSE_CFLAGS'].split(),
+                               link_args: config_host['FUSE_LIBS'].split())
+endif
 
 has_gettid = cc.has_function('gettid')
 
@@ -1531,6 +1536,7 @@  endif
 summary_info += {'thread sanitizer':  config_host.has_key('CONFIG_TSAN')}
 summary_info += {'rng-none':          config_host.has_key('CONFIG_RNG_NONE')}
 summary_info += {'Linux keyring':     config_host.has_key('CONFIG_SECRET_KEYRING')}
+summary_info += {'fuse exports':      config_host.has_key('CONFIG_FUSE')}
 summary(summary_info, bool_yn: true)
 
 if not supported_cpus.contains(cpu)