diff mbox

[2/2] package/libftdi: fix libftdi.pc

Message ID 1421097965-15600-2-git-send-email-s.martin49@gmail.com
State Superseded
Headers show

Commit Message

Samuel Martin Jan. 12, 2015, 9:26 p.m. UTC
This patch fixes libftdi pkg-config module, so that packages linking
against libftdi correctly have all needed CFLAGS and LIBS defined,
especially when running a static build.

Fixes:
  http://autobuild.buildroot.org/results/e90/e90b4d5ad79d99487f21c9d18581e8eba7034501/

Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
---
 ...di.pc.in-requires-libusb-fix-static-build.patch | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 package/libftdi/0002-libftdi.pc.in-requires-libusb-fix-static-build.patch

Comments

Yann E. MORIN Jan. 12, 2015, 11:03 p.m. UTC | #1
Samuel, All,

On 2015-01-12 22:26 +0100, Samuel Martin spake thusly:
> This patch fixes libftdi pkg-config module, so that packages linking
> against libftdi correctly have all needed CFLAGS and LIBS defined,
> especially when running a static build.
> 
> Fixes:
>   http://autobuild.buildroot.org/results/e90/e90b4d5ad79d99487f21c9d18581e8eba7034501/
> 
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Signed-off-by: Samuel Martin <s.martin49@gmail.com>

This does indeed fix the autobuild failure.

However (as discussed on IRC), the real fix is a bit more involved, as
our current libftdi is 0.19, but openocd requires 0.20:

    configure: WARNING: You need a newer libftdi version (0.20 or later)
    [...]
    MPSSE mode of FTDI based devices        no

But as you said, this is material for a further patch. So:

Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.

> ---
>  ...di.pc.in-requires-libusb-fix-static-build.patch | 25 ++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>  create mode 100644 package/libftdi/0002-libftdi.pc.in-requires-libusb-fix-static-build.patch
> 
> diff --git a/package/libftdi/0002-libftdi.pc.in-requires-libusb-fix-static-build.patch b/package/libftdi/0002-libftdi.pc.in-requires-libusb-fix-static-build.patch
> new file mode 100644
> index 0000000..7b0d9c7
> --- /dev/null
> +++ b/package/libftdi/0002-libftdi.pc.in-requires-libusb-fix-static-build.patch
> @@ -0,0 +1,25 @@
> +From c0d957b08b46385da570d8ff2f728369822ad2c1 Mon Sep 17 00:00:00 2001
> +From: Samuel Martin <s.martin49@gmail.com>
> +Date: Mon, 12 Jan 2015 22:10:49 +0100
> +Subject: [PATCH] libftdi.pc.in: requires libusb (fix static build)
> +
> +Signed-off-by: Samuel Martin <s.martin49@gmail.com>
> +---
> + libftdi.pc.in | 1 +
> + 1 file changed, 1 insertion(+)
> +
> +diff --git a/libftdi.pc.in b/libftdi.pc.in
> +index 2061b91..95eb491 100644
> +--- a/libftdi.pc.in
> ++++ b/libftdi.pc.in
> +@@ -6,6 +6,7 @@ includedir=@includedir@
> + Name: libftdi
> + Description: Library to program and control the FTDI USB controller
> + Requires:
> ++Requires.private: libusb
> + Version: @VERSION@
> + Libs: -L${libdir} -lftdi -lusb
> + Cflags: -I${includedir}
> +-- 
> +2.2.1
> +
> -- 
> 2.2.1
>
Thomas Petazzoni Jan. 13, 2015, 1:15 p.m. UTC | #2
Dear Samuel Martin,

On Mon, 12 Jan 2015 22:26:05 +0100, Samuel Martin wrote:

> +diff --git a/libftdi.pc.in b/libftdi.pc.in
> +index 2061b91..95eb491 100644
> +--- a/libftdi.pc.in
> ++++ b/libftdi.pc.in
> +@@ -6,6 +6,7 @@ includedir=@includedir@
> + Name: libftdi
> + Description: Library to program and control the FTDI USB controller
> + Requires:
> ++Requires.private: libusb
> + Version: @VERSION@
> + Libs: -L${libdir} -lftdi -lusb
> + Cflags: -I${includedir}

Are you sure this is the right fix? I believe the right fix is rather:

-Requires:
+Requires: libusb
...
-Libs: -L${libdir} -lftdi -lusb
+Libs: -L${libdir} -lftdi

