Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / libusb.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
3 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
5 ;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Theodoros Foradis <theodoros@foradis.org>
8 ;;; Copyright © 2017 Jonathan Brielmaier <jonathan.brielmaier@web.de>
9 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages libusb)
27 #:use-module (gnu packages)
28 #:use-module (guix licenses)
29 #:use-module (guix packages)
30 #:use-module (guix utils)
31 #:use-module (guix download)
32 #:use-module (guix git-download)
33 #:use-module (guix build-system ant)
34 #:use-module (guix build-system cmake)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system glib-or-gtk)
37 #:use-module (guix build-system python)
38 #:use-module (gnu packages autotools)
39 #:use-module (gnu packages gnupg)
40 #:use-module (gnu packages gtk)
41 #:use-module (gnu packages java)
42 #:use-module (gnu packages linux)
43 #:use-module (gnu packages mp3)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages xiph))
47
48 (define-public libusb
49 (package
50 (name "libusb")
51 (version "1.0.21")
52 (source
53 (origin
54 (method url-fetch)
55 (uri (string-append "mirror://sourceforge/libusb/libusb-1.0/"
56 "libusb-" version "/libusb-" version ".tar.bz2"))
57 (sha256
58 (base32
59 "0jw2n5kdnrqvp7zh792fd6mypzzfap6jp4gfcmq4n6c1kb79rkkx"))))
60 (build-system gnu-build-system)
61
62 ;; XXX: Enabling udev is now recommended, but eudev indirectly depends on
63 ;; libusb.
64 (arguments `(#:configure-flags '("--disable-udev")))
65 ;; (inputs `(("eudev" ,eudev)))
66
67 (home-page "http://libusb.info")
68 (synopsis "User-space USB library")
69 (description
70 "Libusb is a library that gives applications easy access to USB
71 devices on various operating systems.")
72 (license lgpl2.1+)))
73
74 (define-public libusb-compat
75 (package
76 (name "libusb-compat")
77 (version "0.1.5")
78 (source
79 (origin
80 (method url-fetch)
81 (uri (string-append "mirror://sourceforge/libusb/"
82 name "-" (version-major+minor version) "/"
83 name "-" version "/"
84 name "-" version ".tar.bz2"))
85 (sha256
86 (base32
87 "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0"))))
88 (build-system gnu-build-system)
89 (native-inputs
90 `(("pkg-config" ,pkg-config)))
91 (inputs
92 `(("libusb" ,libusb)))
93 (home-page "http://libusb.info")
94 (synopsis "Compatibility shim for libusb")
95 (description
96 "Libusb-compat provides a shim allowing applications based on older
97 version of libusb to run with newer libusb.")
98 (license lgpl2.1+)))
99
100 ;; required by 0xffff, which compiles with libusb-compat, but executes only
101 ;; with libusb-0.1
102 (define-public libusb-0.1
103 (package (inherit libusb)
104 (version "0.1.12")
105 (source
106 (origin
107 (method url-fetch)
108 (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
109 version "/libusb-" version ".tar.gz"))
110 (sha256
111 (base32
112 "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
113 (patches (search-patches "libusb-0.1-disable-tests.patch"))))))
114
115 (define-public libusb4java
116 ;; There is no public release so we take the latest version from git.
117 (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
118 (revision "1"))
119 (package
120 (name "libusb4java")
121 (version (string-append "0-" revision "." (string-take commit 9)))
122 (source (origin
123 (method git-fetch)
124 (uri (git-reference
125 (url "https://github.com/usb4java/libusb4java.git")
126 (commit commit)))
127 (file-name (git-file-name name version))
128 (sha256
129 (base32
130 "0wqgapalhfh9v38ycbl6i2f5lh1wpr6fzwn5dwd0rdacypkd1gml"))))
131 (build-system cmake-build-system)
132 (arguments
133 `(#:tests? #f ; there are no tests
134 #:phases
135 (modify-phases %standard-phases
136 (add-before 'configure 'set-JAVA_HOME
137 (lambda* (#:key inputs #:allow-other-keys)
138 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
139 #t)))))
140 (inputs
141 `(("libusb" ,libusb)))
142 (native-inputs
143 `(("jdk" ,icedtea "jdk")))
144 (home-page "https://github.com/usb4java/libusb4java/")
145 (synopsis "JNI bindings to libusb")
146 (description
147 "This package provides Java JNI bindings to the libusb library for use
148 with usb4java.")
149 (license expat))))
150
151 (define-public java-usb4java
152 (package
153 (name "java-usb4java")
154 (version "1.2.0")
155 (source (origin
156 (method url-fetch)
157 (uri (string-append "https://github.com/usb4java/usb4java/"
158 "archive/usb4java-" version ".tar.gz"))
159 (sha256
160 (base32
161 "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
162 (build-system ant-build-system)
163 (arguments
164 `(#:jar-name "usb4java.jar"
165 #:phases
166 (modify-phases %standard-phases
167 ;; Usually, native libusb4java libraries for all supported systems
168 ;; would be included in the jar and extracted at runtime. Since we
169 ;; build everything from source we cannot just bundle pre-built
170 ;; binaries for other systems. Instead, we patch the loader to
171 ;; directly return the appropriate library for this system. The
172 ;; downside is that the jar will only work on the same architecture
173 ;; that it was built on.
174 (add-after 'unpack 'copy-libusb4java
175 (lambda* (#:key inputs #:allow-other-keys)
176 (substitute* "src/main/java/org/usb4java/Loader.java"
177 (("private static String extractLibrary" line)
178 (string-append
179 line "(final String a, final String b) {"
180 "return \""
181 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
182 "\"; }\n"
183 "private static String _extractLibrary")))
184 #t))
185 (add-after 'unpack 'disable-broken-tests
186 (lambda _
187 (with-directory-excursion "src/test/java/org/usb4java"
188 ;; These tests should only be run when USB devices are present.
189 (substitute* '("LibUsbGlobalTest.java"
190 "TransferTest.java")
191 (("this.context = new Context\\(\\);")
192 "this.context = null;")
193 (("LibUsb.init") "//"))
194 (substitute* "DeviceListIteratorTest.java"
195 (("this.iterator.remove" line)
196 (string-append "assumeUsbTestsEnabled();" line))))
197 #t)))))
198 (inputs
199 `(("libusb4java" ,libusb4java)
200 ("java-commons-lang3" ,java-commons-lang3)
201 ("java-junit" ,java-junit)
202 ("java-hamcrest-core" ,java-hamcrest-core)))
203 (home-page "http://usb4java.org/")
204 (synopsis "USB library for Java")
205 (description
206 "This package provides a USB library for Java based on libusb and
207 implementing @code{javax.usb} (JSR-80).")
208 (license expat)))
209
210 (define-public python-pyusb
211 (package
212 (name "python-pyusb")
213 (version "1.0.0")
214 (source
215 (origin
216 (method url-fetch)
217 (uri (pypi-uri "PyUSB" version))
218 (sha256
219 (base32
220 "0s2k4z06fapd5vp1gnrlf8a9sjpc03p9974lzw5k6ky39akzyd2v"))))
221 (build-system python-build-system)
222 (arguments
223 `(#:tests? #f ;no tests
224 #:modules ((srfi srfi-1)
225 (srfi srfi-26)
226 (guix build utils)
227 (guix build python-build-system))
228 #:phases
229 (modify-phases %standard-phases
230 (add-after 'unpack 'fix-libusb-reference
231 (lambda* (#:key inputs #:allow-other-keys)
232 (substitute* "usb/libloader.py"
233 (("lib = locate_library\\(candidates, find_library\\)")
234 (string-append
235 "lib = \""
236 (find (negate symbolic-link?)
237 (find-files (assoc-ref inputs "libusb")
238 "^libusb-.*\\.so\\..*"))
239 "\"")))
240 #t)))))
241 (inputs
242 `(("libusb" ,libusb)))
243 (home-page "http://walac.github.io/pyusb/")
244 (synopsis "Python bindings to the libusb library")
245 (description
246 "PyUSB aims to be an easy to use Python module to access USB devices.")
247 (license bsd-3)))
248
249 (define-public python2-pyusb
250 (package-with-python2 python-pyusb))
251
252 (define-public libmtp
253 (package
254 (name "libmtp")
255 (version "1.1.14")
256 (source (origin
257 (method url-fetch)
258 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
259 "/libmtp-" version ".tar.gz"))
260 (sha256
261 (base32
262 "1s0jyhypxmj0j8s003ba1n74x63h1rw8am9q4z2ip3xyjvid65rq"))))
263 (build-system gnu-build-system)
264 (native-inputs
265 `(("pkg-config" ,pkg-config)))
266 (propagated-inputs
267 ;; libmtp.pc refers to all these.
268 `(("libgcrypt" ,libgcrypt)
269 ("libusb" ,libusb)))
270 (arguments
271 `(#:configure-flags
272 (list (string-append "--with-udev="
273 (assoc-ref %outputs "out")
274 "/lib/udev"))))
275 (home-page "http://libmtp.sourceforge.net/")
276 (synopsis "Library implementing the Media Transfer Protocol")
277 (description "Libmtp implements an MTP (Media Transfer Protocol)
278 initiator, which means that it initiates MTP sessions with devices. The
279 devices responding are known as MTP responders. Libmtp runs on devices
280 with a USB host controller interface. It implements MTP Basic, which was
281 proposed for standardization.")
282 ;; COPYING contains lgpl2.1, while files headers give
283 ;; "GNU Lesser General Public License as published by the Free Software
284 ;; Foundation; either version 2 of the License, or (at your option) any
285 ;; later version."
286 (license lgpl2.1+)))
287
288 (define-public gmtp
289 (package
290 (name "gmtp")
291 (version "1.3.11")
292 (source (origin
293 (method url-fetch)
294 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
295 "/gmtp-" version ".tar.gz"))
296 (sha256
297 (base32
298 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
299 (build-system glib-or-gtk-build-system)
300 (arguments
301 '(#:configure-flags
302 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
303 (list
304 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
305 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
306 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
307 (inputs
308 `(("gtk+" ,gtk+)
309 ("flac" ,flac)
310 ("libvorbis" ,libvorbis)
311 ("libid3tag" ,libid3tag)
312 ("libmtp" ,libmtp)))
313 (native-inputs
314 `(("pkg-config" ,pkg-config)))
315 (home-page "http://gmtp.sourceforge.net/")
316 (synopsis "Simple graphical MTP client")
317 (description "gMTP is a simple graphical client for the Media Transfer Protocol
318 (MTP), which allows media files to be transferred to and from many portable
319 devices.")
320 (license bsd-3)))
321
322 (define-public hidapi
323 (package
324 (name "hidapi")
325 (version "0.8.0-rc1")
326 (source (origin
327 (method url-fetch)
328 (uri (string-append "https://github.com/signal11/hidapi/archive/hidapi-"
329 version ".tar.gz"))
330 (sha256
331 (base32
332 "0qdgyj9rgb7n0nk3ghfswrhzzknxqn4ibn3wj8g4r828pw07451w"))))
333 (build-system gnu-build-system)
334 (arguments
335 '(#:phases
336 (modify-phases %standard-phases
337 (add-after 'unpack 'bootstrap
338 (lambda _
339 (zero? (system* "autoreconf" "-vfi")))))))
340 (inputs
341 `(("libusb" ,libusb)
342 ("udev" ,eudev)))
343 (native-inputs
344 `(("autoconf" ,autoconf)
345 ("automake" ,automake)
346 ("libtool" ,libtool)
347 ("pkg-config" ,pkg-config)))
348 (home-page "http://www.signal11.us/oss/hidapi/")
349 (synopsis "HID API library")
350 (description
351 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
352 HID-Class devices.")
353 ;; HIDAPI can be used under one of three licenses.
354 (license (list gpl3
355 bsd-3
356 (non-copyleft "file://LICENSE-orig.txt")))))
357
358 (define-public python-hidapi
359 (package
360 (name "python-hidapi")
361 (version "0.7.99.post21")
362 (source
363 (origin
364 (method url-fetch)
365 (uri (pypi-uri "hidapi" version))
366 (sha256
367 (base32
368 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
369 (modules '((guix build utils)))
370 (snippet
371 ;; Remove bundled libraries.
372 '(begin
373 (delete-file-recursively "hidapi")
374 #t))))
375 (build-system python-build-system)
376 (arguments
377 `(#:phases
378 (modify-phases %standard-phases
379 (add-after 'unpack 'patch-configuration
380 (lambda* (#:key inputs #:allow-other-keys)
381 (substitute* "setup.py"
382 (("'/usr/include/libusb-1.0'")
383 (string-append "'" (assoc-ref inputs "libusb")
384 "/include/libusb-1.0'"))
385 (("'/usr/include/hidapi'")
386 (string-append "'" (assoc-ref inputs "hidapi")
387 "/include/hidapi'")))
388 #t))
389 ;; XXX Necessary because python-build-system drops the arguments.
390 (replace 'build
391 (lambda _
392 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
393 (replace 'check
394 (lambda _
395 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
396 (replace 'install
397 (lambda* (#:key outputs #:allow-other-keys)
398 (invoke "python" "setup.py" "install" "--with-system-hidapi"
399 (string-append "--prefix=" (assoc-ref outputs "out"))
400 "--single-version-externally-managed" "--root=/"))))))
401 (inputs
402 `(("hidapi" ,hidapi)
403 ("libusb" ,libusb)
404 ("eudev" ,eudev)))
405 (native-inputs
406 `(("python-cython" ,python-cython)))
407 (home-page "https://github.com/trezor/cython-hidapi")
408 (synopsis "Cython interface to hidapi")
409 (description "This package provides a Cython interface to @code{hidapi}.")
410 ;; The library can be used under either of these licenses.
411 (license (list gpl3 bsd-3
412 (non-copyleft
413 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
414 "You are free to use cython-hidapi code for any purpose.")))))
415
416 (define-public python2-hidapi
417 (package-with-python2 python-hidapi))