chiark / gitweb /
test: run-*: allow overriding the command
[hippotat.git] / Makefile
index 7b3c88129c94604e430e3e44c33db2d2451e0c0d..0cf5f10c5dedea6ccd3ced1826c5c326e45da7e4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,55 @@
-rndaddtoentcnt: rndaddtoentcnt.c
-       $(CC) rndaddtoentcnt.c -o rndaddtoentcnt
+# 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
+
+CFLAGS         += -Wall
+
+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 $@
+
+all:   cargo-build doc
+
+check: all rndaddtoentcnt-build
+
+cargo-build: stamp/cargo-build
+
+stamp/cargo-build: $(call rsrcs,.)
+       $(NAILING_CARGO) build $(CARGO_BUILD_OPTIONS)
+       $(stamp)
+
+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)
+
+rndaddtoentcnt-build: uml/rndaddtoentcnt/rndaddtoentcnt
 
-.PHONY: clean
 clean:
-       rm -f *.o rndaddtoentcnt
+       rm -rf stamp/* doc/html
+       $(NAILING_CARGO) clean
+
+.PHONY: cargo-build rndaddtoentcnt-build all doc clean