-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
128 lines (93 loc) · 4.06 KB
/
Makefile
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
PYTHON?=python3
PYTHON2?=python2
TESTFLAGS=-p -v
TESTOPTS=
SETUPFLAGS=
PYXPDFVERSION:=$(shell sed -ne '/__version__/s|.*__version__\s*=\s*"\([^"]*\)".*|\1|p' src/pyxpdf/__init__.py)
PARALLEL:=$(shell $(PYTHON) -c 'import sys; print("-j7" if sys.version_info >= (3, 5) else "")' )
PARALLEL2:=$(shell $(PYTHON2) -c 'import sys; print("-j7" if sys.version_info >= (3, 5) else "")' )
PYTHON_WITH_CYTHON:=$(shell $(PYTHON) -c 'import Cython.Build.Dependencies' >/dev/null 2>/dev/null && echo " --with-cython" || true)
PY2_WITH_CYTHON:=$(shell $(PYTHON2) -c 'import Cython.Build.Dependencies' >/dev/null 2>/dev/null && echo " --with-cython" || true)
CYTHON_WITH_COVERAGE:=$(shell $(PYTHON) -c 'import Cython.Coverage; import sys; assert not hasattr(sys, "pypy_version_info")' >/dev/null 2>/dev/null && echo " --coverage" || true)
CYTHON2_WITH_COVERAGE:=$(shell $(PYTHON2) -c 'import Cython.Coverage; import sys; assert not hasattr(sys, "pypy_version_info")' >/dev/null 2>/dev/null && echo " --coverage" || true)
ifeq ($(OS),Windows_NT)
detected_OS := Windows
else
detected_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
endif
ifeq ($(detected_OS), Windows)
CFLAGS += /Od
endif
ifeq ($(detected_OS), Linux)
CFLAGS += -O0
endif
.PHONY: all inplace inplace2 rebuild-sdist sdist build require-cython wheel_manylinux wheel
all: inplace
# Build in-place
inplace:
CFLAGS='$(CFLAGS)' $(PYTHON) setup.py $(SETUPFLAGS) build_ext -i $(PYTHON_WITH_CYTHON) --warnings --with-signature --with-coverage $(PARALLEL)
inplace_gcc_debug:
CFLAGS='$(CFLAGS)' $(PYTHON) setup.py $(SETUPFLAGS) build_ext -i $(PYTHON_WITH_CYTHON) --build-libxpdf --warnings --with-signature \
--with-coverage --debug-gcc --cython-gdb \
$(PARALLEL)
inplace2:
$(PYTHON2) setup.py $(SETUPFLAGS) build_ext -i $(PY2_WITH_CYTHON) --warnings --with-coverage $(PARALLEL2)
rebuild-sdist: require-cython
rm -f dist/pyxpdf-$(PYXPDFVERSION).tar.gz
find src -name '*.c' -exec rm -f {} \;
$(MAKE) dist/pyxpdf-$(PYXPDFVERSION).tar.gz
dist/pyxpdf-$(PYXPDFVERSION).tar.gz:
$(PYTHON) setup.py $(SETUPFLAGS) sdist $(PYTHON_WITH_CYTHON)
sdist: dist/pyxpdf-$(PYXPDFVERSION).tar.gz
build:
$(PYTHON) setup.py $(SETUPFLAGS) build $(PYTHON_WITH_CYTHON)
require-cython:
@[ -n "$(PYTHON_WITH_CYTHON)" ] || { \
echo "NOTE: missing Cython - please use this command to install it: $(PYTHON) -m pip install Cython"; false; }
wheel:
$(PYTHON) setup.py $(SETUPFLAGS) bdist_wheel $(PYTHON_WITH_CYTHON)
gcc_debug: inplace_gcc_debug
test_inplace: inplace
$(PYTHON) runtests.py $(TESTFLAGS) $(TESTOPTS)
test_inplace2: inplace2
$(PYTHON2) runtests.py $(TESTFLAGS) $(TESTOPTS) $(CYTHON2_WITH_COVERAGE)
ftest_inplace: inplace
$(PYTHON) runtests.py -f $(TESTFLAGS) $(TESTOPTS)
test_wheel: wheel
pip install -U dist/*.whl
$(PYTHON) runtests.py $(TESTFLAGS) $(TESTOPTS)
valgrind_test_inplace_all: inplace
# Don't know why but supression file is not supressing any python malloc errors
# So for Python >= 3.6, using this hack.
#valgrind --tool=memcheck --leak-check=full --suppressions=valgrind-python.supp
PYTHONMALLOC=malloc valgrind --leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--verbose \
--log-file=valgrind-out.log \
--suppressions=valgrind-python.supp \
python runtests.py
valgrind_test_inplace: inplace
PYTHONMALLOC=malloc valgrind --leak-check=full \
--show-leak-kinds=definite \
--errors-for-leak-kinds=definite \
--suppressions=valgrind-python.supp \
python runtests.py
doc: inplace
$(MAKE) -C docs html
cleandoc:
rm -fr docs/_build
rebuild_doc: cleandoc doc
test: test_inplace
test2: test_inplace2
testw: test_wheel
valtest: valgrind_test_inplace
valtest_all: valgrind_test_inplace_all
ftest: ftest_inplace
clean:
find . -path ./venv -prune -o \( -name '*.o' -o -name '*.so' -o -name '*.py[cod]' -o -name '*.dll' \) -exec rm -f {} \;
rm -rf build
realclean: clean
find src -name '*.cpp' -exec rm -f {} \;
rm -f TAGS
$(PYTHON) setup.py clean -a --without-cython