| 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org> |
| 3 | ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org> |
| 4 | ;;; |
| 5 | ;;; This file is part of GNU Guix. |
| 6 | ;;; |
| 7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
| 8 | ;;; under the terms of the GNU General Public License as published by |
| 9 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
| 10 | ;;; your option) any later version. |
| 11 | ;;; |
| 12 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
| 13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | ;;; GNU General Public License for more details. |
| 16 | ;;; |
| 17 | ;;; You should have received a copy of the GNU General Public License |
| 18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | (define-module (gnu packages autotools) |
| 21 | #:use-module (guix licenses) |
| 22 | #:use-module (gnu packages) |
| 23 | #:use-module (gnu packages perl) |
| 24 | #:use-module (gnu packages m4) |
| 25 | #:use-module (gnu packages bash) |
| 26 | #:use-module (guix utils) |
| 27 | #:use-module (guix packages) |
| 28 | #:use-module (guix download) |
| 29 | #:use-module (guix build-system gnu) |
| 30 | #:use-module (guix build-system trivial)) |
| 31 | |
| 32 | (define-public autoconf |
| 33 | (package |
| 34 | (name "autoconf") |
| 35 | (version "2.69") |
| 36 | (source |
| 37 | (origin |
| 38 | (method url-fetch) |
| 39 | (uri (string-append "mirror://gnu/autoconf/autoconf-" |
| 40 | version ".tar.xz")) |
| 41 | (sha256 |
| 42 | (base32 |
| 43 | "113nlmidxy9kjr45kg9x3ngar4951mvag1js2a3j8nxcz34wxsv4")))) |
| 44 | (build-system gnu-build-system) |
| 45 | (inputs |
| 46 | `(("perl" ,perl) |
| 47 | ("m4" ,m4))) |
| 48 | ;; XXX: testsuite: 209 and 279 failed. The latter is an impurity. It |
| 49 | ;; should use our own "cpp" instead of "/lib/cpp". |
| 50 | (arguments `(#:tests? #f)) |
| 51 | (home-page |
| 52 | "http://www.gnu.org/software/autoconf/") |
| 53 | (synopsis "Create source code configuration scripts") |
| 54 | (description |
| 55 | "GNU Autoconf is an extensible package of M4 macros that produce |
| 56 | shell scripts to automatically configure software source code |
| 57 | packages. These scripts can adapt the packages to many kinds of |
| 58 | UNIX-like systems without manual user intervention. Autoconf |
| 59 | creates a configuration script for a package from a template |
| 60 | file that lists the operating system features that the package |
| 61 | can use, in the form of M4 macro calls.") |
| 62 | (license gpl3+))) ; some files are under GPLv2+ |
| 63 | |
| 64 | (define-public autoconf-wrapper |
| 65 | ;; An Autoconf wrapper that generates `configure' scripts that use our |
| 66 | ;; own Bash instead of /bin/sh in shebangs. For that reason, it |
| 67 | ;; should only be used internally---users should not end up |
| 68 | ;; distributing `configure' files with a system-specific shebang. |
| 69 | (package (inherit autoconf) |
| 70 | (location (source-properties->location (current-source-location))) |
| 71 | (name (string-append (package-name autoconf) "-wrapper")) |
| 72 | (build-system trivial-build-system) |
| 73 | (inputs `(("guile" |
| 74 | ;; XXX: Kludge to hide the circular dependency. |
| 75 | ,(module-ref (resolve-interface '(gnu packages guile)) |
| 76 | 'guile-2.0)) |
| 77 | ("autoconf" ,autoconf) |
| 78 | ("bash" ,bash))) |
| 79 | (arguments |
| 80 | '(#:modules ((guix build utils)) |
| 81 | #:builder |
| 82 | (begin |
| 83 | (use-modules (guix build utils)) |
| 84 | (let* ((out (assoc-ref %outputs "out")) |
| 85 | (bin (string-append out "/bin")) |
| 86 | (autoconf (string-append |
| 87 | (assoc-ref %build-inputs "autoconf") |
| 88 | "/bin/autoconf")) |
| 89 | (guile (string-append |
| 90 | (assoc-ref %build-inputs "guile") |
| 91 | "/bin/guile")) |
| 92 | (sh (string-append |
| 93 | (assoc-ref %build-inputs "bash") |
| 94 | "/bin/sh")) |
| 95 | (modules ((compose dirname dirname dirname) |
| 96 | (search-path %load-path |
| 97 | "guix/build/utils.scm")))) |
| 98 | (mkdir-p bin) |
| 99 | |
| 100 | ;; Symlink all the binaries but `autoconf'. |
| 101 | (with-directory-excursion bin |
| 102 | (for-each (lambda (file) |
| 103 | (unless (string=? (basename file) "autoconf") |
| 104 | (symlink file (basename file)))) |
| 105 | (find-files (dirname autoconf) ".*"))) |
| 106 | |
| 107 | ;; Add an `autoconf' binary that wraps the real one. |
| 108 | (call-with-output-file (string-append bin "/autoconf") |
| 109 | (lambda (port) |
| 110 | ;; Shamefully, Guile can be used in shebangs only if a |
| 111 | ;; single argument is passed (-ds); otherwise it gets |
| 112 | ;; them all as a single argument and fails to parse them. |
| 113 | (format port "#!~a |
| 114 | export GUILE_LOAD_PATH=\"~a\" |
| 115 | export GUILE_LOAD_COMPILED_PATH=\"~a\" |
| 116 | exec ~a --no-auto-compile \"$0\" \"$@\" |
| 117 | !#~%" |
| 118 | sh modules modules guile) |
| 119 | (write |
| 120 | `(begin |
| 121 | (use-modules (guix build utils)) |
| 122 | (let ((result (apply system* ,autoconf |
| 123 | (cdr (command-line))))) |
| 124 | (when (and (file-exists? "configure") |
| 125 | (not (file-exists? "/bin/sh"))) |
| 126 | ;; Patch regardless of RESULT, because `autoconf |
| 127 | ;; -Werror' can both create a `configure' file and |
| 128 | ;; return a non-zero exit code. |
| 129 | (patch-shebang "configure")) |
| 130 | (exit (status:exit-val result)))) |
| 131 | port))) |
| 132 | (chmod (string-append bin "/autoconf") #o555))))))) |
| 133 | |
| 134 | (define-public automake |
| 135 | (package |
| 136 | (name "automake") |
| 137 | (version "1.14") |
| 138 | (source (origin |
| 139 | (method url-fetch) |
| 140 | (uri (string-append "mirror://gnu/automake/automake-" |
| 141 | version ".tar.xz")) |
| 142 | (sha256 |
| 143 | (base32 |
| 144 | "0nc0zqq8j336kamizzd86wb19vhbwywv5avcjh3cyx230xfqy671")))) |
| 145 | (build-system gnu-build-system) |
| 146 | (inputs |
| 147 | `(("autoconf" ,autoconf-wrapper) |
| 148 | ("perl" ,perl) |
| 149 | ("patch/skip-amhello" |
| 150 | ,(search-patch "automake-skip-amhello-tests.patch")))) |
| 151 | (native-search-paths |
| 152 | (list (search-path-specification |
| 153 | (variable "ACLOCAL_PATH") |
| 154 | (directories '("share/aclocal"))))) |
| 155 | (arguments |
| 156 | '(#:patches (list (assoc-ref %build-inputs "patch/skip-amhello")) |
| 157 | #:modules ((guix build gnu-build-system) |
| 158 | (guix build utils) |
| 159 | (srfi srfi-1) |
| 160 | (srfi srfi-26) |
| 161 | (rnrs io ports)) |
| 162 | #:phases (alist-cons-before |
| 163 | 'patch-source-shebangs 'patch-tests-shebangs |
| 164 | (lambda _ |
| 165 | (let ((sh (which "sh"))) |
| 166 | (substitute* (find-files "t" "\\.(sh|tap)$") |
| 167 | (("#![[:blank:]]?/bin/sh") |
| 168 | (string-append "#!" sh))) |
| 169 | |
| 170 | ;; Set these variables for all the `configure' runs |
| 171 | ;; that occur during the test suite. |
| 172 | (setenv "SHELL" sh) |
| 173 | (setenv "CONFIG_SHELL" sh))) |
| 174 | |
| 175 | ;; Files like `install-sh', `mdate.sh', etc. must use |
| 176 | ;; #!/bin/sh, otherwise users could leak erroneous shebangs |
| 177 | ;; in the wild. See <http://bugs.gnu.org/14201> for an |
| 178 | ;; example. |
| 179 | (alist-cons-after |
| 180 | 'install 'unpatch-shebangs |
| 181 | (lambda* (#:key outputs #:allow-other-keys) |
| 182 | (let* ((out (assoc-ref outputs "out")) |
| 183 | (dir (string-append out "/share"))) |
| 184 | (define (starts-with-shebang? file) |
| 185 | (equal? (call-with-input-file file |
| 186 | (lambda (p) |
| 187 | (list (get-u8 p) (get-u8 p)))) |
| 188 | (map char->integer '(#\# #\!)))) |
| 189 | |
| 190 | (for-each (lambda (file) |
| 191 | (when (and (starts-with-shebang? file) |
| 192 | (executable-file? file)) |
| 193 | (format #t "restoring shebang on `~a'~%" |
| 194 | file) |
| 195 | (substitute* file |
| 196 | (("^#!.*/bin/sh") |
| 197 | "#!/bin/sh") |
| 198 | (("^#!.*/bin/env(.*)$" _ args) |
| 199 | (string-append "#!/usr/bin/env" |
| 200 | args))))) |
| 201 | (find-files dir ".*")))) |
| 202 | %standard-phases)))) |
| 203 | (home-page "http://www.gnu.org/software/automake/") |
| 204 | (synopsis "Making GNU standards-compliant Makefiles") |
| 205 | (description |
| 206 | "GNU Automake is a tool for automatically generating |
| 207 | `Makefile.in' files compliant with the GNU Coding |
| 208 | Standards. Automake requires the use of Autoconf.") |
| 209 | (license gpl2+))) ; some files are under GPLv3+ |
| 210 | |
| 211 | (define-public libtool |
| 212 | (package |
| 213 | (name "libtool") |
| 214 | (version "2.4.2") |
| 215 | (source (origin |
| 216 | (method url-fetch) |
| 217 | (uri (string-append "mirror://gnu/libtool/libtool-" |
| 218 | version ".tar.gz")) |
| 219 | (sha256 |
| 220 | (base32 |
| 221 | "0649qfpzkswgcj9vqkkr9rn4nlcx80faxpyqscy2k1x9c94f93dk")))) |
| 222 | (build-system gnu-build-system) |
| 223 | (native-inputs `(("m4" ,m4) |
| 224 | ("perl" ,perl))) |
| 225 | |
| 226 | ;; Separate binaries from the rest. During bootstrap, only ltdl is |
| 227 | ;; used; not depending on the binaries allows us to avoid retaining |
| 228 | ;; a reference to the bootstrap bash. |
| 229 | (outputs '("bin" ; libtoolize, libtool, etc. |
| 230 | "out")) ; libltdl.so, ltdl.h, etc. |
| 231 | |
| 232 | (arguments |
| 233 | `(#:patches (list (assoc-ref %build-inputs "patch/skip-tests")) |
| 234 | ,@(if (%current-target-system) |
| 235 | '() ; no `check' phase when cross-building |
| 236 | '(#:phases (alist-cons-before |
| 237 | 'check 'pre-check |
| 238 | (lambda* (#:key inputs #:allow-other-keys) |
| 239 | ;; Run the test suite in parallel, if possible. |
| 240 | (let ((ncores |
| 241 | (cond |
| 242 | ((getenv "NIX_BUILD_CORES") |
| 243 | => |
| 244 | (lambda (n) |
| 245 | (if (zero? (string->number n)) |
| 246 | (number->string (current-processor-count)) |
| 247 | n))) |
| 248 | (else "1")))) |
| 249 | (setenv "TESTSUITEFLAGS" |
| 250 | (string-append "-j" ncores))) |
| 251 | |
| 252 | ;; Path references to /bin/sh. |
| 253 | (let ((bash (assoc-ref inputs "bash"))) |
| 254 | (substitute* "tests/testsuite" |
| 255 | (("/bin/sh") |
| 256 | (string-append bash "/bin/bash"))))) |
| 257 | %standard-phases))))) |
| 258 | (inputs `(("patch/skip-tests" |
| 259 | ,(search-patch "libtool-skip-tests.patch")))) |
| 260 | (synopsis "Generic shared library support tools") |
| 261 | (description |
| 262 | "GNU libtool is a generic library support script. Libtool hides the |
| 263 | complexity of using shared libraries behind a consistent, portable interface. |
| 264 | |
| 265 | To use libtool, add the new generic library building commands to your |
| 266 | Makefile, Makefile.in, or Makefile.am. See the documentation for |
| 267 | details.") |
| 268 | (license gpl3+) |
| 269 | (home-page "http://www.gnu.org/software/libtool/"))) |