gnu: Add wl-clipboard.
[jackhill/guix/guix.git] / gnu / packages / libffi.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch>
4 ;;; Copyright © 2015 Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
5 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2016, 2017 Ben Woodcroft <donttrustben@gmail.com>
7 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
8 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
16 ;;;
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25 (define-module (gnu packages libffi)
26 #:use-module (gnu packages)
27 #:use-module (guix licenses)
28 #:use-module (guix packages)
29 #:use-module (guix download)
30 #:use-module (gnu packages check)
31 #:use-module (gnu packages pkg-config)
32 #:use-module (gnu packages python)
33 #:use-module (gnu packages ruby)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system python)
36 #:use-module (guix build-system ruby))
37
38 (define-public libffi
39 (package
40 (name "libffi")
41 (version "3.2.1")
42 (source (origin
43 (method url-fetch)
44 (uri
45 (string-append "ftp://sourceware.org/pub/libffi/"
46 name "-" version ".tar.gz"))
47 (sha256
48 (base32
49 "0dya49bnhianl0r65m65xndz6ls2jn1xngyn72gd28ls3n7bnvnh"))
50 (patches (search-patches "libffi-3.2.1-complex-alpha.patch"))))
51 (build-system gnu-build-system)
52 (arguments
53 `(;; Prevent the build system from passing -march and -mtune to the
54 ;; compiler. See "ax_cc_maxopt.m4" and "ax_gcc_archflag.m4".
55 #:configure-flags '("--enable-portable-binary" "--without-gcc-arch")
56 #:phases
57 (modify-phases %standard-phases
58 (add-after 'install 'post-install
59 (lambda* (#:key outputs #:allow-other-keys)
60 (define out (assoc-ref outputs "out"))
61 (symlink (string-append out "/lib/libffi-3.2.1/include")
62 (string-append out "/include"))
63 #t)))))
64 (outputs '("out" "debug"))
65 (synopsis "Foreign function call interface library")
66 (description
67 "The libffi library provides a portable, high level programming interface
68 to various calling conventions. This allows a programmer to call any
69 function specified by a call interface description at run-time.
70
71 FFI stands for Foreign Function Interface. A foreign function interface is
72 the popular name for the interface that allows code written in one language
73 to call code written in another language. The libffi library really only
74 provides the lowest, machine dependent layer of a fully featured foreign
75 function interface. A layer must exist above libffi that handles type
76 conversions for values passed between the two languages.")
77 (home-page "http://sources.redhat.com/libffi/")
78
79 ;; See <https://github.com/atgreen/libffi/blob/master/LICENSE>.
80 (license expat)))
81
82 (define-public python-cffi
83 (package
84 (name "python-cffi")
85 (version "1.11.5")
86 (source
87 (origin
88 (method url-fetch)
89 (uri (pypi-uri "cffi" version))
90 (sha256
91 (base32 "1x3lrj928dcxx1k8k9gf3s4s3jwvzv8mc3kkyg1g7c3a1sc1f3z9"))
92 (patches (search-patches "python-cffi-x87-stack-clean.patch"))))
93 (build-system python-build-system)
94 (outputs '("out" "doc"))
95 (inputs
96 `(("libffi" ,libffi)))
97 (propagated-inputs ; required at run-time
98 `(("python-pycparser" ,python-pycparser)))
99 (native-inputs
100 `(("pkg-config" ,pkg-config)
101 ("python-sphinx" ,python-sphinx)
102 ("python-pytest" ,python-pytest)))
103 (arguments
104 `(#:modules ((ice-9 ftw)
105 (srfi srfi-26)
106 (guix build utils)
107 (guix build python-build-system))
108 #:phases
109 (modify-phases %standard-phases
110 (replace 'check
111 (lambda _
112 (setenv "PYTHONPATH"
113 (string-append
114 (getenv "PYTHONPATH")
115 ":" (getcwd) "/build/"
116 (car (scandir "build" (cut string-prefix? "lib." <>)))))
117
118 ;; XXX The "normal" approach of setting CC and friends does
119 ;; not work here. Is this the correct way of doing things?
120 (substitute* "testing/embedding/test_basic.py"
121 (("c = distutils\\.ccompiler\\.new_compiler\\(\\)")
122 (string-append "c = distutils.ccompiler.new_compiler();"
123 "c.set_executables(compiler='gcc',"
124 "compiler_so='gcc',linker_exe='gcc',"
125 "linker_so='gcc -shared')")))
126 (substitute* "testing/cffi0/test_ownlib.py"
127 (("'cc testownlib") "'gcc testownlib"))
128 (invoke "py.test" "-v" "c/" "testing/")
129 #t))
130 (add-before 'check 'disable-failing-test
131 ;; This is assumed to be a libffi issue:
132 ;; https://bitbucket.org/cffi/cffi/issues/312/tests-failed-with-armv8
133 (lambda _
134 (substitute* "testing/cffi0/test_ownlib.py"
135 (("ret.left") "ownlib.left"))
136 #t))
137 (add-after 'install 'install-doc
138 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
139 (let* ((doc (string-append (assoc-ref outputs "doc")
140 "/share/doc/" ,name "-" ,version))
141 (html (string-append doc "/html")))
142 (with-directory-excursion "doc"
143 (apply invoke "make" "html" make-flags)
144 (mkdir-p html)
145 (copy-recursively "build/html" html))
146 #t))))))
147 (home-page "https://cffi.readthedocs.org")
148 (synopsis "Foreign function interface for Python")
149 (description
150 "Foreign Function Interface for Python calling C code.")
151 (license expat)))
152
153 (define-public python2-cffi
154 (package-with-python2 python-cffi))
155
156 (define-public ruby-ffi
157 (package
158 (name "ruby-ffi")
159 (version "1.9.23")
160 (source (origin
161 (method url-fetch)
162 (uri (rubygems-uri "ffi" version))
163 (sha256
164 (base32
165 "0zw6pbyvmj8wafdc7l5h7w20zkp1vbr2805ql5d941g2b20pk4zr"))))
166 (build-system ruby-build-system)
167 ;; FIXME: Before running tests the build system attempts to build libffi
168 ;; from sources.
169 (arguments `(#:tests? #f))
170 (native-inputs
171 `(("ruby-rake-compiler" ,ruby-rake-compiler)
172 ("ruby-rspec" ,ruby-rspec)
173 ("ruby-rubygems-tasks" ,ruby-rubygems-tasks)))
174 (inputs
175 `(("libffi" ,libffi)))
176 (synopsis "Ruby foreign function interface library")
177 (description "Ruby-FFI is a Ruby extension for programmatically loading
178 dynamic libraries, binding functions within them, and calling those functions
179 from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby
180 and JRuby.")
181 (home-page "http://wiki.github.com/ffi/ffi")
182 (license bsd-3)))