aboutsummaryrefslogtreecommitdiff
# GNU Guix --- Functional package management for GNU
# Copyright © 2012-2024 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2013 Andreas Enge <andreas@enge.fr>
# Copyright © 2015, 2017 Alex Kost <alezost@gmail.com>
# Copyright © 2016, 2018 Mathieu Lirzin <mthl@gnu.org>
# Copyright © 2016, 2017, 2018, 2019 Mark H Weaver <mhw@netris.org>
# Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
# Copyright © 2017 Leo Famulari <leo@famulari.name>
# Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
# Copyright © 2017, 2020, 2023, 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
# Copyright © 2018 Nikita <nikita@n0.is>
# Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
# Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
# Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
# Copyright © 2019, 2023 Efraim Flashner <efraim@flashner.co.il>
# Copyright © 2020, 2021, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
# Copyright © 2021 Andrew Tropin <andrew@trop.in>
# Copyright © 2023 Clément Lassieur <clement@lassieur.org>
# Copyright © 2023, 2024 Wilko Meyer <w@wmeyer.eu>
# Copyright © 2024 gemmaro <gemmaro.dev@gmail.com>
#
# This file is part of GNU Guix.
#
# GNU Guix is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# GNU Guix is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

MSGMERGE_UPDATE = @MSGMERGE@ --update

bin_SCRIPTS = scripts/guix

# Handle substitution of fully-expanded Autoconf variables.
do_subst = $(SED)					\
  -e 's,[@]GUILE[@],$(GUILE),g'				\
  -e 's,[@]guilemoduledir[@],$(guilemoduledir),g'	\
  -e 's,[@]guileobjectdir[@],$(guileobjectdir),g'	\
  -e 's,[@]abs_top_builddir[@],$(abs_top_builddir),g'	\
  -e 's,[@]localedir[@],$(localedir),g'

scripts/guix: scripts/guix.in Makefile
	$(AM_V_at)rm -f $@ $@-t
	$(AM_V_at)$(MKDIR_P) "$(@D)"
	$(AM_V_GEN)$(do_subst) < "$(srcdir)/$@.in" > "$@-t"
	$(AM_V_at)chmod a+x,a-w "$@-t" && mv -f "$@-t" "$@"

# This is our variant of the 'guile' executable, one that doesn't complain
# about locales.
pkglibexec_PROGRAMS = guile
guile_SOURCES = gnu/packages/aux-files/guile-launcher.c
guile_LDADD   = $(GUILE_LIBS)
guile_CFLAGS  = $(GUILE_CFLAGS)

# Have the 'guix' command refer to our 'guile'.
install-exec-hook:
	$(SED) -i "$(DESTDIR)$(bindir)/guix"				\
	       -e 's,^#![[:graph:]]\+,#!$(pkglibexecdir)/guile,g'

nodist_noinst_SCRIPTS =				\
  pre-inst-env					\
  test-env

# Modules that are not compiled but are installed nonetheless, such as
# build-side modules with unusual dependencies.
MODULES_NOT_COMPILED =				\
  guix/build/po.scm				\
  guix/man-db.scm

include gnu/local.mk
include po/doc/local.mk

MODULES =					\
  guix/base16.scm				\
  guix/base32.scm				\
  guix/base64.scm				\
  guix/ci.scm					\
  guix/cpio.scm					\
  guix/cpu.scm					\
  guix/deprecation.scm				\
  guix/docker.scm	   			\
  guix/records.scm				\
  guix/openpgp.scm				\
  guix/pki.scm					\
  guix/progress.scm				\
  guix/combinators.scm				\
  guix/memoization.scm				\
  guix/utils.scm				\
  guix/sets.scm					\
  guix/modules.scm				\
  guix/download.scm				\
  guix/discovery.scm				\
  guix/android-repo-download.scm		\
  guix/bzr-download.scm            		\
  guix/git-download.scm				\
  guix/hg-download.scm				\
  guix/hash.scm					\
  guix/swh.scm					\
  guix/monads.scm				\
  guix/monad-repl.scm				\
  guix/gexp.scm					\
  guix/profiles.scm				\
  guix/serialization.scm			\
  guix/nar.scm					\
  guix/narinfo.scm				\
  guix/derivations.scm				\
  guix/grafts.scm				\
  guix/repl.scm					\
  guix/rpm.scm					\
  guix/transformations.scm			\
  guix/inferior.scm				\
  guix/describe.scm				\
  guix/quirks.scm				\
  guix/channels.scm				\
  guix/gnu-maintenance.scm			\
  guix/self.scm					\
  guix/substitutes.scm				\
  guix/upstream.scm				\
  guix/licenses.scm				\
  guix/lint.scm				\
  guix/glob.scm					\
  guix/git.scm					\
  guix/git-authenticate.scm			\
  guix/graph.scm				\
  guix/cache.scm				\
  guix/cve.scm					\
  guix/workers.scm				\
  guix/least-authority.scm			\
  guix/read-print.scm				\
  guix/ipfs.scm					\
  guix/platform.scm                             \
  guix/platforms/arm.scm                        \
  guix/platforms/avr.scm                        \
  guix/platforms/mips.scm                       \
  guix/platforms/or1k.scm                       \
  guix/platforms/powerpc.scm                    \
  guix/platforms/riscv.scm                      \
  guix/platforms/x86.scm                        \
  guix/platforms/xtensa.scm                     \
  guix/build-system.scm				\
  guix/build-system/agda.scm			\
  guix/build-system/android-ndk.scm		\
  guix/build-system/ant.scm			\
  guix/build-system/asdf.scm			\
  guix/build-system/cargo.scm			\
  guix/build-system/channel.scm		\
  guix/build-system/chicken.scm		\
  guix/build-system/clojure.scm		\
  guix/build-system/cmake.scm			\
  guix/build-system/copy.scm			\
  guix/build-system/composer.scm		\
  guix/build-system/dub.scm			\
  guix/build-system/dune.scm			\
  guix/build-system/elm.scm			\
  guix/build-system/emacs.scm			\
  guix/build-system/font.scm			\
  guix/build-system/glib-or-gtk.scm		\
  guix/build-system/gnu.scm			\
  guix/build-system/go.scm			\
  guix/build-system/guile.scm			\
  guix/build-system/haskell.scm		\
  guix/build-system/julia.scm			\
  guix/build-system/linux-module.scm		\
  guix/build-system/maven.scm			\
  guix/build-system/meson.scm			\
  guix/build-system/minetest.scm		\
  guix/build-system/minify.scm			\
  guix/build-system/mix.scm			\
  guix/build-system/mozilla.scm		\
  guix/build-system/node.scm			\
  guix/build-system/ocaml.scm			\
  guix/build-system/perl.scm			\
  guix/build-system/pyproject.scm		\
  guix/build-system/python.scm			\
  guix/build-system/qt.scm			\
  guix/build-system/r.scm			\
  guix/build-system/rakudo.scm			\
  guix/build-system/rebar.scm			\
  guix/build-system/renpy.scm			\
  guix/build-system/ruby.scm			\
  guix/build-system/scons.scm			\
  guix/build-system/texlive.scm		\
  guix/build-system/tree-sitter.scm		\
  guix/build-system/trivial.scm		\
  guix/build-system/vim.scm			\
  guix/build-system/waf.scm			\
  guix/build-system/zig.scm			\
  guix/ftp-client.scm				\
  guix/http-client.scm				\
  guix/gnupg.scm				\
  guix/elf.scm					\
  guix/profiling.scm				\
  guix/store.scm				\
  guix/cvs-download.scm				\
  guix/svn-download.scm				\
  guix/colors.scm				\
  guix/i18n.scm					\
  guix/diagnostics.scm				\
  guix/ui.scm					\
  guix/status.scm				\
  guix/build/agda-build-system.scm              \
  guix/build/android-ndk-build-system.scm	\
  guix/build/ant-build-system.scm		\
  guix/build/download.scm			\
  guix/build/download-nar.scm			\
  guix/build/cargo-build-system.scm		\
  guix/build/cargo-utils.scm			\
  guix/build/chicken-build-system.scm		\
  guix/build/cmake-build-system.scm		\
  guix/build/composer-build-system.scm		\
  guix/build/dub-build-system.scm		\
  guix/build/dune-build-system.scm		\
  guix/build/elm-build-system.scm		\
  guix/build/emacs-build-system.scm		\
  guix/build/meson-build-system.scm		\
  guix/build/minify-build-system.scm		\
  guix/build/font-build-system.scm		\
  guix/build/go-build-system.scm		\
  guix/build/android-repo.scm			\
  guix/build/asdf-build-system.scm		\
  guix/build/bzr.scm				\
  guix/build/copy-build-system.scm		\
  guix/build/git.scm				\
  guix/build/hg.scm				\
  guix/build/glib-or-gtk-build-system.scm	\
  guix/build/gnu-bootstrap.scm			\
  guix/build/gnu-build-system.scm		\
  guix/build/gnu-dist.scm			\
  guix/build/guile-build-system.scm		\
  guix/build/maven-build-system.scm		\
  guix/build/minetest-build-system.scm		\
  guix/build/mix-build-system.scm		\
  guix/build/node-build-system.scm		\
  guix/build/perl-build-system.scm		\
  guix/build/pyproject-build-system.scm		\
  guix/build/python-build-system.scm		\
  guix/build/ocaml-build-system.scm		\
  guix/build/qt-build-system.scm		\
  guix/build/r-build-system.scm			\
  guix/build/renpy-build-system.scm			\
  guix/build/rakudo-build-system.scm		\
  guix/build/rebar-build-system.scm		\
  guix/build/ruby-build-system.scm		\
  guix/build/scons-build-system.scm		\
  guix/build/texlive-build-system.scm		\
  guix/build/tree-sitter-build-system.scm	\
  guix/build/vim-build-system.scm		\
  guix/build/waf-build-system.scm		\
  guix/build/haskell-build-system.scm		\
  guix/build/julia-build-system.scm		\
  guix/build/kconfig.scm			\
  guix/build/linux-module-build-system.scm	\
  guix/build/store-copy.scm			\
  guix/build/json.scm				\
  guix/build/pack.scm				\
  guix/build/utils.scm				\
  guix/build/union.scm				\
  guix/build/profiles.scm			\
  guix/build/compile.scm			\
  guix/build/cvs.scm				\
  guix/build/svn.scm				\
  guix/build/syscalls.scm                       \
  guix/build/gremlin.scm			\
  guix/build/debug-link.scm			\
  guix/build/clojure-build-system.scm		\
  guix/build/clojure-utils.scm			\
  guix/build/emacs-utils.scm			\
  guix/build/java-utils.scm			\
  guix/build/lisp-utils.scm			\
  guix/build/meson-configuration.scm		\
  guix/build/maven/java.scm			\
  guix/build/maven/plugin.scm			\
  guix/build/maven/pom.scm			\
  guix/build/graft.scm				\
  guix/build/bournish.scm			\
  guix/build/qt-utils.scm			\
  guix/build/zig-build-system.scm		\
  guix/build/make-bootstrap.scm			\
  guix/search-paths.scm				\
  guix/packages.scm				\
  guix/import/cabal.scm				\
  guix/import/composer.scm			\
  guix/import/cpan.scm				\
  guix/import/cran.scm				\
  guix/import/crate.scm				\
  guix/import/egg.scm   			\
  guix/import/elm.scm				\
  guix/import/elpa.scm   			\
  guix/import/gem.scm				\
  guix/import/git.scm                           \
  guix/import/github.scm   			\
  guix/import/gnome.scm				\
  guix/import/gnu.scm				\
  guix/import/go.scm				\
  guix/import/hackage.scm			\
  guix/import/hexpm.scm				\
  guix/import/json.scm				\
  guix/import/kde.scm				\
  guix/import/launchpad.scm   			\
  guix/import/minetest.scm   			\
  guix/import/npm-binary.scm			\
  guix/import/opam.scm				\
  guix/import/print.scm				\
  guix/import/pypi.scm				\
  guix/import/stackage.scm			\
  guix/import/test.scm   			\
  guix/import/texlive.scm   			\
  guix/import/utils.scm				\
  guix/scripts.scm				\
  guix/scripts/download.scm			\
  guix/scripts/perform-download.scm		\
  guix/scripts/build.scm			\
  guix/scripts/archive.scm			\
  guix/scripts/import.scm			\
  guix/scripts/package.scm			\
  guix/scripts/locate.scm			\
  guix/scripts/install.scm			\
  guix/scripts/remove.scm			\
  guix/scripts/upgrade.scm			\
  guix/scripts/search.scm			\
  guix/scripts/show.scm				\
  guix/scripts/gc.scm				\
  guix/scripts/hash.scm				\
  guix/scripts/pack.scm				\
  guix/scripts/pull.scm				\
  guix/scripts/processes.scm			\
  guix/scripts/substitute.scm			\
  guix/scripts/authenticate.scm			\
  guix/scripts/refresh.scm			\
  guix/scripts/repl.scm				\
  guix/scripts/describe.scm			\
  guix/scripts/style.scm			\
  guix/scripts/system.scm			\
  guix/scripts/system/edit.scm			\
  guix/scripts/system/reconfigure.scm		\
  guix/scripts/system/search.scm		\
  guix/scripts/home.scm			\
  guix/scripts/home/edit.scm			\
  guix/scripts/home/import.scm			\
  guix/scripts/lint.scm				\
  guix/scripts/challenge.scm			\
  guix/scripts/import/composer.scm		\
  guix/scripts/import/crate.scm			\
  guix/scripts/import/cpan.scm			\
  guix/scripts/import/cran.scm			\
  guix/scripts/import/egg.scm   		\
  guix/scripts/import/elm.scm			\
  guix/scripts/import/elpa.scm  		\
  guix/scripts/import/gem.scm			\
  guix/scripts/import/gnu.scm			\
  guix/scripts/import/go.scm			\
  guix/scripts/import/hackage.scm		\
  guix/scripts/import/hexpm.scm			\
  guix/scripts/import/json.scm  		\
  guix/scripts/import/minetest.scm  		\
  guix/scripts/import/npm-binary.scm		\
  guix/scripts/import/opam.scm			\
  guix/scripts/import/pypi.scm			\
  guix/scripts/import/stackage.scm		\
  guix/scripts/import/texlive.scm  		\
  guix/scripts/environment.scm			\
  guix/scripts/shell.scm			\
  guix/scripts/publish.scm			\
  guix/scripts/edit.scm				\
  guix/scripts/size.scm				\
  guix/scripts/git.scm				\
  guix/scripts/git/authenticate.scm		\
  guix/scripts/graph.scm			\
  guix/scripts/weather.scm			\
  guix/scripts/container.scm			\
  guix/scripts/container/exec.scm		\
  guix/scripts/deploy.scm			\
  guix/scripts/time-machine.scm			\
  guix.scm					\
  $(GNU_SYSTEM_MODULES)

