gnu: libtool: Restore ltmain.sh shebang.
[jackhill/guix/guix.git] / gnu / packages / autotools.scm
CommitLineData
233e7676
LC
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
89b48232 3;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
2b00a550 4;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
c6e96280 5;;; Copyright © 2014 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
192c6f96 6;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
6b0686fa 7;;; Copyright © 2016 David Thompson <davet@gnu.org>
dc70626d 8;;; Copyright © 2017 ng0 <ng0@libertad.pw>
80ffc708 9;;;
233e7676 10;;; This file is part of GNU Guix.
80ffc708 11;;;
233e7676 12;;; GNU Guix is free software; you can redistribute it and/or modify it
80ffc708
NK
13;;; under the terms of the GNU General Public License as published by
14;;; the Free Software Foundation; either version 3 of the License, or (at
15;;; your option) any later version.
16;;;
233e7676 17;;; GNU Guix is distributed in the hope that it will be useful, but
80ffc708
NK
18;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;;; GNU General Public License for more details.
21;;;
22;;; You should have received a copy of the GNU General Public License
233e7676 23;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
80ffc708 24
1ffa7090 25(define-module (gnu packages autotools)
4a44e743 26 #:use-module (guix licenses)
59a43334 27 #:use-module (gnu packages)
1ffa7090
LC
28 #:use-module (gnu packages perl)
29 #:use-module (gnu packages m4)
98341757 30 #:use-module (gnu packages man)
7cd1d7bd
LC
31 #:use-module (gnu packages bash)
32 #:use-module (guix utils)
80ffc708
NK
33 #:use-module (guix packages)
34 #:use-module (guix download)
7cd1d7bd 35 #:use-module (guix build-system gnu)
c6e96280
MR
36 #:use-module (guix build-system trivial)
37 #:use-module (ice-9 match)
38 #:export (autoconf-wrapper))
80ffc708
NK
39
40(define-public autoconf
41 (package
42 (name "autoconf")
43 (version "2.69")
44 (source
45 (origin
46 (method url-fetch)
47 (uri (string-append "mirror://gnu/autoconf/autoconf-"
48 version ".tar.xz"))
49 (sha256
50 (base32
51 "113nlmidxy9kjr45kg9x3ngar4951mvag1js2a3j8nxcz34wxsv4"))))
52 (build-system gnu-build-system)
a6abac9f 53 (native-inputs
80ffc708
NK
54 `(("perl" ,perl)
55 ("m4" ,m4)))
56 ;; XXX: testsuite: 209 and 279 failed. The latter is an impurity. It
57 ;; should use our own "cpp" instead of "/lib/cpp".
58 (arguments `(#:tests? #f))
59 (home-page
60 "http://www.gnu.org/software/autoconf/")
f50d2669 61 (synopsis "Create source code configuration scripts")
80ffc708 62 (description
a22dc0c4
LC
63 "Autoconf offers the developer a robust set of M4 macros which expand
64into shell code to test the features of Unix-like systems and to adapt
65automatically their software package to these systems. The resulting shell
66scripts are self-contained and portable, freeing the user from needing to
67know anything about Autoconf or M4.")
4a44e743 68 (license gpl3+))) ; some files are under GPLv2+
80ffc708 69
c6e96280
MR
70(define-public autoconf-2.68
71 (package (inherit autoconf)
72 (version "2.68")
73 (source
74 (origin
75 (method url-fetch)
76 (uri (string-append "mirror://gnu/autoconf/autoconf-"
77 version ".tar.xz"))
78 (sha256
79 (base32
80 "1fjm21k2na07f3vasf288a0zx66lbv0hd3l9bvv3q8p62s3pg569"))))))
81
2a7050ab
LC
82(define-public autoconf-2.64
83 ;; As of GDB 7.8, GDB is still developed using this version of Autoconf.
84 (package (inherit autoconf)
85 (version "2.64")
86 (source
87 (origin
88 (method url-fetch)
89 (uri (string-append "mirror://gnu/autoconf/autoconf-"
90 version ".tar.xz"))
91 (sha256
92 (base32
93 "0j3jdjpf5ly39dlp0bg70h72nzqr059k0x8iqxvaxf106chpgn9j"))))))
94
95
c6e96280
MR
96(define* (autoconf-wrapper #:optional (autoconf autoconf))
97 "Return an wrapper around AUTOCONF that generates `configure' scripts that
98use our own Bash instead of /bin/sh in shebangs. For that reason, it should
99only be used internally---users should not end up distributing `configure'
100files with a system-specific shebang."
7cd1d7bd 101 (package (inherit autoconf)
7cd1d7bd
LC
102 (name (string-append (package-name autoconf) "-wrapper"))
103 (build-system trivial-build-system)
104 (inputs `(("guile"
168030ea
LC
105 ;; XXX: Kludge to hide the circular dependency.
106 ,(module-ref (resolve-interface '(gnu packages guile))
107 'guile-2.0))
7cd1d7bd
LC
108 ("autoconf" ,autoconf)
109 ("bash" ,bash)))
110 (arguments
111 '(#:modules ((guix build utils))
112 #:builder
113 (begin
114 (use-modules (guix build utils))
115 (let* ((out (assoc-ref %outputs "out"))
116 (bin (string-append out "/bin"))
117 (autoconf (string-append
118 (assoc-ref %build-inputs "autoconf")
119 "/bin/autoconf"))
120 (guile (string-append
121 (assoc-ref %build-inputs "guile")
122 "/bin/guile"))
123 (sh (string-append
124 (assoc-ref %build-inputs "bash")
125 "/bin/sh"))
126 (modules ((compose dirname dirname dirname)
127 (search-path %load-path
128 "guix/build/utils.scm"))))
129 (mkdir-p bin)
130
131 ;; Symlink all the binaries but `autoconf'.
132 (with-directory-excursion bin
133 (for-each (lambda (file)
134 (unless (string=? (basename file) "autoconf")
135 (symlink file (basename file))))
136 (find-files (dirname autoconf) ".*")))
137
138 ;; Add an `autoconf' binary that wraps the real one.
139 (call-with-output-file (string-append bin "/autoconf")
140 (lambda (port)
141 ;; Shamefully, Guile can be used in shebangs only if a
142 ;; single argument is passed (-ds); otherwise it gets
143 ;; them all as a single argument and fails to parse them.
144 (format port "#!~a
145export GUILE_LOAD_PATH=\"~a\"
146export GUILE_LOAD_COMPILED_PATH=\"~a\"
147exec ~a --no-auto-compile \"$0\" \"$@\"
148!#~%"
149 sh modules modules guile)
150 (write
151 `(begin
152 (use-modules (guix build utils))
153 (let ((result (apply system* ,autoconf
154 (cdr (command-line)))))
f11617d8
LC
155 (when (and (file-exists? "configure")
156 (not (file-exists? "/bin/sh")))
157 ;; Patch regardless of RESULT, because `autoconf
158 ;; -Werror' can both create a `configure' file and
159 ;; return a non-zero exit code.
160 (patch-shebang "configure"))
161 (exit (status:exit-val result))))
7cd1d7bd
LC
162 port)))
163 (chmod (string-append bin "/autoconf") #o555)))))))
164
6b0686fa
DT
165(define-public autoconf-archive
166 (package
167 (name "autoconf-archive")
0bb94615 168 (version "2016.09.16")
6b0686fa
DT
169 (source
170 (origin
171 (method url-fetch)
172 (uri (string-append "mirror://gnu/autoconf-archive/autoconf-archive-"
173 version ".tar.xz"))
174 (sha256
175 (base32
0bb94615 176 "10mxz9hfnfz66m1l9s28sbyfb9a04akz92wkyv9blhpq6p9fzwp8"))))
6b0686fa
DT
177 (build-system gnu-build-system)
178 (home-page "https://www.gnu.org/software/autoconf-archive")
179 (synopsis "Collection of freely reusable Autoconf macros")
180 (description
181 "Autoconf Archive is a collection of over 450 new macros for Autoconf,
182greatly expanding the domain of its functionality. These macros have been
183contributed as free software by the community.")
184 (license gpl3+)))
185
2b00a550
ML
186(define-public autobuild
187 (package
188 (name "autobuild")
189 (version "5.3")
190 (source (origin
191 (method url-fetch)
192 (uri (string-append "mirror://savannah/autobuild/autobuild-"
193 version ".tar.gz"))
194 (sha256
195 (base32
196 "0gv7g61ja9q9zg1m30k4snqwwy1kq7b4df6sb7d2qra7kbdq8af1"))))
197 (build-system gnu-build-system)
198 (inputs `(("perl" ,perl)))
199 (synopsis "Process generated build logs")
200 (description "Autobuild is a package that processes build logs generated
201when building software. Autobuild is primarily focused on packages using
202Autoconf and Automake, but can be used with other build systems too.
203Autobuild generates an HTML summary file, containing links to each build log.
204The summary includes project name, version, build hostname, host type (cross
205compile aware), date of build, and indication of success or failure. The
206output is indexed in many ways to simplify browsing.")
207 (home-page "http://josefsson.org/autobuild/")
208 (license gpl3+)))
209
80ffc708
NK
210(define-public automake
211 (package
212 (name "automake")
aebb05b0 213 (version "1.15")
7cd1d7bd
LC
214 (source (origin
215 (method url-fetch)
216 (uri (string-append "mirror://gnu/automake/automake-"
217 version ".tar.xz"))
218 (sha256
219 (base32
aebb05b0 220 "0dl6vfi2lzz8alnklwxzfz624b95hb1ipjvd3mk177flmddcf24r"))
01eafd38 221 (patches
fc1adab1 222 (search-patches "automake-regexp-syntax.patch"
28206a8e
LC
223 "automake-skip-amhello-tests.patch"
224 "automake-test-gzip-warning.patch"))))
80ffc708 225 (build-system gnu-build-system)
a6abac9f 226 (native-inputs
c6e96280 227 `(("autoconf" ,(autoconf-wrapper))
01eafd38 228 ("perl" ,perl)))
a9db7d10
LC
229 (native-search-paths
230 (list (search-path-specification
231 (variable "ACLOCAL_PATH")
af070955 232 (files '("share/aclocal")))))
7cd1d7bd 233 (arguments
01eafd38 234 '(#:modules ((guix build gnu-build-system)
63b7c6c1
LC
235 (guix build utils)
236 (srfi srfi-1)
237 (srfi srfi-26)
238 (rnrs io ports))
7cd1d7bd
LC
239 #:phases (alist-cons-before
240 'patch-source-shebangs 'patch-tests-shebangs
241 (lambda _
242 (let ((sh (which "sh")))
243 (substitute* (find-files "t" "\\.(sh|tap)$")
244 (("#![[:blank:]]?/bin/sh")
245 (string-append "#!" sh)))
246
247 ;; Set these variables for all the `configure' runs
248 ;; that occur during the test suite.
249 (setenv "SHELL" sh)
250 (setenv "CONFIG_SHELL" sh)))
9be8d7c8 251
63b7c6c1
LC
252 ;; Files like `install-sh', `mdate.sh', etc. must use
253 ;; #!/bin/sh, otherwise users could leak erroneous shebangs
254 ;; in the wild. See <http://bugs.gnu.org/14201> for an
255 ;; example.
256 (alist-cons-after
257 'install 'unpatch-shebangs
258 (lambda* (#:key outputs #:allow-other-keys)
259 (let* ((out (assoc-ref outputs "out"))
260 (dir (string-append out "/share")))
261 (define (starts-with-shebang? file)
262 (equal? (call-with-input-file file
263 (lambda (p)
264 (list (get-u8 p) (get-u8 p))))
265 (map char->integer '(#\# #\!))))
266
267 (for-each (lambda (file)
268 (when (and (starts-with-shebang? file)
269 (executable-file? file))
270 (format #t "restoring shebang on `~a'~%"
271 file)
272 (substitute* file
273 (("^#!.*/bin/sh")
274 "#!/bin/sh")
275 (("^#!.*/bin/env(.*)$" _ args)
276 (string-append "#!/usr/bin/env"
277 args)))))
278 (find-files dir ".*"))))
279 %standard-phases))))
7cd1d7bd 280 (home-page "http://www.gnu.org/software/automake/")
f50d2669 281 (synopsis "Making GNU standards-compliant Makefiles")
80ffc708 282 (description
79c311b8
LC
283 "Automake the part of the GNU build system for producing
284standards-compliant Makefiles. Build requirements are entered in an
285intuitive format and then Automake works with Autoconf to produce a robust
286Makefile, simplifying the entire process for the developer.")
7cd1d7bd 287 (license gpl2+))) ; some files are under GPLv3+
36d4d49e
NK
288
289(define-public libtool
290 (package
291 (name "libtool")
192c6f96 292 (version "2.4.6")
36d4d49e 293 (source (origin
c154e1ea
LC
294 (method url-fetch)
295 (uri (string-append "mirror://gnu/libtool/libtool-"
296 version ".tar.xz"))
297 (sha256
298 (base32
192c6f96 299 "0vxj52zm709125gwv9qqlw02silj8bnjnh4y07arrz60r31ai1vw"))
fc1adab1 300 (patches (search-patches "libtool-skip-tests2.patch"))))
36d4d49e 301 (build-system gnu-build-system)
62c155c0 302 (propagated-inputs `(("m4" ,m4)))
36d4d49e 303 (native-inputs `(("m4" ,m4)
c154e1ea 304 ("perl" ,perl)
98341757 305 ("help2man" ,help2man) ;because we modify ltmain.sh
c154e1ea
LC
306 ("automake" ,automake) ;some tests rely on 'aclocal'
307 ("autoconf" ,(autoconf-wrapper)))) ;others on 'autom4te'
2f8a123e 308
36d4d49e 309 (arguments
3246cc91
LC
310 `(;; Libltdl is provided as a separate package, so don't install it here.
311 #:configure-flags '("--disable-ltdl-install")
312
313 ;; XXX: There are test failures on mips64el-linux starting from 2.4.4:
314 ;; <http://hydra.gnu.org/build/181662>.
315 #:tests? ,(not (string-prefix? "mips64"
316 (or (%current-target-system)
317 (%current-system))))
c154e1ea 318
dc70626d 319 #:phases
320 (modify-phases %standard-phases
321 (add-before 'check 'pre-check
322 (lambda* (#:key inputs #:allow-other-keys)
323 ;; Run the test suite in parallel, if possible.
324 (setenv "TESTSUITEFLAGS"
325 (string-append
326 "-j"
327 (number->string (parallel-job-count))))
328 ;; Path references to /bin/sh.
329 (let ((bash (assoc-ref inputs "bash")))
330 (substitute* "tests/testsuite"
331 (("/bin/sh")
332 (string-append bash "/bin/bash")))))))))
98341757 333 (add-after 'patch-source-shebangs 'restore-ltmain-shebang
334 (lambda* (#:key inputs #:allow-other-keys)
335 (substitute* "build-aux/ltmain.in"
336 (("^#!.*/bin/sh$") "/bin/sh")))))))
42ff70e2 337
f50d2669 338 (synopsis "Generic shared library support tools")
36d4d49e 339 (description
79c311b8
LC
340 "GNU Libtool helps in the creation and use of shared libraries, by
341presenting a single consistent, portable interface that hides the usual
342complexity of working with shared libraries across platforms.")
4a44e743 343 (license gpl3+)
36d4d49e 344 (home-page "http://www.gnu.org/software/libtool/")))
e13f715b 345
3cbb3f9c
LC
346(define-public libltdl
347 ;; This is a libltdl package separate from the libtool package. This is
348 ;; useful because, unlike libtool, it has zero extra dependencies (making it
349 ;; readily usable during bootstrap), and it builds very quickly since
350 ;; Libtool's extensive test suite isn't run.
351 (package
352 (name "libltdl")
192c6f96 353 (version "2.4.6")
a101c891
LC
354 (source (origin
355 (method url-fetch)
356 (uri (string-append "mirror://gnu/libtool/libtool-"
357 version ".tar.xz"))
358 (sha256
359 (base32
ef593a10 360 "0vxj52zm709125gwv9qqlw02silj8bnjnh4y07arrz60r31ai1vw"))))
3cbb3f9c
LC
361 (build-system gnu-build-system)
362 (arguments
363 '(#:configure-flags '("--enable-ltdl-install") ;really install it
364 #:phases (alist-cons-before
365 'configure 'change-directory
366 (lambda _
367 (chdir "libltdl"))
368 %standard-phases)))
369
370 (synopsis "System-independent dlopen wrapper of GNU libtool")
371 (description (package-description libtool))
372 (home-page (package-home-page libtool))
373 (license lgpl2.1+)))