local.mk 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. # Integration of the `guix-daemon' code taken from upstream Nix.
  22. #
  23. BUILT_SOURCES += %D%/libstore/schema.sql.hh
  24. CLEANFILES += %D%/libstore/schema.sql.hh
  25. noinst_LIBRARIES = libformat.a libutil.a libstore.a
  26. # Use '-std=c++11' for 'std::shared_ptr', 'auto', lambdas, and more.
  27. AM_CXXFLAGS = -Wall -std=c++11
  28. libformat_a_SOURCES = \
  29. %D%/boost/format/free_funcs.cc \
  30. %D%/boost/format/parsing.cc \
  31. %D%/boost/format/format_implementation.cc
  32. libformat_headers = \
  33. %D%/boost/throw_exception.hpp \
  34. %D%/boost/format.hpp \
  35. %D%/boost/assert.hpp \
  36. %D%/boost/format/macros_default.hpp \
  37. %D%/boost/format/format_fwd.hpp \
  38. %D%/boost/format/format_class.hpp \
  39. %D%/boost/format/exceptions.hpp \
  40. %D%/boost/format/group.hpp \
  41. %D%/boost/format/feed_args.hpp \
  42. %D%/boost/format/internals_fwd.hpp \
  43. %D%/boost/format/internals.hpp
  44. libformat_a_CPPFLAGS = \
  45. -I$(top_srcdir)/nix
  46. libutil_a_SOURCES = \
  47. %D%/libutil/archive.cc \
  48. %D%/libutil/affinity.cc \
  49. %D%/libutil/serialise.cc \
  50. %D%/libutil/util.cc \
  51. %D%/libutil/hash.cc
  52. libutil_headers = \
  53. %D%/libutil/affinity.hh \
  54. %D%/libutil/hash.hh \
  55. %D%/libutil/serialise.hh \
  56. %D%/libutil/util.hh \
  57. %D%/libutil/archive.hh \
  58. %D%/libutil/types.hh
  59. libutil_a_CPPFLAGS = \
  60. -I$(top_builddir)/nix \
  61. -I$(top_srcdir)/%D%/libutil \
  62. $(libformat_a_CPPFLAGS)
  63. libstore_a_SOURCES = \
  64. %D%/libstore/gc.cc \
  65. %D%/libstore/globals.cc \
  66. %D%/libstore/misc.cc \
  67. %D%/libstore/references.cc \
  68. %D%/libstore/store-api.cc \
  69. %D%/libstore/optimise-store.cc \
  70. %D%/libstore/local-store.cc \
  71. %D%/libstore/build.cc \
  72. %D%/libstore/pathlocks.cc \
  73. %D%/libstore/derivations.cc \
  74. %D%/libstore/builtins.cc \
  75. %D%/libstore/sqlite.cc
  76. libstore_headers = \
  77. %D%/libstore/references.hh \
  78. %D%/libstore/pathlocks.hh \
  79. %D%/libstore/globals.hh \
  80. %D%/libstore/worker-protocol.hh \
  81. %D%/libstore/derivations.hh \
  82. %D%/libstore/misc.hh \
  83. %D%/libstore/local-store.hh \
  84. %D%/libstore/sqlite.hh \
  85. %D%/libstore/builtins.hh \
  86. %D%/libstore/store-api.hh
  87. libstore_a_CPPFLAGS = \
  88. $(libutil_a_CPPFLAGS) \
  89. -I$(top_srcdir)/%D%/libstore \
  90. -I$(top_builddir)/%D%/libstore \
  91. -DNIX_STORE_DIR=\"$(storedir)\" \
  92. -DNIX_STATE_DIR=\"$(localstatedir)/guix\" \
  93. -DNIX_LOG_DIR=\"$(localstatedir)/log/guix\" \
  94. -DGUIX_CONFIGURATION_DIRECTORY=\"$(sysconfdir)/guix\" \
  95. -DNIX_BIN_DIR=\"$(bindir)\" \
  96. -DDEFAULT_CHROOT_DIRS="\"\""
  97. libstore_a_CXXFLAGS = $(AM_CXXFLAGS) \
  98. $(SQLITE3_CFLAGS) $(LIBGCRYPT_CFLAGS)
  99. bin_PROGRAMS = guix-daemon
  100. guix_daemon_SOURCES = \
  101. %D%/nix-daemon/nix-daemon.cc \
  102. %D%/nix-daemon/guix-daemon.cc
  103. guix_daemon_CPPFLAGS = \
  104. -DLOCALEDIR=\"$(localedir)\" \
  105. $(libutil_a_CPPFLAGS) \
  106. -I$(top_srcdir)/%D%/libstore
  107. guix_daemon_LDADD = \
  108. libstore.a libutil.a libformat.a -lz \
  109. $(SQLITE3_LIBS) $(LIBGCRYPT_LIBS)
  110. guix_daemon_headers = \
  111. %D%/nix-daemon/shared.hh
  112. if HAVE_LIBBZ2
  113. guix_daemon_LDADD += -lbz2
  114. endif HAVE_LIBBZ2
  115. noinst_HEADERS = \
  116. $(libformat_headers) $(libutil_headers) $(libstore_headers) \
  117. $(guix_daemon_headers)
  118. %D%/libstore/schema.sql.hh: guix/store/schema.sql
  119. $(AM_V_GEN)$(GUILE) --no-auto-compile -c \
  120. "(use-modules (rnrs io ports)) \
  121. (call-with-output-file \"$@\" \
  122. (lambda (out) \
  123. (call-with-input-file \"$^\" \
  124. (lambda (in) \
  125. (write (get-string-all in) out)))))"
  126. # The '.service' files for systemd.
  127. systemdservicedir = $(libdir)/systemd/system
  128. nodist_systemdservice_DATA = \
  129. etc/gnu-store.mount \
  130. etc/guix-daemon.service \
  131. etc/guix-publish.service
  132. etc/%.mount: etc/%.mount.in \
  133. $(top_builddir)/config.status
  134. $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
  135. $(SED) -e 's|@''storedir''@|$(storedir)|' < \
  136. "$<" > "$@.tmp"; \
  137. mv "$@.tmp" "$@"
  138. etc/guix-%.service: etc/guix-%.service.in \
  139. $(top_builddir)/config.status
  140. $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
  141. $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
  142. "$<" > "$@.tmp"; \
  143. mv "$@.tmp" "$@"
  144. # The service script for sysvinit.
  145. sysvinitservicedir = $(sysconfdir)/init.d
  146. nodist_sysvinitservice_DATA = etc/init.d/guix-daemon
  147. etc/init.d/guix-daemon: etc/init.d/guix-daemon.in \
  148. $(top_builddir)/config.status
  149. $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
  150. $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
  151. "$<" > "$@.tmp"; \
  152. mv "$@.tmp" "$@"
  153. # The service script for openrc.
  154. openrcservicedir = $(sysconfdir)/init.d
  155. nodist_openrcservice_DATA = etc/openrc/guix-daemon
  156. etc/openrc/guix-daemon: etc/openrc/guix-daemon.in \
  157. $(top_builddir)/config.status
  158. $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
  159. $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' < \
  160. "$<" > "$@.tmp"; \
  161. mv "$@.tmp" "$@"
  162. # The '.conf' jobs for Upstart.
  163. upstartjobdir = $(libdir)/upstart/system
  164. nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
  165. etc/guix-%.conf: etc/guix-%.conf.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. CLEANFILES += \
  172. $(nodist_systemdservice_DATA) \
  173. $(nodist_upstartjob_DATA) \
  174. $(nodist_sysvinitservice_DATA) \
  175. $(nodist_openrcservice_DATA)
  176. EXTRA_DIST += \
  177. %D%/AUTHORS \
  178. %D%/COPYING \
  179. etc/guix-daemon.service.in \
  180. etc/guix-daemon.conf.in \
  181. etc/guix-publish.service.in \
  182. etc/guix-publish.conf.in \
  183. etc/init.d/guix-daemon.in \
  184. etc/openrc/guix-daemon.in
  185. if CAN_RUN_TESTS
  186. AM_TESTS_ENVIRONMENT += \
  187. top_builddir="$(abs_top_builddir)"
  188. TESTS += \
  189. tests/guix-daemon.sh
  190. endif CAN_RUN_TESTS
  191. clean-local:
  192. -if test -d "$(GUIX_TEST_ROOT)"; then \
  193. find "$(GUIX_TEST_ROOT)" | xargs chmod +w; \
  194. fi
  195. -rm -rf "$(GUIX_TEST_ROOT)"