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>
16 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
60 ;;; Tools to deal with source code: metrics, cross-references, etc.
68 (uri (string-append "mirror://gnu/cflow/cflow-"
72 "1mzd3yf0dfv8h2av5vsxxlhpk21nw064h91b2kgfrdz92r0pnj1l"))))
73 (build-system gnu-build-system)
75 ;; Needed to have cflow-mode.el installed.
76 (native-inputs `(("emacs" ,emacs-minimal)))
78 '(#:configure-flags (list (string-append "CPPFLAGS="
79 "-D" "CFLOW_PREPROC=\\\""
80 (assoc-ref %build-inputs "gcc")
82 (home-page "https://www.gnu.org/software/cflow/")
83 (synopsis "Create a graph of control flow within a program")
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+)))
91 (define-public complexity
97 (uri (string-append "mirror://gnu/complexity/complexity-"
101 "0lr0l9kj2w3jilz9h9y4np9pf9i9ccpy6331lanki2fnz4z8ldvd"))))
102 (build-system gnu-build-system)
104 `(("texinfo" ,texinfo)
105 ("autogen" ,autogen)))
106 (home-page "https://www.gnu.org/software/complexity/")
107 (synopsis "Analyze complexity of C functions")
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+)))
115 (define-public global ; a global variable
121 (uri (string-append "mirror://gnu/global/global-"
125 "1515642wsjz7x3rsgaqk4sc7n0z2znl7idsk8jz8wgy5aswqqzlq"))))
126 (build-system gnu-build-system)
127 (inputs `(("ncurses" ,ncurses)
132 (list (string-append "--with-ncurses="
133 (assoc-ref %build-inputs "ncurses"))
134 (string-append "--with-sqlite3="
135 (assoc-ref %build-inputs "sqlite")))
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"))
148 (home-page "https://www.gnu.org/software/global/")
149 (synopsis "Cross-environment source code tag system")
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+)))
157 (define-public sloccount
163 (uri (string-append "http://www.dwheeler.com/sloccount/sloccount-"
167 "0ayiwfjdh1946asah861ah9269s5xkc8p5fv1wnxs9znyaxs4zzs"))))
168 (build-system gnu-build-system)
170 '(#:phases (modify-phases %standard-phases
172 (add-before 'build 'make-dotl-files-older
174 ;; Make the '.l' files as old as the '.c'
175 ;; files to avoid triggering the rule that
180 (for-each (lambda (file)
181 (set-file-time file ref))
182 (find-files "." "\\.[chl]$"))
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
190 (mkdir-p (string-append out
195 (setenv "HOME" (getcwd))
197 (string-append (getcwd) ":"
199 (invoke "make" "test"))))
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)")
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+)))
222 (url "https://github.com/AlDanial/cloc.git")
224 (file-name (git-file-name name version))
226 (base32 "14xikdwcr6pcnkk2i43zrsj88z8b3mrv0svbnbvxvarw1id83pnn"))))
227 (build-system gnu-build-system)
229 `(("coreutils" ,coreutils)
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)))
236 `(#:phases (modify-phases %standard-phases
237 (delete 'configure) ; nothing to configure
238 (delete 'build) ; nothing to build
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")
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")
254 ,(string-split (getenv "PERL5LIB") #\:)))
257 ;; Tests require some other packages.
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.
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+)))
269 (define-public the-silver-searcher
271 (name "the-silver-searcher")
276 "https://geoff.greer.fm/ag/releases/the_silver_searcher-"
280 "0w1icjqd8hd45rn1y6nbfznk1a6ip54whwbfbhxp7ws2hn3ilqnr"))))
281 (build-system gnu-build-system)
283 `(("pkg-config" ,pkg-config)))
288 (home-page "https://geoff.greer.fm/ag/")
289 (synopsis "Fast code searching tool")
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)))
304 (uri (string-append "mirror://sourceforge/ctrio/trio/trio-"
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")
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"))))
321 (define-public withershins
329 (url "https://github.com/cameronwhite/withershins.git")
330 (commit (string-append "v" version))))
331 (file-name (git-file-name name version))
333 (base32 "1cviqvbbcwljm1zx12j6511hazr3kscwrvcyifrkfi4fpy5z985m"))))
334 (build-system cmake-build-system)
336 `(#:out-of-source? #f
338 ;; XXX A (justified!) misleading-indentation error breaks the build.
339 (list "-DENABLE_WERROR=OFF")
341 (modify-phases %standard-phases
343 'unpack 'find-libiberty
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" "\"")))
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")))
359 (install-file "src/withershins.hpp" include)
361 (install-file "src/libwithershins.a" lib))
363 (home-page "https://github.com/cameronwhite/withershins")
365 `(("libiberty" ,libiberty)
366 ("binutils" ,binutils) ;for libbfd
368 (synopsis "C++11 library for generating stack traces")
370 "Withershins is a simple cross-platform C++11 library for generating
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+)))
382 (uri (string-append "mirror://sourceforge/ltp/Coverage%20Analysis"
383 "/LCOV-" version "/lcov-" version ".tar.gz"))
386 "06h7ixyznf6vz1qvksjgy5f3q2nw9akf6zx59npf0h3l32cmd68l"))))
387 (build-system gnu-build-system)
390 (let ((out (assoc-ref %outputs "out")))
391 (list (string-append "PREFIX=" out)))
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")
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+)))
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)))
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")))
428 (("#include ?\"rct/(.*.h)\"" all header)
429 (string-append "#include <rct/" header ">")))
433 "0raqjbkl1ykga4ahgl9xw49cgh3cyqcf42z36z7d6fz1fw192kg0"))))
434 (build-system cmake-build-system)
436 '(#:build-type "RelWithDebInfo"
438 '("-DRTAGS_NO_ELISP_FILES=1"
439 "-DBUILD_TESTING=FALSE")
442 `(("pkg-config" ,pkg-config)))
444 `(("bash-completion" ,bash-completion)
450 (home-page "https://github.com/Andersbakken/rtags")
451 (synopsis "Indexer for the C language family with Emacs integration")
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+)))
460 (define-public colormake
463 (version "0.9.20140503")
468 (url "https://github.com/pagekite/Colormake.git")
470 (file-name (git-file-name name version))
472 (base32 "1f9v5s0viq4yc9iv6701h3pv7j21zz1ckl37lpp9hsnliiizv03p"))))
473 (build-system trivial-build-system)
478 `(#:modules ((guix build utils))
481 (use-modules (guix build utils))
482 (copy-recursively (assoc-ref %build-inputs "source") "source")
484 (patch-shebang "colormake.pl"
485 (list (string-append (assoc-ref %build-inputs "perl")
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))
494 (substitute* "colormake"
495 (("colormake\\.pl") (string-append bin "/colormake.pl"))
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")
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+)))
510 (define-public makefile2graph
512 (name "makefile2graph")
518 (url "https://github.com/lindenb/makefile2graph.git")
519 (commit (string-append "v" version))))
520 (file-name (git-file-name name version))
522 (base32 "1gjfk3d8qg3cla7qd2y7r9s03whlfwy83q8k76xfcnqrjjfavdgk"))))
523 (build-system gnu-build-system)
525 '(#:test-target "test"
526 #:make-flags (list "CC=gcc" (string-append "prefix=" %output))
528 (modify-phases %standard-phases
529 (delete 'configure))))
531 `(("graphviz" ,graphviz)))
532 (home-page "https://github.com/lindenb/makefile2graph")
533 (synopsis "Creates a graph of dependencies from GNU Make")
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)))
540 (define-public uncrustify
547 (url "https://github.com/uncrustify/uncrustify/")
548 (commit (string-append name "-" version))))
549 (file-name (git-file-name name version))
552 "0sqrg13kp8fwymq40976bq380bzw40g4ss7ihlbq45d0f90ifa1k"))))
553 (build-system cmake-build-system)
556 ("python" ,python-wrapper)))
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$")))
569 (home-page "http://uncrustify.sourceforge.net/")
570 (synopsis "Code formatter for C and other related languages")
572 "Beautify source code in many languages of the C family (C, C++, C#,
573 Objective@tie{}C, D, Java, Pawn, and Vala). Features:
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.
582 (license license:gpl2+)))
584 (define-public astyle
591 (uri (string-append "mirror://sourceforge/astyle/astyle/astyle%20"
592 version "/astyle_" version "_linux.tar.gz"))
595 "1ms54wcs7hg1bsywqwf2lhdfizgbk7qxc9ghasxk8i99jvwlrk6b"))))
596 (build-system gnu-build-system)
598 `(#:tests? #f ;no tests
599 #:make-flags (list (string-append "prefix=" %output)
602 #:modules ((guix build gnu-build-system) ;; FIXME use %default-modules
606 (modify-phases %standard-phases
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)
618 (regexp-substitute #f
619 (string-match strip-pattern sofile)
622 (copy-file "../../src/astyle.h"
623 (string-append incdir "/astyle.h"))
625 (for-each (lambda (l)
627 l (string-append libdir "/" (basename l))))
628 (find-files "bin" "lib*"))
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\\..*")))
635 (home-page "http://astyle.sourceforge.net/")
636 (synopsis "Source code indenter, formatter, and beautifier")
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+)))
642 (define-public indent
648 (uri (string-append "mirror://gnu/indent/indent-" version
651 (base32 "12xvcd16cwilzglv9h7sgh4h1qqjd1h8s48ji2dla58m4706hzg7"))))
652 (build-system gnu-build-system)
655 (modify-phases %standard-phases
656 (add-after 'unpack 'fix-docdir
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"))
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)
670 (string-append (assoc-ref
671 (or native-inputs inputs) "automake")
673 ,(version-major+minor
674 (package-version automake))
676 '("config.sub" "config.guess")))
679 `(("texinfo" ,texinfo)
680 ("automake" ,automake))) ; For up to date 'config.guess' and 'config.sub'.
681 (synopsis "Code reformatter")
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/")))
691 (define-public amalgamate
692 (let* ((commit "c91f07eea1133aa184f652b8f1398eaf03586208")
694 (version (git-version "1.1.1" revision commit)))
698 (home-page "https://github.com/edlund/amalgamate")
707 "0cllaraw8mxs8q2nr28nhgzkb417gj2wcklqg59w84f4lc78k3yb"))
708 (file-name (git-file-name name version))
709 (modules '((guix build utils)))
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)
716 `(("python" ,python-wrapper)))
719 (modify-phases %standard-phases
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))))
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
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))))