summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Lirzin <mthl@gnu.org>2018-01-17 17:14:24 +0100
committerLudovic Courtès <ludo@gnu.org>2018-01-23 10:13:16 +0100
commitcba386c1295b7054df22dfb4662b1b92f668e2c0 (patch)
tree76078a073f62240b582c39cc20f8c9625edb6380
parent341afe2a36125b11c1bc08bdc8f63421edaba008 (diff)
build: Expand ‘scripts/guix’ at Make time.
This moves the complexity of Autotools variable expansion outside of the application code. * scripts/guix.in (config-lookup): Delete. (maybe-augment-load-paths!, run-guix-main): Use fully expanded variables instead of calling ‘config-lookup’. * configure.ac: Don't use AC_CONFIG_FILES for ‘scripts/guix’. Use AC_PROG_SED. * Makefile.am (scripts/guix): New rule. (do_subst): New variable. (CLEANFILES, EXTRA_DIST): Adapt. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--Makefile.am20
-rw-r--r--configure.ac3
-rw-r--r--scripts/guix.in31
3 files changed, 25 insertions, 29 deletions
diff --git a/Makefile.am b/Makefile.am
index aebd3b1eb7b..9bafdab49b3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@
2# Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> 2# Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
3# Copyright © 2013 Andreas Enge <andreas@enge.fr> 3# Copyright © 2013 Andreas Enge <andreas@enge.fr>
4# Copyright © 2015, 2017 Alex Kost <alezost@gmail.com> 4# Copyright © 2015, 2017 Alex Kost <alezost@gmail.com>
5# Copyright © 2016 Mathieu Lirzin <mthl@gnu.org> 5# Copyright © 2016, 2018 Mathieu Lirzin <mthl@gnu.org>
6# Copyright © 2016, 2017 Mark H Weaver <mhw@netris.org> 6# Copyright © 2016, 2017 Mark H Weaver <mhw@netris.org>
7# Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> 7# Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
8# Copyright © 2017 Leo Famulari <leo@famulari.name> 8# Copyright © 2017 Leo Famulari <leo@famulari.name>
@@ -26,8 +26,20 @@
26# You should have received a copy of the GNU General Public License 26# You should have received a copy of the GNU General Public License
27# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. 27# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28 28
29bin_SCRIPTS = \ 29bin_SCRIPTS = scripts/guix
30 scripts/guix 30
31# Handle substitution of fully-expanded Autoconf variables.
32do_subst = $(SED) \
33 -e 's,[@]GUILE[@],$(GUILE),g' \
34 -e 's,[@]guilemoduledir[@],$(guilemoduledir),g' \
35 -e 's,[@]guileobjectdir[@],$(guileobjectdir),g' \
36 -e 's,[@]localedir[@],$(localedir),g'
37
38scripts/guix: scripts/guix.in Makefile
39 $(AM_V_at)rm -f $@ $@-t
40 $(AM_V_at)$(MKDIR_P) "$(@D)"
41 $(AM_V_GEN)$(do_subst) < "$(srcdir)/$@.in" > "$@-t"
42 $(AM_V_at)chmod a+x,a-w "$@-t" && mv -f "$@-t" "$@"
31 43
32nodist_noinst_SCRIPTS = \ 44nodist_noinst_SCRIPTS = \
33 pre-inst-env \ 45 pre-inst-env \
@@ -437,6 +449,7 @@ EXTRA_DIST = \
437 TODO \ 449 TODO \
438 CODE-OF-CONDUCT \ 450 CODE-OF-CONDUCT \
439 .dir-locals.el \ 451 .dir-locals.el \
452 bin/guix.in \
440 build-aux/build-self.scm \ 453 build-aux/build-self.scm \
441 build-aux/compile-all.scm \ 454 build-aux/compile-all.scm \
442 build-aux/hydra/evaluate.scm \ 455 build-aux/hydra/evaluate.scm \
@@ -473,6 +486,7 @@ endif !BUILD_DAEMON_OFFLOAD
473 486
474 487
475CLEANFILES = \ 488CLEANFILES = \
489 $(bin_SCRIPTS) \
476 $(GOBJECTS) \ 490 $(GOBJECTS) \
477 $(SCM_TESTS:tests/%.scm=%.log) 491 $(SCM_TESTS:tests/%.scm=%.log)
478 492
diff --git a/configure.ac b/configure.ac
index 1e391224835..f69f796484d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,6 +124,8 @@ dnl Make sure we don't suffer from the bug in 'equal?' wrt. syntax objects
124dnl found in 2.2.1. See <https://bugs.gnu.org/29903>. 124dnl found in 2.2.1. See <https://bugs.gnu.org/29903>.
125GUIX_ASSERT_SYNTAX_OBJECT_EQUAL 125GUIX_ASSERT_SYNTAX_OBJECT_EQUAL
126 126
127AC_PROG_SED
128
127dnl Decompressors, for use by the substituter and other modules. 129dnl Decompressors, for use by the substituter and other modules.
128AC_PATH_PROG([GZIP], [gzip]) 130AC_PATH_PROG([GZIP], [gzip])
129AC_PATH_PROG([BZIP2], [bzip2]) 131AC_PATH_PROG([BZIP2], [bzip2])
@@ -272,7 +274,6 @@ AC_CONFIG_FILES([Makefile
272 po/packages/Makefile.in 274 po/packages/Makefile.in
273 guix/config.scm]) 275 guix/config.scm])
274 276
275AC_CONFIG_FILES([scripts/guix], [chmod +x scripts/guix])
276AC_CONFIG_FILES([test-env:build-aux/test-env.in], [chmod +x test-env]) 277AC_CONFIG_FILES([test-env:build-aux/test-env.in], [chmod +x test-env])
277AC_CONFIG_FILES([pre-inst-env:build-aux/pre-inst-env.in], 278AC_CONFIG_FILES([pre-inst-env:build-aux/pre-inst-env.in],
278 [chmod +x pre-inst-env]) 279 [chmod +x pre-inst-env])
diff --git a/scripts/guix.in b/scripts/guix.in
index e20c274242a..af50a782bbb 100644
--- a/scripts/guix.in
+++ b/scripts/guix.in
@@ -3,6 +3,7 @@
3!# 3!#
4;;; GNU Guix --- Functional package management for GNU 4;;; GNU Guix --- Functional package management for GNU
5;;; Copyright © 2013 Mark H Weaver <mhw@netris.org> 5;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
6;;; Copyright © 2018 Mathieu Lirzin <mthl@gnu.org>
6;;; 7;;;
7;;; This file is part of GNU Guix. 8;;; This file is part of GNU Guix.
8;;; 9;;;
@@ -22,35 +23,15 @@
22;; IMPORTANT: We must avoid loading any modules from Guix here, 23;; IMPORTANT: We must avoid loading any modules from Guix here,
23;; because we need to adjust the guile load paths first. 24;; because we need to adjust the guile load paths first.
24;; It's okay to import modules from core Guile though. 25;; It's okay to import modules from core Guile though.
25(use-modules (ice-9 regex) 26(use-modules (srfi srfi-26))
26 (srfi srfi-26))
27 27
28(let () 28(let ()
29 (define-syntax-rule (push! elt v) (set! v (cons elt v))) 29 (define-syntax-rule (push! elt v) (set! v (cons elt v)))
30 30
31 (define config-lookup
32 (let ((config '(("prefix" . "@prefix@")
33 ("exec_prefix" . "@exec_prefix@")
34 ("datarootdir" . "@datarootdir@")
35 ("guilemoduledir" . "@guilemoduledir@")
36 ("guileobjectdir" . "@guileobjectdir@")
37 ("localedir" . "@localedir@")))
38 (var-ref-regexp (make-regexp "\\$\\{([a-z_]+)\\}")))
39 (define (expand-var-ref match)
40 (lookup (match:substring match 1)))
41 (define (expand str)
42 (regexp-substitute/global #f var-ref-regexp str
43 'pre expand-var-ref 'post))
44 (define (lookup name)
45 (expand (assoc-ref config name)))
46 lookup))
47
48 (define (maybe-augment-load-paths!) 31 (define (maybe-augment-load-paths!)
49 (unless (getenv "GUIX_UNINSTALLED") 32 (unless (getenv "GUIX_UNINSTALLED")
50 (let ((module-dir (config-lookup "guilemoduledir")) 33 (push! "@guilemoduledir@" %load-path)
51 (object-dir (config-lookup "guileobjectdir"))) 34 (push! "@guileobjectdir@" %load-compiled-path)
52 (push! module-dir %load-path)
53 (push! object-dir %load-compiled-path))
54 (let ((updates-dir (and=> (or (getenv "XDG_CONFIG_HOME") 35 (let ((updates-dir (and=> (or (getenv "XDG_CONFIG_HOME")
55 (and=> (getenv "HOME") 36 (and=> (getenv "HOME")
56 (cut string-append <> "/.config"))) 37 (cut string-append <> "/.config")))
@@ -64,8 +45,8 @@
64 (define (run-guix-main) 45 (define (run-guix-main)
65 (let ((guix-main (module-ref (resolve-interface '(guix ui)) 46 (let ((guix-main (module-ref (resolve-interface '(guix ui))
66 'guix-main))) 47 'guix-main)))
67 (bindtextdomain "guix" (config-lookup "localedir")) 48 (bindtextdomain "guix" "@localedir@")
68 (bindtextdomain "guix-packages" (config-lookup "localedir")) 49 (bindtextdomain "guix-packages" "@localedir@")
69 (apply guix-main (command-line)))) 50 (apply guix-main (command-line))))
70 51
71 (maybe-augment-load-paths!) 52 (maybe-augment-load-paths!)