gnu: Add colormake.
[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 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2017, 2018 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 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages code)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system cmake)
32 #:use-module (guix build-system trivial)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages base)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages cpp)
37 #:use-module (gnu packages databases)
38 #:use-module (gnu packages emacs)
39 #:use-module (gnu packages gcc)
40 #:use-module (gnu packages pcre)
41 #:use-module (gnu packages pkg-config)
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages texinfo)
44 #:use-module (gnu packages autogen)
45 #:use-module (gnu packages ncurses)
46 #:use-module (gnu packages autotools)
47 #:use-module (gnu packages llvm)
48 #:use-module (gnu packages lua)
49 #:use-module (gnu packages bash))
50
51 ;;; Tools to deal with source code: metrics, cross-references, etc.
52
53 (define-public cflow
54 (package
55 (name "cflow")
56 (version "1.5")
57 (source (origin
58 (method url-fetch)
59 (uri (string-append "mirror://gnu/cflow/cflow-"
60 version ".tar.bz2"))
61 (sha256
62 (base32
63 "0yq33k5ap1zpnja64n89iai4zh018ffr72wki5a6mzczd880mr3g"))))
64 (build-system gnu-build-system)
65
66 ;; Needed to have cflow-mode.el installed.
67 (native-inputs `(("emacs" ,emacs-minimal)))
68 (arguments
69 '(#:configure-flags (list (string-append "CPPFLAGS="
70 "-D" "CFLOW_PREPROC=\\\""
71 (assoc-ref %build-inputs "gcc")
72 "/bin/cpp\\\""))))
73 (home-page "https://www.gnu.org/software/cflow/")
74 (synopsis "Create a graph of control flow within a program")
75 (description
76 "GNU cflow analyzes C source files and produces a graph charting the
77 control flow of the program. It can output the graph in several styles and
78 in either the POSIX format or in an extended GNU format. cflow also includes
79 a major mode for Emacs for examining the flowcharts that it produces.")
80 (license license:gpl3+)))
81
82 (define-public complexity
83 (package
84 (name "complexity")
85 (version "1.10")
86 (source (origin
87 (method url-fetch)
88 (uri (string-append "mirror://gnu/complexity/complexity-"
89 version ".tar.xz"))
90 (sha256
91 (base32
92 "0lr0l9kj2w3jilz9h9y4np9pf9i9ccpy6331lanki2fnz4z8ldvd"))))
93 (build-system gnu-build-system)
94 (native-inputs
95 `(("texinfo" ,texinfo)
96 ("autogen" ,autogen)))
97 (home-page "https://www.gnu.org/software/complexity/")
98 (synopsis "Analyze complexity of C functions")
99 (description
100 "GNU complexity provides tools for finding procedures that are
101 convoluted, overly long or otherwise difficult to understand. This
102 may help in learning or reviewing unfamiliar code or perhaps
103 highlighting your own code that seemed comprehensible when you wrote it.")
104 (license license:gpl3+)))
105
106 (define-public global ; a global variable
107 (package
108 (name "global")
109 (version "6.6.1")
110 (source (origin
111 (method url-fetch)
112 (uri (string-append "mirror://gnu/global/global-"
113 version ".tar.gz"))
114 (sha256
115 (base32
116 "1r2r6z41lmgbszzwx7h3jqhwnqb9jj32pndzhr3lb0id710c8gcl"))))
117 (build-system gnu-build-system)
118 (inputs `(("ncurses" ,ncurses)
119 ("libltdl" ,libltdl)
120 ("sqlite" ,sqlite)))
121 (arguments
122 `(#:configure-flags
123 (list (string-append "--with-ncurses="
124 (assoc-ref %build-inputs "ncurses"))
125 (string-append "--with-sqlite3="
126 (assoc-ref %build-inputs "sqlite")))
127
128 #:phases
129 (modify-phases %standard-phases
130 (add-after 'install 'post-install
131 (lambda* (#:key outputs #:allow-other-keys)
132 ;; Install the Emacs Lisp file in the right place.
133 (let* ((out (assoc-ref outputs "out"))
134 (data (string-append out "/share/gtags"))
135 (lisp (string-append out "/share/emacs/site-lisp")))
136 (install-file (string-append data "/gtags.el") lisp)
137 (delete-file (string-append data "/gtags.el"))
138 #t))))))
139 (home-page "https://www.gnu.org/software/global/")
140 (synopsis "Cross-environment source code tag system")
141 (description
142 "GLOBAL is a source code tagging system that functions in the same way
143 across a wide array of environments, such as different text editors, shells
144 and web browsers. The resulting tags are useful for quickly moving around in
145 a large, deeply nested project.")
146 (license license:gpl3+)))
147
148 (define-public sloccount
149 (package
150 (name "sloccount")
151 (version "2.26")
152 (source (origin
153 (method url-fetch)
154 (uri (string-append "http://www.dwheeler.com/sloccount/sloccount-"
155 version ".tar.gz"))
156 (sha256
157 (base32
158 "0ayiwfjdh1946asah861ah9269s5xkc8p5fv1wnxs9znyaxs4zzs"))))
159 (build-system gnu-build-system)
160 (arguments
161 '(#:phases (modify-phases %standard-phases
162 (delete 'configure)
163 (add-before 'build 'make-dotl-files-older
164 (lambda _
165 ;; Make the '.l' files as old as the '.c'
166 ;; files to avoid triggering the rule that
167 ;; requires Flex.
168 (define ref
169 (stat "README"))
170
171 (for-each (lambda (file)
172 (set-file-time file ref))
173 (find-files "." "\\.[chl]$"))
174 #t))
175 (add-before 'install 'make-target-directories
176 (lambda* (#:key outputs #:allow-other-keys)
177 (let ((out (assoc-ref outputs "out")))
178 (mkdir-p (string-append out "/bin"))
179 (mkdir-p (string-append out
180 "/share/man/man1"))
181 (mkdir-p (string-append out
182 "/share/doc")))))
183 (replace 'check
184 (lambda _
185 (setenv "HOME" (getcwd))
186 (setenv "PATH"
187 (string-append (getcwd) ":"
188 (getenv "PATH")))
189 (zero? (system* "make" "test")))))
190
191 #:make-flags (list (string-append "PREFIX="
192 (assoc-ref %outputs "out")))))
193 (inputs `(("perl" ,perl)))
194 (home-page "http://www.dwheeler.com/sloccount/")
195 (synopsis "Count physical source lines of code (SLOC)")
196 (description
197 "SLOCCount is a set of the programs for counting source lines of
198 code (SLOC) in large software systems. It can automatically identify and
199 measure a wide range of programming languages. It automatically estimates the
200 effort, time, and money it would take to develop the software, using the
201 COCOMO model or user-provided parameters.")
202 (license license:gpl2+)))
203
204 (define-public cloc
205 (package
206 (name "cloc")
207 (version "1.74")
208 (source
209 (origin
210 (method url-fetch)
211 (uri (string-append
212 "https://github.com/AlDanial/cloc/releases/download/" version
213 "/cloc-" version ".tar.gz"))
214 (sha256
215 (base32
216 "0rq5xfiln1wlv3yr9mg18ax4gskbss786iqaf0v45iv6awyl5b2m"))))
217 (build-system gnu-build-system)
218 (inputs
219 `(("coreutils" ,coreutils)
220 ("perl" ,perl)
221 ("perl-algorithm-diff" ,perl-algorithm-diff)
222 ("perl-regexp-common" ,perl-regexp-common)
223 ("perl-digest-md5" ,perl-digest-md5)))
224 (arguments
225 `(#:phases (modify-phases %standard-phases
226 (delete 'configure)
227 (delete 'build)
228 (replace 'install
229 (lambda* (#:key inputs outputs #:allow-other-keys)
230 (let* ((out (assoc-ref outputs "out")))
231 (zero?
232 (system* "make" "-C" "Unix"
233 (string-append "prefix=" out)
234 (string-append "INSTALL="
235 (assoc-ref inputs "coreutils")
236 "/bin/install")
237 "install")))))
238 (add-after 'install 'wrap-program
239 (lambda* (#:key inputs outputs #:allow-other-keys)
240 (let ((out (assoc-ref outputs "out")))
241 (wrap-program (string-append out "/bin/cloc")
242 `("PERL5LIB" ":" =
243 ,(string-split (getenv "PERL5LIB") #\:)))
244 #t))))
245 #:out-of-source? #t
246 ;; Tests require some other packages.
247 #:tests? #f))
248 (home-page "https://github.com/AlDanial/cloc")
249 (synopsis "Count source lines of code (SLOC) and other source code metrics")
250 (description "cloc counts blank lines, comment lines, and physical lines
251 of source code in many programming languages. Given two versions of a code
252 base, cloc can compute differences in blank, comment, and source lines.
253
254 cloc contains code from David Wheeler's SLOCCount. Compared to SLOCCount,
255 cloc can handle a greater variety of programming languages.")
256 (license license:gpl2+)))
257
258 (define-public the-silver-searcher
259 (package
260 (name "the-silver-searcher")
261 (version "2.1.0")
262 (source (origin
263 (method url-fetch)
264 (uri (string-append
265 "http://geoff.greer.fm/ag/releases/the_silver_searcher-"
266 version ".tar.gz"))
267 (sha256
268 (base32
269 "1m0mih1x4jpswc8ganhqh0gmwbmd2hzmz7402mxfh19s3kcjnrfl"))))
270 (build-system gnu-build-system)
271 (native-inputs
272 `(("pkg-config" ,pkg-config)))
273 (inputs
274 `(("pcre" ,pcre)
275 ("xz" ,xz)
276 ("zlib" ,zlib)))
277 (home-page "http://geoff.greer.fm/ag/")
278 (synopsis "Fast code searching tool")
279 (description
280 "The Silver Searcher (@command{ag}) is a tool for quickly searching large
281 numbers of files. It's intended primarily for source code repositories, and
282 respects files like @file{.gitignore} and @file{.hgignore}. It's also an order
283 of magnitude faster than its inspiration, @command{ack}, and less specialised
284 tools such as @command{grep}.")
285 (license license:asl2.0)))
286
287 (define-public trio
288 (package
289 (name "trio")
290 (version "1.16")
291 (source (origin
292 (method url-fetch)
293 (uri (string-append "mirror://sourceforge/ctrio/trio/trio-"
294 version ".tar.gz"))
295 (sha256
296 (base32
297 "02pwd5m5vq7hbrffgm2na1dfc249z50yyr5jv73vdw15bd7ygl44"))))
298 (build-system gnu-build-system)
299 (home-page "http://daniel.haxx.se/projects/trio/")
300 (synopsis "Portable and extendable printf and string functions")
301 (description
302 "Trio is a set of @code{printf} and string functions designed be used by
303 applications with a focus on portability or with the need for additional
304 features that are not supported by the standard @code{stdio} implementation.")
305 ;; This license is very similar to the ISC license, but the wording is
306 ;; slightly different.
307 (license (license:non-copyleft
308 "http://sourceforge.net/p/ctrio/git/ci/master/tree/README"))))
309
310 (define-public withershins
311 (package
312 (name "withershins")
313 (version "0.1")
314 (source (origin
315 (method url-fetch)
316 (uri (string-append
317 "https://github.com/cameronwhite/withershins/archive/v"
318 version ".tar.gz"))
319 (file-name (string-append name "-" version ".tar.gz"))
320 (sha256
321 (base32
322 "08z3lyvswx7sad10637vfpwglbcbgzzcpfihw0x8lzr74f3b70bh"))))
323 (build-system cmake-build-system)
324 (arguments
325 `(#:out-of-source? #f
326 #:phases
327 (modify-phases %standard-phases
328 (add-after
329 'unpack 'find-libiberty
330 (lambda _
331 (let ((libiberty (assoc-ref %build-inputs "libiberty")))
332 (substitute* "cmake/FindIberty.cmake"
333 (("/usr/include") (string-append libiberty "/include"))
334 (("libiberty.a iberty")
335 (string-append "NAMES libiberty.a iberty\nPATHS \""
336 libiberty "/lib" "\"")))
337 #t)))
338 (replace
339 'install
340 (lambda* (#:key outputs #:allow-other-keys)
341 (let* ((out (assoc-ref outputs "out"))
342 (include (string-append out "/include"))
343 (lib (string-append out "/lib")))
344 (mkdir-p include)
345 (install-file "src/withershins.hpp" include)
346 (mkdir-p lib)
347 (install-file "src/libwithershins.a" lib))
348 #t)))))
349 (home-page "https://github.com/cameronwhite/withershins")
350 (inputs
351 `(("libiberty" ,libiberty)
352 ("binutils" ,binutils) ;for libbfd
353 ("zlib" ,zlib)))
354 (synopsis "C++11 library for generating stack traces")
355 (description
356 "Withershins is a simple cross-platform C++11 library for generating
357 stack traces.")
358 ;; Sources are released under Expat license, but since BFD is licensed
359 ;; under the GPLv3+ the combined work is GPLv3+ as well.
360 (license license:gpl3+)))
361
362 (define-public lcov
363 (package
364 (name "lcov")
365 (version "1.13")
366 (source (origin
367 (method url-fetch)
368 (uri (string-append "mirror://sourceforge/ltp/Coverage%20Analysis"
369 "/LCOV-" version "/lcov-" version ".tar.gz"))
370 (sha256
371 (base32
372 "08wabnb0gcjqk0qc65a6cgbbmz6b8lvam3p7byh0dk42hj3jr5s4"))))
373 (build-system gnu-build-system)
374 (arguments
375 '(#:make-flags
376 (let ((out (assoc-ref %outputs "out")))
377 (list (string-append "PREFIX=" out)))
378 #:phases
379 (modify-phases %standard-phases
380 (delete 'configure)) ; no configure script
381 #:tests? #f)) ; no 'check' target
382 (inputs `(("perl" ,perl)))
383 (home-page "http://ltp.sourceforge.net/coverage/lcov.php")
384 (synopsis "Code coverage tool that enhances GNU gcov")
385 (description
386 "LCOV is an extension of @command{gcov}, a tool part of the
387 GNU@tie{}Binutils, which provides information about what parts of a program
388 are actually executed (i.e., \"covered\") while running a particular test
389 case. The extension consists of a set of Perl scripts which build on the
390 textual @command{gcov} output to implement the following enhanced
391 functionality such as HTML output.")
392 (license license:gpl2+)))
393
394 (define-public rtags
395 (package
396 (name "rtags")
397 (version "2.18")
398 (home-page "https://github.com/Andersbakken/rtags")
399 (source
400 (origin
401 (method url-fetch)
402 (uri
403 (string-append home-page "/archive/v" version ".tar.gz"))
404 (file-name (string-append name "-" version ".tar.gz"))
405 (patches (search-patches "rtags-separate-rct.patch"))
406 (modules '((guix build utils)))
407 (snippet
408 ;; Part of spliting rct with rtags.
409 ;; Substitute #include "rct/header.h" with #include <rct/header.h>.
410 '(with-directory-excursion "src"
411 (delete-file-recursively "rct") ;remove bundled copy
412 (let ((files (find-files "." ".*\\.cpp|.*\\.h")))
413 (substitute* files
414 (("#include ?\"rct/(.*.h)\"" all header)
415 (string-append "#include <rct/" header ">"))))))
416 (sha256
417 (base32
418 "0scjbp1z201q8njvrxqz7lk2m9b6k2rxd5q1shrng6532r7ndif2"))))
419 (build-system cmake-build-system)
420 (arguments
421 '(#:configure-flags
422 '("-DRTAGS_NO_ELISP_FILES=1"
423 "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
424 "-DCMAKE_CXX_FLAGS=-std=c++11"
425 "-DBUILD_TESTING=FALSE")
426 #:tests? #f))
427 (native-inputs
428 `(("pkg-config" ,pkg-config)))
429 (inputs
430 `(("bash-completion" ,bash-completion)
431 ("clang" ,clang)
432 ("llvm" ,llvm)
433 ("lua" ,lua)
434 ("rct" ,rct)
435 ("selene" ,selene)))
436 (synopsis "Indexer for the C language family with Emacs integration")
437 (description
438 "RTags is a client/server application that indexes C/C++ code and keeps a
439 persistent file-based database of references, declarations, definitions,
440 symbolnames etc. There’s also limited support for ObjC/ObjC++. It allows you
441 to find symbols by name (including nested class and namespace scope). Most
442 importantly we give you proper follow-symbol and find-references support.")
443 (license license:gpl3+)))
444
445 (define-public colormake
446 (package
447 (name "colormake")
448 (version "0.9.20140503")
449 (source
450 (origin
451 (method url-fetch)
452 (uri (string-append "https://github.com/pagekite/Colormake/archive/"
453 version ".tar.gz"))
454 (file-name (string-append name "-" version ".tar.gz"))
455 (sha256
456 (base32
457 "08ldss9zd8ls6bjahvxhffpsjcysifr720yf3jz9db2mlklzmyd3"))))
458 (build-system trivial-build-system)
459 (native-inputs
460 `(("bash" ,bash)
461 ("gzip" ,gzip)
462 ("perl" ,perl)
463 ("tar" ,tar)))
464 (arguments
465 `(#:modules ((guix build utils))
466 #:builder
467 (begin
468 (use-modules (guix build utils))
469 ;; bootstrap
470 (setenv "PATH" (string-append
471 (assoc-ref %build-inputs "tar") "/bin" ":"
472 (assoc-ref %build-inputs "gzip") "/bin"))
473 (invoke "tar" "xvf" (assoc-ref %build-inputs "source"))
474 (chdir (string-append (string-capitalize ,name) "-" ,version))
475 (patch-shebang "colormake.pl"
476 (list (string-append (assoc-ref %build-inputs "perl")
477 "/bin")))
478 (let* ((out (assoc-ref %outputs "out"))
479 (bin (string-append out "/bin"))
480 (doc (string-append out "/share/doc"))
481 (install-files (lambda (files directory)
482 (for-each (lambda (file)
483 (install-file file directory))
484 files))))
485 (substitute* "colormake"
486 (("colormake\\.pl") (string-append bin "/colormake.pl"))
487 (("/bin/bash")
488 (string-append (assoc-ref %build-inputs "bash") "/bin/sh")))
489 (install-file "colormake.1" (string-append doc "/man/man1"))
490 (install-files '("AUTHORS" "BUGS" "ChangeLog" "README") doc)
491 (install-files '("colormake" "colormake-short" "clmake"
492 "clmake-short" "colormake.pl")
493 bin)))))
494 (home-page "http://bre.klaki.net/programs/colormake/")
495 (synopsis "Wrapper around @command{make} to produce colored output")
496 (description "This package provides a wrapper around @command{make} to
497 produce colored output.")
498 (license license:gpl2+)))