if HAVE_GUILE_SSH

MODULES +=					\
  guix/ssh.scm					\
  guix/remote.scm				\
  guix/scripts/copy.scm				\
  guix/store/ssh.scm

endif HAVE_GUILE_SSH

if HAVE_GUILE_AVAHI

MODULES += 					\
  guix/avahi.scm				\
  guix/scripts/discover.scm

endif HAVE_GUILE_AVAHI

if BUILD_DAEMON_OFFLOAD

MODULES +=					\
  guix/scripts/offload.scm

endif BUILD_DAEMON_OFFLOAD

# Scheme implementation of the build daemon and related functionality.
STORE_MODULES =					\
  guix/store/database.scm			\
  guix/store/deduplication.scm			\
  guix/store/roots.scm

MODULES += $(STORE_MODULES)

# Internal modules with test suite support.
dist_noinst_DATA =				\
  guix/tests.scm				\
  guix/tests/http.scm				\
  guix/tests/git.scm				\
  guix/tests/gnupg.scm

# Auxiliary files for packages.
AUX_FILES =						\
  gnu/packages/aux-files/chromium/master-preferences.json		\
  gnu/packages/aux-files/emacs/comp-integrity.el		\
  gnu/packages/aux-files/emacs/comp-integrity-next.el		\
  gnu/packages/aux-files/emacs/guix-emacs.el		\
  gnu/packages/aux-files/findclass.php			\
  gnu/packages/aux-files/guix.vim			\
  gnu/packages/aux-files/linux-libre/6.10-arm.conf	\
  gnu/packages/aux-files/linux-libre/6.10-arm64.conf	\
  gnu/packages/aux-files/linux-libre/6.10-i686.conf	\
  gnu/packages/aux-files/linux-libre/6.10-x86_64.conf	\
  gnu/packages/aux-files/linux-libre/6.10-riscv.conf	\
  gnu/packages/aux-files/linux-libre/6.6-arm.conf	\
  gnu/packages/aux-files/linux-libre/6.6-arm64.conf	\
  gnu/packages/aux-files/linux-libre/6.6-i686.conf	\
  gnu/packages/aux-files/linux-libre/6.6-x86_64.conf	\
  gnu/packages/aux-files/linux-libre/6.1-arm.conf	\
  gnu/packages/aux-files/linux-libre/6.1-arm64.conf	\
  gnu/packages/aux-files/linux-libre/6.1-i686.conf	\
  gnu/packages/aux-files/linux-libre/6.1-x86_64.conf	\
  gnu/packages/aux-files/linux-libre/5.15-arm.conf	\
  gnu/packages/aux-files/linux-libre/5.15-arm64.conf	\
  gnu/packages/aux-files/linux-libre/5.15-i686.conf	\
  gnu/packages/aux-files/linux-libre/5.15-x86_64.conf	\
  gnu/packages/aux-files/linux-libre/5.10-arm.conf	\
  gnu/packages/aux-files/linux-libre/5.10-arm64.conf	\
  gnu/packages/aux-files/linux-libre/5.10-i686.conf	\
  gnu/packages/aux-files/linux-libre/5.10-x86_64.conf	\
  gnu/packages/aux-files/linux-libre/5.4-arm.conf	\
  gnu/packages/aux-files/linux-libre/5.4-arm64.conf	\
  gnu/packages/aux-files/linux-libre/5.4-i686.conf	\
  gnu/packages/aux-files/linux-libre/5.4-x86_64.conf	\
  gnu/packages/aux-files/linux-libre/4.19-arm.conf	\
  gnu/packages/aux-files/linux-libre/4.19-arm64.conf	\
  gnu/packages/aux-files/linux-libre/4.19-i686.conf	\
  gnu/packages/aux-files/linux-libre/4.19-x86_64.conf	\
  gnu/packages/aux-files/pack-audit.c			\
  gnu/packages/aux-files/python/sanity-check.py		\
  gnu/packages/aux-files/python/sitecustomize.py	\
  gnu/packages/aux-files/renpy/renpy.in	\
  gnu/packages/aux-files/run-in-namespace.c		\
  gnu/packages/aux-files/xml/patch-catalog-xml.xsl	\
  gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml

# Templates, examples.
EXAMPLES =					\
  gnu/system/examples/asus-c201.tmpl		\
  gnu/system/examples/bare-bones.tmpl		\
  gnu/system/examples/bare-hurd.tmpl		\
  gnu/system/examples/beaglebone-black.tmpl	\
  gnu/system/examples/desktop.tmpl		\
  gnu/system/examples/lightweight-desktop.tmpl	\
  gnu/system/examples/docker-image.tmpl		\
  gnu/system/examples/plasma.tmpl		\
  gnu/system/examples/raspberry-pi-64.tmpl	\
  gnu/system/examples/raspberry-pi-64-nfs-root.tmpl	\
  gnu/system/examples/vm-image.tmpl

GOBJECTS = $(MODULES:%.scm=%.go) guix/config.go $(dist_noinst_DATA:%.scm=%.go)

nobase_dist_guilemodule_DATA =					\
  guix/d3.v3.js							\
  guix/graph.js							\
  guix/store/schema.sql						\
  $(MODULES) $(MODULES_NOT_COMPILED) $(AUX_FILES) $(EXAMPLES)	\
  $(MISC_DISTRO_FILES)
nobase_nodist_guilemodule_DATA = guix/config.scm
nobase_nodist_guileobject_DATA = $(GOBJECTS)

# Handy way to remove the .go files without removing all the rest.
clean-go:
	-$(RM) -f $(GOBJECTS)
	@find . -path ./test-tmp -prune -o -name '*.go' -print | \
	  if test -t 1; then \
	    xargs -r echo -e "\033[31mwarning:\033[0m stray .go files:"; \
	  else \
	    xargs -r echo "warning: stray .go files:"; \
	  fi


# Test extensions; has to be unconditional.
TEST_EXTENSIONS = .scm .sh

if CAN_RUN_TESTS

SCM_TESTS =					\
  tests/accounts.scm				\
  tests/base16.scm				\
  tests/base32.scm				\
  tests/base64.scm				\
  tests/boot-parameters.scm			\
  tests/bournish.scm				\
  tests/builders.scm				\
  tests/build-emacs-utils.scm			\
  tests/build-utils.scm			\
  tests/cache.scm				\
  tests/challenge.scm				\
  tests/channels.scm				\
  tests/combinators.scm			\
  tests/composer.scm				\
  tests/containers.scm				\
  tests/cpan.scm				\
  tests/cpio.scm				\
  tests/cran.scm				\
  tests/crate.scm				\
  tests/cve.scm				\
  tests/debug-link.scm				\
  tests/derivations.scm			\
  tests/discovery.scm				\
  tests/egg.scm				\
  tests/elm.scm				\
  tests/elpa.scm				\
  tests/file-systems.scm			\
  tests/gem.scm				\
  tests/gexp.scm				\
  tests/git.scm					\
  tests/git-authenticate.scm			\
  tests/glob.scm				\
  tests/gnu-maintenance.scm			\
  tests/grafts.scm				\
  tests/graph.scm				\
  tests/gremlin.scm				\
  tests/hackage.scm				\
  tests/home-import.scm				\
  tests/home-services.scm			\
  tests/http-client.scm				\
  tests/import-git.scm				\
  tests/import-github.scm			\
  tests/import-utils.scm			\
  tests/inferior.scm				\
  tests/lint.scm				\
  tests/minetest.scm				\
  tests/modules.scm				\
  tests/monads.scm				\
  tests/nar.scm				\
  tests/npm-binary.scm				\
  tests/networking.scm				\
  tests/opam.scm				\
  tests/openpgp.scm				\
  tests/packages.scm				\
  tests/pack.scm				\
  tests/pki.scm				\
  tests/print.scm				\
  tests/processes.scm				\
  tests/profiles.scm				\
  tests/publish.scm				\
  tests/pypi.scm				\
  tests/read-print.scm				\
  tests/records.scm				\
  tests/rpm.scm					\
  tests/scripts.scm				\
  tests/search-paths.scm			\
  tests/services.scm				\
  tests/services/file-sharing.scm		\
  tests/services/configuration.scm		\
  tests/services/lightdm.scm			\
  tests/services/linux.scm			\
  tests/services/pam-mount.scm			\
  tests/services/telephony.scm			\
  tests/services/vpn.scm			\
  tests/sets.scm				\
  tests/size.scm				\
  tests/status.scm				\
  tests/store-database.scm			\
  tests/store-deduplication.scm		\
  tests/store-roots.scm			\
  tests/store.scm				\
  tests/substitute.scm				\
  tests/swh.scm				\
  tests/syscalls.scm				\
  tests/system.scm				\
  tests/style.scm				\
  tests/texlive.scm				\
  tests/transformations.scm			\
  tests/ui.scm					\
  tests/union.scm				\
  tests/upstream.scm				\
  tests/utils.scm				\
  tests/uuid.scm				\
  tests/workers.scm

if HAVE_GUILE_LIB
SCM_TESTS += tests/go.scm
else
EXTRA_DIST += tests/go.scm
endif

if BUILD_DAEMON_OFFLOAD
SCM_TESTS  += tests/offload.scm
else
EXTRA_DIST += tests/offload.scm
endif

