python: Prune CLEANFILES.
[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
70 # Remove the rest.
71 #
72 # 'make distclean' clears the write bit, breaking rm -rf.  Fix the
73 # permissions.
74 clean-local:
75         rm -rf -- build
76         for PYTHON in $(PYTHONS); do \
77           find "$$(basename "$${PYTHON}")-gpg" -type d ! -perm -200 -exec chmod u+w {} ';' ; \
78           rm -rf -- "$$(basename "$${PYTHON}")-gpg" ; \
79         done
80
81 install-exec-local:
82         set -e ; for PYTHON in $(PYTHONS); do \
83           srcdir="$(srcdir)" \
84           top_builddir="$(top_builddir)" \
85           $$PYTHON setup.py \
86           build \
87           --build-base="$$(basename "$${PYTHON}")-gpg" \
88           install \
89           --prefix "$(DESTDIR)$(prefix)" \
90           --verbose ; \
91         done
92
93 uninstall-local:
94         set -x; GV=$$(echo $(VERSION) | tr - _); for PYTHON in $(PYTHONS); do \
95           PLATLIB="$(prefix)/$$("$${PYTHON}" -c 'import sysconfig, os; print(os.path.relpath(sysconfig.get_path("platlib", scheme="posix_prefix"), sysconfig.get_config_var("prefix")))')" ; \
96           rm -rf -- "$(DESTDIR)$${PLATLIB}/gpg" \
97                 "$(DESTDIR)$${PLATLIB}"/gpg-$$GV-py*.egg-info ; \
98         done