chiark / gitweb /
log capturing
[hippotat.git] / Makefile
1 # Copyright 2020-2021 Ian Jackson and contributors to Otter
2 # SPDX-License-Identifier: GPL-3.0-or-later
3 # There is NO WARRANTY.
4
5 SHELL=/bin/bash
6
7 default: all
8
9 CARGO           ?= cargo
10 TARGET_DIR      ?= target
11
12 SPHINXBUILD     ?= sphinx-build
13
14 ifneq (,$(wildcard ../Cargo.nail))
15
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 ---
21
22 else
23
24 endif # Cargo.nail
25
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 $@
29
30 TESTS=$(notdir $(wildcard test/t-*[^~]))
31
32 all:    cargo-build doc
33
34 check:  cargo-test $(addprefix stamp/,$(TESTS))
35
36 cargo-build: stamp/cargo-build
37 cargo-test: # stamp/cargo-test xxx
38
39 stamp/cargo-%: $(call rsrcs,.)
40         $(NAILING_CARGO) $* $(CARGO_BUILD_OPTIONS)
41         $(stamp)
42
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 $@
48
49 doc:    docs/html/index.html
50         @echo 'Documentation can now be found here:'
51         @echo '  file://$(PWD)/$<'
52
53 docs/html/index.html: docs/conf.py $(wildcard docs/*.md docs/*.rst docs/*.png)
54         $(SPHINXBUILD) -M html docs docs $(SPHINXOPTS)
55
56 clean:
57         rm -rf stamp/* doc/html
58         $(NAILING_CARGO) clean
59
60 .PHONY: cargo-build all doc clean