Skip to content

Commit 757b76a

Browse files
committed
Build UTF-8 conversion in build/ instead of mutating sources
make was running convert_to_utf8 on templates/ and messages/ in the source tree, rewriting tracked .po and template files and blocking git pull. Copy locales into build/templates and build/messages, convert there, and install from the build copies so repository sources stay unchanged.
1 parent 18af50c commit 757b76a

2 files changed

Lines changed: 45 additions & 14 deletions

File tree

messages/Makefile.in

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ DEFS= @DEFS@
4343
OPT= @OPT@
4444
CFLAGS= $(OPT) $(DEFS)
4545
PACKAGEDIR= $(prefix)/messages
46+
BUILDDIR= ../build/messages
4647
SHELL= /bin/sh
4748
DIRSETGID= chmod g+s
4849
MSGFMT= $(PYTHON) ../build/bin/msgfmt.py
@@ -55,8 +56,8 @@ LANGUAGES= ar ast ca cs da de el eo es et eu fa fi fr gl he hr hu ia it \
5556
LANGDIRS= $(LANGUAGES:%=messages/%/LC_MESSAGES)
5657
# Human readable po file
5758
POFILES= $(LANGUAGES:%=%/LC_MESSAGES/mailman.po)
58-
# Binary generated mo file
59-
MOFILES= $(LANGUAGES:%=%/LC_MESSAGES/mailman.mo)
59+
# Binary generated mo file (built under BUILDDIR, not in the source tree)
60+
MOFILES= $(LANGUAGES:%=$(BUILDDIR)/%/LC_MESSAGES/mailman.mo)
6061
TARGETS= $(MOFILES)
6162

6263
# Modes for directories and executables created by the install
@@ -68,9 +69,8 @@ FILEMODE= 644
6869
INSTALL_PROGRAM=$(INSTALL) -m $(EXEMODE)
6970
PROG= $(PYTHON) build/bin/pygettext.py
7071

71-
.SUFFIXES: .po .mo
72-
.po.mo:
73-
-$(MSGFMT) -o $@ $<
72+
$(BUILDDIR)/%/LC_MESSAGES/mailman.mo: $(BUILDDIR)/%/LC_MESSAGES/mailman.po
73+
$(MSGFMT) -o $@ $<
7474

7575
.NOTPARALLEL:
7676

@@ -108,28 +108,37 @@ doinstall: .converted.stamp mofiles
108108
done
109109
@for d in $(LANGUAGES); \
110110
do \
111-
po=$(srcdir)/$$d/LC_MESSAGES/mailman.po; \
112-
mo=$(srcdir)/$$d/LC_MESSAGES/mailman.mo; \
111+
po=$(BUILDDIR)/$$d/LC_MESSAGES/mailman.po; \
112+
mo=$(BUILDDIR)/$$d/LC_MESSAGES/mailman.mo; \
113113
dir=$(DESTDIR)$(prefix)/messages/$$d/LC_MESSAGES; \
114114
$(INSTALL) -m $(FILEMODE) $$po $$dir; \
115115
$(INSTALL) -m $(FILEMODE) $$mo $$dir; \
116116
done
117117

118-
# Use a stamp file to track conversion, so it only happens once
118+
# Use a stamp file to track conversion, so it only happens once.
119+
# Convert a copy under build/ so tracked source .po files are not modified.
119120
.converted.stamp: $(POFILES)
120-
$(PYTHON) ../scripts/convert_to_utf8 -d .
121+
rm -rf $(BUILDDIR)
122+
for d in $(LANGUAGES); \
123+
do \
124+
dir=$(BUILDDIR)/$$d/LC_MESSAGES; \
125+
$(srcdir)/../mkinstalldirs $$dir; \
126+
cp $(srcdir)/$$d/LC_MESSAGES/mailman.po $$dir/; \
127+
done
128+
$(PYTHON) ../scripts/convert_to_utf8 -d $(BUILDDIR)
121129
touch .converted.stamp
122130

123131
# Ensure .po files are merged with mailman.pot before conversion
124132
# This depends on the .po files being up to date with mailman.pot
125133
convertpofiles: $(POFILES) .converted.stamp
126134

127-
mofiles: $(MOFILES)
135+
mofiles: .converted.stamp $(MOFILES)
128136

129137
finish:
130138

131139
clean:
132140
-rm -f */LC_MESSAGES/mailman.mo .converted.stamp
141+
-rm -rf $(BUILDDIR)
133142

134143
fileclean:
135144
-rm -f marked.files docstring.files

templates/Makefile.in

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ DEFS= @DEFS@
4040
OPT= @OPT@
4141
CFLAGS= $(OPT) $(DEFS)
4242
TEMPLATEDIR= $(prefix)/templates
43+
BUILDDIR= ../build/templates
4344

4445
SHELL= /bin/sh
4546

@@ -60,9 +61,26 @@ INSTALL_PROGRAM=$(INSTALL) -m $(EXEMODE)
6061

6162
all: converttemplates
6263

63-
# Use a stamp file to track conversion, so it only happens once
64+
# Use a stamp file to track conversion, so it only happens once.
65+
# Convert a copy under build/ so tracked source templates are not modified.
6466
.converted.stamp:
65-
$(PYTHON) ../scripts/convert_to_utf8 -d .
67+
rm -rf $(BUILDDIR)
68+
mkdir -p $(BUILDDIR)
69+
for d in $(LANGUAGES); \
70+
do \
71+
if test -d $(srcdir)/$$d; \
72+
then \
73+
mkdir -p $(BUILDDIR)/$$d; \
74+
for f in $(srcdir)/$$d/*.html $(srcdir)/$$d/*.txt; \
75+
do \
76+
if test -f $$f; \
77+
then \
78+
cp $$f $(BUILDDIR)/$$d/; \
79+
fi; \
80+
done; \
81+
fi; \
82+
done
83+
$(PYTHON) ../scripts/convert_to_utf8 -d $(BUILDDIR)
6684
touch .converted.stamp
6785

6886
converttemplates: .converted.stamp
@@ -71,16 +89,20 @@ install: .converted.stamp
7189
for d in $(LANGUAGES); \
7290
do \
7391
$(srcdir)/../mkinstalldirs $(DESTDIR)$(TEMPLATEDIR)/$$d; \
74-
for f in $(srcdir)/$$d/*.html $(srcdir)/$$d/*.txt; \
92+
for f in $(BUILDDIR)/$$d/*.html $(BUILDDIR)/$$d/*.txt; \
7593
do \
76-
$(INSTALL) -m $(FILEMODE) $$f $(DESTDIR)$(TEMPLATEDIR)/$$d; \
94+
if test -f $$f; \
95+
then \
96+
$(INSTALL) -m $(FILEMODE) $$f $(DESTDIR)$(TEMPLATEDIR)/$$d; \
97+
fi; \
7798
done; \
7899
done
79100

80101
finish:
81102

82103
clean:
83104
-rm -f .converted.stamp
105+
-rm -rf $(BUILDDIR)
84106

85107
distclean: clean
86108
-rm -f Makefile

0 commit comments

Comments
 (0)