# Copyright 2020-2021 Ian Jackson and contributors to Otter # SPDX-License-Identifier: GPL-3.0-or-later # There is NO WARRANTY. SHELL=/bin/bash default: all CARGO ?= cargo TARGET_DIR ?= target SPHINXBUILD ?= sphinx-build ifneq (,$(wildcard ../Cargo.nail)) NAILING_CARGO ?= nailing-cargo CARGO = $(NAILING_CARGO) BUILD_SUBDIR ?= ../Build TARGET_DIR = $(BUILD_SUBDIR)/$(notdir $(PWD))/target NAILING_CARGO_JUST_RUN ?= $(NAILING_CARGO) --just-run -q --- else endif # Cargo.nail rsrcs = $(shell $(foreach x,$(MAKEFILE_FIND_X),set -$x;)\ find -H $1 \( -name Cargo.toml -o -name Cargo.lock -o -name Cargo.lock.example -o -name \*.rs \) ) stamp=@mkdir -p stamp; touch $@ TESTS=$(notdir $(wildcard test/t-*[^~])) all: cargo-build doc check: cargo-test $(addprefix stamp/,$(TESTS)) cargo-build: stamp/cargo-build cargo-test: # stamp/cargo-test xxx stamp/cargo-%: $(call rsrcs,.) $(NAILING_CARGO) $* $(CARGO_BUILD_OPTIONS) $(stamp) stamp/t-%: test/t-% stamp/cargo-build $(wildcard test/*[^~]) $(NAILING_CARGO_JUST_RUN) \ $(abspath test/capture-log) tmp/t-$*.log \ $(abspath test/go-with-unshare test/t-$*) @echo OK t-$*; touch $@ doc: docs/html/index.html @echo 'Documentation can now be found here:' @echo ' file://$(PWD)/$<' docs/html/index.html: docs/conf.py $(wildcard docs/*.md docs/*.rst docs/*.png) $(SPHINXBUILD) -M html docs docs $(SPHINXOPTS) clean: rm -rf stamp/* doc/html $(NAILING_CARGO) clean .PHONY: cargo-build all doc clean