diff mbox

[RFC] allow special paths for libusbx

Message ID 1602530144.326084.1385546959951.open-xchange@email.1und1.de
State New
Headers show

Commit Message

Erik Rull Nov. 27, 2013, 10:09 a.m. UTC
Hi all,

I don't have libusbx installed on my system but the source package is available
and compiled for development.
This may also help other users to enable the libusbx support without having it
actually installed on the compile machine.

It's a first attempt, feel free to optimize it. I would be happy if someone
could commit a patch like that for the next release - this would make it
possible to use the next qemu release instead of the git version with own
patches.

The call parameters would be filled like:

--enable-libusb-special-headers=-I/home/erik/libusbx/libusb
--enable-libusb-special-libs="-L/home/erik/libusbx/libusb/.libs -lusb-1.0"


Thanks.

Erik



---

Comments

Paolo Bonzini Nov. 27, 2013, 10:14 a.m. UTC | #1
Il 27/11/2013 11:09, Erik Rull ha scritto:
> I don't have libusbx installed on my system but the source package is available
> and compiled for development.
> This may also help other users to enable the libusbx support without having it
> actually installed on the compile machine.
> 
> It's a first attempt, feel free to optimize it. I would be happy if someone
> could commit a patch like that for the next release - this would make it
> possible to use the next qemu release instead of the git version with own
> patches.
> 
> The call parameters would be filled like:
> 
> --enable-libusb-special-headers=-I/home/erik/libusbx/libusb
> --enable-libusb-special-libs="-L/home/erik/libusbx/libusb/.libs -lusb-1.0"

I believe you just have a misconfigured pkg-config.

Paolo
Erik Rull Nov. 27, 2013, 10:24 a.m. UTC | #2
> On November 27, 2013 at 11:14 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> Il 27/11/2013 11:09, Erik Rull ha scritto:
> > I don't have libusbx installed on my system but the source package is
> > available
> > and compiled for development.
> > This may also help other users to enable the libusbx support without having
> > it
> > actually installed on the compile machine.
> >
> > It's a first attempt, feel free to optimize it. I would be happy if someone
> > could commit a patch like that for the next release - this would make it
> > possible to use the next qemu release instead of the git version with own
> > patches.
> >
> > The call parameters would be filled like:
> >
> > --enable-libusb-special-headers=-I/home/erik/libusbx/libusb
> > --enable-libusb-special-libs="-L/home/erik/libusbx/libusb/.libs -lusb-1.0"
>
> I believe you just have a misconfigured pkg-config.
>
> Paolo
>

Hi Paolo,

no I have no libusbx installed. I just downloaded the tar.bz2, unpacked it,
configure'd it and called make.

Best regards,

Erik
Daniel P. Berrangé Nov. 27, 2013, 10:25 a.m. UTC | #3
On Wed, Nov 27, 2013 at 11:09:19AM +0100, Erik Rull wrote:
> Hi all,
> 
> I don't have libusbx installed on my system but the source package is available
> and compiled for development.
> This may also help other users to enable the libusbx support without having it
> actually installed on the compile machine.
> 
> It's a first attempt, feel free to optimize it. I would be happy if someone
> could commit a patch like that for the next release - this would make it
> possible to use the next qemu release instead of the git version with own
> patches.
> 
> The call parameters would be filled like:
> 
> --enable-libusb-special-headers=-I/home/erik/libusbx/libusb
> --enable-libusb-special-libs="-L/home/erik/libusbx/libusb/.libs -lusb-1.0"


libusbx provides a pkg-config file so you should merely need todo

  export PKG_CONFIG_PATH=${path-to-libusbx-install-root-prefix}/lib/pkgconfig

Daniel
Paolo Bonzini Nov. 27, 2013, 10:38 a.m. UTC | #4
Il 27/11/2013 11:24, Erik Rull ha scritto:
> no I have no libusbx installed. I just downloaded the tar.bz2, unpacked it,
> configure'd it and called make.

I think your patch wouldn't be enough to actually run QEMU, because the
path to libusbx.so is not in LD_LIBRARY_PATH (and if you can change
LD_LIBRARY_PATH, you can also change PKG_CONFIG_PATH).

