gnu: Add cl-ana.statistical-learning.
[jackhill/guix/guix.git] / gnu / packages / code.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2015, 2018 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2016, 2017, 2019 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org>
8 ;;; Copyright © 2017 Andy Wingo <wingo@igalia.com>
9 ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
10 ;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
11 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
12 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
13 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
14 ;;; Copyright © 2019 Hartmut Goebel <h.goebel@goebel-consult.de>
15 ;;;
16 ;;; This file is part of GNU Guix.
17 ;;;
18 ;;; GNU Guix is free software; you can redistribute it and/or modify it
19 ;;; under the terms of the GNU General Public License as published by
20 ;;; the Free Software Foundation; either version 3 of the License, or (at
21 ;;; your option) any later version.
22 ;;;
23 ;;; GNU Guix is distributed in the hope that it will be useful, but
24 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
25 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 ;;; GNU General Public License for more details.
27 ;;;
28 ;;; You should have received a copy of the GNU General Public License
29 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
30
31 (define-module (gnu packages code)
32 #:use-module (guix packages)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module ((guix licenses) #:prefix license:)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system cmake)
38 #:use-module (guix build-system trivial)
39 #:use-module (gnu packages)
40 #:use-module (gnu packages autogen)
41 #:use-module (gnu packages autotools)
42 #:use-module (gnu packages base)
43 #:use-module (gnu packages bash)
44 #:use-module (gnu packages compression)
45 #:use-module (gnu packages cpp)
46 #:use-module (gnu packages emacs)
47 #:use-module (gnu packages gcc)
48 #:use-module (gnu packages graphviz)
49 #:use-module (gnu packages pcre)
50 #:use-module (gnu packages perl)
51 #:use-module (gnu packages pkg-config)
52 #:use-module (gnu packages python)
53 #:use-module (gnu packages sqlite)
54 #:use-module (gnu packages texinfo)
55 #:use-module (gnu packages ncurses)
56 #:use-module (gnu packages llvm)
57 #:use-module (gnu packages lua))
58
59 ;;; Tools to deal with source code: metrics, cross-references, etc.
60
61 (define-public cflow
62 (package
63 (name "cflow")
64 (version "1.6")
65 (source (origin
66 (method url-fetch)
67 (uri (string-append "mirror://gnu/cflow/cflow-"
68 version ".tar.bz2"))
69 (sha256
70 (base32
71 "1mzd3yf0dfv8h2av5vsxxlhpk21nw064h91b2kgfrdz92r0pnj1l"))))
72 (build-system gnu-build-system)
73
74 ;; Needed to have cflow-mode.el installed.
75 (native-inputs `(("emacs" ,emacs-minimal)))
76 (arguments
77 '(#:configure-flags (list (string-append "CPPFLAGS="
78 "-D" "CFLOW_PREPROC=\\\""
79 (assoc-ref %build-inputs "gcc")
80 "/bin/cpp\\\""))))
81 (home-page "https://www.gnu.org/software/cflow/")
82 (synopsis "Create a graph of control flow within a program")
83 (description
84 "GNU cflow analyzes C source files and produces a graph charting the
85 control flow of the program. It can output the graph in several styles and
86 in either the POSIX format or in an extended GNU format. cflow also includes
87 a major mode for Emacs for examining the flowcharts that it produces.")
88 (license license:gpl3+)))
89
90 (define-public complexity
91 (package
92 (name "complexity")
93 (version "1.10")
94 (source (origin
95 (method url-fetch)
96 (uri (string-append "mirror://gnu/complexity/complexity-"
97 version ".tar.xz"))
98 (sha256
99 (base32
100 "0lr0l9kj2w3jilz9h9y4np9pf9i9ccpy6331lanki2fnz4z8ldvd"))))
101 (build-system gnu-build-system)
102 (native-inputs
103 `(("texinfo" ,texinfo)
104 ("autogen" ,autogen)))
105 (home-page "https://www.gnu.org/software/complexity/")
106 (synopsis "Analyze complexity of C functions")
107 (description
108 "GNU complexity provides tools for finding procedures that are
109 convoluted, overly long or otherwise difficult to understand. This
110 may help in learning or reviewing unfamiliar code or perhaps
111 highlighting your own code that seemed comprehensible when you wrote it.")
112 (license license:gpl3+)))
113
114 (define-public global ; a global variable
115 (package
116 (name "global")
117 (version "6.6.3")
118 (source (origin
119 (method url-fetch)
120 (uri (string-append "mirror://gnu/global/global-"
121 version ".tar.gz"))
122 (sha256
123 (base32
124 "0735pj47dnspf20n0j1px24p59nwjinlmlb2n32ln1hvdkprivnb"))))
125 (build-system gnu-build-system)
126 (inputs `(("ncurses" ,ncurses)
127 ("libltdl" ,libltdl)
128 ("sqlite" ,sqlite)))
129 (arguments
130 `(#:configure-flags
131 (list (string-append "--with-ncurses="
132 (assoc-ref %build-inputs "ncurses"))
133 (string-append "--with-sqlite3="
134 (assoc-ref %build-inputs "sqlite")))
135
136 #:phases
137 (modify-phases %standard-phases
138 (add-after 'install 'post-install
139 (lambda* (#:key outputs #:allow-other-keys)
140 ;; Install the Emacs Lisp file in the right place.
141 (let* ((out (assoc-ref outputs "out"))
142 (data (string-append out "/share/gtags"))
143 (lisp (string-append out "/share/emacs/site-lisp")))
144 (install-file (string-append data "/gtags.el") lisp)
145 (delete-file (string-append data "/gtags.el"))
146 #t))))))
147 (home-page "https://www.gnu.org/software/global/")
148 (synopsis "Cross-environment source code tag system")
149 (description
150 "GNU GLOBAL is a source code tagging system that functions in the same
151 way across a wide array of environments, such as different text editors,
152 shells and web browsers. The resulting tags are useful for quickly moving
153 around in a large, deeply nested project.")
154 (license license:gpl3+)))
155
156 (define-public sloccount
157 (package
158 (name "sloccount")
159 (version "2.26")
160 (source (origin
161 (method url-fetch)
162 (uri (string-append "http://www.dwheeler.com/sloccount/sloccount-"
163 version ".tar.gz"))
164 (sha256
165 (base32
166 "0ayiwfjdh1946asah861ah9269s5xkc8p5fv1wnxs9znyaxs4zzs"))))
167 (build-system gnu-build-system)
168 (arguments
169 '(#:phases (modify-phases %standard-phases
170 (delete 'configure)
171 (add-before 'build 'make-dotl-files-older
172 (lambda _
173 ;; Make the '.l' files as old as the '.c'
174 ;; files to avoid triggering the rule that
175 ;; requires Flex.
176 (define ref
177 (stat "README"))
178
179 (for-each (lambda (file)
180 (set-file-time file ref))
181 (find-files "." "\\.[chl]$"))
182 #t))
183 (add-before 'install 'make-target-directories
184 (lambda* (#:key outputs #:allow-other-keys)
185 (let ((out (assoc-ref outputs "out")))
186 (mkdir-p (string-append out "/bin"))
187 (mkdir-p (string-append out
188 "/share/man/man1"))
189 (mkdir-p (string-append out
190 "/share/doc"))
191 #t)))
192 (replace 'check
193 (lambda _
194 (setenv "HOME" (getcwd))
195 (setenv "PATH"
196 (string-append (getcwd) ":"
197 (getenv "PATH")))
198 (invoke "make" "test"))))
199
200 #:make-flags (list (string-append "PREFIX="
201 (assoc-ref %outputs "out")))))
202 (inputs `(("perl" ,perl)))
203 (home-page "http://www.dwheeler.com/sloccount/")
204 (synopsis "Count physical source lines of code (SLOC)")
205 (description
206 "SLOCCount is a set of the programs for counting source lines of
207 code (SLOC) in large software systems. It can automatically identify and
208 measure a wide range of programming languages. It automatically estimates the
209 effort, time, and money it would take to develop the software, using the
210 COCOMO model or user-provided parameters.")
211 (license license:gpl2+)))
212
213 (define-public cloc
214 (package
215 (name "cloc")
216 (version "1.82")
217 (source
218 (origin
219 (method git-fetch)
220 (uri (git-reference
221 (url "https://github.com/AlDanial/cloc.git")
222 (commit version)))
223 (file-name (git-file-name name version))
224 (sha256
225 (base32 "0fsz07z0slfg58512fmnlj8pnxkc360bgf7fclg60v9clvcjbjsw"))))
226 (build-system gnu-build-system)
227 (inputs
228 `(("coreutils" ,coreutils)
229 ("perl" ,perl)
230 ("perl-algorithm-diff" ,perl-algorithm-diff)
231 ("perl-digest-md5" ,perl-digest-md5)
232 ("perl-parallel-forkmanager" ,perl-parallel-forkmanager)
233 ("perl-regexp-common" ,perl-regexp-common)))
234 (arguments
235 `(#:phases (modify-phases %standard-phases
236 (delete 'configure) ; nothing to configure
237 (delete 'build) ; nothing to build
238 (replace 'install
239 (lambda* (#:key inputs outputs #:allow-other-keys)
240 (let* ((out (assoc-ref outputs "out")))
241 (invoke "make" "-C" "Unix"
242 (string-append "prefix=" out)
243 (string-append "INSTALL="
244 (assoc-ref inputs "coreutils")
245 "/bin/install")
246 "install")
247 #t)))
248 (add-after 'install 'wrap-program
249 (lambda* (#:key inputs outputs #:allow-other-keys)
250 (let ((out (assoc-ref outputs "out")))
251 (wrap-program (string-append out "/bin/cloc")
252 `("PERL5LIB" ":" =
253 ,(string-split (getenv "PERL5LIB") #\:)))
254 #t))))
255 #:out-of-source? #t
256 ;; Tests require some other packages.
257 #:tests? #f))
258 (home-page "https://github.com/AlDanial/cloc")
259 (synopsis "Count source lines of code (SLOC) and other source code metrics")
260 (description "cloc counts blank lines, comment lines, and physical lines
261 of source code in many programming languages. Given two versions of a code
262 base, cloc can compute differences in blank, comment, and source lines.
263
264 cloc contains code from David Wheeler's SLOCCount. Compared to SLOCCount,
265 cloc can handle a greater variety of programming languages.")
266 (license license:gpl2+)))
267
268 (define-public the-silver-searcher
269 (package
270 (name "the-silver-searcher")
271 (version "2.2.0")
272 (source (origin
273 (method url-fetch)
274 (uri (string-append
275 "https://geoff.greer.fm/ag/releases/the_silver_searcher-"
276 version ".tar.gz"))
277 (sha256
278 (base32
279 "0w1icjqd8hd45rn1y6nbfznk1a6ip54whwbfbhxp7ws2hn3ilqnr"))))
280 (build-system gnu-build-system)
281 (native-inputs
282 `(("pkg-config" ,pkg-config)))
283 (inputs
284 `(("pcre" ,pcre)
285 ("xz" ,xz)
286 ("zlib" ,zlib)))
287 (home-page "https://geoff.greer.fm/ag/")
288 (synopsis "Fast code searching tool")
289 (description
290 "The Silver Searcher (@command{ag}) is a tool for quickly searching large
291 numbers of files. It's intended primarily for source code repositories, and
292 respects files like @file{.gitignore} and @file{.hgignore}. It's also an order
293 of magnitude faster than its inspiration, @command{ack}, and less specialised
294 tools such as @command{grep}.")
295 (license license:asl2.0)))
296
297 (define-public trio
298 (package
299 (name "trio")
300 (version "1.16")
301 (source (origin
302 (method url-fetch)
303 (uri (string-append "mirror://sourceforge/ctrio/trio/trio-"
304 version ".tar.gz"))
305 (sha256
306 (base32
307 "02pwd5m5vq7hbrffgm2na1dfc249z50yyr5jv73vdw15bd7ygl44"))))
308 (build-system gnu-build-system)
309 (home-page "http://daniel.haxx.se/projects/trio/")
310 (synopsis "Portable and extendable printf and string functions")
311 (description
312 "Trio is a set of @code{printf} and string functions designed be used by
313 applications with a focus on portability or with the need for additional
314 features that are not supported by the standard @code{stdio} implementation.")
315 ;; This license is very similar to the ISC license, but the wording is
316 ;; slightly different.
317 (license (license:non-copyleft
318 "http://sourceforge.net/p/ctrio/git/ci/master/tree/README"))))
319
320 (define-public withershins
321 (package
322 (name "withershins")
323 (version "0.1")
324 (source
325 (origin
326 (method git-fetch)
327 (uri (git-reference
328 (url "https://github.com/cameronwhite/withershins.git")
329 (commit (string-append "v" version))))
330 (file-name (git-file-name name version))
331 (sha256
332 (base32 "1cviqvbbcwljm1zx12j6511hazr3kscwrvcyifrkfi4fpy5z985m"))))
333 (build-system cmake-build-system)
334 (arguments
335 `(#:out-of-source? #f
336 #:configure-flags
337 ;; XXX A (justified!) misleading-indentation error breaks the build.
338 (list "-DENABLE_WERROR=OFF")
339 #:phases
340 (modify-phases %standard-phases
341 (add-after
342 'unpack 'find-libiberty
343 (lambda _
344 (let ((libiberty (assoc-ref %build-inputs "libiberty")))
345 (substitute* "cmake/FindIberty.cmake"
346 (("/usr/include") (string-append libiberty "/include"))
347 (("libiberty.a iberty")
348 (string-append "NAMES libiberty.a iberty\nPATHS \""
349 libiberty "/lib" "\"")))
350 #t)))
351 (replace
352 'install
353 (lambda* (#:key outputs #:allow-other-keys)
354 (let* ((out (assoc-ref outputs "out"))
355 (include (string-append out "/include"))
356 (lib (string-append out "/lib")))
357 (mkdir-p include)
358 (install-file "src/withershins.hpp" include)
359 (mkdir-p lib)
360 (install-file "src/libwithershins.a" lib))
361 #t)))))
362 (home-page "https://github.com/cameronwhite/withershins")
363 (inputs
364 `(("libiberty" ,libiberty)
365 ("binutils" ,binutils) ;for libbfd
366 ("zlib" ,zlib)))
367 (synopsis "C++11 library for generating stack traces")
368 (description
369 "Withershins is a simple cross-platform C++11 library for generating
370 stack traces.")
371 ;; Sources are released under Expat license, but since BFD is licensed
372 ;; under the GPLv3+ the combined work is GPLv3+ as well.
373 (license license:gpl3+)))
374
375 (define-public lcov
376 (package
377 (name "lcov")
378 (version "1.14")
379 (source (origin
380 (method url-fetch)
381 (uri (string-append "mirror://sourceforge/ltp/Coverage%20Analysis"
382 "/LCOV-" version "/lcov-" version ".tar.gz"))
383 (sha256
384 (base32
385 "06h7ixyznf6vz1qvksjgy5f3q2nw9akf6zx59npf0h3l32cmd68l"))))
386 (build-system gnu-build-system)
387 (arguments
388 '(#:make-flags
389 (let ((out (assoc-ref %outputs "out")))
390 (list (string-append "PREFIX=" out)))
391 #:phases
392 (modify-phases %standard-phases
393 (delete 'configure)) ; no configure script
394 #:tests? #f)) ; no 'check' target
395 (inputs `(("perl" ,perl)))
396 (home-page "http://ltp.sourceforge.net/coverage/lcov.php")
397 (synopsis "Code coverage tool that enhances GNU gcov")
398 (description
399 "LCOV is an extension of @command{gcov}, a tool part of the
400 GNU@tie{}Binutils, which provides information about what parts of a program
401 are actually executed (i.e., \"covered\") while running a particular test
402 case. The extension consists of a set of Perl scripts which build on the
403 textual @command{gcov} output to implement the following enhanced
404 functionality such as HTML output.")
405 (license license:gpl2+)))
406
407 (define-public rtags
408 (package
409 (name "rtags")
410 (version "2.18")
411 (source
412 (origin
413 (method git-fetch)
414 (uri (git-reference
415 (url "https://github.com/Andersbakken/rtags.git")
416 (commit (string-append "v" version))))
417 (file-name (git-file-name name version))
418 (patches (search-patches "rtags-separate-rct.patch"))
419 (modules '((guix build utils)))
420 (snippet
421 ;; Part of spliting rct with rtags.
422 ;; Substitute #include "rct/header.h" with #include <rct/header.h>.
423 '(with-directory-excursion "src"
424 (delete-file-recursively "rct") ;remove bundled copy
425 (let ((files (find-files "." ".*\\.cpp|.*\\.h")))
426 (substitute* files
427 (("#include ?\"rct/(.*.h)\"" all header)
428 (string-append "#include <rct/" header ">")))
429 #t)))
430 (sha256
431 (base32
432 "0raqjbkl1ykga4ahgl9xw49cgh3cyqcf42z36z7d6fz1fw192kg0"))))
433 (build-system cmake-build-system)
434 (arguments
435 '(#:build-type "RelWithDebInfo"
436 #:configure-flags
437 '("-DRTAGS_NO_ELISP_FILES=1"
438 "-DBUILD_TESTING=FALSE")
439 #:tests? #f))
440 (native-inputs
441 `(("pkg-config" ,pkg-config)))
442 (inputs
443 `(("bash-completion" ,bash-completion)
444 ("clang" ,clang)
445 ("llvm" ,llvm)
446 ("lua" ,lua)
447 ("rct" ,rct)
448 ("selene" ,selene)))
449 (home-page "https://github.com/Andersbakken/rtags")
450 (synopsis "Indexer for the C language family with Emacs integration")
451 (description
452 "RTags is a client/server application that indexes C/C++ code and keeps a
453 persistent file-based database of references, declarations, definitions,
454 symbolnames etc. There’s also limited support for ObjC/ObjC++. It allows you
455 to find symbols by name (including nested class and namespace scope). Most
456 importantly we give you proper follow-symbol and find-references support.")
457 (license license:gpl3+)))
458
459 (define-public colormake
460 (package
461 (name "colormake")
462 (version "0.9.20140503")
463 (source
464 (origin
465 (method git-fetch)
466 (uri (git-reference
467 (url "https://github.com/pagekite/Colormake.git")
468 (commit version)))
469 (file-name (git-file-name name version))
470 (sha256
471 (base32 "1f9v5s0viq4yc9iv6701h3pv7j21zz1ckl37lpp9hsnliiizv03p"))))
472 (build-system trivial-build-system)
473 (native-inputs
474 `(("bash" ,bash)
475 ("perl" ,perl)))
476 (arguments
477 `(#:modules ((guix build utils))
478 #:builder
479 (begin
480 (use-modules (guix build utils))
481 (copy-recursively (assoc-ref %build-inputs "source") "source")
482 (chdir "source")
483 (patch-shebang "colormake.pl"
484 (list (string-append (assoc-ref %build-inputs "perl")
485 "/bin")))
486 (let* ((out (assoc-ref %outputs "out"))
487 (bin (string-append out "/bin"))
488 (doc (string-append out "/share/doc"))
489 (install-files (lambda (files directory)
490 (for-each (lambda (file)
491 (install-file file directory))
492 files))))
493 (substitute* "colormake"
494 (("colormake\\.pl") (string-append bin "/colormake.pl"))
495 (("/bin/bash")
496 (string-append (assoc-ref %build-inputs "bash") "/bin/sh")))
497 (install-file "colormake.1" (string-append doc "/man/man1"))
498 (install-files '("AUTHORS" "BUGS" "ChangeLog" "README") doc)
499 (install-files '("colormake" "colormake-short" "clmake"
500 "clmake-short" "colormake.pl")
501 bin)
502 #t))))
503 (home-page "https://bre.klaki.net/programs/colormake/")
504 (synopsis "Wrapper around @command{make} to produce colored output")
505 (description "This package provides a wrapper around @command{make} to
506 produce colored output.")
507 (license license:gpl2+)))
508
509 (define-public makefile2graph
510 (package
511 (name "makefile2graph")
512 (version "1.5.0")
513 (source
514 (origin
515 (method git-fetch)
516 (uri (git-reference
517 (url "https://github.com/lindenb/makefile2graph.git")
518 (commit (string-append "v" version))))
519 (file-name (git-file-name name version))
520 (sha256
521 (base32 "1gjfk3d8qg3cla7qd2y7r9s03whlfwy83q8k76xfcnqrjjfavdgk"))))
522 (build-system gnu-build-system)
523 (arguments
524 '(#:test-target "test"
525 #:make-flags (list "CC=gcc" (string-append "prefix=" %output))
526 #:phases
527 (modify-phases %standard-phases
528 (delete 'configure))))
529 (native-inputs
530 `(("graphviz" ,graphviz)))
531 (home-page "https://github.com/lindenb/makefile2graph")
532 (synopsis "Creates a graph of dependencies from GNU Make")
533 (description
534 "@code{make2graph} creates a graph of dependencies from GNU Make. The
535 output is a graphviz-dot file, a Gexf-XML file or a list of the deepest
536 independent targets.")
537 (license license:expat)))
538
539 (define-public uncrustify
540 (package
541 (name "uncrustify")
542 (version "0.69.0")
543 (source (origin
544 (method git-fetch)
545 (uri (git-reference
546 (url "https://github.com/uncrustify/uncrustify/")
547 (commit (string-append name "-" version))))
548 (file-name (git-file-name name version))
549 (sha256
550 (base32
551 "0sqrg13kp8fwymq40976bq380bzw40g4ss7ihlbq45d0f90ifa1k"))))
552 (build-system cmake-build-system)
553 (native-inputs
554 `(("unzip" ,unzip)
555 ("python" ,python-wrapper)))
556 (arguments
557 `(#:phases
558 (modify-phases %standard-phases
559 (add-after 'unpack 'unpack-etc
560 (lambda* (#:key inputs outputs #:allow-other-keys)
561 ;; Configuration samples are not installed by default.
562 (let* ((output (assoc-ref outputs "out"))
563 (etcdir (string-append output "/etc")))
564 (for-each (lambda (l)
565 (install-file l etcdir))
566 (find-files "etc" "\\.cfg$")))
567 #t)))))
568 (home-page "http://uncrustify.sourceforge.net/")
569 (synopsis "Code formatter for C and other related languages")
570 (description
571 "Beautify source code in many languages of the C family (C, C++, C#,
572 Objective@tie{}C, D, Java, Pawn, and Vala). Features:
573 @itemize
574 @item Indent and align code.
575 @item Reformat comments (a little bit).
576 @item Fix inter-character spacing.
577 @item Add or remove parens / braces.
578 @item Supports embedded SQL @code{EXEC SQL} stuff.
579 @item Highly configurable - More than 600 configurable options.
580 @end itemize\n")
581 (license license:gpl2+)))
582
583 (define-public astyle
584 (package
585 (name "astyle")
586 (version "3.1")
587 (source
588 (origin
589 (method url-fetch)
590 (uri (string-append "mirror://sourceforge/astyle/astyle/astyle%20"
591 version "/astyle_" version "_linux.tar.gz"))
592 (sha256
593 (base32
594 "1ms54wcs7hg1bsywqwf2lhdfizgbk7qxc9ghasxk8i99jvwlrk6b"))))
595 (build-system gnu-build-system)
596 (arguments
597 `(#:tests? #f ;no tests
598 #:make-flags (list (string-append "prefix=" %output)
599 "INSTALL=install"
600 "all")
601 #:modules ((guix build gnu-build-system) ;; FIXME use %default-modules
602 (guix build utils)
603 (ice-9 regex))
604 #:phases
605 (modify-phases %standard-phases
606 (replace 'configure
607 (lambda _ (chdir "build/gcc") #t))
608 (add-after 'install 'install-libs
609 (lambda* (#:key outputs #:allow-other-keys)
610 ;; Libraries and includes are not installed by default
611 (let* ((output (assoc-ref outputs "out"))
612 (incdir (string-append output "/include"))
613 (libdir (string-append output "/lib")))
614 (define (make-so-link sofile strip-pattern)
615 (symlink
616 (basename sofile)
617 (regexp-substitute #f
618 (string-match strip-pattern sofile)
619 'pre)))
620 (mkdir-p incdir)
621 (copy-file "../../src/astyle.h"
622 (string-append incdir "/astyle.h"))
623 (mkdir-p libdir)
624 (for-each (lambda (l)
625 (copy-file
626 l (string-append libdir "/" (basename l))))
627 (find-files "bin" "lib*"))
628 (for-each
629 (lambda (sofile)
630 (make-so-link sofile "(\\.[0-9]){3}$") ;; link .so
631 (make-so-link sofile "(\\.[0-9]){2}$")) ;; link .so.3
632 (find-files libdir "lib.*\\.so\\..*")))
633 #t)))))
634 (home-page "http://astyle.sourceforge.net/")
635 (synopsis "Source code indenter, formatter, and beautifier")
636 (description
637 "Artistic Style is a source code indenter, formatter, and beautifier for
638 the C, C++, C++/CLI, Objective‑C, C#, and Java programming languages.")
639 (license license:lgpl3+)))
640
641 (define-public indent
642 (package
643 (name "indent")
644 (version "2.2.12")
645 (source (origin
646 (method url-fetch)
647 (uri (string-append "mirror://gnu/indent/indent-" version
648 ".tar.gz"))
649 (sha256
650 (base32 "12xvcd16cwilzglv9h7sgh4h1qqjd1h8s48ji2dla58m4706hzg7"))))
651 (build-system gnu-build-system)
652 (arguments
653 `(#:phases
654 (modify-phases %standard-phases
655 (add-after 'unpack 'fix-docdir
656 (lambda _
657 ;; Although indent uses a modern autoconf in which docdir
658 ;; defaults to PREFIX/share/doc, the doc/Makefile.am
659 ;; overrides this to be in PREFIX/doc. Fix this.
660 (substitute* "doc/Makefile.in"
661 (("^docdir = .*$") "docdir = @docdir@\n"))
662 #t)))))
663 (native-inputs
664 `(("texinfo" ,texinfo)))
665 (synopsis "Code reformatter")
666 (description
667 "Indent is a program that makes source code easier to read by
668 reformatting it in a consistent style. It can change the style to one of
669 several different styles such as GNU, BSD or K&R. It has some flexibility to
670 deal with incomplete or malformed syntax. GNU indent offers several
671 extensions over the standard utility.")
672 (license license:gpl3+)
673 (home-page "https://www.gnu.org/software/indent/")))
674
675 (define-public amalgamate
676 (let* ((commit "c91f07eea1133aa184f652b8f1398eaf03586208")
677 (revision "0")
678 (version (git-version "1.1.1" revision commit)))
679 (package
680 (name "amalgamate")
681 (version version)
682 (home-page "https://github.com/edlund/amalgamate")
683 (source
684 (origin
685 (method git-fetch)
686 (uri (git-reference
687 (url home-page)
688 (commit commit)))
689 (sha256
690 (base32
691 "0cllaraw8mxs8q2nr28nhgzkb417gj2wcklqg59w84f4lc78k3yb"))
692 (file-name (git-file-name name version))
693 (modules '((guix build utils)))
694 (snippet
695 '(substitute* "test.sh"
696 (("test_command \"cc -Wall -Wextra -o source.out source.c\"" all)
697 "test_command \"gcc -Wall -Wextra -o source.out source.c\"")))))
698 (build-system gnu-build-system)
699 (inputs
700 `(("python" ,python-wrapper)))
701 (arguments
702 `(#:phases
703 (modify-phases %standard-phases
704 (delete 'configure)
705 (delete 'build)
706 (replace 'install
707 (lambda* (#:key outputs #:allow-other-keys)
708 (let* ((out (assoc-ref outputs "out"))
709 (bin (string-append out "/bin")))
710 (install-file "amalgamate.py" bin))))
711 (replace 'check
712 (lambda _
713 (invoke "./test.sh"))))))
714 (synopsis "Tool for amalgamating C source and header files")
715 ;; The package is indeed a script file, and the term "amalgamate.py" is
716 ;; used by upstream.
717 (description "amalgamate.py aims to make it easy to use SQLite-style C
718 source and header amalgamation in projects.")
719 (license license:bsd-3))))