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