-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (47 loc) · 1.42 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
PKG := checkpkgs
VERSION := 1.0
SHELL := /bin/bash
LOCALE_DIR ?= /usr/share/locale
LOCAL_LOCALE_DIR := ./locale
PO_FILES := $(wildcard $(LOCAL_LOCALE_DIR)/*.po)
define mo-files
$(shell \
lc="$$(basename $1)"; \
lng="$${lc/.*}"; \
mkdir -p $(DESTDIR)$(LOCALE_DIR)/"$$lng"/LC_MESSAGES; \
msgfmt -v $1 -o $(DESTDIR)$(LOCALE_DIR)/"$$lng"/LC_MESSAGES/$(PKG).mo \
)
endef
all: mofiles
potfile: $(PKG).sh
$(shell \
xgettext \
--package-name=$(PKG) \
--package-version=$(VERSION) \
--from-code=UTF-8 \
-L shell \
--package-name=$(PKG) \
-o $(DESTDIR)$(LOCALE_DIR)/$(PKG).pot ./$(PKG).sh \
)
mofiles: $(PO_FILES)
$(foreach PO_FILE, $(PO_FILES), $(call mo-files, $(PO_FILE)))
msginit:
$(shell \
echo -n "Locale to be created: " 1>&2; \
read -r lang; \
msginit -i $(LOCAL_LOCALE_DIR)/$(PKG).pot -l "$$lang" -o $(LOCAL_LOCALE_DIR)/"$$lang".po \
)
man:
$(shell \
pandoc -s -t man $(PKG).8.md -o $(PKG).8 \
)
install: mofiles man
install -Dm755 $(PKG).sh $(DESTDIR)/usr/bin/$(PKG)
install -Dm644 completion/bash $(DESTDIR)/usr/share/bash-completion/completions/$(PKG)
install -Dm644 completion/zsh $(DESTDIR)/usr/share/zsh/site-functions/_$(PKG)
install -Dm644 $(PKG).8 $(DESTDIR)/usr/share/man/man8/$(PKG).8
uninstall:
$(RM) $(DESTDIR)/usr/bin/$(PKG)
$(RM) $(DESTDIR)/usr/share/bash-completion/completions/$(PKG)
$(RM) $(DESTDIR)/usr/share/zsh/site-functions/_$(PKG)
$(RM) $(DESTDIR)/usr/share/man/man8/$(PKG).8