-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
68 lines (57 loc) · 1.77 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright © 2012-2019 Jakub Wilk <[email protected]>
#
# This file is part of didjvu.
#
# didjvu is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# didjvu is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
PYTHON = python
PREFIX = /usr/local
DESTDIR =
bindir = $(PREFIX)/bin
basedir = $(PREFIX)/share/didjvu
mandir = $(PREFIX)/share/man
.PHONY: all
all: ;
python_exe = $(shell $(PYTHON) -c 'import sys; print(sys.executable)')
.PHONY: install
install: didjvu
$(PYTHON) - < lib/__init__.py # Python version check
install -d $(DESTDIR)$(bindir)
sed \
-e "1 s@^#!.*@#!$(python_exe)@" \
-e "s#^basedir = .*#basedir = '$(basedir)/'#" \
$(<) > $(<).tmp
install $(<).tmp $(DESTDIR)$(bindir)/$(<)
rm $(<).tmp
install -d $(DESTDIR)$(basedir)/lib/xmp
install -p -m644 lib/xmp/*.py $(DESTDIR)$(basedir)/lib/xmp/
install -p -m644 lib/*.py $(DESTDIR)$(basedir)/lib/
ifeq "$(DESTDIR)" ""
umask 022 && $(PYTHON) -m compileall -q $(basedir)/lib/
endif
ifeq "$(wildcard doc/*.1)" ""
# run "$(MAKE) -C doc" to build the manpage
else
install -d $(DESTDIR)$(mandir)/man1
install -m644 doc/$(<).1 $(DESTDIR)$(mandir)/man1/
endif
.PHONY: test
test: didjvu
$(PYTHON) $(<) --test --verbose tests/
.PHONY: test-installed
test-installed: $(or $(shell command -v didjvu;),$(bindir)/didjvu)
didjvu --test --verbose tests/
.PHONY: clean
clean:
find . -type f -name '*.py[co]' -delete
find . -type d -name '__pycache__' -delete
rm -f .coverage
rm -f *.tmp
.error = GNU make is required
# vim:ts=4 sts=4 sw=4 noet