1 # Copyright 2020-2021 Ian Jackson and contributors to Otter
2 # SPDX-License-Identifier: GPL-3.0-or-later
3 # There is NO WARRANTY.
12 SPHINXBUILD ?= sphinx-build
14 ifneq (,$(wildcard ../Cargo.nail))
16 NAILING_CARGO ?= nailing-cargo
17 CARGO = $(NAILING_CARGO)
18 BUILD_SUBDIR ?= ../Build
19 TARGET_DIR = $(BUILD_SUBDIR)/$(notdir $(PWD))/target
20 NAILING_CARGO_JUST_RUN ?= $(NAILING_CARGO) --just-run -q ---
26 rsrcs = $(shell $(foreach x,$(MAKEFILE_FIND_X),set -$x;)\
27 find -H $1 \( -name Cargo.toml -o -name Cargo.lock -o -name Cargo.lock.example -o -name \*.rs \) )
28 stamp=@mkdir -p stamp; touch $@
30 TESTS=$(notdir $(wildcard test/t-*[^~]))
34 check: cargo-test $(addprefix stamp/,$(TESTS))
36 cargo-build: stamp/cargo-build
37 cargo-test: stamp/cargo-test
39 stamp/cargo-%: $(call rsrcs,.)
40 $(NAILING_CARGO) $* $(CARGO_BUILD_OPTIONS)
43 stamp/t-%: test/t-% stamp/cargo-build $(wildcard test/*[^~])
44 $(NAILING_CARGO_JUST_RUN) \
45 $(abspath test/capture-log) tmp/t-$*.log \
46 $(abspath test/go-with-unshare test/t-$*)
47 @echo OK t-$*; touch $@
49 doc: docs/html/index.html
50 @echo 'Documentation can now be found here:'
51 @echo ' file://$(PWD)/$<'
53 docs/html/index.html: docs/conf.py $(wildcard docs/*.md docs/*.rst docs/*.png)
54 $(SPHINXBUILD) -M html docs docs $(SPHINXOPTS)
57 rm -rf stamp/* doc/html
58 $(NAILING_CARGO) clean
60 .PHONY: cargo-build all doc clean