diff options
author | Neal H. Walfield <neal@pep.foundation> | 2018-09-08 11:50:11 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2018-09-08 13:01:57 +0200 |
commit | 50e5ecba26948eefbbc058bc4a47205a429453cf (patch) | |
tree | 2d65b2a11e9b5f84366624d0eda14dc61aebcb6f | |
parent | 7bac8e4fed5eccbdc04f48ef5d946c5da2613ec4 (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.
-rw-r--r-- | Makefile | 62 | ||||
-rw-r--r-- | ffi/Makefile | 13 | ||||
-rw-r--r-- | ffi/examples/Makefile | 7 | ||||
-rw-r--r-- | tool/Makefile | 7 |
4 files changed, 59 insertions, 30 deletions
@@ -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 diff --git a/ffi/Makefile b/ffi/Makefile index 352da2b8..b379ac80 100644 --- a/ffi/Makefile +++ b/ffi/Makefile @@ -4,6 +4,11 @@ PREFIX ?= /usr/local DESTDIR ?= +CARGO ?= cargo +CARGO_TARGET_DIR ?= $(shell pwd)/../target +# We currently only support absolute paths. +CARGO_TARGET_DIR := $(abspath $(CARGO_TARGET_DIR)) + VERSION ?= $(shell grep '^version[[:space:]]*=[[:space:]]*' Cargo.toml | cut -d'"' -f2) VERSION_MAJOR = $(shell echo $(VERSION) | cut -d'.' -f1) @@ -20,9 +25,9 @@ all: build build: sed -e 's|VERSION|$(VERSION)|g' \ -e 's|PREFIX|$(shell pwd)|g' \ - -e 's|libdir=.*|libdir=$(shell pwd)/../target/debug|g' \ + -e 's|libdir=.*|libdir='"$(CARGO_TARGET_DIR)"'/debug|g' \ sequoia.pc.in \ - > ../target/debug/sequoia.pc + > $(CARGO_TARGET_DIR)/debug/sequoia.pc # Testing and examples. .PHONY: test check @@ -49,13 +54,13 @@ install: sequoia.pc $(INSTALL) -t $(DESTDIR)$(PREFIX)/include/sequoia \ include/sequoia/*.h $(INSTALL) -d $(DESTDIR)$(PREFIX)/lib - $(INSTALL) ../target/release/libsequoia_ffi.so \ + $(INSTALL) $(CARGO_TARGET_DIR)/release/libsequoia_ffi.so \ $(DESTDIR)$(PREFIX)/lib/libsequoia_ffi.so.$(VERSION) ln -fs libsequoia_ffi.so.$(VERSION) \ $(DESTDIR)$(PREFIX)/lib/libsequoia_ffi.so.$(VERSION_MAJOR) ln -fs libsequoia_ffi.so.$(VERSION) \ $(DESTDIR)$(PREFIX)/lib/libsequoia_ffi.so - $(INSTALL) ../target/release/libsequoia_ffi.a \ + $(INSTALL) $(CARGO_TARGET_DIR)/release/libsequoia_ffi.a \ $(DESTDIR)$(PREFIX)/lib/libsequoia_ffi.a # Housekeeping. diff --git a/ffi/examples/Makefile b/ffi/examples/Makefile index 3b7b6794..5920b9d3 100644 --- a/ffi/examples/Makefile +++ b/ffi/examples/Makefile @@ -1,8 +1,13 @@ # Makefile for examples written in C. +CARGO ?= cargo +CARGO_TARGET_DIR ?= $(shell pwd)/../../target +# We currently only support absolute paths. +CARGO_TARGET_DIR := $(abspath $(CARGO_TARGET_DIR)) + TARGETS = example keyserver configure reader parser encrypt-for CFLAGS = -I../include -O0 -g -Wall -LDFLAGS = -L../../target/debug -lsequoia_ffi +LDFLAGS = -L$(CARGO_TARGET_DIR)/debug -lsequoia_ffi all: $(TARGETS) diff --git a/tool/Makefile b/tool/Makefile index 7cd3bd1f..bd601b00 100644 --- a/tool/Makefile +++ b/tool/Makefile @@ -1,6 +1,9 @@ CARGO ?= cargo -SQ ?= ../target/debug/sq -SQV ?= ../target/debug/sqv +CARGO_TARGET_DIR ?= $(shell pwd)/../target +# We currently only support absolute paths. +CARGO_TARGET_DIR := $(abspath $(CARGO_TARGET_DIR)) +SQ ?= $(CARGO_TARGET_DIR)/debug/sq +SQV ?= $(CARGO_TARGET_DIR)/debug/sqv all: src/sq-usage.rs src/sqv-usage.rs |