1287111Smarcel#
2287111Smarcel# $Id$
3287111Smarcel#
4287111Smarcel# Copyright 2014, Juniper Networks, Inc.
5287111Smarcel# All rights reserved.
6287111Smarcel# This SOFTWARE is licensed under the LICENSE provided in the
7287111Smarcel# ../Copyright file. By downloading, installing, copying, or otherwise
8287111Smarcel# using the SOFTWARE, you agree to be bound by the terms of that
9287111Smarcel# LICENSE.
10287111Smarcel
11287111SmarcelAM_CFLAGS = \
12287111Smarcel    -I${top_srcdir} \
13287111Smarcel    -I${top_srcdir}/libxo \
14287111Smarcel    ${GETTEXT_CFLAGS}
15287111Smarcel
16287111Smarcel# Ick: maintained by hand!
17287111SmarcelTEST_CASES = \
18287111Smarcelgt_01.c
19287111Smarcel
20287111Smarcelgt_01_test_SOURCES = gt_01.c
21287111Smarcel
22287111Smarcel# TEST_CASES := $(shell cd ${srcdir} ; echo *.c )
23287111Smarcel
24287111Smarcelnoinst_PROGRAMS = ${TEST_CASES:.c=.test}
25287111Smarcel
26287111SmarcelLDADD = \
27287111Smarcel    ${top_builddir}/libxo/libxo.la
28287111Smarcel
29287111Smarcelif HAVE_HUMANIZE_NUMBER
30287111SmarcelLDADD += -lutil
31287111Smarcelendif
32287111Smarcel
33287111SmarcelEXTRA_DIST = \
34287111Smarcel    ${TEST_CASES} \
35287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.T.err}} \
36287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.T.out}} \
37287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.XP.err}} \
38287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.XP.out}} \
39287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.JP.err}} \
40287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.JP.out}} \
41287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.HP.err}} \
42287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.HP.out}} \
43287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.X.err}} \
44287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.X.out}} \
45287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.J.err}} \
46287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.J.out}} \
47287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.H.err}} \
48287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.H.out}} \
49287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.HIPx.err}} \
50287111Smarcel    ${addprefix saved/, ${TEST_CASES:.c=.HIPx.out}}
51287111Smarcel
52287111SmarcelPOT_FILES = \
53287111Smarcel    gt_01.pot \
54287111Smarcel    ldns.pot \
55287111Smarcel    strerror.pot
56287111Smarcel
57287111SmarcelPO_FILES = \
58287111Smarcel    po/pig_latin/gt_01.po \
59287111Smarcel    po/pig_latin/ldns.po \
60287111Smarcel    po/pig_latin/strerror.po
61287111Smarcel
62287111SmarcelEXTRA_DIST += ${POT_FILES} ${PO_FILES}
63287111Smarcel
64287111SmarcelS2O = | ${SED} '1,/@@/d'
65287111Smarcel
66287111Smarcelall:
67287111Smarcel
68287111Smarcelvalgrind:
69287111Smarcel	@echo '## Running the regression tests under Valgrind'
70287111Smarcel	${MAKE} CHECKER='valgrind -q' tests
71287111Smarcel
72287111Smarcel#TEST_TRACE = set -x ; 
73287111Smarcel
74287111SmarcelTEST_ONE = \
75287111Smarcel  LIBXO_OPTIONS=:W$$fmt \
76287111Smarcel      ${CHECKER} ./$$base.test ${TEST_OPTS} \
77287111Smarcel      > out/$$base.$$fmt.out 2> out/$$base.$$fmt.err ; \
78287111Smarcel ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.out out/$$base.$$fmt.out ${S2O} ; \
79287111Smarcel ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.err out/$$base.$$fmt.err ${S2O}
80287111Smarcel
81287111SmarcelTEST_FORMATS = T XP JP HP X J H HIPx
82287111Smarcel
83287111Smarceltest tests: ${bin_PROGRAMS} build-mo-files
84287111Smarcel	@${MKDIR} -p out
85287111Smarcel	-@ ${TEST_TRACE} (for test in ${TEST_CASES} ; do \
86287111Smarcel	    base=`${BASENAME} $$test .c` ; \
87287111Smarcel            (for fmt in ${TEST_FORMATS}; do \
88287111Smarcel	        echo "... $$test ... $$fmt ..."; \
89287111Smarcel	        ${TEST_ONE}; \
90287111Smarcel                true; \
91287111Smarcel            done) \
92287111Smarcel	done)
93287111Smarcel
94287111Smarcelone:
95287111Smarcel	-@(test=${TEST_CASE}; data=${TEST_DATA}; ${TEST_ONE} ; true)
96287111Smarcel
97287111Smarcelaccept:
98287111Smarcel	-@(for test in ${TEST_CASES} ; do \
99287111Smarcel	    base=`${BASENAME} $$test .c` ; \
100287111Smarcel            (for fmt in ${TEST_FORMATS}; do \
101287111Smarcel	        echo "... $$test ... $$fmt ..."; \
102287111Smarcel	        ${CP} out/$$base.$$fmt.out ${srcdir}/saved/$$base.$$fmt.out ; \
103287111Smarcel	        ${CP} out/$$base.$$fmt.err ${srcdir}/saved/$$base.$$fmt.err ; \
104287111Smarcel	    done) \
105287111Smarcel	done)
106287111Smarcel
107287111Smarcel.c.test:
108287111Smarcel	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -o $@ $<
109287111Smarcel
110287111SmarcelCLEANFILES = ${TEST_CASES:.c=.test}
111287111SmarcelCLEANDIRS = out
112287111Smarcel
113287111Smarcelclean-local:
114287111Smarcel	rm -rf ${CLEANDIRS}
115287111Smarcel
116287111SmarcelXGETTEXT = ${GETTEXT_BINDIR}/xgettext
117287111SmarcelMSGFMT = ${GETTEXT_BINDIR}/msgfmt -v
118287111SmarcelMSGMERGE = ${GETTEXT_BINDIR}/msgmerge
119287111SmarcelECHO = echo
120287111SmarcelDB=set -x;
121287111SmarcelXOMSGMERGE = ${MSGMERGE} --no-wrap
122287111SmarcelXODIFF = ${DIFF} -bu
123287111Smarcel
124287111SmarcelLANGUAGES = \
125287111Smarcel	es \
126287111Smarcel	fr \
127287111Smarcel	pig_latin
128287111Smarcel
129287111Smarcel# ldns is fake; used only for a gettext domain
130287111SmarcelFAKE_FILES = ldns strerror
131287111SmarcelMO_BASE_FILES = ${TEST_CASES:.c=} ${FAKE_FILES}
132287111Smarcel
133287111Smarcelbuild-pot-files:
134287111Smarcel	for file in ${TEST_CASES} ; do set -x ;\
135287111Smarcel	    base=`${BASENAME} $$file .c` ; \
136287111Smarcel	    ${XGETTEXT} --default-domain=$$base \
137287111Smarcel            --directory=${srcdir} --no-wrap \
138287111Smarcel	    --add-comments --keyword=xo_emit --keyword=xo_emit_h \
139287111Smarcel	    --keyword=xo_emit_warn \
140287111Smarcel	    -C -E -n --foreign-user \
141287111Smarcel	    -o $$base.pot.new $$base.c ; \
142287111Smarcel	done
143287111Smarcel
144287111Smarcelaccept-pot-files:
145287111Smarcel	for base in ${MO_BASE_FILES} ; do set -x ;\
146287111Smarcel	    ${CP} $$base.pot.new ${srcdir}/$$base.pot ; \
147287111Smarcel	done
148287111Smarcel
149287111Smarcelmerge-po-files:
150287111Smarcel	for base in ${MO_BASE_FILES} ; do set -x ;\
151287111Smarcel	    for lang in ${LANGUAGES} ; do \
152287111Smarcel		if [ -f po/$$lang/$$base.po ]; then \
153287111Smarcel		    ${ECHO} "merging $$base.pot into po/$$lang/$$base.po ..." ; \
154287111Smarcel		    if ${XOMSGMERGE} po/$$lang/$$base.po \
155287111Smarcel				${srcdir}/$$base.pot \
156287111Smarcel				-o po/$$lang/$$base.new.po; then \
157287111Smarcel			${MV} po/$$lang/$$base.po \
158287111Smarcel				po/$$lang/$$base.po.old ; \
159287111Smarcel			${MV} po/$$lang/$$base.new.po \
160287111Smarcel				po/$$lang/$$base.po ; \
161287111Smarcel		    else \
162287111Smarcel		      echo "error: msgmerge for $$base failed"; \
163287111Smarcel		    fi ; \
164287111Smarcel		elif [ -f ${srcdir}/po/$$lang/$$base.po ]; then \
165287111Smarcel		    ${ECHO} "merging (srcdir) $$base.pot into po/$$lang/$$base.po ..." ; \
166287111Smarcel		    if ${XOMSGMERGE} ${srcdir}/po/$$lang/$$base.po \
167287111Smarcel				${srcdir}/$$base.pot \
168287111Smarcel				-o po/$$lang/$$base.new.po; then \
169287111Smarcel			${MV} po/$$lang/$$base.po \
170287111Smarcel				po/$$lang/$$base.po.old ; \
171287111Smarcel			${MV} po/$$lang/$$base.new.po \
172287111Smarcel				po/$$lang/$$base.po ; \
173287111Smarcel		    else \
174287111Smarcel		      echo "error: msgmerge for $$base failed"; \
175287111Smarcel		    fi ; \
176287111Smarcel		fi ; \
177287111Smarcel            done ; \
178287111Smarcel        done
179287111Smarcel
180287111Smarcelaccept-po-files:
181287111Smarcel	@(for base in ${MO_BASE_FILES} ; do \
182287111Smarcel	    for lang in ${LANGUAGES} ; do \
183287111Smarcel		if [ -f po/$$lang/$$base.po ]; then \
184287111Smarcel		    ${MKDIR} -p ${srcdir}/po/$$lang ; \
185287111Smarcel		    (${DB} ${CP} po/$$lang/$$base.po ${srcdir}/po/$$lang/$$base.po ); \
186287111Smarcel                fi ; \
187287111Smarcel	    done ; \
188287111Smarcel	done)
189287111Smarcel
190287111Smarcelnew-po-file:
191287111Smarcel	@(for base in ${MO_BASE_FILES} ; do set -x ;\
192287111Smarcel	    for lang in ${LANGUAGES} ; do \
193287111Smarcel		if [ ! -f po/$$lang/$$base.po ]; then \
194287111Smarcel		    ${MKDIR} -p po/$$lang ; \
195287111Smarcel		    (${DB} ${CP} $$base.pot po/$$lang/$$base.po ); \
196287111Smarcel                fi ; \
197287111Smarcel	    done ; \
198287111Smarcel	done)
199287111Smarcel
200287111Smarceldiff:
201287111Smarcel	@(for base in ${MO_BASE_FILES} ; do \
202287111Smarcel	    if [ -f $$base.pot.new ] ; then \
203287111Smarcel	        ${XODIFF} ${srcdir}/$$base.pot $$base.pot.new ; \
204287111Smarcel            fi ; \
205287111Smarcel	    for lang in ${LANGUAGES} ; do \
206287111Smarcel		if [ -f po/$$lang/$$base.po ] ; then \
207287111Smarcel		    ${XODIFF} ${srcdir}/po/$$lang/$$base.po po/$$lang/$$base.po ; \
208287111Smarcel                fi ; \
209287111Smarcel	    done ; \
210287111Smarcel	done)
211287111Smarcel
212287111Smarcelmo build-mo-files:
213287111Smarcel	@(for base in ${MO_BASE_FILES} ; do \
214287111Smarcel	    for lang in ${LANGUAGES} ; do \
215287111Smarcel		${MKDIR} -p po/$$lang/LC_MESSAGES ; \
216287111Smarcel	 	if [ -f po/$$lang/$$base.po ] ; then \
217287111Smarcel		    (${DB} ${MSGFMT} -o po/$$lang/LC_MESSAGES/$$base.mo \
218287111Smarcel				po/$$lang/$$base.po ); \
219287111Smarcel		elif [ -f ${srcdir}/po/$$lang/$$base.po ]; then \
220287111Smarcel		    (${DB} ${MSGFMT} -o po/$$lang/LC_MESSAGES/$$base.mo \
221287111Smarcel			${srcdir}/po/$$lang/$$base.po ;) \
222287111Smarcel                fi ; \
223287111Smarcel	    done ; \
224287111Smarcel	done)
225