-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
99 lines (83 loc) · 2.4 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#####################
# Makefile support
# (C) 2012 Paul W. Frields <[email protected]>
# Licensed uner the GNU General Public License, v2 or later.
#
#####################
# Vars
ifndef LANGUAGES
LANGUAGES:=$(shell ls po/*.po | sed 's/po\/\(.*\).po/\1/')
endif
DOMAIN=pulsecaster
PYTHON=$(shell which python)
MSGMERGE=$(shell which msgmerge)
MSGFMT=$(shell which msgfmt)
TX=$(shell which tx)
PWD=$(shell pwd)
GIT=$(shell which git)
LATEST_TAG=$(shell git describe --tags --abbrev=0)
LATEST_VERSION=$(shell $(PYTHON) -c 'from pulsecaster.config import VERSION; print ("%s" % (VERSION))')
AUTHOR=$(shell $(PYTHON) -c 'from $(DOMAIN).config import * ; print (AUTHOR)')
EMAIL=$(shell $(PYTHON) -c 'from $(DOMAIN).config import * ; print (AUTHOR_EMAIL)')
URL=$(shell $(PYTHON) -c 'from $(DOMAIN).config import * ; print (URL)')
#####################
# Initial stuff
.PHONY:: all clean vars
all::
vars::
@echo LATEST_TAG = $(LATEST_TAG)
@echo LATEST_VERSION = $(LATEST_VERSION)
#####################
#####################
# L10n support
.PHONY:: tx-pull
tx-pull::
$(TX) pull -a
.PHONY:: pot
pot: po/$(DOMAIN).pot
po/$(DOMAIN).pot: $(shell cat po/POTFILES.in) po/POTFILES.in
cd po && intltool-update -p -g $(DOMAIN) && cd ..
.PHONY:: po
po: $(foreach L,$(LANGUAGES),po/$(L).po)
define PO_template =
PO_FILES+= po/$(1).po
po/$(1).po: po/$(DOMAIN).pot
$(TX) pull -l $(1)
cd po && intltool-update -d $(1) -g $(DOMAIN) && cd ..
endef
$(foreach L,$(LANGUAGES),$(eval $(call PO_template,$(L))))
vars::
@echo PO_FILES = $(PO_FILES)
.PHONY:: mo
all:: mo
mo: $(foreach L,$(LANGUAGES),po/$(L).mo)
define MO_template =
MO_FILES+= po/$(1).mo
po/$(1).mo: po/$(1).po
mkdir -p locale/$(1)/LC_MESSAGES && \
$(MSGFMT) -o po/$(1).mo po/$(1).po >/dev/null
clean::
rm -f po/$(1).mo
endef
$(foreach L,$(LANGUAGES),$(eval $(call MO_template,$(L))))
vars::
@echo MO_FILES = $(MO_FILES)
.PHONY:: stats
define STATS_template =
stats:: stats-$(1)
stats-$(1): po/$(1).po
@echo -n "$(1): " && msgfmt --statistics po/$(1).po
endef
$(foreach L,$(LANGUAGES),$(eval $(call STATS_template,$(L))))
#####################
#####################
# Release stuff
.PHONY:: release
release:: $(DOMAIN)-$(LATEST_VERSION).tar.gz
$(DOMAIN)-$(LATEST_VERSION).tar.gz:: po
ifneq ($(LATEST_TAG),$(LATEST_VERSION))
@echo Version=$(LATEST_VERSION), latest git tag=$(LATEST_TAG), either fix config.py or tag repo
else
$(PYTHON) setup.py sdist
@echo Tarball is in dist/$@
endif