SH_TESTS =					\
  tests/guix-build.sh				\
  tests/guix-build-branch.sh			\
  tests/guix-download.sh			\
  tests/guix-gc.sh				\
  tests/guix-git-authenticate.sh		\
  tests/guix-hash.sh				\
  tests/guix-locate.sh				\
  tests/guix-pack.sh				\
  tests/guix-pack-localstatedir.sh		\
  tests/guix-pack-relocatable.sh		\
  tests/guix-package.sh				\
  tests/guix-package-aliases.sh			\
  tests/guix-package-net.sh			\
  tests/guix-style.sh				\
  tests/guix-system.sh				\
  tests/guix-home.sh				\
  tests/guix-archive.sh				\
  tests/guix-authenticate.sh			\
  tests/guix-environment.sh			\
  tests/guix-environment-container.sh		\
  tests/guix-refresh.sh				\
  tests/guix-shell.sh				\
  tests/guix-shell-export-manifest.sh		\
  tests/guix-time-machine.sh			\
  tests/guix-graph.sh				\
  tests/guix-describe.sh			\
  tests/guix-repl.sh     			\
  tests/guix-lint.sh

TESTS = $(SCM_TESTS) $(SH_TESTS)

AM_TESTS_ENVIRONMENT = abs_top_srcdir="$(abs_top_srcdir)" GUILE_AUTO_COMPILE=0

SCM_LOG_DRIVER =				\
  $(top_builddir)/test-env --quiet-stderr	\
  $(GUILE) --no-auto-compile -e main		\
      $(top_srcdir)/build-aux/test-driver.scm

AM_SCM_LOG_DRIVER_FLAGS = --brief=yes

SH_LOG_COMPILER = $(top_builddir)/test-env $(SHELL)
AM_SH_LOG_FLAGS = -x -e

# Make sure `tests/guix-gc.sh' runs last, after all the others.  Otherwise it
# could end up removing files from the store while they are being used by
# other instances of the daemon.
tests/guix-gc.log:							\
  $(patsubst %.sh,%.log,$(filter-out tests/guix-gc.sh,$(SH_TESTS)))	\
  $(SCM_TESTS:%.scm=%.log)

else !CAN_RUN_TESTS

TESTS =
SH_TESTS =
SCM_TESTS =

# Automake always generates a 'check' target, so better not override it.
check-local:
	@echo
	@echo "Cannot run tests because file name limits would be exceeded." >&2
	@echo "Look for 'length' in the 'config.log' file for details." >&2
	@echo
	@exit 1

endif !CAN_RUN_TESTS

check-system: $(GOBJECTS)
	$(AM_V_at)$(top_builddir)/pre-inst-env			\
	  guix build -m $(top_srcdir)/etc/system-tests.scm -K

# Public keys used to sign substitutes.
dist_pkgdata_DATA =				\
  etc/substitutes/berlin.guix.gnu.org.pub	\
  etc/substitutes/ci.guix.gnu.org.pub		\
  etc/substitutes/ci.guix.info.pub		\
  etc/substitutes/bordeaux.guix.gnu.org.pub

# Bash completion file.
dist_bashcompletion_DATA = etc/completion/bash/guix	\
  etc/completion/bash/guix-daemon

# Zsh completion file.
dist_zshcompletion_DATA = etc/completion/zsh/_guix

# Fish completion file.
dist_fishcompletion_DATA = etc/completion/fish/guix.fish

# SELinux policy
nodist_selinux_policy_DATA = etc/guix-daemon.cil

EXTRA_DIST +=						\
  .dir-locals.el					\
  .guix-authorizations					\
  .guix-channel						\
  CODE-OF-CONDUCT					\
  HACKING						\
  ROADMAP						\
  TODO							\
  bootstrap						\
  manifest.scm						\
  build-aux/build-self.scm				\
  build-aux/check-channel-news.scm			\
  build-aux/check-final-inputs-self-contained.scm	\
  build-aux/compile-all.scm				\
  build-aux/compile-as-derivation.scm			\
  build-aux/config.rpath				\
  build-aux/convert-xref.scm				\
  build-aux/generate-authors.scm			\
  build-aux/git-version-gen				\
  build-aux/mdate-from-git.scm				\
  build-aux/test-driver.scm				\
  build-aux/update-NEWS.scm				\
  build-aux/update-guix-package.scm			\
  build-aux/xgettext.scm				\
  doc/build.scm						\
  etc/disarchive-manifest.scm				\
  etc/guix-install.sh					\
  etc/historical-authorizations				\
  etc/news.scm						\
  etc/hurd-manifest.scm					\
  etc/kernels-manifest.scm				\
  etc/release-manifest.scm				\
  etc/source-manifest.scm				\
  etc/system-tests.scm					\
  etc/time-travel-manifest.scm				\
  scripts/guix.in					\
  tests/cve-sample.json					\
  tests/keys/civodul.pub				\
  tests/keys/dsa.pub					\
  tests/keys/ed25519-2.pub				\
  tests/keys/ed25519-2.sec				\
  tests/keys/ed25519-3.pub				\
  tests/keys/ed25519-3.sec				\
  tests/keys/ed25519.pub				\
  tests/keys/ed25519.sec				\
  tests/keys/rsa.pub					\
  tests/keys/signing-key.pub				\
  tests/keys/signing-key.sec				\
  tests/test.drv					\
  $(TESTS)

if !BUILD_DAEMON_OFFLOAD

EXTRA_DIST +=					\
  guix/scripts/offload.scm

endif !BUILD_DAEMON_OFFLOAD


CLEANFILES =					\
  $(bin_SCRIPTS)				\
  $(GOBJECTS)					\
  $(SCM_TESTS:tests/%.scm=%.log)

# Unset 'GUILE_LOAD_COMPILED_PATH' altogether while compiling.  Otherwise, if
# $GUILE_LOAD_COMPILED_PATH contains $(moduledir), we may find .go files in
# there that are newer than the local .scm files (for instance because the
# user ran 'make install' recently).  When that happens, we end up loading
# those previously-installed .go files, which may be stale, thereby breaking
# the whole thing.  Likewise, set 'XDG_CACHE_HOME' to avoid loading possibly
# stale files from ~/.cache/guile/ccache.
%.go: make-go ; @:
make-go: make-core-go make-packages-go make-system-go make-cli-go

# Define a rule to build a subset of the .go files.
define guile-compilation-rule

$(1): $(2)
	$(AM_V_at)echo "Compiling Scheme modules..." ;		\
	unset GUILE_LOAD_COMPILED_PATH ;			\
	XDG_CACHE_HOME=/nowhere					\
	host=$(host) srcdir="$(top_srcdir)"			\
	$(top_builddir)/pre-inst-env				\
	$(GUILE) -L "$(top_builddir)" -L "$(top_srcdir)"	\
	  --no-auto-compile					\
	  -s "$(top_srcdir)"/build-aux/compile-all.scm		\
	  --total $(words $(MODULES))				\
	  --completed $(3)					\
	  $$(filter %.scm,$$^)

endef

# Split compilation in several steps, each of which building a subset of
# $(MODULES).  The main goal is to reduce peak memory consumption, as reported
# in <https://issues.guix.gnu.org/48963>.  Each 'eval' call below creates a
# 'make-*-go' phony target that builds the corresponding subset.

first_fifth :=								\
  gnu/packages/a% gnu/packages/b% gnu/packages/c%

second_fifth :=								\
  gnu/packages/d% gnu/packages/e% gnu/packages/f%

third_fifth :=								\
  gnu/packages/g%  gnu/packages/h% gnu/packages/i%

fourth_fifth :=								\
  gnu/packages/j% gnu/packages/k% gnu/packages/l% gnu/packages/m% 	\
  gnu/packages/n% gnu/packages/o%

MODULES_CORE      := guix.scm $(filter-out guix/scripts/%,$(filter guix/%,$(MODULES)))
MODULES_PACKAGES1 := $(filter $(first_fifth),$(MODULES))
MODULES_PACKAGES2 := $(filter $(second_fifth),$(MODULES))
MODULES_PACKAGES3 := $(filter $(third_fifth),$(MODULES))
MODULES_PACKAGES4 := $(filter $(fourth_fifth),$(MODULES))
MODULES_PACKAGES5 := $(filter-out $(first_fifth) $(second_fifth)	\
			$(third_fifth) $(fourth_fifth),			\
			$(filter gnu/packages/%,$(MODULES)))
MODULES_PACKAGES  := $(MODULES_PACKAGES1) $(MODULES_PACKAGES2)		\
			$(MODULES_PACKAGES3) $(MODULES_PACKAGES4)	\
			$(MODULES_PACKAGES5)
MODULES_SYSTEM    := gnu.scm $(filter-out gnu/packages/%,$(filter gnu/%,$(MODULES)))
MODULES_CLI       := $(filter guix/scripts/%,$(MODULES))
MODULES_PO        := guix/build/po.scm

$(eval $(call guile-compilation-rule,make-core-go,	\
  $(MODULES_CORE) guix/config.scm $(dist_noinst_DATA),	\
  0))
.PHONY: make-core-go

$(eval $(call guile-compilation-rule,make-packages1-go,	\
  $(MODULES_PACKAGES1) make-core-go,			\
  $(words $(MODULES_CORE))))
.PHONY: make-packages1-go

$(eval $(call guile-compilation-rule,make-packages2-go,	\
  $(MODULES_PACKAGES2) make-core-go make-packages1-go,	\
  $(words $(MODULES_CORE) $(MODULES_PACKAGES1))))
.PHONY: make-packages2-go

$(eval $(call guile-compilation-rule,make-packages3-go,				\
  $(MODULES_PACKAGES3) make-core-go make-packages1-go make-packages2-go,	\
  $(words $(MODULES_CORE) $(MODULES_PACKAGES1) $(MODULES_PACKAGES2))))
.PHONY: make-packages3-go

$(eval $(call guile-compilation-rule,make-packages4-go,			\
  $(MODULES_PACKAGES4) make-core-go make-packages1-go make-packages2-go	\
    make-packages3-go,							\
  $(words $(MODULES_CORE) $(MODULES_PACKAGES1) $(MODULES_PACKAGES2)	\
    $(MODULES_PACKAGES3))))
.PHONY: make-packages4-go

$(eval $(call guile-compilation-rule,make-packages5-go,			\
  $(MODULES_PACKAGES5) make-core-go make-packages1-go make-packages2-go	\
    make-packages3-go make-packages4-go,				\
  $(words $(MODULES_CORE) $(MODULES_PACKAGES1) $(MODULES_PACKAGES2)	\
    $(MODULES_PACKAGES3) $(MODULES_PACKAGES4))))
.PHONY: make-packages5-go

make-packages-go: make-packages1-go make-packages2-go \
  make-packages3-go make-packages4-go make-packages5-go
.PHONY: make-packages-go

$(eval $(call guile-compilation-rule,make-system-go,	\
  $(MODULES_SYSTEM) make-packages-go make-core-go,	\
  $(words $(MODULES_CORE) $(MODULES_PACKAGES))))
.PHONY: make-system-go

$(eval $(call guile-compilation-rule,make-cli-go,			\
  $(MODULES_CLI) make-system-go make-packages-go make-core-go,		\
  $(words $(MODULES_CORE) $(MODULES_PACKAGES) $(MODULES_SYSTEM))))
.PHONY: make-cli-go

$(eval $(call guile-compilation-rule,guix/build/po.go,			\
  $(MODULES_PO),							\
  0))

SUFFIXES = .go

# Make sure source files are installed first, so that the mtime of
# installed compiled files is greater than that of installed source
# files.  See
# <http://lists.gnu.org/archive/html/guile-devel/2010-07/msg00125.html>
# for details.
guix_install_go_files = install-nobase_nodist_guileobjectDATA
$(guix_install_go_files): install-nobase_dist_guilemoduleDATA

