gnu: Add python-pyshp.
[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, 2021 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 ;;; Copyright © 2021 Greg Hogan <code@greghogan.com>
19 ;;;
20 ;;; This file is part of GNU Guix.
21 ;;;
22 ;;; GNU Guix is free software; you can redistribute it and/or modify it
23 ;;; under the terms of the GNU General Public License as published by
24 ;;; the Free Software Foundation; either version 3 of the License, or (at
25 ;;; your option) any later version.
26 ;;;
27 ;;; GNU Guix is distributed in the hope that it will be useful, but
28 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
29 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 ;;; GNU General Public License for more details.
31 ;;;
32 ;;; You should have received a copy of the GNU General Public License
33 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
34
35 (define-module (gnu packages boost)
36 #:use-module ((guix licenses) #:prefix license:)
37 #:use-module (guix utils)
38 #:use-module (guix packages)
39 #:use-module (guix download)
40 #:use-module (guix git-download)
41 #:use-module (guix build-system gnu)
42 #:use-module (guix build-system trivial)
43 #:use-module (gnu packages)
44 #:use-module (gnu packages compression)
45 #:use-module (gnu packages hurd)
46 #:use-module (gnu packages icu4c)
47 #:use-module (gnu packages llvm)
48 #:use-module (gnu packages perl)
49 #:use-module (gnu packages python)
50 #:use-module (gnu packages shells)
51 #:use-module (gnu packages mpi)
52 #:use-module (srfi srfi-1))
53
54 (define (version-with-underscores version)
55 (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version))
56
57 (define (boost-patch name version hash)
58 (origin
59 (method url-fetch)
60 (uri (string-append "https://www.boost.org/patches/"
61 (version-with-underscores version) "/" name))
62 (file-name (string-append "boost-" name))
63 (sha256 (base32 hash))))
64
65 (define-public boost
66 (package
67 (name "boost")
68 (version "1.72.0")
69 (source (origin
70 (method url-fetch)
71 (uri (string-append "https://boostorg.jfrog.io/artifactory/main/release/"
72 version "/source/boost_"
73 (version-with-underscores version) ".tar.bz2"))
74 (patches
75 (list (boost-patch
76 ;; 1.72.0 was released with a faulty coroutine submodule:
77 ;; <https://github.com/boostorg/coroutine/issues/46>.
78 "0001-revert-cease-dependence-on-range.patch" version
79 "1zcqxzh56m1s635wqwk15j3zcs2gmjvjy2f0hid7i78s4pgm0yfs")))
80 (sha256
81 (base32
82 "08h7cv61fd0lzb4z50xanfqn0pdgvizjrpd1kcdgj725pisb5jar"))))
83 (build-system gnu-build-system)
84 (inputs `(("icu4c" ,icu4c)
85 ("zlib" ,zlib)))
86 (native-inputs
87 `(("perl" ,perl)
88 ,@(if (%current-target-system)
89 '()
90 `(("python" ,python-wrapper)))
91 ("tcsh" ,tcsh)))
92 (arguments
93 `(#:imported-modules ((guix build python-build-system)
94 ,@%gnu-build-system-modules)
95 #:modules (((guix build python-build-system) #:select (python-version))
96 ,@%gnu-build-system-modules)
97 #:tests? #f
98 #:make-flags
99 (list "threading=multi" "link=shared"
100
101 ;; Set the RUNPATH to $libdir so that the libs find each other.
102 (string-append "linkflags=-Wl,-rpath="
103 (assoc-ref %outputs "out") "/lib")
104 ,@(if (%current-target-system)
105 `("--user-config=user-config.jam"
106 ;; Python is not supported when cross-compiling.
107 "--without-python"
108 "binary-format=elf"
109 "target-os=linux"
110 ,@(cond
111 ((string-prefix? "arm" (%current-target-system))
112 '("abi=aapcs"
113 "address-model=32"
114 "architecture=arm"))
115 ((string-prefix? "aarch64" (%current-target-system))
116 '("abi=aapcs"
117 "address-model=64"
118 "architecture=arm"))
119 (else '())))
120 '()))
121 #:phases
122 (modify-phases %standard-phases
123 (delete 'bootstrap)
124 (replace 'configure
125 (lambda* (#:key inputs outputs #:allow-other-keys)
126 (let ((icu (assoc-ref inputs "icu4c"))
127 (python (assoc-ref inputs "python"))
128 (out (assoc-ref outputs "out")))
129 (substitute* '("libs/config/configure"
130 "libs/spirit/classic/phoenix/test/runtest.sh"
131 "tools/build/src/engine/execunix.cpp"
132 "tools/build/src/engine/Jambase")
133 (("/bin/sh") (which "sh")))
134
135 (setenv "SHELL" (which "sh"))
136 (setenv "CONFIG_SHELL" (which "sh"))
137
138 ,@(if (%current-target-system)
139 `((call-with-output-file "user-config.jam"
140 (lambda (port)
141 (format port
142 "using gcc : cross : ~a-c++ ;"
143 ,(%current-target-system)))))
144 '())
145
146 ;; Change an #ifdef __MACH__ that really targets macOS.
147 ;; TODO: Inline this on the next rebuild cycle.
148 ,@(if (hurd-target?)
149 '((substitute* "boost/test/utils/timer.hpp"
150 (("defined\\(__MACH__\\)")
151 "(defined __MACH__ && !defined __GNU__)"))
152 #t)
153 '())
154
155 (invoke "./bootstrap.sh"
156 (string-append "--prefix=" out)
157 ;; Auto-detection looks for ICU only in traditional
158 ;; install locations.
159 (string-append "--with-icu=" icu)
160 ;; Ditto for Python.
161 ,@(if (%current-target-system)
162 '()
163 `((string-append "--with-python-root=" python)
164 (string-append "--with-python=" python "/bin/python")
165 (string-append "--with-python-version="
166 (python-version python))))
167 "--with-toolset=gcc"))))
168 (replace 'build
169 (lambda* (#:key make-flags #:allow-other-keys)
170 (apply invoke "./b2"
171 (format #f "-j~a" (parallel-job-count))
172 make-flags)))
173 (replace 'install
174 (lambda* (#:key make-flags #:allow-other-keys)
175 (apply invoke "./b2" "install" make-flags)))
176 ,@(if (%current-target-system)
177 '()
178 '((add-after 'install 'provide-libboost_python
179 (lambda* (#:key inputs outputs #:allow-other-keys)
180 (let* ((out (assoc-ref outputs "out"))
181 (python-version (python-version
182 (assoc-ref inputs "python")))
183 (libboost_pythonNN.so
184 (string-append "libboost_python"
185 (string-join (string-split
186 python-version #\.)
187 "")
188 ".so")))
189 (with-directory-excursion (string-append out "/lib")
190 (symlink libboost_pythonNN.so "libboost_python.so")
191 ;; Some packages only look for the major version.
192 (symlink libboost_pythonNN.so
193 (string-append "libboost_python"
194 (string-take python-version 1)
195 ".so")))
196 #t))))))))
197
198 (home-page "https://www.boost.org")
199 (synopsis "Peer-reviewed portable C++ source libraries")
200 (description
201 "A collection of libraries intended to be widely useful, and usable
202 across a broad spectrum of applications.")
203 (license (license:x11-style "https://www.boost.org/LICENSE_1_0.txt"
204 "Some components have other similar licences."))))
205
206 ;; Sadly, this is needed for irods. It won't link with 1.69 or later.
207 (define-public boost-for-irods
208 (package
209 (inherit boost)
210 (name "boost-for-irods")
211 (version "1.68.0")
212 (source (origin
213 (method url-fetch)
214 (uri (string-append
215 "mirror://sourceforge/boost/boost/" version "/boost_"
216 (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version)
217 ".tar.bz2"))
218 (sha256
219 (base32
220 "1dyqsr9yb01y0nnjdq9b8q5s2kvhxbayk34832k5cpzn7jy30qbz"))))
221 (build-system gnu-build-system)
222 (properties `((hidden? . #true)))
223 (inputs
224 `(("icu4c" ,icu4c)
225 ("libcxx" ,libcxx+libcxxabi-6)
226 ("libcxxabi" ,libcxxabi-6)
227 ("zlib" ,zlib)))
228 (native-inputs
229 `(("clang" ,clang-6)
230 ("perl" ,perl)
231 ("tcsh" ,tcsh)))
232 (arguments
233 `(#:tests? #f
234 #:make-flags
235 (list "threading=multi" "link=shared"
236 "cxxflags=-stdlib=libc++"
237 "--without-python"
238
239 ;; Set the RUNPATH to $libdir so that the libs find each other.
240 (string-append "linkflags=-stdlib=libc++ -Wl,-rpath="
241 (assoc-ref %outputs "out") "/lib"))
242 #:phases
243 (modify-phases %standard-phases
244 (delete 'bootstrap)
245 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
246 (lambda* (#:key native-inputs inputs #:allow-other-keys)
247 (let ((gcc (assoc-ref (or native-inputs inputs) "gcc")))
248 (setenv "CPLUS_INCLUDE_PATH"
249 (string-join
250 (cons (string-append (assoc-ref inputs "libcxx")
251 "/include/c++/v1")
252 ;; Hide GCC's C++ headers so that they do not interfere with
253 ;; the Clang headers.
254 (delete (string-append gcc "/include/c++")
255 (string-split (getenv "CPLUS_INCLUDE_PATH")
256 #\:)))
257 ":"))
258 (format #true
259 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
260 (getenv "CPLUS_INCLUDE_PATH")))))
261 (replace 'configure
262 (lambda* (#:key inputs outputs #:allow-other-keys)
263 (let ((icu (assoc-ref inputs "icu4c"))
264 (out (assoc-ref outputs "out"))
265 (sh (string-append (assoc-ref inputs "bash") "/bin/sh")))
266 (substitute* '("libs/config/configure"
267 "libs/spirit/classic/phoenix/test/runtest.sh"
268 "tools/build/src/engine/execunix.c"
269 "tools/build/src/engine/Jambase"
270 "tools/build/src/engine/jambase.c")
271 (("/bin/sh") sh))
272
273 (setenv "SHELL" (which "sh"))
274 (setenv "CONFIG_SHELL" (which "sh"))
275
276 (invoke "./bootstrap.sh"
277 (string-append "--prefix=" out)
278 ;; Auto-detection looks for ICU only in traditional
279 ;; install locations.
280 (string-append "--with-icu=" icu)
281 "--with-toolset=clang"))))
282 (replace 'build
283 (lambda* (#:key make-flags #:allow-other-keys)
284 (apply invoke "./b2"
285 (format #f "-j~a" (parallel-job-count))
286 make-flags)))
287 (replace 'install
288 (lambda* (#:key make-flags #:allow-other-keys)
289 (apply invoke "./b2" "install" make-flags))))))))
290
291 (define-public boost-with-python2
292 (package/inherit boost
293 (name "boost-python2")
294 (native-inputs
295 `(("python" ,python-2)
296 ,@(alist-delete "python" (package-native-inputs boost))))))
297
298 (define-public boost-with-python3
299 (deprecated-package "boost-with-python3" boost))
300
301 (define-public boost-static
302 (package
303 (inherit boost)
304 (name "boost-static")
305 (arguments
306 (substitute-keyword-arguments (package-arguments boost)
307 ((#:make-flags flags)
308 `(cons "link=static" (delete "link=shared" ,flags)))
309 ((#:phases phases)
310 `(modify-phases ,phases
311 (replace 'provide-libboost_python
312 (lambda* (#:key inputs outputs #:allow-other-keys)
313 (let* ((out (assoc-ref outputs "out"))
314 (python-version (python-version
315 (assoc-ref inputs "python")))
316 (libboost_pythonNN.a
317 (string-append "libboost_python"
318 (string-join (string-split
319 python-version #\.)
320 "")
321 ".a")))
322 (with-directory-excursion (string-append out "/lib")
323 (symlink libboost_pythonNN.a "libboost_python.a"))
324 #t)))))))))
325
326 (define-public boost-for-mysql
327 ;; Older version for MySQL 5.7.23.
328 (package
329 (inherit boost)
330 (version "1.59.0")
331 (source (origin
332 (method url-fetch)
333 (uri (string-append
334 "mirror://sourceforge/boost/boost/" version "/boost_"
335 (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version)
336 ".tar.bz2"))
337 (sha256
338 (base32
339 "1jj1aai5rdmd72g90a3pd8sw9vi32zad46xv5av8fhnr48ir6ykj"))))
340 (arguments (substitute-keyword-arguments (package-arguments boost)
341 ((#:phases phases)
342 `(modify-phases ,phases
343 (replace 'configure
344 (lambda* (#:key inputs outputs #:allow-other-keys)
345 (let ((icu (assoc-ref inputs "icu4c"))
346 (out (assoc-ref outputs "out")))
347 (substitute* (append
348 (find-files "tools/build/src/engine/" "execunix\\.c.*")
349 '("libs/config/configure"
350 "libs/spirit/classic/phoenix/test/runtest.sh"
351 "tools/build/doc/bjam.qbk"
352 "tools/build/src/engine/Jambase"))
353 (("/bin/sh") (which "sh")))
354
355 (setenv "SHELL" (which "sh"))
356 (setenv "CONFIG_SHELL" (which "sh"))
357
358 ,@(if (%current-target-system)
359 `((call-with-output-file "user-config.jam"
360 (lambda (port)
361 (format port
362 "using gcc : cross : ~a-c++ ;"
363 ,(%current-target-system)))))
364 '())
365
366 (invoke "./bootstrap.sh"
367 (string-append "--prefix=" out)
368 ;; Auto-detection looks for ICU only in traditional
369 ;; install locations.
370 (string-append "--with-icu=" icu)
371 "--with-toolset=gcc"))))
372 (delete 'provide-libboost_python)))
373 ((#:make-flags make-flags)
374 `(cons* "--without-python" ,make-flags))))
375 (native-inputs
376 (alist-delete "python" (package-native-inputs boost)))
377 (properties '((hidden? . #t)))))
378
379 (define-public boost-sync
380 (let ((commit "c72891d9b90e2ceb466ec859f640cd012b2d8709")
381 (version "1.55")
382 (revision "1"))
383 (package
384 (name "boost-sync")
385 (version (git-version version revision commit))
386 (source (origin
387 (method git-fetch)
388 (uri (git-reference
389 (url "https://github.com/boostorg/sync")
390 (commit commit)))
391 (file-name (git-file-name name version))
392 (sha256
393 (base32
394 "197mp5z048vz5kv1m4v3jm447l2gqsyv0rbfz11dz0ns343ihbyx"))))
395 (build-system trivial-build-system)
396 (arguments
397 `(#:modules ((guix build utils))
398 #:builder
399 (begin
400 (use-modules (guix build utils))
401 (let ((source (assoc-ref %build-inputs "source")))
402 (copy-recursively (string-append source "/include")
403 (string-append %output "/include"))))))
404 (home-page "https://github.com/boostorg/sync")
405 (synopsis "Boost.Sync library")
406 (description "The Boost.Sync library provides mutexes, semaphores, locks
407 and events and other thread related facilities. Boost.Sync originated from
408 Boost.Thread.")
409 (license (license:x11-style "https://www.boost.org/LICENSE_1_0.txt")))))
410
411 (define-public boost-signals2
412 (package
413 (name "boost-signals2")
414 (version (package-version boost))
415 (source (origin
416 (method git-fetch)
417 (uri (git-reference
418 (url "https://github.com/boostorg/signals2")
419 (commit (string-append "boost-" version))))
420 (file-name (git-file-name name version))
421 (sha256
422 (base32
423 "13i5j43nggb46i6qpaf7gk53i7zp7pimphl7sydyfqz2m9yx5cdy"))))
424 (build-system trivial-build-system)
425 (arguments
426 `(#:modules ((guix build utils))
427 #:builder
428 (begin
429 (use-modules (guix build utils))
430 (let ((source (assoc-ref %build-inputs "source")))
431 (copy-recursively (string-append source "/include")
432 (string-append %output "/include"))))))
433 (home-page "https://github.com/boostorg/signals2")
434 (synopsis "Boost.Signals2 library")
435 (description "The Boost.Signals2 library is an implementation of a managed
436 signals and slots system.")
437 (license (license:x11-style "https://www.boost.org/LICENSE_1_0.txt"))))
438
439
440 (define-public boost-mpi
441 (package
442 (inherit boost)
443 (name "boost-mpi")
444 (native-inputs
445 `(("perl" ,perl)
446 ,@(if (%current-target-system)
447 '()
448 `(("python" ,python-wrapper)))
449 ("openmpi" , openmpi)))
450 (arguments
451 (substitute-keyword-arguments (package-arguments boost)
452 ((#:phases phases)
453 `(modify-phases ,phases
454 (add-after 'configure 'update-jam
455 (lambda* (#:key inputs outputs #:allow-other-keys)
456 (let ((output-port (open-file "project-config.jam" "a")))
457 (display "using mpi ;" output-port)
458 (newline output-port)
459 (close output-port))))))))
460 (home-page "https://www.boost.org")
461 (synopsis "Message Passing Interface (MPI) library for C++")))
462
463 (define-public mdds
464 (package
465 (name "mdds")
466 (version "1.5.0")
467 (source (origin
468 (method url-fetch)
469 (uri (string-append
470 "http://kohei.us/files/mdds/src/mdds-" version ".tar.bz2"))
471 (sha256
472 (base32
473 "03b8i43pw4m767mm0cnbi77x7qhpkzpi9b1f6dpp4cmyszmnsk8l"))))
474 (build-system gnu-build-system)
475 (propagated-inputs
476 `(("boost" ,boost))) ; inclusion of header files
477 (home-page "https://gitlab.com/mdds/mdds")
478 (synopsis "Multi-dimensional C++ data structures and indexing algorithms")
479 (description "Mdds (multi-dimensional data structure) provides a
480 collection of multi-dimensional data structures and indexing algorithms
481 for C++. It includes flat segment trees, segment trees, rectangle sets,
482 point quad trees, multi-type vectors and multi-type matrices.")
483 (license license:expat)))