python: Remove usage of PYTHON_VERSIONS
[gpgme.git] / lang / python / Makefile.am
1 # Makefile.am for the Python bindings.
2 # Copyright (C) 2016 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation; either version 2.1 of the
9 # License, or (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 EXTRA_DIST = \
20         README \
21         MANIFEST.in \
22         gpgme.i \
23         helpers.c helpers.h private.h \
24         examples \
25         src
26
27 SUBDIRS = . tests
28
29 .PHONY: prepare
30 prepare: copystamp
31
32 # For VPATH builds we need to copy some files because Python's
33 # distutils are not VPATH-aware.
34 copystamp:
35         ln -sf "$(top_srcdir)/src/data.h" .
36         ln -sf "$(top_builddir)/config.h" .
37         ln -sf "$(srcdir)/src" gpg
38         touch $@
39
40 all-local: copystamp
41         set -e ; for PYTHON in $(PYTHONS); do \
42           CFLAGS="$(CFLAGS)" \
43           srcdir="$(srcdir)" \
44           top_builddir="$(top_builddir)" \
45             $$PYTHON setup.py build --verbose --build-base="$$(basename "$${PYTHON}")-gpg" ; \
46         done
47
48 python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
49         $(MKDIR_P) python$(PYTHON_VERSION)-gpg-dist
50         CFLAGS="$(CFLAGS)" \
51         srcdir="$(srcdir)" \
52         top_builddir="$(top_builddir)" \
53           $(PYTHON) setup.py sdist --verbose --dist-dir=python$(PYTHON_VERSION)-gpg-dist \
54                 --manifest=python$(PYTHON_VERSION)-gpg-dist/MANIFEST
55         gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz
56
57 .PHONY: sdist
58 sdist:  python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
59
60 .PHONY: upload
61 upload: python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz \
62         python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz.asc
63         twine upload $^
64
65 CLEANFILES = copystamp \
66         config.h \
67         data.h \
68         gpg \
69         files.txt \
70         install_files.txt
71
72 # Remove the rest.
73 #
74 # 'make distclean' clears the write bit, breaking rm -rf.  Fix the
75 # permissions.
76 clean-local:
77         rm -rf -- build
78         for PYTHON in $(PYTHONS); do \
79           find "$$(basename "$${PYTHON}")-gpg" -type d ! -perm -200 -exec chmod u+w {} ';' ; \
80           rm -rf -- "$$(basename "$${PYTHON}")-gpg" ; \
81         done
82
83 install-exec-local:
84         set -e ; for PYTHON in $(PYTHONS); do \
85           srcdir="$(srcdir)" \
86           top_builddir="$(top_builddir)" \
87           $$PYTHON setup.py \
88           build \
89           --build-base="$$(basename "$${PYTHON}")-gpg" \
90           install \
91           --prefix "$(DESTDIR)$(prefix)" \
92           --verbose ; \
93         done
94
95 uninstall-local:
96         GV=$$(echo $(VERSION) | tr - _); for PYTHON in $(PYTHONS); do \
97           PLATLIB="$(prefix)/$$("$${PYTHON}" -c 'import sysconfig, os; print(os.path.relpath(sysconfig.get_path("platlib"), sysconfig.get_config_var("prefix")))')" ; \
98           rm -rf -- "$(DESTDIR)$${PLATLIB}/gpg" \
99                 "$(DESTDIR)$${PLATLIB}"/gpg-$$GV-py*.egg-info ; \
100         done