# The above trick doesn't work for 'config.go' because both 'config.scm' and
# 'config.go' are listed in $(nobase_nodist_guileobject_DATA).  Thus, give it
# special treatment.
install-data-hook:
	touch "$(DESTDIR)$(guileobjectdir)/guix/config.go"

# Assuming Guix is already installed and the daemon is up and running, this
# rule builds from $(srcdir), creating and building derivations.
as-derivation:
	$(AM_V_at)echo "Building Guix in Guix..." ;		\
	$(GUILE) --no-auto-compile				\
	  "$(top_srcdir)/build-aux/compile-as-derivation.scm"	\
	  "$(abs_top_srcdir)"

SUBDIRS = po/guix po/packages
BUILT_SOURCES =

include doc/local.mk

if BUILD_DAEMON

include nix/local.mk

endif BUILD_DAEMON

ACLOCAL_AMFLAGS = -I m4

# Pass an explicit '--localstatedir' so that configure does not error out if
# it finds an existing installation with a different localstatedir.  Inherit
# 'ac_cv_guix_test_root' so that "make check" in $(distdir) does not have to
# repopulate the whole store, and to make sure $(GUIX_TEST_ROOT) is short
# enough for shebangs.
AM_DISTCHECK_CONFIGURE_FLAGS =			\
  --localstatedir="$$dc_install_base/var"	\
  --with-libgcrypt-prefix="$(LIBGCRYPT_PREFIX)"	\
  --with-libgcrypt-libdir="$(LIBGCRYPT_LIBDIR)"	\
  --enable-daemon				\
  ac_cv_guix_test_root="$(GUIX_TEST_ROOT)"

# The self-contained tarball.
guix-binary.%.tar.xz:
	$(AM_V_GEN)GUIX_PACKAGE_PATH=					\
	tarball=`$(top_builddir)/pre-inst-env guix pack -C xz		\
	  --fallback							\
	  -s "$*" --localstatedir --profile-name=current-guix		\
	  guix` ;					\
	cp "$$tarball" "$@.tmp" ; mv "$@.tmp" "$@"

# The `dist' target has other dependencies when building from Git
# to assert and achieve reproducibility.
if in_git_p

# The dependency on dist-doc-pot-update is to clean possibly stale doc and po
# files and only then generate the .pot files, which are not checked in.
dist: dist-doc-pot-update
dist-doc-pot-update: auto-clean
	$(MAKE) guile$(EXEEXT)
	$(MAKE) -C po/guix all
	$(MAKE) -C po/packages all
	$(MAKE) doc-pot-update

dist-hook: gen-ChangeLog gen-AUTHORS

# Assert that Autotools cache is up to date with Git, by checking
# PACKAGE_VERSION against HEAD.  Indented to get past Automake.
 ifeq ($(MAKECMDGOALS),dist)
 git_version = $(shell build-aux/git-version-gen .tarball-version)
 ifneq ($(PACKAGE_VERSION),$(git_version))
 $(warning Autotools cache out of date.)
 $(info Autotools cache version: $(PACKAGE_VERSION).)
 $(info Git version: $(git_version).)
 $(info Please run ./bootstrap && ./configure $(DIST_CONFIGURE_FLAGS))
 ifneq ($(GUIX_ALLOW_IRREPRODUCIBLE_TARBALL),yes)
 $(error Cannot create reproducible tarball)
 else
 $(warning Tarball will be irreproducible; distdir will not get removed!)
 endif # !GUIX_ALLOW_IRREPRODUCIBLE_TARBALL
 endif # PACKAGE_VERSION != git_version
 endif # MAKECMDGOALS dist

else # !in_git_p

dist: doc-pot-update

 ifeq ($(MAKECMDGOALS),dist)
$(warning Not using Git, tarball will likely be irreproducible!)
 endif # MAKECMDGOALS dist
endif # !in_git_p

dist-hook: gen-tarball-version
dist-hook: assert-no-store-file-names

distcheck-hook: assert-binaries-available assert-final-inputs-self-contained

EXTRA_DIST += $(top_srcdir)/.version
BUILT_SOURCES += $(top_srcdir)/.version
$(top_srcdir)/.version: config.status
	$(AM_V_GEN)echo $(VERSION) > "$@-t" && mv "$@-t" "$@"

gen-tarball-version:
	echo $(VERSION) > "$(distdir)/.tarball-version"
	echo $(SOURCE_DATE_EPOCH) > $(distdir)/.tarball-timestamp

gen-ChangeLog:
	$(AM_V_GEN)if test -d $(top_srcdir)/.git; then		\
	  set -e;						\
	  export LC_ALL=en_US.UTF-8;				\
	  export TZ=UTC0;					\
	  $(top_srcdir)/build-aux/gitlog-to-changelog		\
	    > $(distdir)/ChangeLog.tmp;				\
	  rm -f $(distdir)/ChangeLog;				\
	  mv $(distdir)/ChangeLog.tmp $(distdir)/ChangeLog;	\
	fi

gen-AUTHORS:
	$(AM_V_GEN)if test -d $(top_srcdir)/.git; then		\
	  set -e;						\
	  rm -f "$(distdir)/AUTHORS";				\
	  export LC_ALL=en_US.UTF-8;				\
	  export TZ=UTC0;					\
	  $(top_builddir)/pre-inst-env "$(GUILE)"		\
	    "$(top_srcdir)/build-aux/generate-authors.scm"	\
	    "$(top_srcdir)" "$(distdir)/AUTHORS";

# Like 'dist', but regenerate 'configure' so we get an up-to-date
# 'PACKAGE_VERSION' string.  (In Gnulib, 'GNUmakefile' has a special trick to
# do that whenever a 'dist' target is used.)
dist-with-updated-version:
	@echo "Running './bootstrap' for new version string..."
	$(top_srcdir)/bootstrap
	$(MAKE) $(AM_MAKEFLAGS) $(top_srcdir)/.version dist

.PHONY: dist-with-updated-version


#
# Release management.
#

# Reproducible tarball
override GZIP_ENV = --best --no-name
# Be friendly to Debian; avoid using EPOCH
override am__tar = $${TAR-tar}			\
 --format=ustar					\
 --sort=name					\
 --mode=go=rX,u+rw,a-s				\
 --mtime=@$$(cat "$$tardir"/.tarball-timestamp)	\
 --owner=0 --group=0 --numeric-owner		\
 -cf -						\
 "$$tardir"

releasedir = release-$(PACKAGE_VERSION)

PACKAGE_FULL_TARNAME = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)

# List of source tarballs produced.  This must be kept in sync with the
# 'dist-' options of 'AM_INIT_AUTOMAKE' in 'configure.ac'.
SOURCE_TARBALLS =					\
  $(foreach ext,tar.gz,$(PACKAGE_FULL_TARNAME).$(ext))

# Systems supported by Guix.
SUPPORTED_SYSTEMS ?= x86_64-linux i686-linux armhf-linux aarch64-linux \
  powerpc64le-linux

# Guix binary tarballs.
BINARY_TARBALLS =							\
  $(foreach system,$(SUPPORTED_SYSTEMS),guix-binary.$(system).tar.xz)

# Systems supported by Guix System.
GUIX_SYSTEM_SUPPORTED_SYSTEMS ?= x86_64-linux i686-linux

# Systems for which we build Guix VMs.
GUIX_SYSTEM_VM_SYSTEMS ?= x86_64-linux

# Prefix of the Guix installation image file name.
GUIX_SYSTEM_IMAGE_BASE = guix-system-install-$(PACKAGE_VERSION)

# Prefix of the Guix VM image file name.
GUIX_SYSTEM_VM_IMAGE_BASE = guix-system-vm-image-$(PACKAGE_VERSION)

# Flags for 'guix system vm-image'.  By default create a VM image that appears
# to have a 20G hard disk.
GUIX_SYSTEM_VM_IMAGE_FLAGS ?= --image-size=30G

# Return the sequence of '-s' flags for the given systems.
system_flags = $(foreach system,$(1),-s $(system))

