summaryrefslogtreecommitdiff
path: root/common.mk
diff options
context:
space:
mode:
Diffstat (limited to 'common.mk')
-rw-r--r--common.mk24
1 files changed, 24 insertions, 0 deletions
diff --git a/common.mk b/common.mk
index 6c29c03..89ab001 100644
--- a/common.mk
+++ b/common.mk
@@ -17,6 +17,27 @@ indent = emacs --batch $1 \
--eval '(indent-region (point-min) (point-max) nil)' \
-f save-buffer &>/dev/null
+# Usage <INPUT $(pofmt) >OUTPUT
+# Normalize a .po(t) file
+pofmt = msguniq -Fi
+
+pot-remove-wrap = tr '\n' '\r' | sed 's/"\r\s*"//g' | tr '\r' '\n'
+html-whitespace-collapse = sed -r -e 's/(\\n|\\t|\t)/ /g' -e 's/ +/ /g'
+define xgettext-prose =
+ xgettext --omit-header --from-code=UTF-8 -L shell \
+ -k \
+ --keyword={prose,bullet,flag:2} \
+ -o - $^ | $(pot-remove-wrap) | $(html-whitespace-collapse) | sed '/^#, sh-format/d'
+endef
+define xgettext-main =
+ xgettext --omit-header --from-code=UTF-8 -L shell \
+ -k \
+ --keyword={_,print} \
+ --keyword={msg,msg2,warning,error,stat_busy} \
+ --keyword={lock,slock}:3 \
+ -o - $^
+endef
+
# Usage: as a variable
# relative path to `/` from $(bindir)
# used for symlinking libexec files
@@ -69,6 +90,9 @@ build: PHONY $(build_files)
%.html: %.ronn
ronn --html $(RONNFLAGS) < '$<' > '$@'
+%.pot: %
+ { $(xgettext-main); $(xgettext-prose); } | $(pofmt) > '$@'
+
# Install ######################################################################
install: PHONY $(install_files)