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 $@
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/*[^~])
@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)
+install: all
+ $(INSTALL) -d $(DESTDIR)/usr/{bin,sbin,share/doc/hippotat}
+ $(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)/usr/share/doc/hippotat/
+
clean:
rm -rf stamp/* doc/html