]>
Commit | Line | Data |
---|---|---|
f22ab085 MT |
1 | |
2 | PACKAGE_NAME = ddns | |
3 | PACKAGE_VERSION = 0.01 | |
4 | ||
5 | DESTDIR = | |
6 | PREFIX = /usr | |
7 | SYSCONFDIR = /etc | |
8 | BINDIR = $(PREFIX)/bin | |
9 | LIBDIR = $(PREFIX)/lib | |
10 | LOCALEDIR = $(PREFIX)/share/locale | |
11 | ||
12 | # Get the version and configuration of the python interpreter. | |
13 | PYTHON_VERSION = $(shell python -c "import platform; print '.'.join(platform.python_version_tuple()[:2])") | |
14 | ifeq "$(PYTHON_VERSION)" "" | |
15 | $(error Could not determine the version of the python interpreter.) | |
16 | endif | |
17 | PYTHON_DIR = $(LIBDIR)/python$(PYTHON_VERSION)/site-packages/ddns | |
18 | ||
19 | VERSION_FILE = ddns/__version__.py | |
20 | ||
21 | ### | |
22 | # Translation stuff | |
23 | ### | |
24 | # A list of all files that need translation | |
25 | TRANSLATION_FILES = $(wildcard ddns/*.py) ddns.py | |
26 | ||
27 | POT_FILE = po/$(PACKAGE_NAME).pot | |
28 | PO_FILES = $(wildcard po/*.po) | |
29 | MO_FILES = $(patsubst %.po,%.mo,$(PO_FILES)) | |
30 | ||
31 | ################################################################################ | |
32 | ||
33 | all: $(POT_FILE) $(MO_FILES) | |
34 | @: # Do nothing else. | |
35 | ||
36 | $(VERSION_FILE): Makefile | |
37 | echo "# this file is autogenerated by the build system" > $(VERSION_FILE) | |
38 | echo "CLIENT_VERSION = \"$(PACKAGE_VERSION)\"" >> $(VERSION_FILE) | |
39 | ||
40 | install: $(VERSION_FILE) $(MO_FILES) | |
41 | # Install the main command. | |
42 | -mkdir -pv $(DESTDIR)$(BINDIR) | |
43 | install -v -m 755 ddns.py $(DESTDIR)$(BINDIR)/ddns | |
44 | ||
45 | # Install python module. | |
46 | -mkdir -pv $(DESTDIR)$(PYTHON_DIR) | |
47 | install -v -m 644 ddns/*.py $(DESTDIR)$(PYTHON_DIR) | |
48 | ||
49 | # Install the example configuration file. | |
50 | -mkdir -pv $(DESTDIR)$(SYSCONFDIR) | |
51 | install -v -m 640 ddns.conf $(DESTDIR)$(SYSCONFDIR)/ddns.conf | |
52 | ||
53 | # Install translation files. | |
54 | -mkdir -pv $(DESTDIR)$(LOCALEDIR) | |
55 | for file in $(MO_FILES); do \ | |
56 | lang=$${file/.mo/}; \ | |
57 | mkdir -pv $(DESTDIR)$(LOCALEDIR)/$${lang}/LC_MESSAGES; \ | |
58 | install -v -m 644 $${file} \ | |
59 | $(DESTDIR)$(LOCALEDIR)/$${lang}/LC_MESSAGES/$(PACKAGE_NAME).mo; \ | |
60 | done | |
61 | ||
62 | # Cleanup temporary files. | |
63 | clean: | |
64 | rm -f $(VERSION_FILE) | |
65 | rm -f $(MO_FILES) | |
66 | ||
67 | # Translation stuff. | |
68 | $(POT_FILE): $(TRANSLATION_FILES) Makefile | |
69 | xgettext --language python -d $(PACKAGE_NAME) -k_ -kN_ \ | |
70 | -o $@ --add-comments --from-code=UTF-8 $^ | |
71 | ||
72 | # Compile gettext dictionaries from translation files. | |
73 | %.mo: %.po $(POT_FILE) | |
74 | msgfmt -o $@ $< |