-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
+
+clean:
+ rm -rf stamp/* doc/html
+ $(NAILING_CARGO) clean
+
+.PHONY: cargo-build rndaddtoentcnt-build all doc clean