xref: /freebsd/contrib/libxo/tests/gettext/Makefile.am (revision 63d1fd5970ec814904aa0f4580b10a0d302d08b2)
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  LIBXO_OPTIONS=:W$$fmt \
76      ${CHECKER} ./$$base.test ${TEST_OPTS} \
77      > out/$$base.$$fmt.out 2> out/$$base.$$fmt.err ; \
78 ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.out out/$$base.$$fmt.out ${S2O} ; \
79 ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.err out/$$base.$$fmt.err ${S2O}
80
81TEST_FORMATS = T XP JP HP X J H HIPx
82
83test tests: ${bin_PROGRAMS} build-mo-files
84	@${MKDIR} -p out
85	-@ ${TEST_TRACE} (for test in ${TEST_CASES} ; do \
86	    base=`${BASENAME} $$test .c` ; \
87            (for fmt in ${TEST_FORMATS}; do \
88	        echo "... $$test ... $$fmt ..."; \
89	        ${TEST_ONE}; \
90                true; \
91            done) \
92	done)
93
94one:
95	-@(test=${TEST_CASE}; data=${TEST_DATA}; ${TEST_ONE} ; true)
96
97accept:
98	-@(for test in ${TEST_CASES} ; do \
99	    base=`${BASENAME} $$test .c` ; \
100            (for fmt in ${TEST_FORMATS}; do \
101	        echo "... $$test ... $$fmt ..."; \
102	        ${CP} out/$$base.$$fmt.out ${srcdir}/saved/$$base.$$fmt.out ; \
103	        ${CP} out/$$base.$$fmt.err ${srcdir}/saved/$$base.$$fmt.err ; \
104	    done) \
105	done)
106
107.c.test:
108	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -o $@ $<
109
110CLEANFILES = ${TEST_CASES:.c=.test}
111CLEANDIRS = out
112
113clean-local:
114	rm -rf ${CLEANDIRS}
115
116XGETTEXT = ${GETTEXT_BINDIR}/xgettext
117MSGFMT = ${GETTEXT_BINDIR}/msgfmt -v
118MSGMERGE = ${GETTEXT_BINDIR}/msgmerge
119ECHO = echo
120DB=set -x;
121XOMSGMERGE = ${MSGMERGE} --no-wrap
122XODIFF = ${DIFF} -bu
123
124LANGUAGES = \
125	es \
126	fr \
127	pig_latin
128
129# ldns is fake; used only for a gettext domain
130FAKE_FILES = ldns strerror
131MO_BASE_FILES = ${TEST_CASES:.c=} ${FAKE_FILES}
132
133build-pot-files:
134	for file in ${TEST_CASES} ; do set -x ;\
135	    base=`${BASENAME} $$file .c` ; \
136	    ${XGETTEXT} --default-domain=$$base \
137            --directory=${srcdir} --no-wrap \
138	    --add-comments --keyword=xo_emit --keyword=xo_emit_h \
139	    --keyword=xo_emit_warn \
140	    -C -E -n --foreign-user \
141	    -o $$base.pot.new $$base.c ; \
142	done
143
144accept-pot-files:
145	for base in ${MO_BASE_FILES} ; do set -x ;\
146	    ${CP} $$base.pot.new ${srcdir}/$$base.pot ; \
147	done
148
149merge-po-files:
150	for base in ${MO_BASE_FILES} ; do set -x ;\
151	    for lang in ${LANGUAGES} ; do \
152		if [ -f po/$$lang/$$base.po ]; then \
153		    ${ECHO} "merging $$base.pot into po/$$lang/$$base.po ..." ; \
154		    if ${XOMSGMERGE} po/$$lang/$$base.po \
155				${srcdir}/$$base.pot \
156				-o po/$$lang/$$base.new.po; then \
157			${MV} po/$$lang/$$base.po \
158				po/$$lang/$$base.po.old ; \
159			${MV} po/$$lang/$$base.new.po \
160				po/$$lang/$$base.po ; \
161		    else \
162		      echo "error: msgmerge for $$base failed"; \
163		    fi ; \
164		elif [ -f ${srcdir}/po/$$lang/$$base.po ]; then \
165		    ${ECHO} "merging (srcdir) $$base.pot into po/$$lang/$$base.po ..." ; \
166		    if ${XOMSGMERGE} ${srcdir}/po/$$lang/$$base.po \
167				${srcdir}/$$base.pot \
168				-o po/$$lang/$$base.new.po; then \
169			${MV} po/$$lang/$$base.po \
170				po/$$lang/$$base.po.old ; \
171			${MV} po/$$lang/$$base.new.po \
172				po/$$lang/$$base.po ; \
173		    else \
174		      echo "error: msgmerge for $$base failed"; \
175		    fi ; \
176		fi ; \
177            done ; \
178        done
179
180accept-po-files:
181	@(for base in ${MO_BASE_FILES} ; do \
182	    for lang in ${LANGUAGES} ; do \
183		if [ -f po/$$lang/$$base.po ]; then \
184		    ${MKDIR} -p ${srcdir}/po/$$lang ; \
185		    (${DB} ${CP} po/$$lang/$$base.po ${srcdir}/po/$$lang/$$base.po ); \
186                fi ; \
187	    done ; \
188	done)
189
190new-po-file:
191	@(for base in ${MO_BASE_FILES} ; do set -x ;\
192	    for lang in ${LANGUAGES} ; do \
193		if [ ! -f po/$$lang/$$base.po ]; then \
194		    ${MKDIR} -p po/$$lang ; \
195		    (${DB} ${CP} $$base.pot po/$$lang/$$base.po ); \
196                fi ; \
197	    done ; \
198	done)
199
200diff:
201	@(for base in ${MO_BASE_FILES} ; do \
202	    if [ -f $$base.pot.new ] ; then \
203	        ${XODIFF} ${srcdir}/$$base.pot $$base.pot.new ; \
204            fi ; \
205	    for lang in ${LANGUAGES} ; do \
206		if [ -f po/$$lang/$$base.po ] ; then \
207		    ${XODIFF} ${srcdir}/po/$$lang/$$base.po po/$$lang/$$base.po ; \
208                fi ; \
209	    done ; \
210	done)
211
212mo build-mo-files:
213	@(for base in ${MO_BASE_FILES} ; do \
214	    for lang in ${LANGUAGES} ; do \
215		${MKDIR} -p po/$$lang/LC_MESSAGES ; \
216	 	if [ -f po/$$lang/$$base.po ] ; then \
217		    (${DB} ${MSGFMT} -o po/$$lang/LC_MESSAGES/$$base.mo \
218				po/$$lang/$$base.po ); \
219		elif [ -f ${srcdir}/po/$$lang/$$base.po ]; then \
220		    (${DB} ${MSGFMT} -o po/$$lang/LC_MESSAGES/$$base.mo \
221			${srcdir}/po/$$lang/$$base.po ;) \
222                fi ; \
223	    done ; \
224	done)
225