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>
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 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))
59 ;;; Tools to deal with source code: metrics, cross-references, etc.
67 (uri (string-append "mirror://gnu/cflow/cflow-"
71 "1mzd3yf0dfv8h2av5vsxxlhpk21nw064h91b2kgfrdz92r0pnj1l"))))
72 (build-system gnu-build-system)
74 ;; Needed to have cflow-mode.el installed.
75 (native-inputs `(("emacs" ,emacs-minimal)))
77 '(#:configure-flags (list (string-append "CPPFLAGS="
78 "-D" "CFLOW_PREPROC=\\\""
79 (assoc-ref %build-inputs "gcc")
81 (home-page "https://www.gnu.org/software/cflow/")
82 (synopsis "Create a graph of control flow within a program")
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+)))
90 (define-public complexity
96 (uri (string-append "mirror://gnu/complexity/complexity-"
100 "0lr0l9kj2w3jilz9h9y4np9pf9i9ccpy6331lanki2fnz4z8ldvd"))))
101 (build-system gnu-build-system)
103 `(("texinfo" ,texinfo)
104 ("autogen" ,autogen)))
105 (home-page "https://www.gnu.org/software/complexity/")
106 (synopsis "Analyze complexity of C functions")
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+)))
114 (define-public global ; a global variable
120 (uri (string-append "mirror://gnu/global/global-"
124 "0735pj47dnspf20n0j1px24p59nwjinlmlb2n32ln1hvdkprivnb"))))
125 (build-system gnu-build-system)
126 (inputs `(("ncurses" ,ncurses)
131 (list (string-append "--with-ncurses="
132 (assoc-ref %build-inputs "ncurses"))
133 (string-append "--with-sqlite3="
134 (assoc-ref %build-inputs "sqlite")))
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"))
147 (home-page "https://www.gnu.org/software/global/")
148 (synopsis "Cross-environment source code tag system")
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+)))
156 (define-public sloccount
162 (uri (string-append "http://www.dwheeler.com/sloccount/sloccount-"
166 "0ayiwfjdh1946asah861ah9269s5xkc8p5fv1wnxs9znyaxs4zzs"))))
167 (build-system gnu-build-system)
169 '(#:phases (modify-phases %standard-phases
171 (add-before 'build 'make-dotl-files-older
173 ;; Make the '.l' files as old as the '.c'
174 ;; files to avoid triggering the rule that
179 (for-each (lambda (file)
180 (set-file-time file ref))
181 (find-files "." "\\.[chl]$"))
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
189 (mkdir-p (string-append out
194 (setenv "HOME" (getcwd))
196 (string-append (getcwd) ":"
198 (invoke "make" "test"))))
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)")
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+)))
221 (url "https://github.com/AlDanial/cloc.git")
223 (file-name (git-file-name name version))
225 (base32 "0fsz07z0slfg58512fmnlj8pnxkc360bgf7fclg60v9clvcjbjsw"))))
226 (build-system gnu-build-system)
228 `(("coreutils" ,coreutils)
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)))
235 `(#:phases (modify-phases %standard-phases
236 (delete 'configure) ; nothing to configure
237 (delete 'build) ; nothing to build
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")
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")
253 ,(string-split (getenv "PERL5LIB") #\:)))
256 ;; Tests require some other packages.
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.
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+)))
268 (define-public the-silver-searcher
270 (name "the-silver-searcher")
275 "https://geoff.greer.fm/ag/releases/the_silver_searcher-"
279 "0w1icjqd8hd45rn1y6nbfznk1a6ip54whwbfbhxp7ws2hn3ilqnr"))))
280 (build-system gnu-build-system)
282 `(("pkg-config" ,pkg-config)))
287 (home-page "https://geoff.greer.fm/ag/")
288 (synopsis "Fast code searching tool")
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)))
303 (uri (string-append "mirror://sourceforge/ctrio/trio/trio-"
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")
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"))))
320 (define-public withershins
328 (url "https://github.com/cameronwhite/withershins.git")
329 (commit (string-append "v" version))))
330 (file-name (git-file-name name version))
332 (base32 "1cviqvbbcwljm1zx12j6511hazr3kscwrvcyifrkfi4fpy5z985m"))))
333 (build-system cmake-build-system)
335 `(#:out-of-source? #f
337 ;; XXX A (justified!) misleading-indentation error breaks the build.
338 (list "-DENABLE_WERROR=OFF")
340 (modify-phases %standard-phases
342 'unpack 'find-libiberty
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" "\"")))
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")))
358 (install-file "src/withershins.hpp" include)
360 (install-file "src/libwithershins.a" lib))
362 (home-page "https://github.com/cameronwhite/withershins")
364 `(("libiberty" ,libiberty)
365 ("binutils" ,binutils) ;for libbfd
367 (synopsis "C++11 library for generating stack traces")
369 "Withershins is a simple cross-platform C++11 library for generating
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+)))
381 (uri (string-append "mirror://sourceforge/ltp/Coverage%20Analysis"
382 "/LCOV-" version "/lcov-" version ".tar.gz"))
385 "06h7ixyznf6vz1qvksjgy5f3q2nw9akf6zx59npf0h3l32cmd68l"))))
386 (build-system gnu-build-system)
389 (let ((out (assoc-ref %outputs "out")))
390 (list (string-append "PREFIX=" out)))
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")
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+)))
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)))
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")))
427 (("#include ?\"rct/(.*.h)\"" all header)
428 (string-append "#include <rct/" header ">")))
432 "0raqjbkl1ykga4ahgl9xw49cgh3cyqcf42z36z7d6fz1fw192kg0"))))
433 (build-system cmake-build-system)
435 '(#:build-type "RelWithDebInfo"
437 '("-DRTAGS_NO_ELISP_FILES=1"
438 "-DBUILD_TESTING=FALSE")
441 `(("pkg-config" ,pkg-config)))
443 `(("bash-completion" ,bash-completion)
449 (home-page "https://github.com/Andersbakken/rtags")
450 (synopsis "Indexer for the C language family with Emacs integration")
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+)))
459 (define-public colormake
462 (version "0.9.20140503")
467 (url "https://github.com/pagekite/Colormake.git")
469 (file-name (git-file-name name version))
471 (base32 "1f9v5s0viq4yc9iv6701h3pv7j21zz1ckl37lpp9hsnliiizv03p"))))
472 (build-system trivial-build-system)
477 `(#:modules ((guix build utils))
480 (use-modules (guix build utils))
481 (copy-recursively (assoc-ref %build-inputs "source") "source")
483 (patch-shebang "colormake.pl"
484 (list (string-append (assoc-ref %build-inputs "perl")
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))
493 (substitute* "colormake"
494 (("colormake\\.pl") (string-append bin "/colormake.pl"))
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")
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+)))
509 (define-public makefile2graph
511 (name "makefile2graph")
517 (url "https://github.com/lindenb/makefile2graph.git")
518 (commit (string-append "v" version))))
519 (file-name (git-file-name name version))
521 (base32 "1gjfk3d8qg3cla7qd2y7r9s03whlfwy83q8k76xfcnqrjjfavdgk"))))
522 (build-system gnu-build-system)
524 '(#:test-target "test"
525 #:make-flags (list "CC=gcc" (string-append "prefix=" %output))
527 (modify-phases %standard-phases
528 (delete 'configure))))
530 `(("graphviz" ,graphviz)))
531 (home-page "https://github.com/lindenb/makefile2graph")
532 (synopsis "Creates a graph of dependencies from GNU Make")
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)))
539 (define-public uncrustify
546 (url "https://github.com/uncrustify/uncrustify/")
547 (commit (string-append name "-" version))))
548 (file-name (git-file-name name version))
551 "0sqrg13kp8fwymq40976bq380bzw40g4ss7ihlbq45d0f90ifa1k"))))
552 (build-system cmake-build-system)
555 ("python" ,python-wrapper)))
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$")))
568 (home-page "http://uncrustify.sourceforge.net/")
569 (synopsis "Code formatter for C and other related languages")
571 "Beautify source code in many languages of the C family (C, C++, C#,
572 Objective@tie{}C, D, Java, Pawn, and Vala). Features:
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.
581 (license license:gpl2+)))
583 (define-public astyle
590 (uri (string-append "mirror://sourceforge/astyle/astyle/astyle%20"
591 version "/astyle_" version "_linux.tar.gz"))
594 "1ms54wcs7hg1bsywqwf2lhdfizgbk7qxc9ghasxk8i99jvwlrk6b"))))
595 (build-system gnu-build-system)
597 `(#:tests? #f ;no tests
598 #:make-flags (list (string-append "prefix=" %output)
601 #:modules ((guix build gnu-build-system) ;; FIXME use %default-modules
605 (modify-phases %standard-phases
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)
617 (regexp-substitute #f
618 (string-match strip-pattern sofile)
621 (copy-file "../../src/astyle.h"
622 (string-append incdir "/astyle.h"))
624 (for-each (lambda (l)
626 l (string-append libdir "/" (basename l))))
627 (find-files "bin" "lib*"))
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\\..*")))
634 (home-page "http://astyle.sourceforge.net/")
635 (synopsis "Source code indenter, formatter, and beautifier")
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+)))
641 (define-public indent
647 (uri (string-append "mirror://gnu/indent/indent-" version
650 (base32 "12xvcd16cwilzglv9h7sgh4h1qqjd1h8s48ji2dla58m4706hzg7"))))
651 (build-system gnu-build-system)
654 (modify-phases %standard-phases
655 (add-after 'unpack 'fix-docdir
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"))
664 `(("texinfo" ,texinfo)))
665 (synopsis "Code reformatter")
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/")))
675 (define-public amalgamate
676 (let* ((commit "c91f07eea1133aa184f652b8f1398eaf03586208")
678 (version (git-version "1.1.1" revision commit)))
682 (home-page "https://github.com/edlund/amalgamate")
691 "0cllaraw8mxs8q2nr28nhgzkb417gj2wcklqg59w84f4lc78k3yb"))
692 (file-name (git-file-name name version))
693 (modules '((guix build utils)))
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)
700 `(("python" ,python-wrapper)))
703 (modify-phases %standard-phases
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))))
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
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))))