daemon: Install 'authenticate' script under LIBEXECDIR/guix.
[jackhill/guix/guix.git] / nix / local.mk
1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2012, 2013, 2014, 2015, 2016, 2018 Ludovic Courtès <ludo@gnu.org>
3 # Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
4 #
5 # This file is part of GNU Guix.
6 #
7 # GNU Guix is free software; you can redistribute it and/or modify it
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 #
12 # GNU Guix is distributed in the hope that it will be useful, but
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
18 # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 #
21 # Integration of the `guix-daemon' code taken from upstream Nix.
22 #
23
24 BUILT_SOURCES += %D%/libstore/schema.sql.hh
25 CLEANFILES += %D%/libstore/schema.sql.hh
26
27 noinst_LIBRARIES = libformat.a libutil.a libstore.a
28
29 # Use '-std=c++11' for 'std::shared_ptr', 'auto', lambdas, and more.
30 AM_CXXFLAGS = -Wall -std=c++11
31
32 libformat_a_SOURCES = \
33 %D%/boost/format/free_funcs.cc \
34 %D%/boost/format/parsing.cc \
35 %D%/boost/format/format_implementation.cc
36
37 libformat_headers = \
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
49
50 libformat_a_CPPFLAGS = \
51 -I$(top_srcdir)/nix
52
53 libutil_a_SOURCES = \
54 %D%/libutil/archive.cc \
55 %D%/libutil/affinity.cc \
56 %D%/libutil/serialise.cc \
57 %D%/libutil/util.cc \
58 %D%/libutil/hash.cc \
59 %D%/libutil/gcrypt-hash.cc
60
61 libutil_headers = \
62 %D%/libutil/affinity.hh \
63 %D%/libutil/hash.hh \
64 %D%/libutil/serialise.hh \
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
73
74 libutil_a_CPPFLAGS = \
75 -I$(top_builddir)/nix \
76 -I$(top_srcdir)/%D%/libutil \
77 $(libformat_a_CPPFLAGS)
78
79 libstore_a_SOURCES = \
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 \
90 %D%/libstore/builtins.cc \
91 %D%/libstore/sqlite.cc
92
93 libstore_headers = \
94 %D%/libstore/references.hh \
95 %D%/libstore/pathlocks.hh \
96 %D%/libstore/globals.hh \
97 %D%/libstore/worker-protocol.hh \
98 %D%/libstore/derivations.hh \
99 %D%/libstore/misc.hh \
100 %D%/libstore/local-store.hh \
101 %D%/libstore/sqlite.hh \
102 %D%/libstore/builtins.hh \
103 %D%/libstore/store-api.hh
104
105 libstore_a_CPPFLAGS = \
106 $(libutil_a_CPPFLAGS) \
107 -I$(top_srcdir)/%D%/libstore \
108 -I$(top_builddir)/%D%/libstore \
109 -DNIX_STORE_DIR=\"$(storedir)\" \
110 -DNIX_DATA_DIR=\"$(datadir)\" \
111 -DNIX_STATE_DIR=\"$(localstatedir)/guix\" \
112 -DNIX_LOG_DIR=\"$(localstatedir)/log/guix\" \
113 -DGUIX_CONFIGURATION_DIRECTORY=\"$(sysconfdir)/guix\" \
114 -DNIX_LIBEXEC_DIR=\"$(libexecdir)\" \
115 -DNIX_BIN_DIR=\"$(bindir)\" \
116 -DDEFAULT_CHROOT_DIRS="\"\""
117
118 libstore_a_CXXFLAGS = $(AM_CXXFLAGS) \
119 $(SQLITE3_CFLAGS) $(LIBGCRYPT_CFLAGS)
120
121 bin_PROGRAMS = guix-daemon
122
123 guix_daemon_SOURCES = \
124 %D%/nix-daemon/nix-daemon.cc \
125 %D%/nix-daemon/guix-daemon.cc
126
127 guix_daemon_CPPFLAGS = \
128 -DLOCALEDIR=\"$(localedir)\" \
129 $(libutil_a_CPPFLAGS) \
130 -I$(top_srcdir)/%D%/libstore
131
132 guix_daemon_LDADD = \
133 libstore.a libutil.a libformat.a -lz \
134 $(SQLITE3_LIBS) $(LIBGCRYPT_LIBS)
135
136 guix_daemon_headers = \
137 %D%/nix-daemon/shared.hh
138
139 if HAVE_LIBBZ2
140
141 guix_daemon_LDADD += -lbz2
142
143 endif HAVE_LIBBZ2
144
145 noinst_HEADERS = \
146 $(libformat_headers) $(libutil_headers) $(libstore_headers) \
147 $(guix_daemon_headers)
148
149 %D%/libstore/schema.sql.hh: guix/store/schema.sql
150 $(AM_V_GEN)$(GUILE) --no-auto-compile -c \
151 "(use-modules (rnrs io ports)) \
152 (call-with-output-file \"$@\" \
153 (lambda (out) \
154 (call-with-input-file \"$^\" \
155 (lambda (in) \
156 (write (get-string-all in) out)))))"
157
158 nodist_pkglibexec_SCRIPTS = \
159 %D%/scripts/list-runtime-roots \
160 %D%/scripts/substitute \
161 %D%/scripts/download
162
163 if BUILD_DAEMON_OFFLOAD
164
165 nodist_pkglibexec_SCRIPTS += \
166 %D%/scripts/offload
167
168 endif BUILD_DAEMON_OFFLOAD
169
170 nodist_pkglibexec_SCRIPTS += \
171 %D%/scripts/authenticate
172
173 # The '.service' files for systemd.
174 systemdservicedir = $(libdir)/systemd/system
175 nodist_systemdservice_DATA = etc/guix-daemon.service etc/guix-publish.service
176
177 etc/guix-%.service: etc/guix-%.service.in \
178 $(top_builddir)/config.status
179 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
180 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
181 "$<" > "$@.tmp"; \
182 mv "$@.tmp" "$@"
183
184 # The '.conf' jobs for Upstart.
185 upstartjobdir = $(libdir)/upstart/system
186 nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
187
188 etc/guix-%.conf: etc/guix-%.conf.in \
189 $(top_builddir)/config.status
190 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
191 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
192 "$<" > "$@.tmp"; \
193 mv "$@.tmp" "$@"
194
195 CLEANFILES += \
196 $(nodist_systemdservice_DATA) \
197 $(nodist_upstartjob_DATA)
198
199 EXTRA_DIST += \
200 %D%/AUTHORS \
201 %D%/COPYING \
202 etc/guix-daemon.service.in \
203 etc/guix-daemon.conf.in \
204 etc/guix-publish.service.in \
205 etc/guix-publish.conf.in
206
207 if CAN_RUN_TESTS
208
209 AM_TESTS_ENVIRONMENT += \
210 top_builddir="$(abs_top_builddir)"
211
212 TESTS += \
213 tests/guix-daemon.sh
214
215 endif CAN_RUN_TESTS
216
217 clean-local:
218 -if test -d "$(GUIX_TEST_ROOT)"; then \
219 find "$(GUIX_TEST_ROOT)" | xargs chmod +w; \
220 fi
221 -rm -rf "$(GUIX_TEST_ROOT)"