@@ -13,56 +13,69 @@ TEMPLATE=roundup.pot
1313PACKAGES =$(shell find ../roundup ../share/roundup/templates -name '* .py' \
1414 | sed -e 's,/[^/]* $$,,' | sort | uniq)
1515SOURCES=$(PACKAGES: =/*.py)
16+ TEMPLATES =$(wildcard ../share/roundup/templates/* /html/* .html)
1617PO_FILES =$(wildcard * .po)
1718MO_FILES=$(PO_FILES:.po =.mo)
1819RUN_PYTHON=PYTHONPATH =.. $(PYTHON ) -O
1920
20- all : dist
21-
22- help :
23- @echo " $( MAKE) - build MO files. Run this before sdist"
24- @echo " $( MAKE) dist - same as above"
25- @echo " $( MAKE) template - update message template from sources"
26- @echo " $( MAKE) merge - merge template into *.po files"
27- @echo " $( MAKE) diff - see template differences in vi"
28- @echo " $( MAKE) potest - check .po files for errors"
29- @echo " $( MAKE) pytest - create locale files to run pytest"
30- @echo " $( MAKE) locale.po - update message file from template"
31- @echo " $( MAKE) locale.mo - compile individual message file"
32- @echo " $( MAKE) help - this text"
33- @echo " "
34- @echo " Running make dist is the same as: make template merge dist"
21+ # #@ default target
22+ all : dist # # build MO files. Run this before sdist"
3523
3624# This will rebuild all MO files without updating their corresponding PO
3725# files first. Run before creating Roundup distribution (hence the name).
3826# PO files should be updated by their translators only, automatic update
3927# adds unwanted fuzzy labels.
40- dist : $(MO_FILES )
28+ dist : $(MO_FILES ) # # same as all target
4129
42- template : roundup.pot
30+ # #@ Update files
31+ template : roundup.pot # # extract messages from source into template
4332
44- pytest local_install :
45- for file in $( PO_FILES) ; do \
46- ${MSGFMT} -o `basename $$file .po`.mo $$file; \
47- done
48- for file in $(MO_FILES); do \
49- lang=`basename $$file .mo`; \
50- mkdir -p locale/$$lang/LC_MESSAGES; \
51- cp $$file locale/$$lang/LC_MESSAGES/roundup.mo; \
52- done
33+ merge : $(PO_FILES ) # # merge template updates into *.po files
34+
35+ # do the template file update
36+ roundup.pot : $(SOURCES ) $(TEMPLATES )
37+ ${XPOT} -n -o $(TEMPLATE ) $(SOURCES ) 2>&1 | sed -e " /: Unexpected in Python source: #64 \` @'/d"
38+
39+ ${RUN_PYTHON} ../roundup/cgi/TAL/talgettext.py -u $(TEMPLATE) \
40+ ../share/roundup/templates/classic/html/*.html \
41+ ../share/roundup/templates/devel/html/*.html \
42+ ../share/roundup/templates/minimal/html/*.html \
43+ ../share/roundup/templates/responsive/html/*.html
44+ VERSION="`${RUN_PYTHON} -c 'from roundup import __version__; \
45+ print(__version__)';`"; \
46+ ${XGETTEXT} -j -w 80 -F \
47+ --add-comments=".Hint " \
48+ --package-name=Roundup \
49+ --package-version=$$VERSION \
50+ 51+ --copyright-holder="See Roundup README.txt" \
52+ -o $(TEMPLATE) $(SOURCES)
5353
54- # helps to check template file before check in
55- diff :
54+ # # QA commands
55+ diff : # # see template file (roundup.pot) differences
5656 hg cat roundup.pot | diff -u -I ' ^\#: \.\./roundup.*$$' \
5757 -I ' ^#:\s*:[0-9]*.*$$' \
5858 - roundup.pot || exit 0
59- merge : $(PO_FILES )
6059
61- potest :
60+ potest : # # check .po files for errors
6261 sh -c ' for file in $(PO_FILES); do \
6362 ${MSGFMT} -cv --statistics $$ file; \
6463 done' 2>&1 | sort -k 2,2n
6564
65+
66+ # #@ Testing
67+ pytest : local_install # # create locale files to run pytest
68+ local_install :
69+ for file in $( PO_FILES) ; do \
70+ ${MSGFMT} -o `basename $$file .po`.mo $$file; \
71+ done
72+ for file in $(MO_FILES); do \
73+ lang=`basename $$file .mo`; \
74+ mkdir -p locale/$$lang/LC_MESSAGES; \
75+ cp $$file locale/$$lang/LC_MESSAGES/roundup.mo; \
76+ done
77+
78+ # ## template rules
6679% .po : $(TEMPLATE )
6780 @echo " Rebuild $@ "
6881 @${MSGMERGE} -U --suffix=.bak $@ $<
@@ -75,21 +88,13 @@ potest:
7588% .mo : % .po
7689 ${MSGFMT} -o $@ $<
7790
78- roundup.pot : $(SOURCES ) $(TEMPLATES )
79- ${XPOT} -n -o $(TEMPLATE ) $(SOURCES ) 2>&1 | sed -e " /: Unexpected in Python source: #64 \` @'/d"
80-
81- ${RUN_PYTHON} ../roundup/cgi/TAL/talgettext.py -u $(TEMPLATE) \
82- ../share/roundup/templates/classic/html/*.html \
83- ../share/roundup/templates/devel/html/*.html \
84- ../share/roundup/templates/minimal/html/*.html \
85- ../share/roundup/templates/responsive/html/*.html
86- VERSION="`${RUN_PYTHON} -c 'from roundup import __version__; \
87- print(__version__)';`"; \
88- ${XGETTEXT} -j -w 80 -F \
89- --add-comments=".Hint " \
90- --package-name=Roundup \
91- --package-version=$$VERSION \
92- 93- --copyright-holder="See Roundup README.txt" \
94- -o $(TEMPLATE) $(SOURCES)
91+ # from https://www.thapaliya.com/en/writings/well-documented-makefiles/ via
92+ # https://til.jakelazaroff.com/make/list-all-commands-in-a-makefile/
93+ help : # # this text
94+ @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[.a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
9595
96+ @echo ""
97+ @printf " \033[36m%-15s\033[0m %s\n" "<locale>.po" "update message file from template"
98+ @printf " \033[36m%-15s\033[0m %s\n" "<locale>.mo" "compile individual message file"
99+ @echo ""
100+ @echo "Running 'make' is the same as: make template merge dist"
0 commit comments