boost.scm 20 KB

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