blob: 99d8847d4f9a6c56083415b0195a4229cda52ec2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# Makefile for Sequoia's Python bindings.
# Configuration.
PREFIX ?= /usr/local
DESTDIR ?=
CFLAGS += -I../../include -I../../../openpgp-ffi/include
# Tools.
PYTHON ?= python3
IPYTHON ?= ipython3
PYTEST ?= pytest-3
ifneq ($(filter Darwin FreeBSD,$(shell uname -s)),"")
INSTALL ?= ginstall
else
INSTALL ?= install
endif
CARGO_TARGET_DIR ?= ../../../target
ifneq "$(PYTHON)" "disable"
PY_VERSION = $(shell $(PYTHON) -c \
'import sys; print("{0.major}.{0.minor}".format(sys.version_info))')
endif
# Make sure subprocesses pick these up.
export CFLAGS
all: build
.PHONY: build
build: .stamp-build
.stamp-build: sequoia/* ../../include/sequoia/*
ifneq "$(PYTHON)" "disable"
LDFLAGS=-L$(CARGO_TARGET_DIR)/debug $(PYTHON) setup.py build
touch $@
endif
# Testing and examples.
.PHONY: test check
test check:
ifneq "$(PYTHON)" "disable"
LDFLAGS=-L$(CARGO_TARGET_DIR)/debug LD_LIBRARY_PATH=$(CARGO_TARGET_DIR)/debug \
$(PYTHON) setup.py test
endif
.PHONY: shell
shell: build
ifneq "$(PYTHON)" "disable"
cp build/*/_sequoia.abi*.so . # XXX can we get setuptools to do that?
LDFLAGS=-L$(CARGO_TARGET_DIR)/debug LD_LIBRARY_PATH=$(CARGO_TARGET_DIR)/debug \
$(IPYTHON) -i -c \
'from sequoia.prelude import *; ctx = Context()'
endif
# Installation.
.PHONY: build-release
build-release: .stamp-build-release
.stamp-build-release:
ifneq "$(PYTHON)" "disable"
rm -f .stamp-build
$(PYTHON) setup.py clean
LDFLAGS=-L$(CARGO_TARGET_DIR)/release \
$(PYTHON) setup.py build
touch $@
endif
ifneq "$(DESTDIR)" ""
root_arg=--root=$(DESTDIR)
endif
.PHONY: install
install: build-release
ifneq "$(PYTHON)" "disable"
$(INSTALL) -d $(DESTDIR)$(PREFIX)/lib/python$(PY_VERSION)/site-packages
LDFLAGS=-L$(CARGO_TARGET_DIR)/release \
$(PYTHON) setup.py install $(root_arg) --prefix=$(PREFIX)
endif
# Housekeeping.
.PHONY: clean
clean:
ifneq "$(PYTHON)" "disable"
$(PYTHON) setup.py clean
rm -f _sequoia.*.so
rm -f .stamp-build .stamp-build-release
endif
|