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>
15 ;;; This file is part of GNU Guix.
17 ;;; GNU Guix is free software; you can redistribute it and/or modify it
18 ;;; under the terms of the GNU General Public License as published by
19 ;;; the Free Software Foundation; either version 3 of the License, or (at
20 ;;; your option) any later version.
22 ;;; GNU Guix is distributed in the hope that it will be useful, but
23 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;;; GNU General Public License for more details.
27 ;;; You should have received a copy of the GNU General Public License
28 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
30 (define-module (gnu packages code)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix git-download)
34 #:use-module ((guix licenses) #:prefix license:)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system cmake)
37 #:use-module (guix build-system trivial)
38 #:use-module (gnu packages)
39 #:use-module (gnu packages autogen)
40 #:use-module (gnu packages autotools)
41 #:use-module (gnu packages base)
42 #:use-module (gnu packages bash)
43 #:use-module (gnu packages compression)
44 #:use-module (gnu packages cpp)
45 #:use-module (gnu packages emacs)
46 #:use-module (gnu packages gcc)
47 #:use-module (gnu packages graphviz)
48 #:use-module (gnu packages pcre)
49 #:use-module (gnu packages perl)
50 #:use-module (gnu packages pkg-config)
51 #:use-module (gnu packages python)
52 #:use-module (gnu packages sqlite)
53 #:use-module (gnu packages texinfo)
54 #:use-module (gnu packages ncurses)
55 #:use-module (gnu packages llvm)
56 #:use-module (gnu packages lua))
58 ;;; Tools to deal with source code: metrics, cross-references, etc.
66 (uri (string-append "mirror://gnu/cflow/cflow-"
70 "1mzd3yf0dfv8h2av5vsxxlhpk21nw064h91b2kgfrdz92r0pnj1l"))))
71 (build-system gnu-build-system)
73 ;; Needed to have cflow-mode.el installed.
74 (native-inputs `(("emacs" ,emacs-minimal)))
76 '(#:configure-flags (list (string-append "CPPFLAGS="
77 "-D" "CFLOW_PREPROC=\\\""
78 (assoc-ref %build-inputs "gcc")
80 (home-page "https://www.gnu.org/software/cflow/")
81 (synopsis "Create a graph of control flow within a program")
83 "GNU cflow analyzes C source files and produces a graph charting the
84 control flow of the program. It can output the graph in several styles and
85 in either the POSIX format or in an extended GNU format. cflow also includes
86 a major mode for Emacs for examining the flowcharts that it produces.")
87 (license license:gpl3+)))
89 (define-public complexity
95 (uri (string-append "mirror://gnu/complexity/complexity-"
99 "0lr0l9kj2w3jilz9h9y4np9pf9i9ccpy6331lanki2fnz4z8ldvd"))))
100 (build-system gnu-build-system)
102 `(("texinfo" ,texinfo)
103 ("autogen" ,autogen)))
104 (home-page "https://www.gnu.org/software/complexity/")
105 (synopsis "Analyze complexity of C functions")
107 "GNU complexity provides tools for finding procedures that are
108 convoluted, overly long or otherwise difficult to understand. This
109 may help in learning or reviewing unfamiliar code or perhaps
110 highlighting your own code that seemed comprehensible when you wrote it.")
111 (license license:gpl3+)))
113 (define-public global ; a global variable
119 (uri (string-append "mirror://gnu/global/global-"
123 "0735pj47dnspf20n0j1px24p59nwjinlmlb2n32ln1hvdkprivnb"))))
124 (build-system gnu-build-system)
125 (inputs `(("ncurses" ,ncurses)
130 (list (string-append "--with-ncurses="
131 (assoc-ref %build-inputs "ncurses"))
132 (string-append "--with-sqlite3="
133 (assoc-ref %build-inputs "sqlite")))
136 (modify-phases %standard-phases
137 (add-after 'install 'post-install
138 (lambda* (#:key outputs #:allow-other-keys)
139 ;; Install the Emacs Lisp file in the right place.
140 (let* ((out (assoc-ref outputs "out"))
141 (data (string-append out "/share/gtags"))
142 (lisp (string-append out "/share/emacs/site-lisp")))
143 (install-file (string-append data "/gtags.el") lisp)
144 (delete-file (string-append data "/gtags.el"))
146 (home-page "https://www.gnu.org/software/global/")
147 (synopsis "Cross-environment source code tag system")
149 "GNU GLOBAL is a source code tagging system that functions in the same
150 way across a wide array of environments, such as different text editors,
151 shells and web browsers. The resulting tags are useful for quickly moving
152 around in a large, deeply nested project.")
153 (license license:gpl3+)))
155 (define-public sloccount
161 (uri (string-append "http://www.dwheeler.com/sloccount/sloccount-"
165 "0ayiwfjdh1946asah861ah9269s5xkc8p5fv1wnxs9znyaxs4zzs"))))
166 (build-system gnu-build-system)
168 '(#:phases (modify-phases %standard-phases
170 (add-before 'build 'make-dotl-files-older
172 ;; Make the '.l' files as old as the '.c'
173 ;; files to avoid triggering the rule that
178 (for-each (lambda (file)
179 (set-file-time file ref))
180 (find-files "." "\\.[chl]$"))
182 (add-before 'install 'make-target-directories
183 (lambda* (#:key outputs #:allow-other-keys)
184 (let ((out (assoc-ref outputs "out")))
185 (mkdir-p (string-append out "/bin"))
186 (mkdir-p (string-append out
188 (mkdir-p (string-append out
193 (setenv "HOME" (getcwd))
195 (string-append (getcwd) ":"
197 (invoke "make" "test"))))
199 #:make-flags (list (string-append "PREFIX="
200 (assoc-ref %outputs "out")))))
201 (inputs `(("perl" ,perl)))
202 (home-page "http://www.dwheeler.com/sloccount/")
203 (synopsis "Count physical source lines of code (SLOC)")
205 "SLOCCount is a set of the programs for counting source lines of
206 code (SLOC) in large software systems. It can automatically identify and
207 measure a wide range of programming languages. It automatically estimates the
208 effort, time, and money it would take to develop the software, using the
209 COCOMO model or user-provided parameters.")
210 (license license:gpl2+)))
220 "https://github.com/AlDanial/cloc/releases/download/v" version
221 "/cloc-" version ".tar.gz"))
224 "0rqxnaskg5b736asyzfda1113zvpkajyqjf49vl9wgzf1r9m6bq8"))))
225 (build-system gnu-build-system)
227 `(("coreutils" ,coreutils)
229 ("perl-algorithm-diff" ,perl-algorithm-diff)
230 ("perl-digest-md5" ,perl-digest-md5)
231 ("perl-parallel-forkmanager" ,perl-parallel-forkmanager)
232 ("perl-regexp-common" ,perl-regexp-common)))
234 `(#:phases (modify-phases %standard-phases
235 (delete 'configure) ; nothing to configure
236 (delete 'build) ; nothing to build
238 (lambda* (#:key inputs outputs #:allow-other-keys)
239 (let* ((out (assoc-ref outputs "out")))
240 (invoke "make" "-C" "Unix"
241 (string-append "prefix=" out)
242 (string-append "INSTALL="
243 (assoc-ref inputs "coreutils")
247 (add-after 'install 'wrap-program
248 (lambda* (#:key inputs outputs #:allow-other-keys)
249 (let ((out (assoc-ref outputs "out")))
250 (wrap-program (string-append out "/bin/cloc")
252 ,(string-split (getenv "PERL5LIB") #\:)))
255 ;; Tests require some other packages.
257 (home-page "https://github.com/AlDanial/cloc")
258 (synopsis "Count source lines of code (SLOC) and other source code metrics")
259 (description "cloc counts blank lines, comment lines, and physical lines
260 of source code in many programming languages. Given two versions of a code
261 base, cloc can compute differences in blank, comment, and source lines.
263 cloc contains code from David Wheeler's SLOCCount. Compared to SLOCCount,
264 cloc can handle a greater variety of programming languages.")
265 (license license:gpl2+)))
267 (define-public the-silver-searcher
269 (name "the-silver-searcher")
274 "https://geoff.greer.fm/ag/releases/the_silver_searcher-"
278 "0w1icjqd8hd45rn1y6nbfznk1a6ip54whwbfbhxp7ws2hn3ilqnr"))))
279 (build-system gnu-build-system)
281 `(("pkg-config" ,pkg-config)))
286 (home-page "https://geoff.greer.fm/ag/")
287 (synopsis "Fast code searching tool")
289 "The Silver Searcher (@command{ag}) is a tool for quickly searching large
290 numbers of files. It's intended primarily for source code repositories, and
291 respects files like @file{.gitignore} and @file{.hgignore}. It's also an order
292 of magnitude faster than its inspiration, @command{ack}, and less specialised
293 tools such as @command{grep}.")
294 (license license:asl2.0)))
302 (uri (string-append "mirror://sourceforge/ctrio/trio/trio-"
306 "02pwd5m5vq7hbrffgm2na1dfc249z50yyr5jv73vdw15bd7ygl44"))))
307 (build-system gnu-build-system)
308 (home-page "http://daniel.haxx.se/projects/trio/")
309 (synopsis "Portable and extendable printf and string functions")
311 "Trio is a set of @code{printf} and string functions designed be used by
312 applications with a focus on portability or with the need for additional
313 features that are not supported by the standard @code{stdio} implementation.")
314 ;; This license is very similar to the ISC license, but the wording is
315 ;; slightly different.
316 (license (license:non-copyleft
317 "http://sourceforge.net/p/ctrio/git/ci/master/tree/README"))))
319 (define-public withershins
326 "https://github.com/cameronwhite/withershins/archive/v"
328 (file-name (string-append name "-" version ".tar.gz"))
331 "08z3lyvswx7sad10637vfpwglbcbgzzcpfihw0x8lzr74f3b70bh"))))
332 (build-system cmake-build-system)
334 `(#:out-of-source? #f
336 (modify-phases %standard-phases
338 'unpack 'find-libiberty
340 (let ((libiberty (assoc-ref %build-inputs "libiberty")))
341 (substitute* "cmake/FindIberty.cmake"
342 (("/usr/include") (string-append libiberty "/include"))
343 (("libiberty.a iberty")
344 (string-append "NAMES libiberty.a iberty\nPATHS \""
345 libiberty "/lib" "\"")))
349 (lambda* (#:key outputs #:allow-other-keys)
350 (let* ((out (assoc-ref outputs "out"))
351 (include (string-append out "/include"))
352 (lib (string-append out "/lib")))
354 (install-file "src/withershins.hpp" include)
356 (install-file "src/libwithershins.a" lib))
358 (home-page "https://github.com/cameronwhite/withershins")
360 `(("libiberty" ,libiberty)
361 ("binutils" ,binutils) ;for libbfd
363 (synopsis "C++11 library for generating stack traces")
365 "Withershins is a simple cross-platform C++11 library for generating
367 ;; Sources are released under Expat license, but since BFD is licensed
368 ;; under the GPLv3+ the combined work is GPLv3+ as well.
369 (license license:gpl3+)))
377 (uri (string-append "mirror://sourceforge/ltp/Coverage%20Analysis"
378 "/LCOV-" version "/lcov-" version ".tar.gz"))
381 "06h7ixyznf6vz1qvksjgy5f3q2nw9akf6zx59npf0h3l32cmd68l"))))
382 (build-system gnu-build-system)
385 (let ((out (assoc-ref %outputs "out")))
386 (list (string-append "PREFIX=" out)))
388 (modify-phases %standard-phases
389 (delete 'configure)) ; no configure script
390 #:tests? #f)) ; no 'check' target
391 (inputs `(("perl" ,perl)))
392 (home-page "http://ltp.sourceforge.net/coverage/lcov.php")
393 (synopsis "Code coverage tool that enhances GNU gcov")
395 "LCOV is an extension of @command{gcov}, a tool part of the
396 GNU@tie{}Binutils, which provides information about what parts of a program
397 are actually executed (i.e., \"covered\") while running a particular test
398 case. The extension consists of a set of Perl scripts which build on the
399 textual @command{gcov} output to implement the following enhanced
400 functionality such as HTML output.")
401 (license license:gpl2+)))
411 (url "https://github.com/Andersbakken/rtags.git")
412 (commit (string-append "v" version))))
413 (file-name (git-file-name name version))
414 (patches (search-patches "rtags-separate-rct.patch"))
415 (modules '((guix build utils)))
417 ;; Part of spliting rct with rtags.
418 ;; Substitute #include "rct/header.h" with #include <rct/header.h>.
419 '(with-directory-excursion "src"
420 (delete-file-recursively "rct") ;remove bundled copy
421 (let ((files (find-files "." ".*\\.cpp|.*\\.h")))
423 (("#include ?\"rct/(.*.h)\"" all header)
424 (string-append "#include <rct/" header ">")))
428 "0raqjbkl1ykga4ahgl9xw49cgh3cyqcf42z36z7d6fz1fw192kg0"))))
429 (build-system cmake-build-system)
431 '(#:build-type "RelWithDebInfo"
433 '("-DRTAGS_NO_ELISP_FILES=1"
434 "-DCMAKE_CXX_FLAGS=-std=c++11"
435 "-DBUILD_TESTING=FALSE")
438 `(("pkg-config" ,pkg-config)))
440 `(("bash-completion" ,bash-completion)
446 (home-page "https://github.com/Andersbakken/rtags")
447 (synopsis "Indexer for the C language family with Emacs integration")
449 "RTags is a client/server application that indexes C/C++ code and keeps a
450 persistent file-based database of references, declarations, definitions,
451 symbolnames etc. There’s also limited support for ObjC/ObjC++. It allows you
452 to find symbols by name (including nested class and namespace scope). Most
453 importantly we give you proper follow-symbol and find-references support.")
454 (license license:gpl3+)))
456 (define-public colormake
459 (version "0.9.20140503")
463 (uri (string-append "https://github.com/pagekite/Colormake/archive/"
465 (file-name (string-append name "-" version ".tar.gz"))
468 "08ldss9zd8ls6bjahvxhffpsjcysifr720yf3jz9db2mlklzmyd3"))))
469 (build-system trivial-build-system)
476 `(#:modules ((guix build utils))
479 (use-modules (guix build utils))
481 (setenv "PATH" (string-append
482 (assoc-ref %build-inputs "tar") "/bin" ":"
483 (assoc-ref %build-inputs "gzip") "/bin"))
484 (invoke "tar" "xvf" (assoc-ref %build-inputs "source"))
485 (chdir (string-append (string-capitalize ,name) "-" ,version))
486 (patch-shebang "colormake.pl"
487 (list (string-append (assoc-ref %build-inputs "perl")
489 (let* ((out (assoc-ref %outputs "out"))
490 (bin (string-append out "/bin"))
491 (doc (string-append out "/share/doc"))
492 (install-files (lambda (files directory)
493 (for-each (lambda (file)
494 (install-file file directory))
496 (substitute* "colormake"
497 (("colormake\\.pl") (string-append bin "/colormake.pl"))
499 (string-append (assoc-ref %build-inputs "bash") "/bin/sh")))
500 (install-file "colormake.1" (string-append doc "/man/man1"))
501 (install-files '("AUTHORS" "BUGS" "ChangeLog" "README") doc)
502 (install-files '("colormake" "colormake-short" "clmake"
503 "clmake-short" "colormake.pl")
506 (home-page "http://bre.klaki.net/programs/colormake/")
507 (synopsis "Wrapper around @command{make} to produce colored output")
508 (description "This package provides a wrapper around @command{make} to
509 produce colored output.")
510 (license license:gpl2+)))
512 (define-public makefile2graph
514 (name "makefile2graph")
518 (uri (string-append "https://github.com/lindenb/" name
519 "/archive/v" version ".tar.gz"))
522 "0h1vchkpmm9h6s87p5nf0ksjxcmsxpx8k62a508w428n570wcr4l"))
523 (file-name (string-append name "-" version ".tar.gz"))))
524 (build-system gnu-build-system)
526 '(#:test-target "test"
527 #:make-flags (list "CC=gcc" (string-append "prefix=" %output))
529 (modify-phases %standard-phases
530 (delete 'configure))))
532 `(("graphviz" ,graphviz)))
533 (home-page "https://github.com/lindenb/makefile2graph")
534 (synopsis "Creates a graph of dependencies from GNU Make")
536 "@code{make2graph} creates a graph of dependencies from GNU Make. The
537 output is a graphviz-dot file, a Gexf-XML file or a list of the deepest
538 independent targets.")
539 (license license:expat)))
541 (define-public uncrustify
548 (url "https://github.com/uncrustify/uncrustify/")
549 (commit (string-append name "-" version))))
550 (file-name (git-file-name name version))
553 "0gf6vjcfy8pl7idvwsd500ffj9hri62q0n79kpb6cnfprrqpbgf4"))))
554 (build-system cmake-build-system)
557 ("python" ,python-wrapper)))
560 (modify-phases %standard-phases
561 (add-after 'unpack 'unpack-etc
562 (lambda* (#:key inputs outputs #:allow-other-keys)
563 ;; Configuration samples are not installed by default.
564 (let* ((output (assoc-ref outputs "out"))
565 (etcdir (string-append output "/etc")))
566 (for-each (lambda (l)
567 (install-file l etcdir))
568 (find-files "etc" "\\.cfg$")))
570 (home-page "http://uncrustify.sourceforge.net/")
571 (synopsis "Code formatter for C and other related languages")
573 "Beautify source code in many languages of the C family (C, C++, C#,
574 Objective@tie{}C, D, Java, Pawn, and Vala). Features:
576 @item Indent and align code.
577 @item Reformat comments (a little bit).
578 @item Fix inter-character spacing.
579 @item Add or remove parens / braces.
580 @item Supports embedded SQL @code{EXEC SQL} stuff.
581 @item Highly configurable - More than 600 configurable options.
583 (license license:gpl2+)))
585 (define-public astyle
592 (uri (string-append "mirror://sourceforge/astyle/astyle/astyle%20"
593 version "/astyle_" version "_linux.tar.gz"))
596 "1ms54wcs7hg1bsywqwf2lhdfizgbk7qxc9ghasxk8i99jvwlrk6b"))))
597 (build-system gnu-build-system)
599 `(#:tests? #f ;no tests
600 #:make-flags (list (string-append "prefix=" %output)
604 (modify-phases %standard-phases
606 (lambda _ (chdir "build/gcc") #t))
607 (add-after 'install 'install-libs
608 (lambda* (#:key outputs #:allow-other-keys)
609 ;; Libraries are not installed by default
610 (let* ((output (assoc-ref outputs "out"))
611 (libdir (string-append output "/lib")))
614 (for-each (lambda (l)
616 l (string-append libdir "/" (basename l))))
617 (find-files "bin" "lib*"))))
619 (home-page "http://astyle.sourceforge.net/")
620 (synopsis "Source code indenter, formatter, and beautifier")
622 "Artistic Style is a source code indenter, formatter, and beautifier for
623 the C, C++, C++/CLI, Objective‑C, C#, and Java programming languages.")
624 (license license:lgpl3+)))
626 (define-public indent
632 (uri (string-append "mirror://gnu/indent/indent-" version
635 "0f9655vqdvfwbxvs1gpa7py8k1z71aqh8hp73f65vazwbfz436wa"))))
636 (build-system gnu-build-system)
639 (modify-phases %standard-phases
640 (add-after 'unpack 'fix-docdir
642 ;; Although indent uses a modern autoconf in which docdir
643 ;; defaults to PREFIX/share/doc, the doc/Makefile.am
644 ;; overrides this to be in PREFIX/doc. Fix this.
645 (substitute* "doc/Makefile.in"
646 (("^docdir = .*$") "docdir = @docdir@\n"))
648 (synopsis "Code reformatter")
650 "Indent is a program that makes source code easier to read by
651 reformatting it in a consistent style. It can change the style to one of
652 several different styles such as GNU, BSD or K&R. It has some flexibility to
653 deal with incomplete or malformed syntax. GNU indent offers several
654 extensions over the standard utility.")
655 (license license:gpl3+)
656 (home-page "https://www.gnu.org/software/indent/")))
658 (define-public indent-2.2.12
664 (uri (string-append "mirror://gnu/indent/indent-" version
668 "12xvcd16cwilzglv9h7sgh4h1qqjd1h8s48ji2dla58m4706hzg7"))))
669 (native-inputs `(("texinfo" ,texinfo)))))
671 (define-public amalgamate
672 (let* ((commit "c91f07eea1133aa184f652b8f1398eaf03586208")
674 (version (git-version "1.1.1" revision commit)))
678 (home-page "https://github.com/edlund/amalgamate")
687 "0cllaraw8mxs8q2nr28nhgzkb417gj2wcklqg59w84f4lc78k3yb"))
688 (file-name (git-file-name name version))
689 (modules '((guix build utils)))
691 '(substitute* "test.sh"
692 (("test_command \"cc -Wall -Wextra -o source.out source.c\"" all)
693 "test_command \"gcc -Wall -Wextra -o source.out source.c\"")))))
694 (build-system gnu-build-system)
696 `(("python" ,python-wrapper)))
699 (modify-phases %standard-phases
703 (lambda* (#:key outputs #:allow-other-keys)
704 (let* ((out (assoc-ref outputs "out"))
705 (bin (string-append out "/bin")))
706 (install-file "amalgamate.py" bin))))
709 (invoke "./test.sh"))))))
710 (synopsis "Tool for amalgamating C source and header files")
711 ;; The package is indeed a script file, and the term "amalgamate.py" is
713 (description "amalgamate.py aims to make it easy to use SQLite-style C
714 source and header amalgamation in projects.")
715 (license license:bsd-3))))