summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2018-09-08 11:50:11 +0200
committerNeal H. Walfield <neal@pep.foundation>2018-09-08 13:01:57 +0200
commit50e5ecba26948eefbbc058bc4a47205a429453cf (patch)
tree2d65b2a11e9b5f84366624d0eda14dc61aebcb6f /Makefile
parent7bac8e4fed5eccbdc04f48ef5d946c5da2613ec4 (diff)
Change Makefiles to support CARGO_TARGET_DIR.
- Also use 'cargo clean' instead of 'rm -rf $(CARGO_TARGET_DIR)' in case $(CARGO_TARGET_DIR) is incorrectly set.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile62
1 files changed, 39 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 9f0bc7f5..f5aa652c 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,12 @@
PREFIX ?= /usr/local
DESTDIR ?=
CARGO_FLAGS ?=
+# cargo's "target" directory. Normally, this is in the root
+# directory of the project, but it can be overriden by setting
+# CARGO_TARGET_DIR.
+CARGO_TARGET_DIR ?= $(shell pwd)/target
+# We currently only support absolute paths.
+CARGO_TARGET_DIR := $(abspath $(CARGO_TARGET_DIR))
FFI_RUSTDOCFLAGS ?= --html-in-header ffi/rustdoc.head.html
# Signing source distributions.
@@ -28,67 +34,77 @@ VERSION ?= $(shell grep '^version[[:space:]]*=[[:space:]]*' Cargo.toml | cut -d
export PREFIX
export DESTDIR
export CARGO_FLAGS
+export CARGO_TARGET_DIR
all: build ffi/examples
.PHONY: build
build:
- $(CARGO) build $(CARGO_FLAGS) --all
+ CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(CARGO) build $(CARGO_FLAGS) --all
$(MAKE) -Cffi build
# Testing and examples.
.PHONY: test check
test check:
- $(CARGO) test $(CARGO_FLAGS) --all
+ CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(CARGO) test $(CARGO_FLAGS) --all
$(MAKE) -Cffi test
$(MAKE) examples
.PHONY: examples
examples:
- $(CARGO) build $(CARGO_FLAGS) --examples
+ CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
+ $(CARGO) build $(CARGO_FLAGS) --examples
$(MAKE) -Cffi examples
# Documentation.
.PHONY: doc
doc:
- $(CARGO) doc $(CARGO_FLAGS) --no-deps --all
+ CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
+ $(CARGO) doc $(CARGO_FLAGS) --no-deps --all
env RUSTDOCFLAGS="$(FFI_RUSTDOCFLAGS)" \
+ CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
$(CARGO) doc $(CARGO_FLAGS) --no-deps --package sequoia-ffi
- $(CARGO) doc $(CARGO_FLAGS) --no-deps --package nettle
+ CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
+ $(CARGO) doc $(CARGO_FLAGS) --no-deps --package nettle
.PHONY: deploy-doc
deploy-doc: doc
- $(RSYNC) $(RSYNC_FLAGS) -r target/doc/* $(DOC_TARGET)
+ $(RSYNC) $(RSYNC_FLAGS) -r $(CARGO_TARGET_DIR)/doc/* $(DOC_TARGET)
# Installation.
.PHONY: build-release
build-release:
- $(CARGO) build $(CARGO_FLAGS) --release --all
+ CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
+ $(CARGO) build $(CARGO_FLAGS) --release --all
$(MAKE) -Cffi build-release
.PHONY: install
install: build-release
$(INSTALL) -d $(DESTDIR)$(PREFIX)/lib/sequoia
- $(INSTALL) -t $(DESTDIR)$(PREFIX)/lib/sequoia target/release/sequoia-public-key-store
+ $(INSTALL) -t $(DESTDIR)$(PREFIX)/lib/sequoia \
+ $(CARGO_TARGET_DIR)/release/sequoia-public-key-store
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
- $(INSTALL) -t $(DESTDIR)$(PREFIX)/bin target/release/sq target/release/sqv
+ $(INSTALL) -t $(DESTDIR)$(PREFIX)/bin \
+ $(CARGO_TARGET_DIR)/release/sq $(CARGO_TARGET_DIR)/release/sqv
$(MAKE) -Cffi install
# Infrastructure for creating source distributions.
.PHONY: dist
-dist: target/dist/sequoia-$(VERSION).tar.xz.sig
+dist: $(CARGO_TARGET_DIR)/dist/sequoia-$(VERSION).tar.xz.sig
-target/dist/sequoia-$(VERSION):
- $(GIT) clone . target/dist/sequoia-$(VERSION)
- cd target/dist/sequoia-$(VERSION) && \
+$(CARGO_TARGET_DIR)/dist/sequoia-$(VERSION):
+ $(GIT) clone . $(CARGO_TARGET_DIR)/dist/sequoia-$(VERSION)
+ cd $(CARGO_TARGET_DIR)/dist/sequoia-$(VERSION) && \
mkdir .cargo && \
- $(CARGO) vendor $(CARGO_FLAGS) \
+ CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
+ $(CARGO) vendor $(CARGO_FLAGS) \
| sed 's/^directory = ".*"$$/directory = "vendor"/' \
> .cargo/config && \
rm -rf .git
-target/dist/sequoia-$(VERSION).tar: target/dist/sequoia-$(VERSION)
- $(TAR) cf $@ -C target/dist sequoia-$(VERSION)
+$(CARGO_TARGET_DIR)/dist/sequoia-$(VERSION).tar: \
+ $(CARGO_TARGET_DIR)/dist/sequoia-$(VERSION)
+ $(TAR) cf $@ -C $(CARGO_TARGET_DIR)/dist sequoia-$(VERSION)
%.xz: %
$(XZ) -c $< >$@
@@ -97,16 +113,16 @@ target/dist/sequoia-$(VERSION).tar: target/dist/sequoia-$(VERSION)
$(GPG) --local-user $(SIGN_WITH) --detach-sign --armor $<
.PHONY: dist-test dist-check
-dist-test dist-check: target/dist/sequoia-$(VERSION).tar.xz
- rm -rf target/dist-check/sequoia-$(VERSION)
- mkdir -p target/dist-check
- $(TAR) xf $< -C target/dist-check
- cd target/dist-check/sequoia-$(VERSION) && \
+dist-test dist-check: $(CARGO_TARGET_DIR)/dist/sequoia-$(VERSION).tar.xz
+ rm -rf $(CARGO_TARGET_DIR)/dist-check/sequoia-$(VERSION)
+ mkdir -p $(CARGO_TARGET_DIR)/dist-check
+ $(TAR) xf $< -C $(CARGO_TARGET_DIR)/dist-check
+ cd $(CARGO_TARGET_DIR)/dist-check/sequoia-$(VERSION) && \
CARGO_HOME=$$(mktemp -d) $(MAKE) test CARGO_FLAGS=--frozen
- rm -rf target/dist-check/sequoia-$(VERSION)
+ rm -rf $(CARGO_TARGET_DIR)/dist-check/sequoia-$(VERSION)
# Housekeeping.
.PHONY: clean
clean:
- rm -rf target
+ CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(CARGO) $(CARGO_FLAGS) clean
$(MAKE) -Cffi clean