xref: /freebsd/contrib/libxo/tests/gettext/Makefile.am (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1#
2# $Id$
3#
4# Copyright 2014, Juniper Networks, Inc.
5# All rights reserved.
6# This SOFTWARE is licensed under the LICENSE provided in the
7# ../Copyright file. By downloading, installing, copying, or otherwise
8# using the SOFTWARE, you agree to be bound by the terms of that
9# LICENSE.
10
11AM_CFLAGS = \
12    -I${top_srcdir} \
13    -I${top_srcdir}/libxo \
14    ${GETTEXT_CFLAGS}
15
16# Ick: maintained by hand!
17TEST_CASES = \
18gt_01.c
19
20gt_01_test_SOURCES = gt_01.c
21
22# TEST_CASES := $(shell cd ${srcdir} ; echo *.c )
23
24noinst_PROGRAMS = ${TEST_CASES:.c=.test}
25
26LDADD = \
27    ${top_builddir}/libxo/libxo.la
28
29if HAVE_HUMANIZE_NUMBER
30LDADD += -lutil
31endif
32
33EXTRA_DIST = \
34    ${TEST_CASES} \
35    ${addprefix saved/, ${TEST_CASES:.c=.T.err}} \
36    ${addprefix saved/, ${TEST_CASES:.c=.T.out}} \
37    ${addprefix saved/, ${TEST_CASES:.c=.XP.err}} \
38    ${addprefix saved/, ${TEST_CASES:.c=.XP.out}} \
39    ${addprefix saved/, ${TEST_CASES:.c=.JP.err}} \
40    ${addprefix saved/, ${TEST_CASES:.c=.JP.out}} \
41    ${addprefix saved/, ${TEST_CASES:.c=.HP.err}} \
42    ${addprefix saved/, ${TEST_CASES:.c=.HP.out}} \
43    ${addprefix saved/, ${TEST_CASES:.c=.X.err}} \
44    ${addprefix saved/, ${TEST_CASES:.c=.X.out}} \
45    ${addprefix saved/, ${TEST_CASES:.c=.J.err}} \
46    ${addprefix saved/, ${TEST_CASES:.c=.J.out}} \
47    ${addprefix saved/, ${TEST_CASES:.c=.H.err}} \
48    ${addprefix saved/, ${TEST_CASES:.c=.H.out}} \
49    ${addprefix saved/, ${TEST_CASES:.c=.HIPx.err}} \
50    ${addprefix saved/, ${TEST_CASES:.c=.HIPx.out}}
51
52POT_FILES = \
53    gt_01.pot \
54    ldns.pot \
55    strerror.pot
56
57PO_FILES = \
58    po/pig_latin/gt_01.po \
59    po/pig_latin/ldns.po \
60    po/pig_latin/strerror.po
61
62EXTRA_DIST += ${POT_FILES} ${PO_FILES}
63
64S2O = | ${SED} '1,/@@/d'
65
66all:
67
68valgrind:
69	@echo '## Running the regression tests under Valgrind'
70	${MAKE} CHECKER='valgrind -q' tests
71
72#TEST_TRACE = set -x ;
73
74TEST_ONE = \
75      ${CHECKER} ./$$base.test --libxo:W$$fmt ${TEST_OPTS} \
76      > out/$$base.$$fmt.out 2> out/$$base.$$fmt.err ; \
77 ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.out out/$$base.$$fmt.out ${S2O} ; \
78 ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.err out/$$base.$$fmt.err ${S2O}
79
80TEST_FORMATS = T XP JP HP X J H HIPx
81
82test tests: ${bin_PROGRAMS} build-mo-files
83	@${MKDIR} -p out
84	-@ ${TEST_TRACE} (for test in ${TEST_CASES} ; do \
85	    base=`${BASENAME} $$test .c` ; \
86            (for fmt in ${TEST_FORMATS}; do \
87	        echo "... $$test ... $$fmt ..."; \
88	        ${TEST_ONE}; \
89                true; \
90            done) \
91	done)
92
93one:
94	-@(test=${TEST_CASE}; data=${TEST_DATA}; ${TEST_ONE} ; true)
95
96accept:
97	-@(for test in ${TEST_CASES} ; do \
98	    base=`${BASENAME} $$test .c` ; \
99            (for fmt in ${TEST_FORMATS}; do \
100	        echo "... $$test ... $$fmt ..."; \
101	        ${CP} out/$$base.$$fmt.out ${srcdir}/saved/$$base.$$fmt.out ; \
102	        ${CP} out/$$base.$$fmt.err ${srcdir}/saved/$$base.$$fmt.err ; \
103	    done) \
104	done)
105
106.c.test:
107	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -o $@ $<
108
109CLEANFILES = ${TEST_CASES:.c=.test}
110CLEANDIRS = out
111
112clean-local:
113	rm -rf ${CLEANDIRS}
114
115XGETTEXT = ${GETTEXT_BINDIR}/xgettext
116MSGFMT = ${GETTEXT_BINDIR}/msgfmt -v
117MSGMERGE = ${GETTEXT_BINDIR}/msgmerge
118ECHO = echo
119DB=set -x;
120XOMSGMERGE = ${MSGMERGE} --no-wrap
121XODIFF = ${DIFF} -bu
122
123LANGUAGES = \
124	es \
125	fr \
126	pig_latin
127
128# ldns is fake; used only for a gettext domain
129FAKE_FILES = ldns strerror
130MO_BASE_FILES = ${TEST_CASES:.c=} ${FAKE_FILES}
131
132build-pot-files:
133	for file in ${TEST_CASES} ; do set -x ;\
134	    base=`${BASENAME} $$file .c` ; \
135	    ${XGETTEXT} --default-domain=$$base \
136            --directory=${srcdir} --no-wrap \
137	    --add-comments --keyword=xo_emit --keyword=xo_emit_h \
138	    --keyword=xo_emit_warn \
139	    -C -E -n --foreign-user \
140	    -o $$base.pot.new $$base.c ; \
141	done
142
143accept-pot-files:
144	for base in ${MO_BASE_FILES} ; do set -x ;\
145	    ${CP} $$base.pot.new ${srcdir}/$$base.pot ; \
146	done
147
148merge-po-files:
149	for base in ${MO_BASE_FILES} ; do set -x ;\
150	    for lang in ${LANGUAGES} ; do \
151		if [ -f po/$$lang/$$base.po ]; then \
152		    ${ECHO} "merging $$base.pot into po/$$lang/$$base.po ..." ; \
153		    if ${XOMSGMERGE} po/$$lang/$$base.po \
154				${srcdir}/$$base.pot \
155				-o po/$$lang/$$base.new.po; then \
156			${MV} po/$$lang/$$base.po \
157				po/$$lang/$$base.po.old ; \
158			${MV} po/$$lang/$$base.new.po \
159				po/$$lang/$$base.po ; \
160		    else \
161		      echo "error: msgmerge for $$base failed"; \
162		    fi ; \
163		elif [ -f ${srcdir}/po/$$lang/$$base.po ]; then \
164		    ${ECHO} "merging (srcdir) $$base.pot into po/$$lang/$$base.po ..." ; \
165		    if ${XOMSGMERGE} ${srcdir}/po/$$lang/$$base.po \
166				${srcdir}/$$base.pot \
167				-o po/$$lang/$$base.new.po; then \
168			${MV} po/$$lang/$$base.po \
169				po/$$lang/$$base.po.old ; \
170			${MV} po/$$lang/$$base.new.po \
171				po/$$lang/$$base.po ; \
172		    else \
173		      echo "error: msgmerge for $$base failed"; \
174		    fi ; \
175		fi ; \
176            done ; \
177        done
178
179accept-po-files:
180	@(for base in ${MO_BASE_FILES} ; do \
181	    for lang in ${LANGUAGES} ; do \
182		if [ -f po/$$lang/$$base.po ]; then \
183		    ${MKDIR} -p ${srcdir}/po/$$lang ; \
184		    (${DB} ${CP} po/$$lang/$$base.po ${srcdir}/po/$$lang/$$base.po ); \
185                fi ; \
186	    done ; \
187	done)
188
189new-po-file:
190	@(for base in ${MO_BASE_FILES} ; do set -x ;\
191	    for lang in ${LANGUAGES} ; do \
192		if [ ! -f po/$$lang/$$base.po ]; then \
193		    ${MKDIR} -p po/$$lang ; \
194		    (${DB} ${CP} $$base.pot po/$$lang/$$base.po ); \
195                fi ; \
196	    done ; \
197	done)
198
199diff:
200	@(for base in ${MO_BASE_FILES} ; do \
201	    if [ -f $$base.pot.new ] ; then \
202	        ${XODIFF} ${srcdir}/$$base.pot $$base.pot.new ; \
203            fi ; \
204	    for lang in ${LANGUAGES} ; do \
205		if [ -f po/$$lang/$$base.po ] ; then \
206		    ${XODIFF} ${srcdir}/po/$$lang/$$base.po po/$$lang/$$base.po ; \
207                fi ; \
208	    done ; \
209	done)
210
211mo build-mo-files:
212	@(for base in ${MO_BASE_FILES} ; do \
213	    for lang in ${LANGUAGES} ; do \
214		${MKDIR} -p po/$$lang/LC_MESSAGES ; \
215	 	if [ -f po/$$lang/$$base.po ] ; then \
216		    (${DB} ${MSGFMT} -o po/$$lang/LC_MESSAGES/$$base.mo \
217				po/$$lang/$$base.po ); \
218		elif [ -f ${srcdir}/po/$$lang/$$base.po ]; then \
219		    (${DB} ${MSGFMT} -o po/$$lang/LC_MESSAGES/$$base.mo \
220			${srcdir}/po/$$lang/$$base.po ;) \
221                fi ; \
222	    done ; \
223	done)
224