c.scm 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016, 2018 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2016, 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
  4. ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
  6. ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (gnu packages c)
  23. #:use-module ((guix licenses) #:prefix license:)
  24. #:use-module (guix packages)
  25. #:use-module (guix download)
  26. #:use-module (guix git-download)
  27. #:use-module (guix build-system gnu)
  28. #:use-module (guix build-system trivial)
  29. #:use-module (gnu packages bootstrap)
  30. #:use-module (gnu packages bison)
  31. #:use-module (gnu packages flex)
  32. #:use-module (gnu packages perl)
  33. #:use-module (gnu packages texinfo)
  34. #:use-module (gnu packages guile)
  35. #:use-module (gnu packages multiprecision)
  36. #:use-module (gnu packages pcre)
  37. #:use-module (gnu packages python)
  38. #:use-module (gnu packages autotools)
  39. #:use-module (gnu packages gettext)
  40. #:use-module (gnu packages pkg-config))
  41. (define-public tcc
  42. (package
  43. (name "tcc") ;aka. "tinycc"
  44. (version "0.9.27")
  45. (source (origin
  46. (method url-fetch)
  47. (uri (string-append "mirror://savannah/tinycc/tcc-"
  48. version ".tar.bz2"))
  49. (sha256
  50. (base32
  51. "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
  52. (build-system gnu-build-system)
  53. (native-inputs `(("perl" ,perl)
  54. ("texinfo" ,texinfo)))
  55. (arguments
  56. `(#:configure-flags (list (string-append "--elfinterp="
  57. (assoc-ref %build-inputs "libc")
  58. ,(glibc-dynamic-linker))
  59. (string-append "--crtprefix="
  60. (assoc-ref %build-inputs "libc")
  61. "/lib")
  62. (string-append "--sysincludepaths="
  63. (assoc-ref %build-inputs "libc")
  64. "/include:"
  65. (assoc-ref %build-inputs
  66. "kernel-headers")
  67. "/include:{B}/include")
  68. (string-append "--libpaths="
  69. (assoc-ref %build-inputs "libc")
  70. "/lib")
  71. ,@(if (string-prefix? "armhf-linux"
  72. (or (%current-target-system)
  73. (%current-system)))
  74. `("--triplet=arm-linux-gnueabihf")
  75. '()))
  76. #:test-target "test"))
  77. ;; Fails to build on MIPS: "Unsupported CPU"
  78. (supported-systems (delete "mips64el-linux" %supported-systems))
  79. (synopsis "Tiny and fast C compiler")
  80. (description
  81. "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
  82. written in C. It supports ANSI C with GNU and extensions and most of the C99
  83. standard.")
  84. (home-page "http://www.tinycc.org/")
  85. ;; An attempt to re-licence tcc under the Expat licence is underway but not
  86. ;; (if ever) complete. See the RELICENSING file for more information.
  87. (license license:lgpl2.1+)))
  88. (define-public tcc-wrapper
  89. (package
  90. (inherit tcc)
  91. (name "tcc-wrapper")
  92. (build-system trivial-build-system)
  93. (native-inputs '())
  94. (inputs `(("tcc" ,tcc)
  95. ("guile" ,guile-2.2)))
  96. ;; By default TCC does not honor any search path environment variable.
  97. ;; This wrapper adds them.
  98. ;;
  99. ;; FIXME: TCC includes its own linker so our 'ld-wrapper' hack to set the
  100. ;; RUNPATH is ineffective here. We should modify TCC itself.
  101. (native-search-paths
  102. (list (search-path-specification
  103. (variable "TCC_CPATH")
  104. (files '("include")))
  105. (search-path-specification
  106. (variable "TCC_LIBRARY_PATH")
  107. (files '("lib" "lib64")))))
  108. (arguments
  109. '(#:builder
  110. (let* ((out (assoc-ref %outputs "out"))
  111. (bin (string-append out "/bin"))
  112. (tcc (assoc-ref %build-inputs "tcc"))
  113. (guile (assoc-ref %build-inputs "guile")))
  114. (mkdir out)
  115. (mkdir bin)
  116. (call-with-output-file (string-append bin "/cc")
  117. (lambda (port)
  118. (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
  119. (write
  120. `(begin
  121. (use-modules (ice-9 match)
  122. (srfi srfi-26))
  123. (define (split path)
  124. (string-tokenize path (char-set-complement
  125. (char-set #\:))))
  126. (apply execl ,(string-append tcc "/bin/tcc")
  127. ,(string-append tcc "/bin/tcc") ;argv[0]
  128. (append (cdr (command-line))
  129. (match (getenv "TCC_CPATH")
  130. (#f '())
  131. (str
  132. (map (cut string-append "-I" <>)
  133. (split str))))
  134. (match (getenv "TCC_LIBRARY_PATH")
  135. (#f '())
  136. (str
  137. (map (cut string-append "-L" <>)
  138. (split str)))))))
  139. port)
  140. (chmod port #o777)))
  141. #t)))
  142. (synopsis "Wrapper providing the 'cc' command for TCC")))
  143. (define-public pcc
  144. (package
  145. (name "pcc")
  146. (version "20170109")
  147. (source (origin
  148. (method url-fetch)
  149. (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
  150. version ".tgz"))
  151. (sha256
  152. (base32
  153. "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
  154. (build-system gnu-build-system)
  155. (arguments
  156. `(#:phases
  157. (modify-phases %standard-phases
  158. (replace 'check
  159. (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
  160. (native-inputs
  161. `(("bison" ,bison)
  162. ("flex" ,flex)))
  163. (synopsis "Portable C compiler")
  164. (description
  165. "PCC is a portable C compiler. The project goal is to write a C99
  166. compiler while still keeping it small, simple, fast and understandable.")
  167. (home-page "http://pcc.ludd.ltu.se")
  168. (supported-systems (delete "aarch64-linux" %supported-systems))
  169. ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
  170. ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
  171. (license (list license:bsd-2 license:bsd-3))))
  172. (define-public libbytesize
  173. (package
  174. (name "libbytesize")
  175. (version "1.4")
  176. (source (origin
  177. (method url-fetch)
  178. (uri (string-append
  179. "https://github.com/storaged-project/libbytesize/releases/"
  180. "download/" version "/libbytesize-" version ".tar.gz"))
  181. (sha256
  182. (base32
  183. "0bbqzln1nhjxl71aydq9k4jg3hvki9lqsb4w10s1i27jgibxqkdv"))
  184. (modules '((guix build utils)))
  185. (snippet
  186. '(begin
  187. ;; This Makefile hard-codes MSGMERGE et al. instead of
  188. ;; honoring what 'configure' detected. Fix that.
  189. (substitute* "po/Makefile.in"
  190. (("^MSGMERGE = msgmerge")
  191. "MSGMERGE = @MSGMERGE@\n"))
  192. #t))))
  193. (build-system gnu-build-system)
  194. (arguments
  195. ;; When running "make", the POT files are built with the build time as
  196. ;; their "POT-Creation-Date". Later on, "make" notices that .pot
  197. ;; files were updated and goes on to run "msgmerge"; as a result, the
  198. ;; non-deterministic POT-Creation-Date finds its way into .po files,
  199. ;; and then in .gmo files. To avoid that, simply make sure 'msgmerge'
  200. ;; never runs. See <https://bugs.debian.org/792687>.
  201. '(#:configure-flags '("ac_cv_path_MSGMERGE=true")
  202. #:phases (modify-phases %standard-phases
  203. (add-after 'configure 'create-merged-po-files
  204. (lambda _
  205. ;; Create "merged PO" (.mpo) files so that 'msgmerge'
  206. ;; doesn't need to run.
  207. (for-each (lambda (po-file)
  208. (let ((merged-po
  209. (string-append (dirname po-file) "/"
  210. (basename po-file
  211. ".po")
  212. ".mpo")))
  213. (copy-file po-file merged-po)))
  214. (find-files "po" "\\.po$"))
  215. #t)))
  216. ;; One test fails because busctl (systemd only?) and python2-pocketlint
  217. ;; are missing. Should we fix it, we would need the "python-2" ,
  218. ;; "python2-polib" and "python2-six" native-inputs.
  219. #:tests? #f))
  220. (native-inputs
  221. `(("gettext" ,gettext-minimal)
  222. ("pkg-config" ,pkg-config)
  223. ("python" ,python)))
  224. (inputs
  225. `(("mpfr" ,mpfr)
  226. ("pcre" ,pcre)))
  227. (home-page "https://github.com/storaged-project/libbytesize")
  228. (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
  229. (description
  230. "The goal of this project is to provide a tiny library that would
  231. facilitate the common operations with sizes in bytes. Many projects need to
  232. work with sizes in bytes (be it sizes of storage space, memory...) and all of
  233. them need to deal with the same issues like:
  234. @itemize
  235. @item How to get a human-readable string for the given size?
  236. @item How to store the given size so that no significant information is lost?
  237. @item If we store the size in bytes, what if the given size gets over the
  238. MAXUINT64 value?
  239. @item How to interpret sizes entered by users according to their locale and
  240. typing conventions?
  241. @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
  242. @end itemize
  243. @code{libbytesize} offers a generally usable solution that could be used by
  244. every project that needs to deal with sizes in bytes. It is written in the C
  245. language with thin bindings for other languages.")
  246. (license license:lgpl2.1+)))