guix-install.sh: Support OpenRC.
[jackhill/guix/guix.git] / nix / local.mk
1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 # Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
4 # Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 #
6 # This file is part of GNU Guix.
7 #
8 # GNU Guix is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or (at
11 # your option) any later version.
12 #
13 # GNU Guix is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 #
22 # Integration of the `guix-daemon' code taken from upstream Nix.
23 #
24
25 BUILT_SOURCES += %D%/libstore/schema.sql.hh
26 CLEANFILES += %D%/libstore/schema.sql.hh
27
28 noinst_LIBRARIES = libformat.a libutil.a libstore.a
29
30 # Use '-std=c++11' for 'std::shared_ptr', 'auto', lambdas, and more.
31 AM_CXXFLAGS = -Wall -std=c++11
32
33 libformat_a_SOURCES = \
34 %D%/boost/format/free_funcs.cc \
35 %D%/boost/format/parsing.cc \
36 %D%/boost/format/format_implementation.cc
37
38 libformat_headers = \
39 %D%/boost/throw_exception.hpp \
40 %D%/boost/format.hpp \
41 %D%/boost/assert.hpp \
42 %D%/boost/format/macros_default.hpp \
43 %D%/boost/format/format_fwd.hpp \
44 %D%/boost/format/format_class.hpp \
45 %D%/boost/format/exceptions.hpp \
46 %D%/boost/format/group.hpp \
47 %D%/boost/format/feed_args.hpp \
48 %D%/boost/format/internals_fwd.hpp \
49 %D%/boost/format/internals.hpp
50
51 libformat_a_CPPFLAGS = \
52 -I$(top_srcdir)/nix
53
54 libutil_a_SOURCES = \
55 %D%/libutil/archive.cc \
56 %D%/libutil/affinity.cc \
57 %D%/libutil/serialise.cc \
58 %D%/libutil/util.cc \
59 %D%/libutil/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
69 libutil_a_CPPFLAGS = \
70 -I$(top_builddir)/nix \
71 -I$(top_srcdir)/%D%/libutil \
72 $(libformat_a_CPPFLAGS)
73
74 libstore_a_SOURCES = \
75 %D%/libstore/gc.cc \
76 %D%/libstore/globals.cc \
77 %D%/libstore/misc.cc \
78 %D%/libstore/references.cc \
79 %D%/libstore/store-api.cc \
80 %D%/libstore/optimise-store.cc \
81 %D%/libstore/local-store.cc \
82 %D%/libstore/build.cc \
83 %D%/libstore/pathlocks.cc \
84 %D%/libstore/derivations.cc \
85 %D%/libstore/builtins.cc \
86 %D%/libstore/sqlite.cc
87
88 libstore_headers = \
89 %D%/libstore/references.hh \
90 %D%/libstore/pathlocks.hh \
91 %D%/libstore/globals.hh \
92 %D%/libstore/worker-protocol.hh \
93 %D%/libstore/derivations.hh \
94 %D%/libstore/misc.hh \
95 %D%/libstore/local-store.hh \
96 %D%/libstore/sqlite.hh \
97 %D%/libstore/builtins.hh \
98 %D%/libstore/store-api.hh
99
100 libstore_a_CPPFLAGS = \
101 $(libutil_a_CPPFLAGS) \
102 -I$(top_srcdir)/%D%/libstore \
103 -I$(top_builddir)/%D%/libstore \
104 -DNIX_STORE_DIR=\"$(storedir)\" \
105 -DNIX_STATE_DIR=\"$(localstatedir)/guix\" \
106 -DNIX_LOG_DIR=\"$(localstatedir)/log/guix\" \
107 -DGUIX_CONFIGURATION_DIRECTORY=\"$(sysconfdir)/guix\" \
108 -DNIX_BIN_DIR=\"$(bindir)\" \
109 -DDEFAULT_CHROOT_DIRS="\"\""
110
111 libstore_a_CXXFLAGS = $(AM_CXXFLAGS) \
112 $(SQLITE3_CFLAGS) $(LIBGCRYPT_CFLAGS)
113
114 bin_PROGRAMS = guix-daemon
115
116 guix_daemon_SOURCES = \
117 %D%/nix-daemon/nix-daemon.cc \
118 %D%/nix-daemon/guix-daemon.cc
119
120 guix_daemon_CPPFLAGS = \
121 -DLOCALEDIR=\"$(localedir)\" \
122 $(libutil_a_CPPFLAGS) \
123 -I$(top_srcdir)/%D%/libstore
124
125 guix_daemon_LDADD = \
126 libstore.a libutil.a libformat.a -lz \
127 $(SQLITE3_LIBS) $(LIBGCRYPT_LIBS)
128
129 guix_daemon_headers = \
130 %D%/nix-daemon/shared.hh
131
132 if HAVE_LIBBZ2
133
134 guix_daemon_LDADD += -lbz2
135
136 endif HAVE_LIBBZ2
137
138 noinst_HEADERS = \
139 $(libformat_headers) $(libutil_headers) $(libstore_headers) \
140 $(guix_daemon_headers)
141
142 %D%/libstore/schema.sql.hh: guix/store/schema.sql
143 $(AM_V_GEN)$(GUILE) --no-auto-compile -c \
144 "(use-modules (rnrs io ports)) \
145 (call-with-output-file \"$@\" \
146 (lambda (out) \
147 (call-with-input-file \"$^\" \
148 (lambda (in) \
149 (write (get-string-all in) out)))))"
150
151 # The '.service' files for systemd.
152 systemdservicedir = $(libdir)/systemd/system
153 nodist_systemdservice_DATA = \
154 etc/gnu-store.mount \
155 etc/guix-daemon.service \
156 etc/guix-publish.service
157
158 etc/%.mount: etc/%.mount.in \
159 $(top_builddir)/config.status
160 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
161 $(SED) -e 's|@''storedir''@|$(storedir)|' < \
162 "$<" > "$@.tmp"; \
163 mv "$@.tmp" "$@"
164
165 etc/guix-%.service: etc/guix-%.service.in \
166 $(top_builddir)/config.status
167 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
168 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
169 "$<" > "$@.tmp"; \
170 mv "$@.tmp" "$@"
171
172 # The service script for sysvinit.
173 sysvinitservicedir = $(sysconfdir)/init.d
174 nodist_sysvinitservice_DATA = etc/init.d/guix-daemon
175
176 etc/init.d/guix-daemon: etc/init.d/guix-daemon.in \
177 $(top_builddir)/config.status
178 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
179 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
180 "$<" > "$@.tmp"; \
181 mv "$@.tmp" "$@"
182
183 # The service script for openrc.
184 openrcservicedir = $(sysconfdir)/init.d
185 nodist_openrcservice_DATA = etc/openrc/guix-daemon
186
187 etc/openrc/guix-daemon: etc/openrc/guix-daemon.in \
188 $(top_builddir)/config.status
189 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
190 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
191 "$<" > "$@.tmp"; \
192 mv "$@.tmp" "$@"
193
194 # The '.conf' jobs for Upstart.
195 upstartjobdir = $(libdir)/upstart/system
196 nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
197
198 etc/guix-%.conf: etc/guix-%.conf.in \
199 $(top_builddir)/config.status
200 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
201 $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
202 "$<" > "$@.tmp"; \
203 mv "$@.tmp" "$@"
204
205 CLEANFILES += \
206 $(nodist_systemdservice_DATA) \
207 $(nodist_upstartjob_DATA) \
208 $(nodist_sysvinitservice_DATA) \
209 $(nodist_openrcservice_DATA)
210
211 EXTRA_DIST += \
212 %D%/AUTHORS \
213 %D%/COPYING \
214 etc/guix-daemon.service.in \
215 etc/guix-daemon.conf.in \
216 etc/guix-publish.service.in \
217 etc/guix-publish.conf.in \
218 etc/init.d/guix-daemon.in \
219 etc/openrc/guix-daemon.in
220
221 if CAN_RUN_TESTS
222
223 AM_TESTS_ENVIRONMENT += \
224 top_builddir="$(abs_top_builddir)"
225
226 TESTS += \
227 tests/guix-daemon.sh
228
229 endif CAN_RUN_TESTS
230
231 clean-local:
232 -if test -d "$(GUIX_TEST_ROOT)"; then \
233 find "$(GUIX_TEST_ROOT)" | xargs chmod +w; \
234 fi
235 -rm -rf "$(GUIX_TEST_ROOT)"