summaryrefslogtreecommitdiffstats
path: root/ffi/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 /ffi/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 'ffi/Makefile')
-rw-r--r--ffi/Makefile13
1 files changed, 9 insertions, 4 deletions
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.