1 # Copyright 2020-2022 Ian Jackson and contributors to Hippotat
2 # SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Hippotat-OpenSSL-Exception
3 # There is NO WARRANTY.
9 SPHINXBUILD ?= sphinx-build
13 ifneq (,$(NAILING_CARGO))
15 NAILING_CARGO ?= nailing-cargo
16 CARGO = $(NAILING_CARGO)
17 BUILD_SUBDIR ?= ../Build
18 TARGET_DIR ?= $(BUILD_SUBDIR)/$(notdir $(PWD))/target
19 NAILING_CARGO_JUST_RUN ?= $(NAILING_CARGO) --just-run -q ---
28 CARGO_RELEASE ?= release
29 TARGET_RELEASE_DIR ?= $(TARGET_DIR)/$(CARGO_RELEASE)
31 ifneq (debug,$(CARGO_RELEASE))
32 CARGO_RELEASE_ARG ?= --$(CARGO_RELEASE)
35 rsrcs = $(shell $(foreach x,$(MAKEFILE_FIND_X),set -$x;)\
36 find -H $1 \( -name Cargo.toml -o -name Cargo.lock -o -name Cargo.lock.example -o -name \*.rs \) )
37 stamp=@mkdir -p stamp; touch $@
39 TESTS=$(notdir $(wildcard test/t-*[^~]))
43 check: cargo-test $(addprefix stamp/,$(TESTS))
45 cargo-build: stamp/cargo-build
46 cargo-test: stamp/cargo-test
48 stamp/cargo-%: $(call rsrcs,.)
49 $(CARGO) $* $(CARGO_RELEASE_ARG) $(CARGO_BUILD_OPTIONS)
52 stamp/t-%: test/t-% stamp/cargo-build $(wildcard test/*[^~])
53 $(NAILING_CARGO_JUST_RUN) \
54 $(abspath test/capture-log) tmp/t-$*.log \
55 $(abspath test/go-with-unshare test/t-$*)
56 @echo OK t-$*; touch $@
58 doc: docs/html/index.html
59 @echo 'Documentation can now be found here:'
60 @echo ' file://$(PWD)/$<'
62 docs/html/index.html: docs/conf.py $(wildcard docs/*.md docs/*.rst docs/*.png)
64 $(SPHINXBUILD) -M html docs docs $(SPHINXOPTS)
66 doch=/usr/share/doc/hippotat/
69 $(INSTALL) -d $(DESTDIR)/usr/{bin,sbin} $(DESTDIR)$(doch)
70 $(INSTALL) -m 755 $(TARGET_RELEASE_DIR)/hippotat $(DESTDIR)/usr/bin/.
71 $(INSTALL) -m 755 $(TARGET_RELEASE_DIR)/hippotatd $(DESTDIR)/usr/sbin/.
72 cp -r docs/html $(DESTDIR)$(doch)
73 $(INSTALL) -m 644 PROTOCOL.txt $(DESTDIR)$(doch)/
76 rm -rf stamp/* doc/html
81 #---------- docs publication ----------
83 PUBLISHED_BRANCH=published
85 PUBLISH_USER=ianmdlvl@login.chiark.greenend.org.uk
86 PUBLISH_DOC_SPHINX_BASE=public-html/hippotat
87 PUBLISH_DOC_SPHINX_TAIL=$(PUBLISH_VERSION)/docs
88 PUBLISH_DOC_SPHINX=$(PUBLISH_USER):$(PUBLISH_DOC_SPHINX_BASE)/$(PUBLISH_DOC_SPHINX_TAIL)
91 ssh $(PUBLISH_USER) 'cd $(PUBLISH_DOC_SPHINX_BASE) && mkdir -p $(PUBLISH_DOC_SPHINX_TAIL)'
92 rsync -r --delete-delay docs/html/. $(PUBLISH_DOC_SPHINX)/.
93 git branch -f $(PUBLISHED_BRANCH)
96 ssh $(PUBLISH_USER) 'set -e; cd $(PUBLISH_DOC_SPHINX_BASE); rm -f current.tmp; ln -s $(PUBLISH_VERSION) current.tmp; mv -T current.tmp current'
98 .PHONY: cargo-build all doc clean