The right way to do it is:

* add --prefix=$HOME to your configure command line.

* call "make install" after "make"

* add $HOME/lib to your LD_LIBRARY_PATH

* add the right subdirectory of $HOME/lib to your PKG_CONFIG_PATH

* test that it works with "pkg-config --cflags libusb-1.0"

* configure QEMU with no extra options

Paolo
Erik Rull Nov. 27, 2013, 11:33 a.m. UTC | #5
> On November 27, 2013 at 11:38 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> Il 27/11/2013 11:24, Erik Rull ha scritto:
> > no I have no libusbx installed. I just downloaded the tar.bz2, unpacked it,
> > configure'd it and called make.
>
> I think your patch wouldn't be enough to actually run QEMU, because the
> path to libusbx.so is not in LD_LIBRARY_PATH (and if you can change
> LD_LIBRARY_PATH, you can also change PKG_CONFIG_PATH).
>
> The right way to do it is:
>
> * add --prefix=$HOME to your configure command line.
>
> * call "make install" after "make"
>
> * add $HOME/lib to your LD_LIBRARY_PATH
>
> * add the right subdirectory of $HOME/lib to your PKG_CONFIG_PATH
>
> * test that it works with "pkg-config --cflags libusb-1.0"
>
> * configure QEMU with no extra options
>
> Paolo

Hi Paolo,

hm, sounds reasonable. I will try that and let you know if it worked.

Best regards,

Erik
Erik Rull Nov. 27, 2013, 1:19 p.m. UTC | #6
> On November 27, 2013 at 11:38 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> Il 27/11/2013 11:24, Erik Rull ha scritto:
> > no I have no libusbx installed. I just downloaded the tar.bz2, unpacked it,
> > configure'd it and called make.
>
> I think your patch wouldn't be enough to actually run QEMU, because the
> path to libusbx.so is not in LD_LIBRARY_PATH (and if you can change
> LD_LIBRARY_PATH, you can also change PKG_CONFIG_PATH).
>
> The right way to do it is:
>
> * add --prefix=$HOME to your configure command line.
>
> * call "make install" after "make"
>
> * add $HOME/lib to your LD_LIBRARY_PATH
>
> * add the right subdirectory of $HOME/lib to your PKG_CONFIG_PATH
>
> * test that it works with "pkg-config --cflags libusb-1.0"
>
> * configure QEMU with no extra options
>
> Paolo

Even easier - a temporary change of the PKG_CONFIG_PATH is sufficient, configure
does everything that is needed later on:

erik@debian:~/qemu-test/qemu$ env
PKG_CONFIG_PATH=/home/erik/libusbx/.install/lib/pkgconfig:$PKG_CONFIG_PATH
./configure [...]

where the .install directory was created by a manual call of make install from
libusbx.

Works fine for me.

Best regards,

Erik
diff mbox

Patch

diff --git a/configure b/configure
index 0666228..98cc72b 100755
--- a/configure
+++ b/configure
@@ -935,6 +935,10 @@  for opt do
   ;;
   --enable-libusb) libusb="yes"
   ;;
+  --enable-libusb-special-headers=*) libusb="yes"; libusb_cflags="$optarg"
+  ;;
+  --enable-libusb-special-libs=*) libusb="yes"; libusb_libs="$optarg"
+  ;;
   --disable-usb-redir) usb_redir="no"
   ;;
   --enable-usb-redir) usb_redir="yes"
@@ -3155,6 +3159,11 @@  fi

 # check for libusb
 if test "$libusb" != "no" ; then
+    if test -n "$libusb_cflags" && test -n "$libusb_libs"; then
+        libusb="yes"
+        QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
+        libs_softmmu="$libs_softmmu $libusb_libs"
+    else
     if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
         libusb="yes"
         libusb_cflags=$($pkg_config --cflags libusb-1.0)
@@ -3167,6 +3176,7 @@  if test "$libusb" != "no" ; then
         fi
         libusb="no"
     fi
+    fi
 fi

 # check for usbredirparser for usb network redirection support