# The release process works in several phases:
#
#   0. We assume the developer created a 'vX.Y.Z' tag.
#   1. Build the source tarball.
#   2. Update the 'guix' package so that it corresponds to the 'vX.Y.Z' tag.
#   3. Build the binary tarballs for that 'guix' package.
#   4. Update the 'guix' package again.
#   5. Build the installation and VM images.  The images will run 'guix'
#      corresponding to 'vX.Y.Z' + 1 commit, and they will install 'vX.Y.Z'.
#
# This 'release' target takes care of everything and copies the resulting
# files to $(releasedir).
#
# XXX: Depend on 'dist' rather than 'distcheck' to work around the Gettext
# issue described at <https://savannah.gnu.org/bugs/index.php?51027>.
release: dist-with-updated-version all
	@if ! git diff-index --quiet HEAD; then			\
	  echo "There are uncommitted changes; stopping." >&2 ;	\
	  exit 1 ;						\
	fi
	$(MKDIR_P) "$(releasedir)"
	rm -f "$(releasedir)"/*
	mv $(SOURCE_TARBALLS) "$(releasedir)"
# Bump the Guix package version and build it.
	GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT=yes \
	$(top_builddir)/pre-inst-env "$(GUILE)"	\
		$(top_srcdir)/build-aux/update-guix-package.scm	\
	   	"`git rev-parse HEAD`" "$(PACKAGE_VERSION)"
	git add $(top_srcdir)/gnu/packages/package-management.scm
	git commit -m "gnu: guix: Update to $(PACKAGE_VERSION)."
	$(top_builddir)/pre-inst-env guix build guix	\
	      $(call system_flags,$(SUPPORTED_SYSTEMS))	\
	      -v1 --no-grafts --fallback
# Generate the binary release tarballs.
	rm -f $(BINARY_TARBALLS)
	$(MAKE) $(BINARY_TARBALLS)
	for system in $(SUPPORTED_SYSTEMS) ; do					\
	  mv "guix-binary.$$system.tar.xz"					\
	      "$(releasedir)/guix-binary-$(PACKAGE_VERSION).$$system.tar.xz" ;	\
	done
# Build 'current-guix' to speed things up for the next step.
	$(top_builddir)/pre-inst-env guix build				\
	      -e '((@ (gnu packages package-management) current-guix))'	\
	      $(call system_flags,$(GUIX_SYSTEM_SUPPORTED_SYSTEMS))	\
	      -v1 --no-grafts --fallback
# Generate the ISO installation images.
	for system in $(GUIX_SYSTEM_SUPPORTED_SYSTEMS) ; do				\
	  GUIX_DISPLAYED_VERSION="`git describe --match=v* | sed -'es/^v//'`" ;		\
	  image=`$(top_builddir)/pre-inst-env						\
	    guix system image -t iso9660						\
	    --label="GUIX_$${system}_$(VERSION)"					\
            --system=$$system --fallback						\
	    gnu/system/install.scm` ;							\
	  if [ ! -f "$$image" ] ; then							\
	    echo "failed to produce Guix installation image for $$system" >&2 ;		\
	    exit 1 ;									\
	  fi ;										\
	  cp "$$image" "$(releasedir)/$(GUIX_SYSTEM_IMAGE_BASE).$$system.iso.tmp" ;	\
	  mv "$(releasedir)/$(GUIX_SYSTEM_IMAGE_BASE).$$system.iso.tmp"			\
	     "$(releasedir)/$(GUIX_SYSTEM_IMAGE_BASE).$$system.iso" ;			\
	done
# Generate the VM images.
	for system in $(GUIX_SYSTEM_VM_SYSTEMS) ; do					\
	  GUIX_DISPLAYED_VERSION="`git describe --match=v* | sed -'es/^v//'`" ;		\
	  image=`$(top_builddir)/pre-inst-env						\
	    guix system image -t qcow2 $(GUIX_SYSTEM_VM_IMAGE_FLAGS)			\
	    --save-provenance								\
	    --system=$$system --fallback						\
	    gnu/system/examples/vm-image.tmpl` ;					\
	  if [ ! -f "$$image" ] ; then							\
	    echo "failed to produce Guix VM image for $$system" >&2 ;			\
	    exit 1 ;									\
	  fi ;										\
	  cp "$$image" "$(releasedir)/$(GUIX_SYSTEM_VM_IMAGE_BASE).$$system.qcow2";	\
	done
	@echo
	@echo "Congratulations!  All the release files are now in $(releasedir)."
	@echo

update-guix-package:
	git rev-parse HEAD
	$(top_builddir)/pre-inst-env "$(GUILE)"			\
	   $(top_srcdir)/build-aux/update-guix-package.scm	\
	   "`git rev-parse HEAD`"

# Location of a checkout of <git://git.savannah.gnu.org/guix/maintenance.git>.
# Package data from this checkout is used by 'update-NEWS.scm'.
GUIX_MAINTENANCE_DIRECTORY ?= $(top_srcdir)/../guix-maintenance

update-NEWS: $(GOBJECTS)
	$(top_builddir)/pre-inst-env "$(GUILE)"				\
	  $(top_srcdir)/build-aux/update-NEWS.scm			\
	  $(top_srcdir)/NEWS "$(GUIX_MAINTENANCE_DIRECTORY)/data"

# Make sure we're not shipping a file that embeds a local /gnu/store file name.
assert-no-store-file-names:
	$(AM_V_at)if grep -r --exclude=*.texi --exclude=*.info			\
	     --exclude=*.info-[0-9] --exclude=*.dot				\
	     --exclude=*.eps --exclude-dir=bootstrap				\
	     --exclude=guix-manual.pot --exclude=guix-manual.*.po		\
	     --exclude=guix-cookbook.pot --exclude=guix-cookbook.*.po		\
	     --exclude=guix-prettify.el						\
	     --exclude=ChangeLog*						\
	     --exclude=binutils-boot-2.20*.patch				\
	     -E "$(storedir)/[a-z0-9]{32}-" $(distdir) ;			\
	then									\
	  echo "error: store file names embedded in the distribution" >&2 ;	\
	  exit 1 ;								\
	fi

# Make sure important substitutes are available.  Check only the primary
# server so that '--display-missing' doesn't print two lists.
assert-binaries-available: $(GOBJECTS)
	$(AM_V_at)$(top_builddir)/pre-inst-env				\
	  guix weather -m "$(top_srcdir)/etc/release-manifest.scm"	\
	                --substitute-urls="https://ci.guix.gnu.org"	\
	                --display-missing

# Make sure the final inputs don't refer to bootstrap tools.
assert-final-inputs-self-contained: $(GOBJECTS)
	$(AM_V_at)$(top_builddir)/pre-inst-env "$(GUILE)"			\
	  "$(top_srcdir)/build-aux/check-final-inputs-self-contained.scm"

# Validate channel news.
check-channel-news: $(GOBJECTS)
	$(AM_V_at)$(top_builddir)/pre-inst-env "$(GUILE)"	\
	  "$(top_srcdir)/build-aux/check-channel-news.scm"

# Compute the Cuirass jobs.
cuirass-jobs: $(GOBJECTS)
	rm -rf "$@"
	$(AM_V_at)$(MKDIR_P) "$@"
	$(AM_V_GEN)$(top_builddir)/pre-inst-env "$(GUILE)"		\
	  "$(top_srcdir)/build-aux/cuirass/evaluate.scm" "$@"

.PHONY: gen-ChangeLog gen-AUTHORS gen-tarball-version
.PHONY: assert-no-store-file-names assert-binaries-available
.PHONY: assert-final-inputs-self-contained check-channel-news
.PHONY: clean-go make-go as-derivation
.PHONY: update-guix-package update-NEWS cuirass-jobs release

# Git auto-configuration.
.git/hooks/%: etc/git/%
	$(AM_V_at)if test -d .git; then \
	cp "$<" "$@"; \
	fi

.git/config: etc/git/gitconfig
	$(AM_V_at)if command -v git >/dev/null && test -d .git; then \
	git config --fixed-value --replace-all include.path \
	  ../etc/git/gitconfig ../etc/git/gitconfig; \
	fi

COMMIT_MSG_MAGIC = VGhpcyBpcyB0aGUgY29tbWl0LW1zZyBob29rIG9mIEd1aXg=
.git/hooks/commit-msg: etc/git/commit-msg
	$(AM_V_at)if test -d .git; then \
	if test -f $@  && ! grep -qF $(COMMIT_MSG_MAGIC) $@; then \
	  mkdir -p $@.d && mv $@ $@.d && \
	@ echo user commit-msg hook moved to $@.d/commit-msg; \
	fi; \
	cp etc/git/commit-msg $@; \
	fi

# The etc/git/ config files are not distributed and have no use when building
# from a tarball.  Do not add dependencies on these to *_DATA when building
# from a tarball, as that breaks the build.
if in_git_p
nodist_noinst_DATA =				\
  .git/hooks/pre-push				\
  .git/hooks/post-merge				\
  .git/config					\
  .git/hooks/commit-msg
endif

# Downloading up-to-date PO files.

WEBLATE_REPO = https://framagit.org/tyreunom/guix-translations

# Shallow clone the Git repository behind Weblate and copy files from it if
# they contain at least one translation, and they are well-formed (Scheme
# format only), warn otherwise.  Copied files are converted to a canonical
# form.
download-po:
	dir=$$(mktemp -d); \
	git clone --depth 1 "$(WEBLATE_REPO)" "$$dir/translations" && \
	for domain in po/doc po/guix po/packages; do \
	    for po in "$$dir/translations/$$domain"/*.po; do \
	        translated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | cut -f1 -d' '); \
	        untranslated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | rev | cut -f3 -d' ' | rev); \
	        untranslated=$${untranslated:-0}; \
	        total=$$(($$translated+$$untranslated)); \
	        target=$$(basename "$$po"); \
	        target="$$domain/$$target"; \
	        msgfmt -c "$$po"; \
	        if msgfmt -c "$$po" && [ "$$translated" != "0" ] && ([ "$$domain" != "po/doc" ] || [ "$$translated" -gt $$(($$total/10)) ] || [ -f $$target ]); then \
	            msgfilter --no-wrap -i "$$po" cat > "$$po".tmp; \
	            mv "$$po".tmp "$$target"; \
	            echo "copied $$target."; \
	        else \
	            echo "WARN: $$target ($$translated translated messages ($$((translated/total*100))%)) was not added/updated."; \
	        fi; \
	    done; \
	done; \
	for po in po/doc/*.po; do \
	    translated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | cut -f1 -d' '); \
	    untranslated=$$(LANG=en_US.UTF-8 msgfmt --statistics "$$po" 2>&1 | rev | cut -f3 -d' ' | rev); \
	    untranslated=$${untranslated:-0}; \
	    total=$$(($$translated + $$untranslated)); \
	    if [ "$$translated" -lt "$$(($$total/20))" ]; then \
	        echo "WARN: $$po was removed because it is below the 5% threshold: $$((translated/total*100))%"; \
	        rm $$po; \
	    fi; \
	done; \
	rm -rf "$$dir"
.PHONY: download-po

## -------------- ##
## Silent rules.  ##
## -------------- ##

AM_V_DL = $(AM_V_DL_$(V))
AM_V_DL_ = $(AM_V_DL_$(AM_DEFAULT_VERBOSITY))
AM_V_DL_0 = @echo "  DL      " $@;

AM_V_DOT = $(AM_V_DOT_$(V))
AM_V_DOT_ = $(AM_V_DOT_$(AM_DEFAULT_VERBOSITY))
AM_V_DOT_0 = @echo "  DOT     " $@;

AM_V_HELP2MAN = $(AM_V_HELP2MAN_$(V))
AM_V_HELP2MAN_ = $(AM_V_HELP2MAN_$(AM_DEFAULT_VERBOSITY))
AM_V_HELP2MAN_0 = @echo "  HELP2MAN" $@;

AM_V_PO4A = $(AM_V_PO4A_$(V))
AM_V_PO4A_ = $(AM_V_PO4A_$(AM_DEFAULT_VERBOSITY))
AM_V_PO4A_0 = @echo "  PO4A    " $@;

AM_V_POXREF = $(AM_V_POXREF_$(V))
AM_V_POXREF_ = $(AM_V_POXREF_$(AM_DEFAULT_VERBOSITY))
AM_V_POXREF_0 = @echo "  POXREF  " $@;
@pxref{Contributing,,, guix, GNU Guix Reference Manual})
+
+
+It's a community effort so the more join in, the better Guix becomes!
+
+@node Extended example
+@subsection Extended example
+
+The above "Hello World" example is as simple as it goes. Packages can be more
+complex than that and Guix can handle more advanced scenarios. Let's look at
+another, more sophisticated package (slightly modified from the source):
+
+@example
+(define-module (gnu packages version-control)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix utils)
+ #:use-module (guix packages)
+ #:use-module (guix git-download)
+ #:use-module (guix build-system cmake)
+ #:use-module (gnu packages ssh)
+ #:use-module (gnu packages web)
+ #:use-module (gnu packages pkg-config)
+ #:use-module (gnu packages python)
+ #:use-module (gnu packages compression)
+ #:use-module (gnu packages tls))
+
+(define-public my-libgit2
+ (let ((commit "e98d0a37c93574d2c6107bf7f31140b548c6a7bf")
+ (revision "1"))
+ (package
+ (name "my-libgit2")
+ (version (git-version "0.26.6" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/libgit2/libgit2/")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "17pjvprmdrx4h6bb1hhc98w9qi6ki7yl57f090n9kbhswxqfs7s3"))
+ (patches (search-patches "libgit2-mtime-0.patch"))
+ (modules '((guix build utils)))
+ (snippet '(begin
+ ;; Remove bundled software.
+ (delete-file-recursively "deps")
+ #t))))
+ (build-system cmake-build-system)
+ (outputs '("out" "debug"))
+ (arguments
+ `(#:tests? #t ; Run the test suite (this is the default)
+ #:configure-flags '("-DUSE_SHA1DC=ON") ; SHA-1 collision detection
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'fix-hardcoded-paths
+ (lambda _
+ (substitute* "tests/repo/init.c"
+ (("#!/bin/sh") (string-append "#!" (which "sh"))))
+ (substitute* "tests/clar/fs.h"
+ (("/bin/cp") (which "cp"))
+ (("/bin/rm") (which "rm")))
+ #t))
+ ;; Run checks more verbosely.
+ (replace 'check
+ (lambda _ (invoke "./libgit2_clar" "-v" "-Q")))
+ (add-after 'unpack 'make-files-writable-for-tests
+ (lambda _ (for-each make-file-writable (find-files "." ".*")))))))
+ (inputs
+ `(("libssh2" ,libssh2)
+ ("http-parser" ,http-parser)
+ ("python" ,python-wrapper)))
+ (native-inputs
+ `(("pkg-config" ,pkg-config)))
+ (propagated-inputs
+ ;; These two libraries are in 'Requires.private' in libgit2.pc.
+ `(("openssl" ,openssl)
+ ("zlib" ,zlib)))
+ (home-page "https://libgit2.github.com/")
+ (synopsis "Library providing Git core methods")
+ (description
+ "Libgit2 is a portable, pure C implementation of the Git core methods
+provided as a re-entrant linkable library with a solid API, allowing you to
+write native speed custom Git applications in any language with bindings.")
+ ;; GPLv2 with linking exception
+ (license license:gpl2))))
+@end example
+
+(In those cases were you only want to tweak a few fields from a package
+definition, you should rely on inheritance instead of copy-pasting everything.
+See below.)
+
+Let's discuss those fields in depth.
+
+@subsubsection @code{git-fetch} method
+
+Unlike the @code{url-fetch} method, @code{git-fetch} expects a @code{git-reference} which takes
+a Git repository and a commit. The commit can be any Git reference such as
+tags, so if the @code{version} is tagged, then it can be used directly. Sometimes
+the tag is prefixed with a @code{v}, in which case you'd use @code{(commit (string-append
+"v" version))}.
+
+To ensure that the source code from the Git repository is stored in a unique
+directory with a readable name we use @code{(file-name (git-file-name name
+version))}.
+
+Note that there is also a @code{git-version} procedure that can be used to derive the
+version when packaging programs for a specific commit.
+
+@subsubsection Snippets
+
+Snippets are quoted (i.e. non-evaluated) Scheme code that are a means of patching
+the source. They are a Guix-y alternative to the traditional @samp{.patch} files.
+Because of the quote, the code in only evaluated when passed to the Guix daemon
+for building.
+
+There can be as many snippet as needed.
+
+Snippets might need additional Guile modules which can be imported from the
+@code{modules} field.
+
+@subsubsection Inputs
+
+First, a syntactic comment: See the quasi-quote / comma syntax?
+
+@example
+ (native-inputs
+ `(("pkg-config" ,pkg-config)))
+@end example
+
+is equivalent to
+
+@example
+ (native-inputs
+ (list (list "pkg-config" pkg-config)))
+@end example
+
+You'll mostly see the former because it's shorter.
+
+There are 3 different input types. In short:
+
+@table @asis
+@item native-inputs
+Required for building but not runtime -- installing a package
+through a substitute won't install these inputs.
+@item inputs
+Installed in the store but not in the profile, as well as being
+present at build time.
+@item propagated-inputs
+Installed in the store and in the profile, as well as
+being present at build time.
+@end table
+
+@xref{Package Reference,,, guix, GNU Guix Reference Manual} for more details.
+
+The distinction between the various inputs is important: if a dependency can be
+handled as an @emph{input} instead of a @emph{propagated input}, it should be done so, or
+else it "pollutes" the user profile for no good reason.
+
+For instance, a user installing a graphical program that depends on a
+command line tool might only be interested in the graphical part, so there is no
+need to force the command line tool into the user profile. The dependency is a
+concern to the package, not to the user. @emph{Inputs} make it possible to handle
+dependencies without bugging the user by adding undesired executable files (or
+libraries) to their profile.
+
+Same goes for @emph{native-inputs}: once the program is installed, build-time
+dependencies can be safely garbage-collected.
+It also matters when a substitute is available, in which case only the @emph{inputs}
+and @emph{propagated inputs} will be fetched: the @emph{native inputs} are not required to
+install a package from a substitute.
+
+@subsubsection Outputs
+
+Just like how a package can have multiple inputs, it can also produce multiple
+outputs.
+
+Each output corresponds to a separate directory in the store.
+
+The user can choose which output to install; this is useful to save space or
+to avoid polluting the user profile with unwanted executables or libraries.
+
+Output separation is optional. When the @code{outputs} field is left out, the
+default and only output (the complete package) is referred to as @code{"out"}.
+
+Typical separate output names include @code{debug} and @code{doc}.
+
+It's advised to separate outputs only when you've shown it's worth it: if the
+output size is significant (compare with @code{guix size}) or in case the package is
+modular.
+
+@subsubsection Build system arguments
+
+The @code{arguments} is a keyword-value list used to configure the build process.
+
+The simplest argument @code{#:tests?} can be used to disable the test suite when
+building the package. This is mostly useful when the package does not feature
+any test suite. It's strongly recommended to keep the test suite on if there is
+one.
+
+Another common argument is @code{:make-flags}, which specifies a list of flags to
+append when running make, as you would from the command line. For instance, the
+following flags
+
+@example
+#:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out"))
+ "CC=gcc")
+@end example
+
+translate into
+
+@example
+$ make CC=gcc prefix=/gnu/store/...-<out>
+@end example
+
+This sets the C compiler to @code{gcc} and the @code{prefix} variable (the installation
+directory in Make parlance) to @code{(assoc-ref %outputs "out")}, which is a build-stage
+global variable pointing to the destination directory in the store (something like
+@samp{/gnu/store/...-my-libgit2-20180408}).
+
+Similarly, it's possible to set the "configure" flags.
+
+@example
+#:configure-flags '("-DUSE_SHA1DC=ON")
+@end example
+
+The @code{%build-inputs} variable is also generated in scope. It's an association
+table that maps the input names to their store directories.
+
+The @code{phases} keyword lists the sequential steps of the build system. Typically
+phases include @code{unpack}, @code{configure}, @code{build}, @code{install} and @code{check}. To know
+more about those phases, you need to work out the appropriate build system
+definition in @samp{$GUIX_CHECKOUT/guix/build/gnu-build-system.scm}:
+
+@example
+(define %standard-phases
+ ;; Standard build phases, as a list of symbol/procedure pairs.
+ (let-syntax ((phases (syntax-rules ()
+ ((_ p ...) `((p . ,p) ...)))))
+ (phases set-SOURCE-DATE-EPOCH set-paths install-locale unpack
+ bootstrap
+ patch-usr-bin-file
+ patch-source-shebangs configure patch-generated-file-shebangs
+ build check install
+ patch-shebangs strip
+ validate-runpath
+ validate-documentation-location
+ delete-info-dir-file
+ patch-dot-desktop-files
+ install-license-files
+ reset-gzip-timestamps
+ compress-documentation)))
+@end example
+
+Or from the REPL:
+
+@example
+> (add-to-load-path "/path/to/guix/checkout")
+> ,module (guix build gnu-build-system)
+> (map first %standard-phases)
+(set-SOURCE-DATE-EPOCH set-paths install-locale unpack bootstrap patch-usr-bin-file patch-source-shebangs configure patch-generated-file-shebangs build check install patch-shebangs strip validate-runpath validate-documentation-location delete-info-dir-file patch-dot-desktop-files install-license-files reset-gzip-timestamps compress-documentation)
+@end example
+
+If you want to know more about what happens during those phases, consult the
+associated procedures.
+
+For instance, as of this writing the definition of @code{unpack} for the GNU build
+system is
+
+@example
+(define* (unpack #:key source #:allow-other-keys)
+ "Unpack SOURCE in the working directory, and change directory within the
+source. When SOURCE is a directory, copy it in a sub-directory of the current
+working directory."
+ (if (file-is-directory? source)
+ (begin
+ (mkdir "source")
+ (chdir "source")
+
+ ;; Preserve timestamps (set to the Epoch) on the copied tree so that
+ ;; things work deterministically.
+ (copy-recursively source "."
+ #:keep-mtime? #t))
+ (begin
+ (if (string-suffix? ".zip" source)
+ (invoke "unzip" source)
+ (invoke "tar" "xvf" source))
+ (chdir (first-subdirectory "."))))
+ #t)
+@end example
+
+Note the @code{chdir} call: it changes the working directory to where the source was
+unpacked.
+Thus every phase following the @code{unpack} will use the source as a working
+directory, which is why we can directly work on the source files.
+That is to say, unless a later phase changes the working directory to something
+else.
+
+We modify the list of @code{%standard-phases} of the build system with the
+@code{modify-phases} macro as per the list of specified modifications, which may have
+the following forms:
+
+@itemize
+@item
+@code{(add-before PHASE NEW-PHASE PROCEDURE)}: Run @code{PROCEDURE} named @code{NEW-PHASE} before @code{PHASE}.
+@item
+@code{(add-after PHASE NEW-PHASE PROCEDURE)}: Same, but afterwards.
+@item
+@code{(replace PHASE PROCEDURE)}.
+@item
+@code{(delete PHASE)}.
+@end itemize
+
+The @code{PROCEDURE} supports the keyword arguments @code{inputs} and @code{outputs}. Each
+input (whether @emph{native}, @emph{propagated} or not) and output directory is referenced
+by their name in those variables. Thus @code{(assoc-ref outputs "out")} is the store
+directory of the main output of the package. A phase procedure may look like
+this:
+
+@example
+(lambda* (#:key inputs outputs #:allow-other-keys)
+ (let (((bash-directory (assoc-ref inputs "bash"))
+ (output-directory (assoc-ref outputs "out"))
+ (doc-directory (assoc-ref outputs "doc"))
+ ; ...
+ #t)
+@end example
+
+The procedure must return @code{#t} on success. It's brittle to rely on the return
+value of the last expression used to tweak the phase because there is no
+guarantee it would be a @code{#t}. Hence the trailing @code{#t} to ensure the right value
+is returned on success.
+
+@subsubsection Code staging
+
+The astute reader may have noticed the quasi-quote and comma syntax in the
+argument field. Indeed, the build code in the package declaration should not be
+evaluated on the client side, but only when passed to the Guix daemon. This
+mechanism of passing code around two running processes is called @uref{https://arxiv.org/abs/1709.00833, code staging}.
+
+@subsubsection "Utils" functions
+
+When customizing @code{phases}, we often need to write code that mimics the
+equivalent system invocations (@code{make}, @code{mkdir}, @code{cp}, etc.) commonly used during
+regular "Unix-style" installations.
+
+Some like @code{chmod} are native to Guile.
+@xref{,,, guile, Guile reference manual} for a complete list.
+
+Guix provides additional helper functions which prove especially handy in the
+context of package management.
+
+Some of those functions can be found in
+@samp{$GUIX_CHECKOUT/guix/guix/build/utils.scm}. Most of them mirror the behaviour
+of the traditional Unix system commands:
+
+@table @asis
+@item which
+Like the @samp{which} system command.
+@item find-files
+Akin to the @samp{find} system command.
+@item mkdir-p
+Like @samp{mkdir -p}, which creates all parents as needed.
+@item install-file
+Similar to @samp{install} when installing a file to a (possibly
+non-existing) directory. Guile has @code{copy-file} which works
+like @samp{cp}.
+@item copy-recursively
+Like @samp{cp -r}.
+@item delete-file-recursively
+Like @samp{rm -rf}.
+@item invoke
+Run an executable. This should be used instead of @code{system*}.
+@item with-directory-excursion
+Run the body in a different working directory,
+then restore the previous working directory.
+@item substitute*
+A "sed-like" function.
+@end table
+
+@subsubsection Module prefix
+
+The license in our last example needs a prefix: this is because of how the
+@code{license} module was imported in the package, as @code{#:use-module ((guix licenses)
+#:prefix license:)}. The Guile module import mechanism
+(@pxref{Using Guile Modules,,, guile, Guile reference manual})
+gives the user full control over namespacing: this is needed to avoid
+clashes between, say, the
+@samp{zlib} variable from @samp{licenses.scm} (a @emph{license} value) and the @samp{zlib} variable
+from @samp{compression.scm} (a @emph{package} value).
+
+@node Other build systems
+@subsection Other build systems
+
+What we've seen so far covers the majority of packages using a build system
+other than the @code{trivial-build-system}. The latter does not automate anything
+and leaves you to build everything manually. This can be more demanding and we
+won't cover it here for now, but thankfully it is rarely necessary to fall back
+on this system.
+
+For the other build systems, such as ASDF, Emacs, Perl, Ruby and many more, the
+process is very similar to the GNU build system except for a few specialized
+arguments.
+
+Learn more about build systems in
+@itemize
+@item
+@uref{https://www.gnu.org/software/guix/manual/en/html_node/Build-Systems.html#Build-Systems, the manual, section 4.2 Build systems},
+@item
+the source code in the @samp{$GUIX_CHECKOUT/guix/build} and
+@samp{$GUIX_CHECKOUT/guix/build-system} directories.
+@end itemize
+
+@node Programmable and automated package definition
+@subsection Programmable and automated package definition
+
+We can't repeat it enough: having a full-fledged programming language at hand
+empowers us in ways that reach far beyond traditional package management.
+
+Let's illustrate this with some awesome features of Guix!
+
+@node Recursive importers
+@subsubsection Recursive importers
+
+You might find some build systems good enough that there is little to do at all
+to write a package, to the point that it becomes repetitive and tedious after a
+while. A @emph{raison d'être} of computers is to replace human beings at those
+boring tasks. So let's tell Guix to do this for us and create the package
+definition of an R package from CRAN (the output is trimmed for conciseness):
+
+@example
+$ guix import cran --recursive walrus
+
+(define-public r-mc2d
+ ; ...
+ (license gpl2+)))
+
+(define-public r-jmvcore
+ ; ...
+ (license gpl2+)))
+
+(define-public r-wrs2
+ ; ...
+ (license gpl3)))
+
+(define-public r-walrus
+ (package
+ (name "r-walrus")
+ (version "1.0.3")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (cran-uri "walrus" version))
+ (sha256
+ (base32
+ "1nk2glcvy4hyksl5ipq2mz8jy4fss90hx6cq98m3w96kzjni6jjj"))))
+ (build-system r-build-system)
+ (propagated-inputs
+ `(("r-ggplot2" ,r-ggplot2)
+ ("r-jmvcore" ,r-jmvcore)
+ ("r-r6" ,r-r6)
+ ("r-wrs2" ,r-wrs2)))
+ (home-page "https://github.com/jamovi/walrus")
+ (synopsis "Robust Statistical Methods")
+ (description
+ "This package provides a toolbox of common robust statistical
+tests, including robust descriptives, robust t-tests, and robust ANOVA.
+It is also available as a module for 'jamovi' (see
+<https://www.jamovi.org> for more information). Walrus is based on the
+WRS2 package by Patrick Mair, which is in turn based on the scripts and
+work of Rand Wilcox. These analyses are described in depth in the book
+'Introduction to Robust Estimation & Hypothesis Testing'.")
+ (license gpl3)))
+@end example
+
+The recursive importer won't import packages for which Guix already has package
+definitions, except for the very first.
+
+Not all applications can be packaged this way, only those relying on a select
+number of supported systems. Read about the full list of importers in
+the guix import section of the manual
+(@pxref{Invoking guix import,,, guix, GNU Guix Reference Manual}).
+
+@node Automatic update
+@subsubsection Automatic update
+
+Guix can be smart enough to check for updates on systems it knows. It can
+report outdated package definitions with
+
+@example
+$ guix refresh hello
+@end example
+
+In most cases, updating a package to a newer version requires little more than
+changing the version number and the checksum. Guix can do that automatically as
+well:
+
+@example
+$ guix refresh hello --update
+@end example
+
+@node Inheritance
+@subsubsection Inheritance
+
+If you've started browsing the existing package definitions, you might have
+noticed that a significant number of them have a @code{inherit} field:
+
+@example
+(define-public adwaita-icon-theme
+ (package (inherit gnome-icon-theme)
+ (name "adwaita-icon-theme")
+ (version "3.26.1")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "mirror://gnome/sources/" name "/"
+ (version-major+minor version) "/"
+ name "-" version ".tar.xz"))
+ (sha256
+ (base32
+ "17fpahgh5dyckgz7rwqvzgnhx53cx9kr2xw0szprc6bnqy977fi8"))))
+ (native-inputs
+ `(("gtk-encode-symbolic-svg" ,gtk+ "bin")))))
+@end example
+
+All unspecified fields are inherited from the parent package. This is very
+convenient to create alternative packages, for instance with different source,
+version or compilation options.
+
+@node Getting help
+@subsection Getting help
+
+Sadly, some applications can be tough to package. Sometimes they need a patch to
+work with the non-standard filesystem hierarchy enforced by the store.
+Sometimes the tests won't run properly. (They can be skipped but this is not
+recommended.) Other times the resulting package won't be reproducible.
+
+Should you be stuck, unable to figure out how to fix any sort of packaging
+issue, don't hesitate to ask the community for help.
+
+See the @uref{https://www.gnu.org/software/guix/contact/, Guix homepage} for information on the mailing lists, IRC, etc.
+
+@node Conclusion
+@subsection Conclusion
+
+This tutorial was a showcase of the sophisticated package management that Guix
+boasts. At this point we have mostly restricted this introduction to the
+@code{gnu-build-system} which is a core abstraction layer on which more advanced
+abstractions are based.
+
+Where do we go from here? Next we ought to dissect the innards of the build
+system by removing all abstractions, using the @code{trivial-build-system}: this
+should give us a thorough understanding of the process before investigating some
+more advanced packaging techniques and edge cases.
+
+Other features worth exploring are the interactive editing and debugging
+capabilities of Guix provided by the Guile REPL@.
+
+Those fancy features are completely optional and can wait; now is a good time
+to take a well-deserved break. With what we've introduced here you should be
+well armed to package lots of programs. You can get started right away and
+hopefully we will see your contributions soon!
+
+@node References
+@subsection References
+
+@itemize
+@item
+The @uref{https://www.gnu.org/software/guix/manual/en/html_node/Defining-Packages.html, package reference in the manual}
+
+@item
+@uref{https://gitlab.com/pjotrp/guix-notes/blob/master/HACKING.org, Pjotr’s hacking guide to GNU Guix}
+
+@item
+@uref{https://www.gnu.org/software/guix/guix-ghm-andreas-20130823.pdf, "GNU Guix: Package without a scheme!"}, by Andreas Enge
+@end itemize
@c *********************************************************************
@node System Configuration
@@ -801,7 +1579,7 @@ reference.
Guix provides a very useful feature that may be quite foreign to newcomers:
@emph{profiles}. They are a way to group package installations together and all users
-on a same system are free to use as many profiles as they want.
+on the same system are free to use as many profiles as they want.
Whether you're a developer or not, you may find that multiple profiles bring you
great power and flexibility. While they shift the paradigm somewhat compared to
@@ -830,7 +1608,7 @@ shells, each of them running different profiles.
@item
Isolation: Programs from one profile will not use programs from the other, and
-they user can even install different versions of the same programs to the two
+the user can even install different versions of the same programs to the two
profiles without conflict.
@item
@@ -840,8 +1618,10 @@ This makes multiple profiles storage-efficient.
@item
Reproducible: when used with declarative manifests, a profile can be fully
specified by the Guix commit that was active when it was set up. This means
-that the exact same profile can be @uref{https://guix.gnu.org/blog/2018/multi-dimensional-transactions-and-rollbacks-oh-my/, set up anywhere, anytime}, with just the
-commit information. See the section on @ref{Reproducible profiles}.
+that the exact same profile can be
+@uref{https://guix.gnu.org/blog/2018/multi-dimensional-transactions-and-rollbacks-oh-my/,
+set up anywhere and anytime}, with just the commit information. See the
+section on @ref{Reproducible profiles}.
@item
Easier upgrades and maintenance: Multiple profiles make it easy to keep
@@ -994,6 +1774,14 @@ You can roll-back to any generation of a given profile:
guix package -p "$GUIX_EXTRA_PROFILES"/my-project/my-project --switch-generations=17
@end example
+Finally, if you want to switch to a profile without inheriting from the
+current environment, you can activate it from an empty shell:
+
+@example
+env -i $(which bash) --login --noprofile --norc
+. my-project/etc/profile
+@end example
+
@node Required packages
@subsection Required packages
@@ -1012,7 +1800,7 @@ the profile is loaded, you've got two options:
@item
Either export the variable manually, e.g.
@example
-export MANPATH=/path/to/profile$@{MANPATH:+:@}$MANPATH"
+export MANPATH=/path/to/profile$@{MANPATH:+:@}$MANPATH
@end example
@item
diff --git a/doc/guix.texi b/doc/guix.texi
index a934626e5a..f6dcb2ac63 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3666,6 +3666,21 @@ descriptions, and deploys it. Source code is downloaded from a
@uref{https://git-scm.com, Git} repository, by default the official
GNU@tie{}Guix repository, though this can be customized.
+Specifically, @command{guix pull} downloads code from the @dfn{channels}
+(@pxref{Channels}) specified by one of the followings, in this order:
+
+@enumerate
+@item
+the @option{--channels} option;
+@item
+the user's @file{~/.config/guix/channels.scm} file;
+@item
+the system-wide @file{/etc/guix/channels.scm} file;
+@item
+the built-in default channels specified in the @code{%default-channels}
+variable.
+@end enumerate
+
On completion, @command{guix package} will use packages and package
versions from this just-retrieved copy of Guix. Not only that, but all
the Guix commands and Scheme modules will also be taken from that latest
@@ -3763,7 +3778,8 @@ configuration in the @file{~/.config/guix/channels.scm} file or using the
@item --channels=@var{file}
@itemx -C @var{file}
Read the list of channels from @var{file} instead of
-@file{~/.config/guix/channels.scm}. @var{file} must contain Scheme code that
+@file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
+@var{file} must contain Scheme code that
evaluates to a list of channel objects. @xref{Channels}, for more
information.
@@ -22378,9 +22394,69 @@ The port to run mpd on.
The address that mpd will bind to. To use a Unix domain socket,
an absolute path can be specified here.
+@item @code{outputs} (default: @code{"(list (mpd-output))"})
+The audio outputs that MPD can use. By default this is a single output using pulseaudio.
+
@end table
@end deftp
+@deftp {Data Type} mpd-output
+Data type representing an @command{mpd} audio output.
+
+@table @asis
+@item @code{name} (default: @code{"MPD"})
+The name of the audio output.
+
+@item @code{type} (default: @code{"pulse"})
+The type of audio output.
+
+@item @code{enabled?} (default: @code{#t})
+Specifies whether this audio output is enabled when MPD is started. By
+default, all audio outputs are enabled. This is just the default
+setting when there is no state file; with a state file, the previous
+state is restored.
+
+@item @code{tags?} (default: @code{#t})
+If set to @code{#f}, then MPD will not send tags to this output. This
+is only useful for output plugins that can receive tags, for example the
+@code{httpd} output plugin.
+
+@item @code{always-on?} (default: @code{#f})
+If set to @code{#t}, then MPD attempts to keep this audio output always
+open. This may be useful for streaming servers, when you don’t want to
+disconnect all listeners even when playback is accidentally stopped.
+
+@item @code{mixer-type}
+This field accepts a symbol that specifies which mixer should be used
+for this audio output: the @code{hardware} mixer, the @code{software}
+mixer, the @code{null} mixer (allows setting the volume, but with no
+effect; this can be used as a trick to implement an external mixer
+External Mixer) or no mixer (@code{none}).
+
+@item @code{extra-options} (default: @code{'()"})
+An association list of option symbols to string values to be appended to
+the audio output configuration.
+
+@end table
+@end deftp
+
+The following example shows a configuration of @code{mpd} that provides
+an HTTP audio streaming output.
+
+@lisp
+(service mpd-service-type
+ (mpd-configuration
+ (outputs
+ (list (mpd-output
+ (name "streaming")
+ (type "httpd")
+ (mixer-type 'null)
+ (extra-options
+ `((encoder . "vorbis")
+ (port . "8080"))))))))
+@end lisp
+
+
@node Virtualization Services
@subsection Virtualization services
diff --git a/etc/news.scm b/etc/news.scm
index 80f7ba522c..5bcd075057 100644
--- a/etc/news.scm
+++ b/etc/news.scm
@@ -9,6 +9,22 @@
(channel-news
(version 0)
+ (entry (commit "49af34cfac89d384c46269bfd9388b2c73b1220a")
+ (title (en "@command{guix pull} now honors
+@file{/etc/guix/channels.scm}")
+ (fr "@command{guix pull} lit maintenant
+@file{/etc/guix/channels.scm}"))
+ (body
+ (en "The @command{guix pull} command will now read the
+@file{/etc/guix/channels.scm} file if it exists and if the per-user
+@file{~/.config/guix/channels.scm} is not present. This allows administrators
+of multi-user systems to define site-wide defaults.")
+ (fr "La commande @command{guix pull} lira maintenant le fichier
+@file{/etc/guix/channels.scm} s'il existe et si le fichier
+@file{~/.config/guix/channels.scm} par utilisateur·rice n'est pas présent.
+Cela permet aux personnes administrant des systèmes multi-utilisateurs de
+définir les canaux par défaut.")))
+
(entry (commit "81c580c8664bfeeb767e2c47ea343004e88223c7")
(title (en "Insecure @file{/var/guix/profiles/per-user} permissions (CVE-2019-18192)")
(de "Sicherheitslücke in @file{/var/guix/profiles/per-user}-Berechtigungen (CVE-2019-18192)")
diff --git a/gnu/local.mk b/gnu/local.mk
index 683bcc5f45..5dab77f899 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -974,9 +974,8 @@ dist_patch_DATA = \
%D%/packages/patches/hurd-fix-eth-multiplexer-dependency.patch \
%D%/packages/patches/hplip-remove-imageprocessor.patch \
%D%/packages/patches/hydra-disable-darcs-test.patch \
+ %D%/packages/patches/icecat-gnuzilla-fixes.patch \
%D%/packages/patches/icecat-makeicecat.patch \
- %D%/packages/patches/icecat-default-search-ddg.patch \
- %D%/packages/patches/icecat-disable-sync.patch \
%D%/packages/patches/icecat-avoid-bundled-libraries.patch \
%D%/packages/patches/icecat-use-system-graphite2+harfbuzz.patch \
%D%/packages/patches/icecat-use-system-media-libs.patch \
@@ -1066,7 +1065,6 @@ dist_patch_DATA = \
%D%/packages/patches/libmpeg2-global-symbol-test.patch \
%D%/packages/patches/libmygpo-qt-fix-qt-5.11.patch \
%D%/packages/patches/libmygpo-qt-missing-qt5-modules.patch \
- %D%/packages/patches/libreoffice-boost.patch \
%D%/packages/patches/libreoffice-icu.patch \
%D%/packages/patches/libreoffice-glm.patch \
%D%/packages/patches/libsndfile-armhf-type-checks.patch \
@@ -1448,9 +1446,7 @@ dist_patch_DATA = \
%D%/packages/patches/xfce4-panel-plugins.patch \
%D%/packages/patches/xfce4-settings-defaults.patch \
%D%/packages/patches/xinetd-fix-fd-leak.patch \
- %D%/packages/patches/xinetd-CVE-2013-4342.patch \
- %D%/packages/patches/xorriso-no-partition-table-in-inner-efi.patch \
- %D%/packages/patches/xorriso-no-mbr-in-inner-efi.patch
+ %D%/packages/patches/xinetd-CVE-2013-4342.patch
MISC_DISTRO_FILES = \
%D%/packages/ld-wrapper.in
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 82f1bb4eb8..08dac76a41 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -1128,7 +1128,7 @@ system administrator.")
(define-public sudo
(package
(name "sudo")
- (version "1.8.28p1")
+ (version "1.8.29")
(source (origin
(method url-fetch)
(uri
@@ -1138,7 +1138,7 @@ system administrator.")
version ".tar.gz")))
(sha256
(base32
- "09xhx2k7j6wlqs9bl7snamd4k6lkyv9ycjwdspgbbqrimy25mfi3"))
+ "0z4wyadh9cks17gdpfgx4kvbrlnyb6nai2sd6chk7qh4jsngylyf"))
(modules '((guix build utils)))
(snippet
'(begin
@@ -1184,6 +1184,12 @@ system administrator.")
(("\\$\\(DESTDIR\\)\\$\\(vardir\\)")
;; Don't try to create /var/db/sudo.
"$(TMPDIR)/dummy"))
+
+ ;; ‘Checking existing [/etc/]sudoers file for syntax errors’ is
+ ;; not the task of the build system, and fails.
+ (substitute* "plugins/sudoers/Makefile.in"
+ (("^pre-install:" match)
+ (string-append match "\ndisabled-" match)))
#t)))
;; XXX: The 'testsudoers' test series expects user 'root' to exist, but
diff --git a/gnu/packages/algebra.scm b/gnu/packages/algebra.scm
index 828a0fc748..6a9784f551 100644
--- a/gnu/packages/algebra.scm
+++ b/gnu/packages/algebra.scm
@@ -483,7 +483,7 @@ fast arithmetic.")
(define-public arb
(package
(name "arb")
- (version "2.16.0")
+ (version "2.17.0")
(source (origin
(method git-fetch)
(uri (git-reference
@@ -492,7 +492,7 @@ fast arithmetic.")
(file-name (git-file-name name version))
(sha256
(base32
- "0478671wfwy3gl26sbxh1jq1ih36z4k72waa8y2y2lvn649gb7cd"))))
+ "05lpy3hkl5f8ik19aw40cqydrb932xaf2n8hbq9ib5dnk7f010p1"))))
(build-system gnu-build-system)
(propagated-inputs
`(("flint" ,flint))) ; flint.h is included by arf.h
@@ -508,8 +508,8 @@ fast arithmetic.")
(flint (assoc-ref inputs "flint"))
(gmp (assoc-ref inputs "gmp"))
(mpfr (assoc-ref inputs "mpfr")))
- ;; do not pass "--enable-fast-install", which makes the
- ;; homebrew configure process fail
+ ;; Do not pass "--enable-fast-install", which makes the
+ ;; homebrew configure process fail.
(invoke "./configure"
(string-append "--prefix=" out)
(string-append "--with-flint=" flint)
@@ -522,7 +522,7 @@ arithmetic. It supports efficient high-precision computation with
polynomials, power series, matrices and special functions over the
real and complex numbers, with automatic, rigorous error control.")
(license license:lgpl2.1+)
- (home-page "http://fredrikj.net/arb/")))
+ (home-page "http://arblib.org")))
(define-public python-flint
(package
diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index 110903e2fe..88b5696a9b 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -1107,7 +1107,7 @@ follower.")
(define-public fluidsynth
(package
(name "fluidsynth")
- (version "2.0.7")
+ (version "2.0.8")
(source (origin
(method git-fetch)
(uri (git-reference
@@ -1116,7 +1116,7 @@ follower.")
(file-name (git-file-name name version))
(sha256
(base32
- "1h1dj3wmjwzny2hgr41k3p67w4kxvzn365kkqwyfd6yk0v3rahic"))))
+ "1s32c0jxjica2agy0mp36vgvpgj2vl5i5zvacd6igmbam0x4gs7c"))))
(build-system cmake-build-system)
(arguments
'(#:tests? #f ; no check target
diff --git a/gnu/packages/bittorrent.scm b/gnu/packages/bittorrent.scm
index 416186409c..6b6998b323 100644
--- a/gnu/packages/bittorrent.scm
+++ b/gnu/packages/bittorrent.scm
@@ -416,7 +416,7 @@ desktops.")
(define-public qbittorrent
(package
(name "qbittorrent")
- (version "4.1.8")
+ (version "4.1.9")
(source
(origin
(method git-fetch)
@@ -425,7 +425,7 @@ desktops.")
(commit (string-append "release-" version))))
(file-name (git-file-name name version))
(sha256
- (base32 "1mx59mazfmd5yaqdgb6cm8hr5sbp2xgzz3y3yipq1fwq85dj3r5w"))))
+ (base32 "044r3y3vvm2rqagmwlqlhvb4kkyqpkmpnlhv68hzkl3w5bvf8zl8"))))
(build-system gnu-build-system)
(arguments
`(#:configure-flags
diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
index ee713db0cf..c6e3c697e6 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -33,6 +33,7 @@
#:use-module ((guix derivations)
#:select (derivation derivation-input derivation->output-path))
#:use-module ((guix utils) #:select (gnu-triplet->nix-system))
+ #:use-module ((guix gexp) #:select (lower-object))
#:use-module (guix memoization)
#:use-module (guix i18n)
#:use-module (srfi srfi-1)
@@ -167,19 +168,22 @@ for system '~a'")
("patch" ,%bootstrap-coreutils&co)))
(let ((orig-method (origin-method source)))
- (origin (inherit source)
- (method (cond ((eq? orig-method url-fetch)
- (boot url-fetch))
- (else orig-method)))
- (patch-guile %bootstrap-guile)
- (patch-inputs %bootstrap-patch-inputs)
-
- ;; Patches can be origins as well, so process them.
- (patches (map (match-lambda
- ((? origin? patch)
- (bootstrap-origin patch))
- (patch patch))
- (origin-patches source))))))
+ (if (or (not (null? (origin-patches source)))
+ (origin-snippet source))
+ (origin (inherit source)
+ (method (if (eq? orig-method url-fetch)
+ (boot url-fetch)
+ orig-method))
+ (patch-guile %bootstrap-guile)
+ (patch-inputs %bootstrap-patch-inputs)
+
+ ;; Patches can be origins as well, so process them.
+ (patches (map (match-lambda
+ ((? origin? patch)
+ (bootstrap-origin patch))
+ (patch patch))
+ (origin-patches source))))
+ source)))
(define* (package-from-tarball name source program-to-test description
#:key snippet)
@@ -345,8 +349,8 @@ or false to signal an error."
#:allow-other-keys)
(define (->store file)
(run-with-store store
- (origin->derivation (bootstrap-executable file system)
- system)))
+ (lower-object (bootstrap-executable file system)
+ system)))
(let* ((tar (->store "tar"))
(xz (->store "xz"))
diff --git a/gnu/packages/cdrom.scm b/gnu/packages/cdrom.scm
index ef4ce022e4..9c2b11c047 100644
--- a/gnu/packages/cdrom.scm
+++ b/gnu/packages/cdrom.scm
@@ -3,7 +3,7 @@
;;; Copyright © 2013, 2014 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
;;; Copyright © 2015 Paul van der Walt <paul@denknerd.org>
-;;; Copyright © 2015, 2016, 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2015, 2016, 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2017 John Darrington <jmd@gnu.org>
@@ -155,17 +155,14 @@ libcdio.")
(define-public xorriso
(package
(name "xorriso")
- (version "1.5.0")
+ (version "1.5.2")
(source (origin
(method url-fetch)
(uri (string-append "mirror://gnu/xorriso/xorriso-"
version ".tar.gz"))
(sha256
(base32
- "0aq6lvlwlkxz56l5sbvgycr6j5c82ch2bv6zrnc2345ibfpafgx9"))
- (patches
- (search-patches "xorriso-no-partition-table-in-inner-efi.patch"
- "xorriso-no-mbr-in-inner-efi.patch"))))
+ "1rqpzj95f70jfwpn4lamasfgqpizjsipz12aprdhri777b4zas9v"))))
(build-system gnu-build-system)
(arguments
`(#:phases
@@ -815,14 +812,14 @@ DVD-RW, DVD-R, DVD-R/DL, BD-R, and BD-RE.")
(define-public libisofs
(package
(name "libisofs")
- (version "1.5.0")
+ (version "1.5.2")
(source (origin
(method url-fetch)
(uri (string-append "http://files.libburnia-project.org/releases/"
"libisofs-" version ".tar.gz"))
(sha256
(base32
- "001l3akf3wb6msl9man776w560iqyvsbwwzs7d7y7msx13irspys"))))
+ "002mcyqwg625a8hqvsrmgm26mhhfwj0j7rahfhsqirmk02b16npg"))))
(build-system gnu-build-system)
(inputs
`(("zlib" ,zlib)
diff --git a/gnu/packages/ci.scm b/gnu/packages/ci.scm
index 964980ef88..b49ac0f7c1 100644
--- a/gnu/packages/ci.scm
+++ b/gnu/packages/ci.scm
@@ -3,7 +3,7 @@
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2016, 2017 Mathieu Lirzin <mthl@gnu.org>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
-;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
;;;
;;; This file is part of GNU Guix.
@@ -47,8 +47,8 @@
#:use-module (guix build-system gnu))
(define-public cuirass
- (let ((commit "80b6e89a7b2e9a6f9dee26dcf22277970930039f")
- (revision "25"))
+ (let ((commit "e20ff86d97f7dd92dad140b5919e3cbdf2fb1ce6")
+ (revision "26"))
(package
(name "cuirass")
(version (string-append "0.0.1-" revision "." (string-take commit 7)))
@@ -60,7 +60,7 @@
(file-name (string-append name "-" version))
(sha256
(base32
- "0m7g7wqa1l8gab8pcyi43a6w6rxhaqbpsrwlnadwsds1b95x9bka"))))
+ "1c3rcfmx7vm13x3nid9xbl18rrqljh5vb71qxps4yqid75br4hrb"))))
(build-system gnu-build-system)
(arguments
'(#:modules ((guix build utils)
diff --git a/gnu/packages/cran.scm b/gnu/packages/cran.scm
index fc5d40186c..1509ff5d0d 100644
--- a/gnu/packages/cran.scm
+++ b/gnu/packages/cran.scm