Debian Codegraph @

Makefile

raw
1 # Copyright © 2012-2022 Jakub Wilk <[email protected]>
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the “Software”), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12 #
13 # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 # SOFTWARE.
20
21 PYTHON = python3
22 INSTALL = $(if $(shell command -v ginstall;),ginstall,install)
23
24 PREFIX = /usr/local
25 DESTDIR =
26
27 bindir = $(PREFIX)/bin
28 basedir = $(PREFIX)/share/i18nspector
29 mandir = $(PREFIX)/share/man
30
31 .PHONY: all
32 all: ;
33
34 .PHONY: install
35 install: i18nspector
36 # executable:
37 $(INSTALL) -d $(DESTDIR)$(bindir)
38 python_exe=$$($(PYTHON) -c 'import sys; print(sys.executable)') && \
39 sed \
40 -e "1 s@^#!.*@#!$$python_exe@" \
41 -e "s#^basedir_fallback = .*#basedir_fallback = '$(basedir)/'#" \
42 $(<) > $(<).tmp
43 install $(<).tmp $(DESTDIR)$(bindir)/$(<)
44 rm $(<).tmp
45 # library + data:
46 ( find lib data -type f ! -name '*.py[co]' ) \
47 | xargs -t -I {} $(INSTALL) -p -D -m644 {} $(DESTDIR)$(basedir)/{}
48 ifeq "$(DESTDIR)" ""
49 umask 022 && $(PYTHON) -m compileall -q $(basedir)/lib/
50 endif
51 ifeq "$(wildcard doc/*.1)" ""
52 # run "$(MAKE) -C doc" to build the manpage
53 else
54 # manual page:
55 $(INSTALL) -p -D -m644 doc/$(<).1 $(DESTDIR)$(mandir)/man1/$(<).1
56 endif
57
58 .PHONY: test
59 test:
60 $(PYTHON) -bb -m pytest -v
61
62 .PHONY: clean
63 clean:
64 find . -type f -name '*.py[co]' -delete
65 find . -type d -name '__pycache__' -delete
66 rm -rf .pytest_cache
67 rm -f .coverage
68 rm -f *.tmp
69
70 .error = GNU make is required
71
72 # vim:ts=4 sts=4 sw=4 noet