Makefile.am 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. # Makefile.am -- How to build and install the Shepherd.
  2. # Copyright © 2002, 2003 Wolfgang Jährling <wolfgang@pro-linux.de>
  3. # Copyright © 2013, 2014, 2015, 2016, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
  4. # Copyright © 2018 Carlo Zancanaro <carlo@zancanaro.id.au>
  5. #
  6. # This file is part of the GNU Shepherd.
  7. #
  8. # The GNU Shepherd 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. # The GNU Shepherd 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 the GNU Shepherd. If not, see <http://www.gnu.org/licenses/>.
  20. # The main programs.
  21. bin_SCRIPTS = shepherd herd
  22. sbin_SCRIPTS = halt reboot
  23. templates = \
  24. shepherd.in herd.in halt.in reboot.in \
  25. modules/shepherd/config.scm.in \
  26. modules/shepherd/system.scm.in
  27. # Build this module first.
  28. BUILT_SOURCES = modules/shepherd/config.scm
  29. # The source files.
  30. # XXX: we can't use 'nobase_' because of the modules/ subdirectory.
  31. dist_guilemodule_DATA = \
  32. modules/shepherd.scm
  33. nodist_guileobject_DATA = $(dist_guilemodule_DATA:%.scm=%.go)
  34. shepherdsubdir = $(guilemoduledir)/shepherd
  35. dist_shepherdsub_DATA = \
  36. modules/shepherd/args.scm \
  37. modules/shepherd/service.scm \
  38. modules/shepherd/support.scm \
  39. modules/shepherd/comm.scm
  40. nodist_shepherdsub_DATA = \
  41. modules/shepherd/config.scm \
  42. modules/shepherd/system.scm
  43. shepherdgosubdir = $(guileobjectdir)/shepherd
  44. nodist_shepherdgosub_DATA = \
  45. modules/shepherd/config.go \
  46. modules/shepherd/system.go \
  47. $(dist_shepherdsub_DATA:%.scm=%.go)
  48. scriptsdir = $(shepherdsubdir)/scripts
  49. dist_scripts_DATA = \
  50. modules/shepherd/scripts/halt.scm \
  51. modules/shepherd/scripts/herd.scm \
  52. modules/shepherd/scripts/reboot.scm
  53. scriptsgodir = $(shepherdgosubdir)/scripts
  54. nodist_scriptsgo_DATA = \
  55. $(dist_scripts_DATA:%.scm=%.go)
  56. CLEANFILES = \
  57. $(nodist_guilemodule_DATA) $(nodist_shepherdsub_DATA) \
  58. $(nodist_guileobject_DATA) \
  59. $(nodist_shepherdgosub_DATA) \
  60. $(nodist_scriptsgo_DATA) \
  61. $(bin_SCRIPTS) $(sbin_SCRIPTS)
  62. # Crash handler.
  63. EXTRA_DIST = etc/crash-handler.c etc/open-fdes.c
  64. libraries =
  65. all-local: $(libraries)
  66. if BUILD_CRASH_HANDLER
  67. # Build the crash handler "manually" rather than with Libtool.
  68. libraries += etc/crash-handler.so
  69. install-crash-handler:
  70. $(MKDIR_P) $(DESTDIR)$(pkglibdir)
  71. $(INSTALL) -m 755 etc/crash-handler.so \
  72. $(DESTDIR)$(pkglibdir)/crash-handler.so
  73. etc/crash-handler.so: etc/crash-handler.c
  74. $(AM_V_GEN)$(MKDIR_P) etc; \
  75. $(CC) -O2 -g -Wall -shared -fPIC -o "$@" "$^"
  76. CLEANFILES += etc/crash-handler.so
  77. else !BUILD_CRASH_HANDLER
  78. install-crash-handler:
  79. endif !BUILD_CRASH_HANDLER
  80. # TODO it would be nice to build only a single library.
  81. if BUILD_OPEN_FDES
  82. libraries += etc/open-fdes.so
  83. install-open-fdes:
  84. $(MKDIR_P) $(DESTDIR)$(pkglibdir)
  85. $(INSTALL) -m 755 etc/open-fdes.so \
  86. $(DESTDIR)$(pkglibdir)/open-fdes.so
  87. etc/open-fdes.so: etc/open-fdes.c
  88. $(AM_V_GEN)$(MKDIR_P) etc; \
  89. $(CC) -O2 -g -Wall -shared -fPIC -o "$@" "$^"
  90. else !BUILD_OPEN_FDES
  91. install-open-fdes:
  92. endif
  93. .PHONY: install-crash-handler install-open-fdes
  94. # Documentation.
  95. info_TEXINFOS = doc/shepherd.texi
  96. doc_shepherd_TEXINFOS = doc/fdl-1.3.texi
  97. AM_V_HELP2MAN = $(AM_V_HELP2MAN_$(V))
  98. AM_V_HELP2MAN_ = $(AM_V_HELP2MAN_$(AM_DEFAULT_VERBOSITY))
  99. AM_V_HELP2MAN_0 = @echo " HELP2MAN" $@;
  100. HELP2MANFLAGS = --source=GNU --info-page=$(PACKAGE_TARNAME)
  101. gen_man = $(AM_V_HELP2MAN)LANGUAGE= $(HELP2MAN) $(HELP2MANFLAGS)
  102. doc/shepherd.1: modules/shepherd.scm configure.ac
  103. $(gen_man) --output="$@" "$(top_builddir)/`basename "$@" .1`"
  104. doc/%.1: modules/shepherd/scripts/%.scm configure.ac
  105. $(gen_man) --output="$@" "$(top_builddir)/`basename "$@" .1`"
  106. doc/%.8: modules/shepherd/scripts/%.scm configure.ac
  107. $(gen_man) --section=8 --output="$@" \
  108. "$(top_builddir)/`basename "$@" .8`"
  109. dist_man1_MANS = doc/shepherd.1 doc/herd.1
  110. dist_man8_MANS = doc/halt.8 doc/reboot.8
  111. # Things not automatically included in the distribution.
  112. EXTRA_DIST += \
  113. build-aux/config.rpath \
  114. ChangeLog-2003 \
  115. QUESTIONS \
  116. $(templates) \
  117. doc/examples/README \
  118. doc/examples/_unknown.scm \
  119. doc/examples/wolfgangj.scm
  120. # Create the socket directory (aka. 'default-socket-dir'.) Make it
  121. # accessible only by its owner since otherwise 'shepherd' suggests using
  122. # '--insecure'. This is just a convenience, so allow it to fail.
  123. install-data-local:
  124. -$(MKDIR_P) $(DESTDIR)$(localstatedir)/run/shepherd
  125. -chmod 700 $(DESTDIR)$(localstatedir)/run/shepherd
  126. # Relocate the script---i.e., have them refer to the installed module
  127. # directory.
  128. install-exec-hook: install-executable-symlinks install-crash-handler install-open-fdes
  129. for script in \
  130. $(bin_SCRIPTS:%=$(DESTDIR)$(bindir)/%) \
  131. $(sbin_SCRIPTS:%=$(DESTDIR)$(sbindir)/%) ; \
  132. do \
  133. $(SED) -e's|$(abs_top_srcdir)/modules\(.*\)%load-path|$(guilemoduledir)\1%load-path|g' \
  134. -e's|$(abs_top_builddir)/modules\(.*\)%load-compiled-path|$(guileobjectdir)\1%load-compiled-path|g' \
  135. -i $$script ; \
  136. done
  137. # Install 'shutdown' as a symlink to 'halt; XXX: someday we'll do
  138. # better.
  139. install-executable-symlinks:
  140. cd $(DESTDIR)$(sbindir); ln -s halt shutdown
  141. # Remove the 'shutdown' symlink and 'crash-handler.so'.
  142. uninstall-hook:
  143. cd $(DESTDIR)$(sbindir); rm -f shutdown
  144. cd $(DESTDIR)$(pkglibdir); rm -f crash-handler.so
  145. # 'sed' expression to instantiate templates.
  146. instantiate = \
  147. -e 's,%PREFIX%,${prefix},g' \
  148. -e 's,%modsrcdir%,${abs_top_srcdir}/modules,g' \
  149. -e 's,%modbuilddir%,${abs_top_builddir}/modules,g' \
  150. -e 's,%localstatedir%,${localstatedir},g' \
  151. -e 's,%pkglibdir%,${pkglibdir},g' \
  152. -e 's,%sysconfdir%,${sysconfdir},g' \
  153. -e 's,%localedir%,${localedir},g' \
  154. -e 's,%VERSION%,@VERSION@,g' \
  155. -e 's,%PACKAGE_BUGREPORT%,@PACKAGE_BUGREPORT@,g' \
  156. -e 's,%PACKAGE_NAME%,@PACKAGE_NAME@,g' \
  157. -e 's,%PACKAGE_URL%,@PACKAGE_URL@,g' \
  158. -e 's,%GUILE%,$(GUILE),g'
  159. # Instantiate templates.
  160. # Emit a 'chmod +x' command only if $@ matches one of the scripts.
  161. maybe_executable = \
  162. $(subst $@,chmod +x $@, \
  163. $(findstring $@,$(bin_SCRIPTS) $(sbin_SCRIPTS)))
  164. %: %.in Makefile
  165. $(AM_V_GEN)$(MKDIR_P) "`dirname $@`" ; \
  166. $(SED) $(instantiate) < $< >$@ ; \
  167. $(maybe_executable)
  168. modules/shepherd/config.scm: modules/shepherd/config.scm.in Makefile
  169. $(MKDIR_P) "`dirname $@`"
  170. $(SED) $(instantiate) < $< >$@
  171. AM_V_GUILEC = $(AM_V_GUILEC_$(V))
  172. AM_V_GUILEC_ = $(AM_V_GUILEC_$(AM_DEFAULT_VERBOSITY))
  173. AM_V_GUILEC_0 = @echo " GUILEC " $@;
  174. # Make sure 'modules/shepherd/{config,system.scm}' are built first.
  175. # Unset 'GUILE_LOAD_COMPILED_PATH' so we can be sure that any .go file that we
  176. # load comes from the build directory.
  177. # XXX: Use the C locale for when Guile lacks
  178. # <http://git.sv.gnu.org/cgit/guile.git/commit/?h=stable-2.0&id=e2c6bf3866d1186c60bacfbd4fe5037087ee5e3f>.
  179. %.go: %.scm $(templates:%.in=%)
  180. $(AM_V_GUILEC)$(MKDIR_P) "`dirname "$@"`" ; \
  181. $(AM_V_P) && out=1 || out=- ; \
  182. unset GUILE_LOAD_COMPILED_PATH ; LC_ALL=C \
  183. $(GUILD) compile --target="$(host)" \
  184. -L "$(top_builddir)/modules" \
  185. -L "$(top_srcdir)/modules" \
  186. -Wformat -Wunbound-variable -Warity-mismatch \
  187. -o "$@" "$<" >&$$out
  188. SUFFIXES = .go
  189. TESTS = \
  190. tests/basic.sh \
  191. tests/replacement.sh \
  192. tests/respawn.sh \
  193. tests/respawn-throttling.sh \
  194. tests/restart.sh \
  195. tests/misbehaved-client.sh \
  196. tests/no-home.sh \
  197. tests/pid-file.sh \
  198. tests/file-creation-mask.sh \
  199. tests/status-sexp.sh \
  200. tests/forking-service.sh \
  201. tests/one-shot.sh \
  202. tests/signals.sh \
  203. tests/fd-mapping.sh
  204. TEST_EXTENSIONS = .sh
  205. EXTRA_DIST += $(TESTS)
  206. AM_TESTS_ENVIRONMENT = \
  207. unset XDG_CONFIG_HOME; unset LANGUAGE; \
  208. LC_ALL=C LC_MESSAGES=C \
  209. PATH="$(abs_top_builddir):$$PATH" \
  210. SHELL="$(SHELL)" GUILE="$(GUILE)" \
  211. GUILE_LOAD_PATH="$(abs_top_srcdir)/modules:$(abs_top_builddir)/modules:$$GUILE_LOAD_PATH" \
  212. GUILE_LOAD_COMPILED_PATH="$(abs_top_srcdir)/modules:$(abs_top_builddir)/modules:$$GUILE_LOAD_COMPILED_PATH"
  213. SH_LOG_COMPILER = $(SHELL)
  214. AM_SH_LOG_FLAGS = -x -e
  215. # Make sure source files are installed first, so that the mtime of
  216. # installed compiled files is greater than that of installed source
  217. # files. See
  218. # <http://lists.gnu.org/archive/html/guile-devel/2010-07/msg00125.html>
  219. # for details.
  220. shepherd_install_go_files = install-nodist_guileobjectDATA
  221. $(shepherd_install_go_files): install-dist_guilemoduleDATA
  222. shepherdsub_install_go_files = install-nodist_shepherdgosubDATA
  223. $(shepherdsub_install_go_files): install-dist_shepherdsubDATA install-nodist_shepherdsubDATA
  224. scripts_install_go_files = install-nodist_scriptsgoDATA
  225. $(scripts_install_go_files): install-dist_scriptsDATA
  226. gen-ChangeLog:
  227. if test -d .git; then \
  228. $(top_srcdir)/build-aux/gitlog-to-changelog \
  229. 8da9cf2..HEAD > $(distdir)/cl-t; \
  230. rm -f $(distdir)/ChangeLog; \
  231. mv $(distdir)/cl-t $(distdir)/ChangeLog; \
  232. fi
  233. dist-hook: gen-ChangeLog
  234. .PHONY: gen-ChangeLog
  235. SUBDIRS = po
  236. ACLOCAL_AMFLAGS = -I m4