daemon: Turn retrying SQLite transactions into a higher-order function.
[jackhill/guix/guix.git] / nix / local.mk
CommitLineData
233e7676 1# GNU Guix --- Functional package management for GNU
bb251307 2# Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
e71ad29d 3# Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
c2033df4 4#
233e7676 5# This file is part of GNU Guix.
c2033df4 6#
233e7676 7# GNU Guix is free software; you can redistribute it and/or modify it
c2033df4
LC
8# under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or (at
10# your option) any later version.
11#
233e7676 12# GNU Guix is distributed in the hope that it will be useful, but
c2033df4
LC
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
233e7676 18# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
c2033df4
LC
19
20#
21# Integration of the `guix-daemon' code taken from upstream Nix.
22#
23
c0d2e7b1 24BUILT_SOURCES += %D%/libstore/schema.sql.hh
ad227484 25CLEANFILES += $(BUILT_SOURCES) etc/guix-daemon.service etc/guix-daemon.conf
c2033df4
LC
26
27noinst_LIBRARIES = libformat.a libutil.a libstore.a
28
2bb04905
LC
29# Use '-std=c++11' for 'std::shared_ptr', 'auto', lambdas, and more.
30AM_CXXFLAGS = -Wall -std=c++11
996ed6ac 31
c2033df4 32libformat_a_SOURCES = \
c0d2e7b1
ML
33 %D%/boost/format/free_funcs.cc \
34 %D%/boost/format/parsing.cc \
35 %D%/boost/format/format_implementation.cc
c2033df4
LC
36
37libformat_headers = \
c0d2e7b1
ML
38 %D%/boost/throw_exception.hpp \
39 %D%/boost/format.hpp \
40 %D%/boost/assert.hpp \
41 %D%/boost/format/macros_default.hpp \
42 %D%/boost/format/format_fwd.hpp \
43 %D%/boost/format/format_class.hpp \
44 %D%/boost/format/exceptions.hpp \
45 %D%/boost/format/group.hpp \
46 %D%/boost/format/feed_args.hpp \
47 %D%/boost/format/internals_fwd.hpp \
48 %D%/boost/format/internals.hpp
c2033df4
LC
49
50libformat_a_CPPFLAGS = \
51 -I$(top_srcdir)/nix
52
53libutil_a_SOURCES = \
c0d2e7b1
ML
54 %D%/libutil/archive.cc \
55 %D%/libutil/affinity.cc \
56 %D%/libutil/serialise.cc \
57 %D%/libutil/util.cc \
c0d2e7b1
ML
58 %D%/libutil/hash.cc \
59 %D%/libutil/gcrypt-hash.cc
c2033df4
LC
60
61libutil_headers = \
c0d2e7b1
ML
62 %D%/libutil/affinity.hh \
63 %D%/libutil/hash.hh \
64 %D%/libutil/serialise.hh \
c0d2e7b1
ML
65 %D%/libutil/util.hh \
66 %D%/libutil/archive.hh \
67 %D%/libutil/types.hh \
68 %D%/libutil/gcrypt-hash.hh \
69 %D%/libutil/md5.h \
70 %D%/libutil/sha1.h \
71 %D%/libutil/sha256.h \
72 %D%/libutil/sha512.h
c2033df4
LC
73
74libutil_a_CPPFLAGS = \
75 -I$(top_builddir)/nix \
c0d2e7b1 76 -I$(top_srcdir)/%D%/libutil \
c2033df4
LC
77 $(libformat_a_CPPFLAGS)
78
79libstore_a_SOURCES = \
c0d2e7b1
ML
80 %D%/libstore/gc.cc \
81 %D%/libstore/globals.cc \
82 %D%/libstore/misc.cc \
83 %D%/libstore/references.cc \
84 %D%/libstore/store-api.cc \
85 %D%/libstore/optimise-store.cc \
86 %D%/libstore/local-store.cc \
87 %D%/libstore/build.cc \
88 %D%/libstore/pathlocks.cc \
89 %D%/libstore/derivations.cc
c2033df4
LC
90
91libstore_headers = \
c0d2e7b1
ML
92 %D%/libstore/references.hh \
93 %D%/libstore/pathlocks.hh \
94 %D%/libstore/globals.hh \
95 %D%/libstore/worker-protocol.hh \
96 %D%/libstore/derivations.hh \
97 %D%/libstore/misc.hh \
98 %D%/libstore/local-store.hh \
99 %D%/libstore/store-api.hh
c2033df4
LC
100
101libstore_a_CPPFLAGS = \
102 $(libutil_a_CPPFLAGS) \
c0d2e7b1
ML
103 -I$(top_srcdir)/%D%/libstore \
104 -I$(top_builddir)/%D%/libstore \
c2033df4
LC
105 -DNIX_STORE_DIR=\"$(storedir)\" \
106 -DNIX_DATA_DIR=\"$(datadir)\" \
f5768afa
LC
107 -DNIX_STATE_DIR=\"$(localstatedir)/guix\" \
108 -DNIX_LOG_DIR=\"$(localstatedir)/log/guix\" \
9dd674db 109 -DGUIX_CONFIGURATION_DIRECTORY=\"$(sysconfdir)/guix\" \
c2033df4
LC
110 -DNIX_LIBEXEC_DIR=\"$(libexecdir)\" \
111 -DNIX_BIN_DIR=\"$(bindir)\" \
2bb04905
LC
112 -DOPENSSL_PATH="\"guix-authenticate\"" \
113 -DDEFAULT_CHROOT_DIRS="\"\""
c2033df4 114
06ea5c8f 115libstore_a_CXXFLAGS = $(AM_CXXFLAGS) \
c2033df4
LC
116 $(SQLITE3_CFLAGS) $(LIBGCRYPT_CFLAGS)
117
118bin_PROGRAMS = guix-daemon
a7a4e6a4 119sbin_PROGRAMS = guix-register
c2033df4
LC
120
121guix_daemon_SOURCES = \
c0d2e7b1
ML
122 %D%/nix-daemon/nix-daemon.cc \
123 %D%/nix-daemon/guix-daemon.cc
c2033df4
LC
124
125guix_daemon_CPPFLAGS = \
7887bcbf 126 -DLOCALEDIR=\"$(localedir)\" \
c2033df4 127 $(libutil_a_CPPFLAGS) \
c0d2e7b1 128 -I$(top_srcdir)/%D%/libstore
c2033df4
LC
129
130guix_daemon_LDADD = \
131 libstore.a libutil.a libformat.a -lbz2 \
132 $(SQLITE3_LIBS) $(LIBGCRYPT_LIBS)
133
351782e2 134guix_daemon_headers = \
c0d2e7b1 135 %D%/nix-daemon/shared.hh
c2033df4 136
a7a4e6a4
LC
137
138guix_register_SOURCES = \
c0d2e7b1 139 %D%/guix-register/guix-register.cc
a7a4e6a4
LC
140
141guix_register_CPPFLAGS = \
142 $(libutil_a_CPPFLAGS) \
143 $(libstore_a_CPPFLAGS) \
c0d2e7b1 144 -I$(top_srcdir)/%D%/libstore
a7a4e6a4
LC
145
146# XXX: Should we start using shared libs?
147guix_register_LDADD = \
148 libstore.a libutil.a libformat.a -lbz2 \
149 $(SQLITE3_LIBS) $(LIBGCRYPT_LIBS)
150
151
c2033df4 152noinst_HEADERS = \
351782e2
LC
153 $(libformat_headers) $(libutil_headers) $(libstore_headers) \
154 $(guix_daemon_headers)
c2033df4 155
c0d2e7b1 156%D%/libstore/schema.sql.hh: %D%/libstore/schema.sql
e71ad29d 157 $(AM_V_GEN)$(GUILE) --no-auto-compile -c \
c2033df4
LC
158 "(use-modules (rnrs io ports)) \
159 (call-with-output-file \"$@\" \
160 (lambda (out) \
161 (call-with-input-file \"$^\" \
162 (lambda (in) \
163 (write (get-string-all in) out)))))"
164
f5c82e15 165nodist_pkglibexec_SCRIPTS = \
c0d2e7b1
ML
166 %D%/scripts/list-runtime-roots \
167 %D%/scripts/substitute
f5c82e15 168
49e6291a
LC
169if BUILD_DAEMON_OFFLOAD
170
171nodist_pkglibexec_SCRIPTS += \
c0d2e7b1 172 %D%/scripts/offload
49e6291a
LC
173
174endif BUILD_DAEMON_OFFLOAD
175
176
7edccf4d
LC
177# XXX: It'd be better to hide it in $(pkglibexecdir).
178nodist_libexec_SCRIPTS = \
c0d2e7b1 179 %D%/scripts/guix-authenticate
7edccf4d 180
d2825c96
LC
181# The '.service' file for systemd.
182systemdservicedir = $(libdir)/systemd/system
183nodist_systemdservice_DATA = etc/guix-daemon.service
184
185etc/guix-daemon.service: etc/guix-daemon.service.in \
186 $(top_builddir)/config.status
e71ad29d 187 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
f262f9f5 188 $(SED) -e 's|@''bindir''@|$(bindir)|' < \
e71ad29d 189 "$(srcdir)/etc/guix-daemon.service.in" > "$@.tmp"; \
d2825c96
LC
190 mv "$@.tmp" "$@"
191
ad227484
MDRS
192# The '.conf' job for Upstart.
193upstartjobdir = $(libdir)/upstart/system
194nodist_upstartjob_DATA = etc/guix-daemon.conf
195
196etc/guix-daemon.conf: etc/guix-daemon.conf.in \
197 $(top_builddir)/config.status
e71ad29d 198 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
ad227484 199 $(SED) -e 's|@''bindir''@|$(bindir)|' < \
e71ad29d 200 "$(srcdir)/etc/guix-daemon.conf.in" > "$@.tmp"; \
ad227484
MDRS
201 mv "$@.tmp" "$@"
202
c2033df4 203EXTRA_DIST += \
c0d2e7b1
ML
204 %D%/libstore/schema.sql \
205 %D%/AUTHORS \
206 %D%/COPYING \
ad227484
MDRS
207 etc/guix-daemon.service.in \
208 etc/guix-daemon.conf.in
d23077dc 209
bb251307
LC
210if CAN_RUN_TESTS
211
d23077dc 212AM_TESTS_ENVIRONMENT += \
69cfce50 213 top_builddir="$(abs_top_builddir)"
d23077dc
LC
214
215TESTS += \
216 tests/guix-daemon.sh
217
bb251307
LC
218endif CAN_RUN_TESTS
219
d23077dc 220clean-local:
03fa2758
LC
221 -if test -d "$(GUIX_TEST_ROOT)"; then \
222 find "$(GUIX_TEST_ROOT)" | xargs chmod +w; \
223 fi
69cfce50 224 -rm -rf "$(GUIX_TEST_ROOT)"