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