Subject: [PATCH v2 8/9] gnu: libftdi: Update to 1.5.

From: Simon South <[email-masked]>
Date: Thu, 7 Sep 2023 12:37:57 -0400

* gnu/packages/patches/libftdi-fix-paths-when-FTDIPP-set.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/libftdi.scm (libftdi): Update to 1.5.
[source]: Apply patch.
[arguments]<#:configure-flags>: Add "-DFTDIPP", "-DPYTHON_BINDINGS".
---
 gnu/local.mk                                  |  1 +
 gnu/packages/libftdi.scm                      | 10 +++--
 .../libftdi-fix-paths-when-FTDIPP-set.patch   | 39 +++++++++++++++++++
 3 files changed, 47 insertions(+), 3 deletions(-)
 create mode 100644 gnu/packages/patches/libftdi-fix-paths-when-FTDIPP-set.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 54aec9316a..1f1f9450ab 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1445,6 +1445,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/json-c-0.12-CVE-2020-12762.patch		\
   %D%/packages/patches/julia-SOURCE_DATE_EPOCH-mtime.patch	\
   %D%/packages/patches/julia-Use-MPFR-4.2.patch	                \
+  %D%/packages/patches/libftdi-fix-paths-when-FTDIPP-set.patch	\
   %D%/packages/patches/libgeotiff-fix-tests-with-proj-9.1.1.patch	\
   %D%/packages/patches/libobjc2-unbundle-robin-map.patch	\
   %D%/packages/patches/librime-fix-build-with-gcc10.patch	\
diff --git a/gnu/packages/libftdi.scm b/gnu/packages/libftdi.scm
index 773b0ec73e..bdfc635379 100644
--- a/gnu/packages/libftdi.scm
+++ b/gnu/packages/libftdi.scm
@@ -37,7 +37,7 @@ (define-module (gnu packages libftdi)
 (define-public libftdi
   (package
     (name "libftdi")
-    (version "1.4")
+    (version "1.5")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -45,7 +45,9 @@ (define-public libftdi
                     "libftdi1-" version ".tar.bz2"))
               (sha256
                (base32
-                "0x0vncf6i92slgrn0h7ghkskqbglbs534220qa84d0qg114zndpc"))))
+                "0jdh5r499wbz83vmpskczq5m3cfc1mcv8xqisj5i95k1r3lr2w3w"))
+              (patches
+               (search-patches "libftdi-fix-paths-when-FTDIPP-set.patch"))))
     (build-system cmake-build-system)
     (outputs '("out" "python"))
     (arguments
@@ -54,7 +56,9 @@ (define-public libftdi
       #~(list (string-append "-DCMAKE_INSTALL_DOCDIR="
                              #$output "/share/doc/" #$name "-" #$version)
               "-DEXAMPLES=OFF"
-              "-DLIB_SUFFIX=''")        ; place libraries in /lib, not /lib64
+              "-DFTDIPP=ON"
+              "-DLIB_SUFFIX=''"         ; place libraries in /lib, not /lib64
+              "-DPYTHON_BINDINGS=ON")
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'install 'install-python-binding
diff --git a/gnu/packages/patches/libftdi-fix-paths-when-FTDIPP-set.patch b/gnu/packages/patches/libftdi-fix-paths-when-FTDIPP-set.patch
new file mode 100644
index 0000000000..0a81cceb26
--- /dev/null
+++ b/gnu/packages/patches/libftdi-fix-paths-when-FTDIPP-set.patch
@@ -0,0 +1,39 @@
+commit cdb28383402d248dbc6062f4391b038375c52385
+Author: Fabrice Fontaine <[email-masked]>
+Date:   Fri Jul 17 21:25:03 2020 +0200
+
+    CMakeLists.txt: fix paths when FTDIPP is set
+    
+    Use the same project name (i.e. libftdi1 and not libftdipp1) when FTDIPP
+    is enabled as suggested by Aurelien Jarno in
+    http://developer.intra2net.com/mailarchive/html/libftdi/2020/msg00044.html
+    
+    Without this change, the libftdi1.pc config file defines the include
+    path as /usr/local/include/libftdipp1 while the ftdi.h file is actually
+    installed in /usr/local/include/libftdi1
+    
+    This is an issue for example for libsigrok which will fail on:
+    
+    In file included from src/hardware/asix-sigma/protocol.c:27:
+    src/hardware/asix-sigma/protocol.h:28:10: fatal error: ftdi.h: No such file or directory
+       28 | #include <ftdi.h>
+          |          ^~~~~~~~
+    
+    Fixes:
+     - http://autobuild.buildroot.org/results/1427f44e36752c337791597fab47a1889552a2fe
+    
+    Signed-off-by: Fabrice Fontaine <[email-masked]>
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 5aecafc..3b0b87c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -136,7 +136,7 @@ endif ()
+ 
+ add_subdirectory(src)
+ if ( FTDIPP )
+-  project(libftdipp1 C CXX)
++  project(libftdi1 C CXX)
+   add_subdirectory(ftdipp)
+ endif ()
+ if ( PYTHON_BINDINGS )
-- 
2.40.1