Imported Upstream version 1.9.0
[platform/upstream/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         gpgme-h-clean.py \
25         examples \
26         gpg
27
28 SUBDIRS = . tests
29
30 COPY_FILES = \
31         $(srcdir)/gpgme.i \
32         $(srcdir)/README \
33         $(srcdir)/MANIFEST.in \
34         $(srcdir)/gpgme-h-clean.py \
35         $(srcdir)/examples \
36         $(srcdir)/helpers.c $(srcdir)/helpers.h $(srcdir)/private.h
37
38 COPY_FILES_GPG = \
39         $(srcdir)/gpg/callbacks.py \
40         $(srcdir)/gpg/constants \
41         $(srcdir)/gpg/core.py \
42         $(srcdir)/gpg/errors.py \
43         $(srcdir)/gpg/__init__.py \
44         $(srcdir)/gpg/results.py \
45         $(srcdir)/gpg/util.py
46
47 # For VPATH builds we need to copy some files because Python's
48 # distutils are not VPATH-aware.
49 copystamp: $(COPY_FILES) $(COPY_FILES_GPG)
50         set -e ; for VERSION in $(PYTHON_VERSIONS); do \
51           $(MKDIR_P)              python$${VERSION}-gpg/gpg ; \
52           cp -R $(COPY_FILES)     python$${VERSION}-gpg ; \
53           cp setup.py             python$${VERSION}-gpg ; \
54           cp gpg/version.py       python$${VERSION}-gpg/gpg ; \
55           ln -sf "$(abs_top_srcdir)/src/data.h" python$${VERSION}-gpg ; \
56           ln -sf "$(abs_top_builddir)/config.h" python$${VERSION}-gpg ; \
57           cp -R $(COPY_FILES_GPG) python$${VERSION}-gpg/gpg ; \
58         done
59         touch $@
60
61 all-local: copystamp
62         set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
63           PYTHON="$$1" ; shift ; \
64           cd python$${VERSION}-gpg && \
65           CFLAGS="$(CFLAGS)" \
66             $$PYTHON setup.py build --verbose ; \
67           cd .. ; \
68         done
69
70 python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
71 python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
72         cd python$(PYTHON_VERSION)-gpg && \
73         CFLAGS="$(CFLAGS)" \
74           $(PYTHON) setup.py sdist --verbose
75         gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz
76
77 .PHONY: prepare
78 prepare: copystamp
79
80 .PHONY: sdist
81 sdist: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
82        python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
83
84 .PHONY: upload
85 upload: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
86         python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
87         twine upload $^
88
89 CLEANFILES = copystamp
90
91 # Remove the rest.
92 #
93 # 'make distclean' clears the write bit, breaking rm -rf.  Fix the
94 # permissions.
95 clean-local:
96         rm -rf -- build
97         for VERSION in $(PYTHON_VERSIONS); do \
98           find python$${VERSION}-gpg -type d ! -perm -200 -exec chmod u+w {} ';' ; \
99           rm -rf -- python$${VERSION}-gpg ; \
100         done
101
102 install-exec-local:
103         rm -f install_files.txt
104         set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
105           PYTHON="$$1" ; shift ; \
106           cd python$${VERSION}-gpg ; \
107           $$PYTHON setup.py install \
108           --prefix $(DESTDIR)$(prefix) \
109           --record files.txt \
110           --verbose ; \
111           cat files.txt >> ../install_files.txt ; \
112           rm files.txt ; \
113           cd .. ; \
114         done
115         $(MKDIR_P) $(DESTDIR)$(pythondir)/gpg
116         mv install_files.txt $(DESTDIR)$(pythondir)/gpg
117
118 uninstall-local:
119         xargs <$(DESTDIR)$(pythondir)/gpg/install_files.txt -- rm -rf --
120         rm -rf -- $(DESTDIR)$(pythondir)/gpg