gnu: emacs-consult: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / boost.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
3 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
5 ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
6 ;;; Copyright © 2015, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
7 ;;; Copyright © 2017 Thomas Danckaert <post@thomasdanckaert.be>
8 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
10 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
11 ;;; Copyright © 2018 Maxim Cournoyer <maxim.cournoyer@gmail.com>
12 ;;; Copyright © 2018, 2020 Efraim Flashner <efraim@flashner.co.il>
13 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
14 ;;; Copyright © 2019, 2020 Giacomo Leidi <goodoldpaul@autistici.org>
15 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
16 ;;; Copyright © 2020 Jonathan Brielmaier <jonathan.brielmaier@web.de>
17 ;;; Copyright © 2021 Franck Pérignon <franck.perignon@univ-grenoble-alpes.fr>
18 ;;;
19 ;;; This file is part of GNU Guix.
20 ;;;
21 ;;; GNU Guix is free software; you can redistribute it and/or modify it
22 ;;; under the terms of the GNU General Public License as published by
23 ;;; the Free Software Foundation; either version 3 of the License, or (at
24 ;;; your option) any later version.
25 ;;;
26 ;;; GNU Guix is distributed in the hope that it will be useful, but
27 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
28 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 ;;; GNU General Public License for more details.
30 ;;;
31 ;;; You should have received a copy of the GNU General Public License
32 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
33
34 (define-module (gnu packages boost)
35 #:use-module ((guix licenses) #:prefix license:)
36 #:use-module (guix utils)
37 #:use-module (guix packages)
38 #:use-module (guix download)
39 #:use-module (guix git-download)
40 #:use-module (guix build-system gnu)
41 #:use-module (guix build-system trivial)
42 #:use-module (gnu packages)
43 #:use-module (gnu packages compression)
44 #:use-module (gnu packages hurd)
45 #:use-module (gnu packages icu4c)
46 #:use-module (gnu packages perl)
47 #:use-module (gnu packages python)
48 #:use-module (gnu packages shells)
49 #:use-module (gnu packages mpi)
50 #:use-module (srfi srfi-1))
51
52 (define (version-with-underscores version)
53 (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version))
54
55 (define (boost-patch name version hash)
56 (origin
57 (method url-fetch)
58 (uri (string-append "https://www.boost.org/patches/"
59 (version-with-underscores version) "/" name))
60 (file-name (string-append "boost-" name))
61 (sha256 (base32 hash))))
62
63 (define-public boost
64 (package
65 (name "boost")
66 (version "1.72.0")
67 (source (origin
68 (method url-fetch)
69 (uri (string-append "https://dl.bintray.com/boostorg/release/"
70 version "/source/boost_"
71 (version-with-underscores version) ".tar.bz2"))
72 (patches
73 (list (boost-patch
74 ;; 1.72.0 was released with a faulty coroutine submodule:
75 ;; <https://github.com/boostorg/coroutine/issues/46>.
76 "0001-revert-cease-dependence-on-range.patch" version
77 "1zcqxzh56m1s635wqwk15j3zcs2gmjvjy2f0hid7i78s4pgm0yfs")))
78 (sha256
79 (base32
80 "08h7cv61fd0lzb4z50xanfqn0pdgvizjrpd1kcdgj725pisb5jar"))))
81 (build-system gnu-build-system)
82 (inputs `(("icu4c" ,icu4c)
83 ("zlib" ,zlib)))
84 (native-inputs
85 `(("perl" ,perl)
86 ,@(if (%current-target-system)
87 '()
88 `(("python" ,python-wrapper)))
89 ("tcsh" ,tcsh)))
90 (arguments
91 `(#:imported-modules ((guix build python-build-system)
92 ,@%gnu-build-system-modules)
93 #:modules (((guix build python-build-system) #:select (python-version))
94 ,@%gnu-build-system-modules)
95 #:tests? #f
96 #:make-flags
97 (list "threading=multi" "link=shared"
98
99 ;; Set the RUNPATH to $libdir so that the libs find each other.
100 (string-append "linkflags=-Wl,-rpath="
101 (assoc-ref %outputs "out") "/lib")
102 ,@(if (%current-target-system)
103 `("--user-config=user-config.jam"
104 ;; Python is not supported when cross-compiling.
105 "--without-python"
106 "binary-format=elf"
107 "target-os=linux"
108 ,@(cond
109 ((string-prefix? "arm" (%current-target-system))
110 '("abi=aapcs"
111 "address-model=32"
112 "architecture=arm"))
113 ((string-prefix? "aarch64" (%current-target-system))
114 '("abi=aapcs"
115 "address-model=64"
116 "architecture=arm"))
117 (else '())))
118 '()))
119 #:phases
120 (modify-phases %standard-phases
121 (delete 'bootstrap)
122 (replace 'configure
123 (lambda* (#:key inputs outputs #:allow-other-keys)
124 (let ((icu (assoc-ref inputs "icu4c"))
125 (python (assoc-ref inputs "python"))
126 (out (assoc-ref outputs "out")))
127 (substitute* '("libs/config/configure"
128 "libs/spirit/classic/phoenix/test/runtest.sh"
129 "tools/build/src/engine/execunix.cpp"
130 "tools/build/src/engine/Jambase")
131 (("/bin/sh") (which "sh")))
132
133 (setenv "SHELL" (which "sh"))
134 (setenv "CONFIG_SHELL" (which "sh"))
135
136 ,@(if (%current-target-system)
137 `((call-with-output-file "user-config.jam"
138 (lambda (port)
139 (format port
140 "using gcc : cross : ~a-c++ ;"
141 ,(%current-target-system)))))
142 '())
143
144 ;; Change an #ifdef __MACH__ that really targets macOS.
145 ;; TODO: Inline this on the next rebuild cycle.
146 ,@(if (hurd-target?)
147 '((substitute* "boost/test/utils/timer.hpp"
148 (("defined\\(__MACH__\\)")
149 "(defined __MACH__ && !defined __GNU__)"))
150 #t)
151 '())
152
153 (invoke "./bootstrap.sh"
154 (string-append "--prefix=" out)
155 ;; Auto-detection looks for ICU only in traditional
156 ;; install locations.
157 (string-append "--with-icu=" icu)
158 ;; Ditto for Python.
159 ,@(if (%current-target-system)
160 '()
161 `((string-append "--with-python-root=" python)
162 (string-append "--with-python=" python "/bin/python")
163 (string-append "--with-python-version="
164 (python-version python))))
165 "--with-toolset=gcc"))))
166 (replace 'build
167 (lambda* (#:key make-flags #:allow-other-keys)
168 (apply invoke "./b2"
169 (format #f "-j~a" (parallel-job-count))
170 make-flags)))
171 (replace 'install
172 (lambda* (#:key make-flags #:allow-other-keys)
173 (apply invoke "./b2" "install" make-flags)))
174 ,@(if (%current-target-system)
175 '()
176 '((add-after 'install 'provide-libboost_python
177 (lambda* (#:key inputs outputs #:allow-other-keys)
178 (let* ((out (assoc-ref outputs "out"))
179 (python-version (python-version
180 (assoc-ref inputs "python")))
181 (libboost_pythonNN.so
182 (string-append "libboost_python"
183 (string-join (string-split
184 python-version #\.)
185 "")
186 ".so")))
187 (with-directory-excursion (string-append out "/lib")
188 (symlink libboost_pythonNN.so "libboost_python.so")
189 ;; Some packages only look for the major version.
190 (symlink libboost_pythonNN.so
191 (string-append "libboost_python"
192 (string-take python-version 1)
193 ".so")))
194 #t))))))))
195
196 (home-page "https://www.boost.org")
197 (synopsis "Peer-reviewed portable C++ source libraries")
198 (description
199 "A collection of libraries intended to be widely useful, and usable
200 across a broad spectrum of applications.")
201 (license (license:x11-style "https://www.boost.org/LICENSE_1_0.txt"
202 "Some components have other similar licences."))))
203
204 (define-public boost-with-python2
205 (package/inherit boost
206 (name "boost-python2")
207 (native-inputs
208 `(("python" ,python-2)
209 ,@(alist-delete "python" (package-native-inputs boost))))))
210
211 (define-public boost-with-python3
212 (deprecated-package "boost-with-python3" boost))
213
214 (define-public boost-static
215 (package
216 (inherit boost)
217 (name "boost-static")
218 (arguments
219 (substitute-keyword-arguments (package-arguments boost)
220 ((#:make-flags flags)
221 `(cons "link=static" (delete "link=shared" ,flags)))
222 ((#:phases phases)
223 `(modify-phases ,phases
224 (replace 'provide-libboost_python
225 (lambda* (#:key inputs outputs #:allow-other-keys)
226 (let* ((out (assoc-ref outputs "out"))
227 (python-version (python-version
228 (assoc-ref inputs "python")))
229 (libboost_pythonNN.a
230 (string-append "libboost_python"
231 (string-join (string-split
232 python-version #\.)
233 "")
234 ".a")))
235 (with-directory-excursion (string-append out "/lib")
236 (symlink libboost_pythonNN.a "libboost_python.a"))
237 #t)))))))))
238
239 (define-public boost-for-mysql
240 ;; Older version for MySQL 5.7.23.
241 (package
242 (inherit boost)
243 (version "1.59.0")
244 (source (origin
245 (method url-fetch)
246 (uri (string-append
247 "mirror://sourceforge/boost/boost/" version "/boost_"
248 (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version)
249 ".tar.bz2"))
250 (sha256
251 (base32
252 "1jj1aai5rdmd72g90a3pd8sw9vi32zad46xv5av8fhnr48ir6ykj"))))
253 (arguments (substitute-keyword-arguments (package-arguments boost)
254 ((#:phases phases)
255 `(modify-phases ,phases
256 (replace 'configure
257 (lambda* (#:key inputs outputs #:allow-other-keys)
258 (let ((icu (assoc-ref inputs "icu4c"))
259 (out (assoc-ref outputs "out")))
260 (substitute* (append
261 (find-files "tools/build/src/engine/" "execunix\\.c.*")
262 '("libs/config/configure"
263 "libs/spirit/classic/phoenix/test/runtest.sh"
264 "tools/build/doc/bjam.qbk"
265 "tools/build/src/engine/Jambase"))
266 (("/bin/sh") (which "sh")))
267
268 (setenv "SHELL" (which "sh"))
269 (setenv "CONFIG_SHELL" (which "sh"))
270
271 ,@(if (%current-target-system)
272 `((call-with-output-file "user-config.jam"
273 (lambda (port)
274 (format port
275 "using gcc : cross : ~a-c++ ;"
276 ,(%current-target-system)))))
277 '())
278
279 (invoke "./bootstrap.sh"
280 (string-append "--prefix=" out)
281 ;; Auto-detection looks for ICU only in traditional
282 ;; install locations.
283 (string-append "--with-icu=" icu)
284 "--with-toolset=gcc"))))
285 (delete 'provide-libboost_python)))
286 ((#:make-flags make-flags)
287 `(cons* "--without-python" ,make-flags))))
288 (native-inputs
289 (alist-delete "python" (package-native-inputs boost)))
290 (properties '((hidden? . #t)))))
291
292 (define-public boost-sync
293 (let ((commit "c72891d9b90e2ceb466ec859f640cd012b2d8709")
294 (version "1.55")
295 (revision "1"))
296 (package
297 (name "boost-sync")
298 (version (git-version version revision commit))
299 (source (origin
300 (method git-fetch)
301 (uri (git-reference
302 (url "https://github.com/boostorg/sync")
303 (commit commit)))
304 (file-name (git-file-name name version))
305 (sha256
306 (base32
307 "197mp5z048vz5kv1m4v3jm447l2gqsyv0rbfz11dz0ns343ihbyx"))))
308 (build-system trivial-build-system)
309 (arguments
310 `(#:modules ((guix build utils))
311 #:builder
312 (begin
313 (use-modules (guix build utils))
314 (let ((source (assoc-ref %build-inputs "source")))
315 (copy-recursively (string-append source "/include")
316 (string-append %output "/include"))))))
317 (home-page "https://github.com/boostorg/sync")
318 (synopsis "Boost.Sync library")
319 (description "The Boost.Sync library provides mutexes, semaphores, locks
320 and events and other thread related facilities. Boost.Sync originated from
321 Boost.Thread.")
322 (license (license:x11-style "https://www.boost.org/LICENSE_1_0.txt")))))
323
324 (define-public boost-signals2
325 (package
326 (name "boost-signals2")
327 (version (package-version boost))
328 (source (origin
329 (method git-fetch)
330 (uri (git-reference
331 (url "https://github.com/boostorg/signals2")
332 (commit (string-append "boost-" version))))
333 (file-name (git-file-name name version))
334 (sha256
335 (base32
336 "13i5j43nggb46i6qpaf7gk53i7zp7pimphl7sydyfqz2m9yx5cdy"))))
337 (build-system trivial-build-system)
338 (arguments
339 `(#:modules ((guix build utils))
340 #:builder
341 (begin
342 (use-modules (guix build utils))
343 (let ((source (assoc-ref %build-inputs "source")))
344 (copy-recursively (string-append source "/include")
345 (string-append %output "/include"))))))
346 (home-page "https://github.com/boostorg/signals2")
347 (synopsis "Boost.Signals2 library")
348 (description "The Boost.Signals2 library is an implementation of a managed
349 signals and slots system.")
350 (license (license:x11-style "https://www.boost.org/LICENSE_1_0.txt"))))
351
352
353 (define-public boost-mpi
354 (package
355 (inherit boost)
356 (name "boost-mpi")
357 (native-inputs
358 `(("perl" ,perl)
359 ,@(if (%current-target-system)
360 '()
361 `(("python" ,python-wrapper)))
362 ("openmpi" , openmpi)))
363 (arguments
364 (substitute-keyword-arguments (package-arguments boost)
365 ((#:phases phases)
366 `(modify-phases ,phases
367 (add-after 'configure 'update-jam
368 (lambda* (#:key inputs outputs #:allow-other-keys)
369 (let ((output-port (open-file "project-config.jam" "a")))
370 (display "using mpi ;" output-port)
371 (newline output-port)
372 (close output-port))))))))
373 (home-page "https://www.boost.org")
374 (synopsis "Message Passing Interface (MPI) library for C++")))
375
376 (define-public mdds
377 (package
378 (name "mdds")
379 (version "1.5.0")
380 (source (origin
381 (method url-fetch)
382 (uri (string-append
383 "http://kohei.us/files/mdds/src/mdds-" version ".tar.bz2"))
384 (sha256
385 (base32
386 "03b8i43pw4m767mm0cnbi77x7qhpkzpi9b1f6dpp4cmyszmnsk8l"))))
387 (build-system gnu-build-system)
388 (propagated-inputs
389 `(("boost" ,boost))) ; inclusion of header files
390 (home-page "https://gitlab.com/mdds/mdds")
391 (synopsis "Multi-dimensional C++ data structures and indexing algorithms")
392 (description "Mdds (multi-dimensional data structure) provides a
393 collection of multi-dimensional data structures and indexing algorithms
394 for C++. It includes flat segment trees, segment trees, rectangle sets,
395 point quad trees, multi-type vectors and multi-type matrices.")
396 (license license:expat)))