chiark / gitweb /
packaging: wip
[hippotat.git] / Makefile
index 77a98e3db53b4d5b24e5ccb02ca2efc5ee24d4b5..ceae377e7a0de1639b183a4b4a0a76f15ca9dc8f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2020-2021 Ian Jackson and contributors to Otter
+# Copyright 2020-2022 Ian Jackson and contributors to Hippotat
 # SPDX-License-Identifier: GPL-3.0-or-later
 # There is NO WARRANTY.
 
@@ -6,23 +6,32 @@ SHELL=/bin/bash
 
 default: all
 
-CARGO          ?= cargo
-TARGET_DIR     ?= target
-
 SPHINXBUILD    ?= sphinx-build
 
-ifneq (,$(wildcard ../Cargo.nail))
+INSTALL                ?= install
+
+ifneq (,$(NAILING_CARGO))
 
 NAILING_CARGO ?= nailing-cargo
 CARGO = $(NAILING_CARGO)
 BUILD_SUBDIR ?= ../Build
-TARGET_DIR = $(BUILD_SUBDIR)/$(notdir $(PWD))/target
+TARGET_DIR ?= $(BUILD_SUBDIR)/$(notdir $(PWD))/target
 NAILING_CARGO_JUST_RUN ?= $(NAILING_CARGO) --just-run -q ---
 
 else
 
+CARGO          ?= cargo
+TARGET_DIR     ?= target
+
 endif # Cargo.nail
 
+CARGO_RELEASE ?= release
+TARGET_RELEASE_DIR ?= $(TARGET_DIR)/$(CARGO_RELEASE)
+
+ifneq (debug,$(CARGO_RELEASE))
+CARGO_RELEASE_ARG ?= --$(CARGO_RELEASE)
+endif
+
 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 $@
@@ -37,7 +46,7 @@ cargo-build: stamp/cargo-build
 cargo-test: stamp/cargo-test
 
 stamp/cargo-%: $(call rsrcs,.)
-       $(NAILING_CARGO) $* $(CARGO_BUILD_OPTIONS)
+       $(CARGO) $* $(CARGO_RELEASE_ARG) $(CARGO_BUILD_OPTIONS)
        $(stamp)
 
 stamp/t-%: test/t-% stamp/cargo-build $(wildcard test/*[^~])
@@ -51,8 +60,18 @@ doc: docs/html/index.html
        @echo '  file://$(PWD)/$<'
 
 docs/html/index.html: docs/conf.py $(wildcard docs/*.md docs/*.rst docs/*.png)
+       rm -rf docs/html
        $(SPHINXBUILD) -M html docs docs $(SPHINXOPTS)
 
+doch=/usr/share/doc/hippotat/
+
+install: all
+       $(INSTALL) -d $(DESTDIR)/usr/{bin,sbin} $(DESTDIR)$(doch)
+       $(INSTALL) -m 755 $(TARGET_RELEASE_DIR)/hippotat $(DESTDIR)/usr/bin/.
+       $(INSTALL) -m 755 $(TARGET_RELEASE_DIR)/hippotatd $(DESTDIR)/usr/sbin/.
+       cp -r docs/html $(DESTDIR)$(doch)
+       $(INSTALL) -m 644 PROTOCOL.txt $(DESTDIR)$(doch)/
+
 clean:
        rm -rf stamp/* doc/html