gnu: sssd: Update to 2.7.4.
[jackhill/guix/guix.git] / gnu / packages / libffi.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
b6e5eb4d 2;;; Copyright © 2012, 2013, 2014, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
0751fddd 3;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch>
d47e99e0 4;;; Copyright © 2015, 2019 Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
9562d50d 5;;; Copyright © 2016, 2017, 2020, 2021 Efraim Flashner <efraim@flashner.co.il>
838b232e 6;;; Copyright © 2016, 2017 Ben Woodcroft <donttrustben@gmail.com>
a16ca6b3 7;;; Copyright © 2017, 2019, 2020, 2022 Marius Bakke <marius@gnu.org>
667e6f1e 8;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
220a153c 9;;; Copyright © 2019, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
7eaa2f24 10;;; Copyright © 2020 John Doe <dftxbs3e@free.fr>
c44899a2 11;;;
233e7676 12;;; This file is part of GNU Guix.
c44899a2 13;;;
233e7676 14;;; GNU Guix is free software; you can redistribute it and/or modify it
c44899a2
LC
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
233e7676 19;;; GNU Guix is distributed in the hope that it will be useful, but
c44899a2
LC
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
233e7676 25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
c44899a2 26
1ffa7090 27(define-module (gnu packages libffi)
1602fcea 28 #:use-module (gnu packages)
4a44e743 29 #:use-module (guix licenses)
c44899a2 30 #:use-module (guix packages)
87f5d366 31 #:use-module (guix download)
075afce2 32 #:use-module (guix git-download)
ac257f12 33 #:use-module (gnu packages check)
0751fddd
EF
34 #:use-module (gnu packages pkg-config)
35 #:use-module (gnu packages python)
44d10b1f 36 #:use-module (gnu packages python-xyz)
838b232e 37 #:use-module (gnu packages ruby)
9d0c291e 38 #:use-module (gnu packages sphinx)
0751fddd 39 #:use-module (guix build-system gnu)
838b232e
EF
40 #:use-module (guix build-system python)
41 #:use-module (guix build-system ruby))
c44899a2
LC
42
43(define-public libffi
667e6f1e 44 (package
c44899a2 45 (name "libffi")
5f1000d5 46 (version "3.3")
c44899a2 47 (source (origin
667e6f1e
TGR
48 (method url-fetch)
49 (uri
50 (string-append "ftp://sourceware.org/pub/libffi/"
51 name "-" version ".tar.gz"))
52 (sha256
53 (base32
4659e046 54 "0mi0cpf8aa40ljjmzxb7im6dbj45bb0kllcd09xgmp834y9agyvj"))
9562d50d
EF
55 (patches (search-patches "libffi-3.3-powerpc-fixes.patch"
56 "libffi-float128-powerpc64le.patch"))))
c44899a2 57 (build-system gnu-build-system)
667e6f1e 58 (arguments
1935b8d5
MB
59 `(;; Prevent the build system from passing -march and -mtune to the
60 ;; compiler. See "ax_cc_maxopt.m4" and "ax_gcc_archflag.m4".
9562d50d
EF
61 #:configure-flags '("--enable-portable-binary"
62 "--without-gcc-arch")))
9bf62d9b 63 (outputs '("out" "debug"))
089b0634 64 (synopsis "Foreign function call interface library")
c44899a2
LC
65 (description
66 "The libffi library provides a portable, high level programming interface
67to various calling conventions. This allows a programmer to call any
68function specified by a call interface description at run-time.
69
70FFI stands for Foreign Function Interface. A foreign function interface is
71the popular name for the interface that allows code written in one language
72to call code written in another language. The libffi library really only
73provides the lowest, machine dependent layer of a fully featured foreign
74function interface. A layer must exist above libffi that handles type
75conversions for values passed between the two languages.")
b6e5eb4d
LC
76 (home-page "http://www.sourceware.org/libffi/")
77 (properties `((release-monitoring-url . ,home-page)))
c44899a2 78
7bf837fd 79 ;; See <https://github.com/atgreen/libffi/blob/master/LICENSE>.
667e6f1e 80 (license expat)))
c44899a2 81
0751fddd
EF
82(define-public python-cffi
83 (package
84 (name "python-cffi")
d50a2d91 85 (version "1.14.4")
0751fddd
EF
86 (source
87 (origin
88 (method url-fetch)
89 (uri (pypi-uri "cffi" version))
90 (sha256
d50a2d91 91 (base32 "0v080s7vlrjz9z823x2yh36yc8drwpvvir6w8wfkkzd7k2z5qihs"))))
0751fddd 92 (build-system python-build-system)
0751fddd 93 (inputs
8394619b 94 (list libffi))
0751fddd 95 (propagated-inputs ; required at run-time
8394619b 96 (list python-pycparser))
0751fddd 97 (native-inputs
8394619b 98 (list pkg-config python-pytest))
0751fddd 99 (arguments
220a153c 100 `(#:phases
0751fddd
EF
101 (modify-phases %standard-phases
102 (replace 'check
103 (lambda _
0751fddd
EF
104 ;; XXX The "normal" approach of setting CC and friends does
105 ;; not work here. Is this the correct way of doing things?
106 (substitute* "testing/embedding/test_basic.py"
107 (("c = distutils\\.ccompiler\\.new_compiler\\(\\)")
108 (string-append "c = distutils.ccompiler.new_compiler();"
109 "c.set_executables(compiler='gcc',"
110 "compiler_so='gcc',linker_exe='gcc',"
111 "linker_so='gcc -shared')")))
112 (substitute* "testing/cffi0/test_ownlib.py"
41fdad9f 113 (("\"cc testownlib") "\"gcc testownlib"))
220a153c 114 (invoke "py.test" "-v" "c/" "testing/")))
4e933afd
MC
115 (add-before 'check 'patch-paths-of-dynamically-loaded-libraries
116 (lambda* (#:key inputs #:allow-other-keys)
117 ;; Shared libraries should be referred by their absolute path as
118 ;; using find_library or the like with their name fail when the
119 ;; resolved .so object is a linker script rather than an ELF
120 ;; binary (this is a limitation of the ctype library of Python).
121 (let* ((glibc (assoc-ref inputs "libc"))
122 (libm (string-append glibc "/lib/libm.so.6"))
123 (libc (string-append glibc "/lib/libc.so.6")))
124 (substitute* '("testing/cffi0/test_function.py"
125 "testing/cffi0/test_parsing.py"
126 "testing/cffi0/test_unicode_literals.py"
127 "testing/cffi0/test_zdistutils.py"
128 "testing/cffi1/test_recompiler.py")
129 (("lib_m = ['\"]{1}m['\"]{1}")
130 (format #f "lib_m = '~a'" libm)))
131 (substitute* '("testing/cffi0/test_verify.py"
132 "testing/cffi1/test_verify1.py")
133 (("lib_m = \\[['\"]{1}m['\"]{1}\\]")
134 (format #f "lib_m = ['~a']" libm)))
135 (substitute* "c/test_c.py"
136 (("find_and_load_library\\(['\"]{1}c['\"]{1}")
220a153c 137 (format #f "find_and_load_library('~a'" libc)))))))))
4e933afd 138 (home-page "https://cffi.readthedocs.io/")
0751fddd 139 (synopsis "Foreign function interface for Python")
4e933afd 140 (description "Foreign Function Interface for Python calling C code.")
0751fddd
EF
141 (license expat)))
142
a16ca6b3
MB
143;; TODO(staging): Merge with the above.
144(define-public python-cffi-1.15
145 (package
146 (inherit python-cffi)
147 (version "1.15.0")
148 (source
149 (origin
150 (method url-fetch)
151 (uri (pypi-uri "cffi" version))
152 (sha256
153 (base32 "0m3rz2pqfmyfagx0bhj2jlbr2h58j3wr3cyv1agxkhlnm1k0s3wj"))))))
154
95dc93da
MB
155(define-public python-cffi-documentation
156 (package
157 (name "python-cffi-documentation")
158 (version (package-version python-cffi))
159 (source (package-source python-cffi))
160 (build-system gnu-build-system)
161 (arguments
162 `(#:tests? #f
163 #:phases (modify-phases %standard-phases
164 (add-after 'unpack 'chdir
165 (lambda _ (chdir "doc") #t))
166 (delete 'configure)
167 (replace 'build
168 (lambda* (#:key (make-flags '()) #:allow-other-keys)
169 (apply invoke "make" "html" make-flags)))
170 (replace 'install
171 (lambda* (#:key outputs #:allow-other-keys)
172 (let ((out (assoc-ref outputs "out")))
173 (copy-recursively "build/html" (string-append out "/html"))
174 #t))))))
175 (native-inputs
176 `(("sphinx-build" ,python-sphinx)))
177 (home-page (package-home-page python-cffi))
178 (synopsis "Documentation for the Python CFFI interface")
179 (description
180 "This package contains HTML documentation for the @code{python-cffi}
181project.")
182 (license (package-license python-cffi))))
183
838b232e
EF
184(define-public ruby-ffi
185 (package
186 (name "ruby-ffi")
8df29c26 187 (version "1.15.5")
838b232e 188 (source (origin
075afce2
MB
189 ;; Pull from git because the RubyGems release bundles LibFFI,
190 ;; and comes with a gemspec that makes it difficult to unbundle.
191 (method git-fetch)
192 (uri (git-reference
193 (url "https://github.com/ffi/ffi")
8df29c26 194 (commit (string-append "v" version))))
075afce2 195 (file-name (git-file-name name version))
838b232e
EF
196 (sha256
197 (base32
8df29c26 198 "1qk55s1zwpdjykwkj9l37m71i5n228i7f8bg3ply3ks9py16m7s6"))))
838b232e 199 (build-system ruby-build-system)
075afce2
MB
200 (arguments
201 `(#:phases
202 (modify-phases %standard-phases
075afce2
MB
203 (replace 'replace-git-ls-files
204 (lambda _
205 ;; Do not try to execute git, or include the (un)bundled LibFFI.
206 (substitute* "ffi.gemspec"
207 (("git ls-files -z")
208 "find * -type f -print0 | sort -z")
209 (("lfs \\+?= .*")
210 "lfs = []\n"))
211 (substitute* "Rakefile"
8df29c26
EF
212 (("git .*ls-files -z")
213 "find * -type f -print0 | sort -z")
075afce2 214 (("LIBFFI_GIT_FILES = .*")
8df29c26 215 "LIBFFI_GIT_FILES = []\n"))))
075afce2
MB
216 (replace 'build
217 (lambda _
218 ;; Tests depend on the native extensions, so we build it
219 ;; beforehand without going through the gem machinery.
220 (invoke "rake" "compile")
221
222 ;; XXX: Ideally we'd use "rake native gem" here to prevent the
223 ;; install phase from needlessly rebuilding everything, but that
224 ;; requires the bundled LibFFI, and the install phase can not
225 ;; deal with such gems anyway.
226 (invoke "gem" "build" "ffi.gemspec")))
227 (replace 'check
228 (lambda* (#:key tests? #:allow-other-keys)
229 (if tests?
230 (begin
231 (setenv "MAKE" "make")
232 (setenv "CC" "gcc")
233 (invoke "rspec" "spec"))
8df29c26 234 (format #t "test suite not run~%")))))))
838b232e 235 (native-inputs
8394619b 236 (list ruby-rake-compiler ruby-rspec ruby-rubygems-tasks))
838b232e 237 (inputs
8394619b 238 (list libffi))
838b232e
EF
239 (synopsis "Ruby foreign function interface library")
240 (description "Ruby-FFI is a Ruby extension for programmatically loading
241dynamic libraries, binding functions within them, and calling those functions
242from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby
243and JRuby.")
702a1012 244 (home-page "https://wiki.github.com/ffi/ffi")
838b232e 245 (license bsd-3)))