This properly declares the fact that libftdi requires libusb. And
libusb.pc already has the appropriate Requires.private field on
libusb-1.0. With this change, you get what I believe is the correct
behavior:

When linking dynamically, we're only linked against -lusb (i.e the
libusb-compat library) :

$ ./output/host/usr/bin/pkg-config --libs libftdi
-lftdi -L/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib -lusb  

When linking statically, we correct get both -lusb and -lusb-1.0:

$ ./output/host/usr/bin/pkg-config --static --libs libftdi
-lftdi -lusb -L/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib -lusb-1.0 -pthread

This is more or less what was done upstream at
http://developer.intra2net.com/git/?p=libftdi;a=commitdiff;h=ac5790a7af9ffb45c00bde056b308643cd52537e,
though this commit was after they switched to libusb instead of
libusb-compat.

Thanks,

Thomas
Samuel Martin Jan. 19, 2015, 10:47 p.m. UTC | #3
Thomas, all,

On Tue, Jan 13, 2015 at 2:15 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Samuel Martin,
>
> On Mon, 12 Jan 2015 22:26:05 +0100, Samuel Martin wrote:
>
>> +diff --git a/libftdi.pc.in b/libftdi.pc.in
>> +index 2061b91..95eb491 100644
>> +--- a/libftdi.pc.in
>> ++++ b/libftdi.pc.in
>> +@@ -6,6 +6,7 @@ includedir=@includedir@
>> + Name: libftdi
>> + Description: Library to program and control the FTDI USB controller
>> + Requires:
>> ++Requires.private: libusb
>> + Version: @VERSION@
>> + Libs: -L${libdir} -lftdi -lusb
>> + Cflags: -I${includedir}
>
> Are you sure this is the right fix? I believe the right fix is rather:
>
> -Requires:
> +Requires: libusb
> ...
> -Libs: -L${libdir} -lftdi -lusb
> +Libs: -L${libdir} -lftdi
>
> This properly declares the fact that libftdi requires libusb. And
> libusb.pc already has the appropriate Requires.private field on
> libusb-1.0. With this change, you get what I believe is the correct
> behavior:
>
> When linking dynamically, we're only linked against -lusb (i.e the
> libusb-compat library) :
>
> $ ./output/host/usr/bin/pkg-config --libs libftdi
> -lftdi -L/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib -lusb
>
> When linking statically, we correct get both -lusb and -lusb-1.0:
>
> $ ./output/host/usr/bin/pkg-config --static --libs libftdi
> -lftdi -lusb -L/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib -lusb-1.0 -pthread
>
> This is more or less what was done upstream at
> http://developer.intra2net.com/git/?p=libftdi;a=commitdiff;h=ac5790a7af9ffb45c00bde056b308643cd52537e,
> though this commit was after they switched to libusb instead of
> libusb-compat.

Right, it is a much better fix. I'll respin shortly.

Regards,

>
> Thanks,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
diff mbox

Patch

diff --git a/package/libftdi/0002-libftdi.pc.in-requires-libusb-fix-static-build.patch b/package/libftdi/0002-libftdi.pc.in-requires-libusb-fix-static-build.patch
new file mode 100644
index 0000000..7b0d9c7
--- /dev/null
+++ b/package/libftdi/0002-libftdi.pc.in-requires-libusb-fix-static-build.patch
@@ -0,0 +1,25 @@ 
+From c0d957b08b46385da570d8ff2f728369822ad2c1 Mon Sep 17 00:00:00 2001
+From: Samuel Martin <s.martin49@gmail.com>
+Date: Mon, 12 Jan 2015 22:10:49 +0100
+Subject: [PATCH] libftdi.pc.in: requires libusb (fix static build)
+
+Signed-off-by: Samuel Martin <s.martin49@gmail.com>
+---
+ libftdi.pc.in | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libftdi.pc.in b/libftdi.pc.in
+index 2061b91..95eb491 100644
+--- a/libftdi.pc.in
++++ b/libftdi.pc.in
+@@ -6,6 +6,7 @@ includedir=@includedir@
+ Name: libftdi
+ Description: Library to program and control the FTDI USB controller
+ Requires:
++Requires.private: libusb
+ Version: @VERSION@
+ Libs: -L${libdir} -lftdi -lusb
+ Cflags: -I${includedir}
+-- 
+2.2.1
+