1PYTHON2 ?= python
2PYTHON3 ?= python3
3
4.PHONY: gen_const install install3 install_cython sdist sdist3 bdist bdist3 clean check
5
6gen_const:
7	cd .. && $(PYTHON2) const_generator.py python
8
9install:
10	rm -rf src/
11	if test -n "${DESTDIR}"; then \
12		$(PYTHON2) setup.py build install --root="${DESTDIR}"; \
13	else \
14		$(PYTHON2) setup.py build install; \
15	fi
16
17install3:
18	rm -rf src/
19	if test -n "${DESTDIR}"; then \
20		$(PYTHON3) setup.py build install --root="${DESTDIR}"; \
21	else \
22		$(PYTHON3) setup.py build install; \
23	fi
24
25# NOTE: Newer cython can be installed by: sudo pip install --upgrade cython
26install_cython:
27	rm -rf src/
28	if test -n "${DESTDIR}"; then \
29		$(PYTHON2) setup_cython.py build install --root="${DESTDIR}"; \
30	else \
31		$(PYTHON2) setup_cython.py build install; \
32	fi
33
34install3_cython:
35	rm -rf src/
36	if test -n "${DESTDIR}"; then \
37		$(PYTHON3) setup_cython.py build install --root="${DESTDIR}"; \
38	else \
39		$(PYTHON3) setup_cython.py build install; \
40	fi
41
42# build & upload PyPi package with source code of the core
43sdist:
44	rm -rf src/ dist/
45	$(PYTHON2) setup.py sdist register upload
46
47# build & upload PyPi package with source code of the core
48sdist3:
49	rm -rf src/ dist/
50	$(PYTHON3) setup.py sdist register upload
51
52# build & upload PyPi package with prebuilt core
53bdist:
54	rm -rf src/ dist/
55	$(PYTHON2) setup.py bdist_wheel register upload
56
57# build & upload PyPi package with prebuilt core
58bdist3:
59	rm -rf src/ dist/
60	$(PYTHON3) setup.py bdist_wheel register upload
61
62clean:
63	rm -rf build/ src/ dist/ *.egg-info
64	rm -rf capstone/lib capstone/include pyx/lib pyx/include
65	rm -f pyx/*.c pyx/__init__.py
66	for f in capstone/*.py; do rm -f pyx/$$(basename $$f)x; done
67	rm -f MANIFEST
68	rm -f *.pyc capstone/*.pyc
69
70
71TESTS = test_basic.py test_detail.py test_arm.py test_arm64.py test_m68k.py test_mips.py
72TESTS += test_ppc.py test_sparc.py test_systemz.py test_x86.py test_xcore.py test_tms320c64x.py
73TESTS += test_m680x.py test_skipdata.py test_mos65xx.py
74
75check:
76	@for t in $(TESTS); do \
77		echo Check $$t ... ; \
78		./$$t > /dev/null; \
79		if [ $$? -eq 0 ]; then echo OK; else echo FAILED; exit 1; fi \
80	done
81
82