1#******************************************************************************
2#
3#   Copyright (C) 1998-2010, International Business Machines
4#   Corporation and others.  All Rights Reserved.
5#
6#******************************************************************************
7## Top-level Makefile.in for ICU
8## Stephen F. Booth
9
10## Source directory information
11srcdir = @srcdir@
12top_srcdir = @top_srcdir@
13
14top_builddir = ../..
15
16include $(top_builddir)/icudefs.mk
17
18## Build directory information
19subdir = test/testdata
20
21## Files to remove for 'make clean'
22CLEANFILES = *~ 
23
24SUBDIRS = 
25
26-include Makefile.local
27
28## List of phony targets
29.PHONY : all all-local all-recursive install install-local	\
30install-recursive clean clean-local clean-recursive distclean	\
31distclean-local distclean-recursive doc dist dist-local dist-recursive	\
32check check-local check-recursive build-dir testdata.jar xcheck
33
34xcheck: all-local
35
36.NOTPARALLEL: build-dir
37
38## Clear suffix list
39.SUFFIXES :
40
41## List of standard targets
42all: all-local
43install: install-local
44clean: clean-local
45distclean : distclean-local
46dist: dist-local
47check: all check-local
48
49all-local: build-dir build-testdata testdata packagetest
50
51install-local: 
52
53dist-local:
54
55clean-local:
56	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
57	$(RMV) $(TESTOUTDIR)
58
59distclean-local: clean-local
60	$(RMV) Makefile pkgdata.inc
61
62check-local:
63
64Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
65	cd $(top_builddir) \
66	&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
67
68pkgdata.inc: pkgdataMakefile
69	$(MAKE) -f pkgdataMakefile
70
71pkgdataMakefile:
72	cd $(top_builddir) \
73	&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
74
75#########################################################################
76############################## Test ## stuff ############################
77
78# relative lib links from pkgdata are the same as for tmp
79GENRBOPTS=-k
80# use the cross root, in case we are cross compiling. Otherwise it is equal to top_builddir
81TOOLDIR=$(cross_buildroot)/tools
82SRCDATADIR=$(top_srcdir)/data
83UNICODEDATADIR=$(SRCDATADIR)/unidata
84OUTDIR=$(top_builddir)/data/out
85OUTTMPDIR=$(top_builddir)/data/out/tmp
86BUILDDIR=$(OUTDIR)/build/$(ICUDATA_PLATFORM_NAME)
87TESTSRCDATADIR=$(top_srcdir)/test/testdata
88TESTOUTDIR=$(top_builddir)/test/testdata/out
89BUILD_DIRS = $(TESTOUTDIR) $(TESTBUILDDIR) $(TESTOUTDIR)/$(TESTDT)
90GENTEST=$(TOOLDIR)/gentest/gentest$(TOOLEXEEXT)
91
92ifeq ($(PKGDATA_MODE),common)
93ICU_DATA_OPT = -i $(OUTDIR)
94else
95ifeq ($(PKGDATA_MODE),dll)
96ifneq ($(ENABLE_SHARED),YES)
97ICU_DATA_OPT = -i $(BUILDDIR)
98else
99ICU_DATA_OPT =
100endif
101else
102ICU_DATA_OPT = -i $(BUILDDIR)
103endif
104endif
105
106CURDIR:=$(CURR_FULL_DIR)
107# current directory should not be blank
108ifeq ($(CURDIR),)
109CURDIR=.
110endif
111
112PKGDATA = $(TOOLBINDIR)/pkgdata -q -c -s $(CURDIR)/out/build/$(ICUDATA_PLATFORM_NAME)
113PKGDATA_INVOKE:=$(INVOKE) $(PKGDATA_INVOKE_OPTS)
114
115# Contains all 'intermediate' files (and temp files) except for 'unpackaged data' below
116TESTBUILDDIR=$(TESTOUTDIR)/build
117
118# unpackaged files  - live in 'out' so that the path can find them as part of the pkg
119UNPACKAGEDTESTDATA=$(TESTOUTDIR)/$(TESTDT)/nam.typ
120
121# pkg name for testdata
122TESTDATA=testdata
123# prefix for files that are testdata
124TESTDT=$(TESTDATA)
125
126# File definitions 
127TEST_DAT_FILES=$(TESTBUILDDIR)/test.icu
128TEST_SPP_FILES=$(TESTBUILDDIR)/nfscsi.spp $(TESTBUILDDIR)/nfscss.spp $(TESTBUILDDIR)/nfscis.spp $(TESTBUILDDIR)/nfsmxs.spp $(TESTBUILDDIR)/nfsmxp.spp
129
130TEST_UCM_SOURCE= test1.ucm test1bmp.ucm test3.ucm test4.ucm test4x.ucm test5.ucm ibm9027.ucm
131TEST_UCM_FILES=$(TEST_UCM_SOURCE:%=$(TESTSRCDATADIR)/data/%)
132TEST_CNV_FILES=$(TEST_UCM_SOURCE:%.ucm=$(TESTBUILDDIR)/%.cnv)
133
134TEST_NRM_FILES=$(TESTBUILDDIR)/testnorm.nrm
135
136# import the shared .mk file
137include $(TESTSRCDATADIR)/tstfiles.mk
138-include $(TESTSRCDATADIR)/tstlocal.mk
139
140# TEST_RES_SOURCE comes from tstfiles.mk
141TEST_RES = $(TEST_RES_SOURCE) $(TEST_RES_LOCAL) casing.txt mc.txt root.txt sh.txt sh_YU.txt te.txt te_IN.txt te_IN_REVISED.txt testtypes.txt testaliases.txt testempty.txt structLocale.txt idna_rules.txt conversion.txt icuio.txt testtable32.txt
142TEST_RES_FILES=$(TEST_RES:%.txt=$(TESTBUILDDIR)/%.res) $(TESTBUILDDIR)/iscii.res $(TESTBUILDDIR)/old_l_testtypes.res $(TESTBUILDDIR)/old_e_testtypes.res
143
144ALL_TEST_FILES = $(TEST_DAT_FILES) $(TEST_SPP_FILES) $(TEST_BRK_FILES) $(TEST_CNV_FILES) $(TEST_NRM_FILES) $(TEST_RES_FILES) $(TESTOUTDIR)/$(TESTDT)/nam.typ
145
146# list
147
148$(TESTBUILDDIR)/testdata.lst: $(SRCLISTDEPS)
149	@echo "generating $@ (list of data files)"
150	@-$(RMV) $@
151	@for file in $(TEST_RES_FILES:$(TESTBUILDDIR)/%.res=%.res) $(TEST_DAT_FILES:$(TESTBUILDDIR)/%.icu=%.icu) $(TEST_SPP_FILES:$(TESTBUILDDIR)/%.spp=%.spp) $(TEST_CNV_FILES:$(TESTBUILDDIR)/%.cnv=%.cnv) $(TEST_NRM_FILES:$(TESTBUILDDIR)/%.nrm=%.nrm); do \
152	  echo $$file >> $@; \
153	done;
154
155
156build-testdata: build-dir $(ALL_TEST_FILES) $(TESTBUILDDIR)/testdata.lst $(TESTBUILDDIR)/iscii.res
157
158# test.icu
159$(TESTBUILDDIR)/test.icu: $(GENTEST)
160	$(INVOKE) $(GENTEST) -d $(TESTBUILDDIR) 
161
162$(TESTBUILDDIR)/testtable32.txt:  $(GENTEST)
163	$(INVOKE) $(GENTEST) -r -d $(TESTBUILDDIR) 
164
165$(TESTBUILDDIR)/testtable32.res: $(TESTBUILDDIR)/testtable32.txt $(TOOLBINDIR)/genrb$(EXEEXT)
166	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -s $(TESTBUILDDIR) $(ICU_DATA_OPT) -d $(TESTBUILDDIR) $(<F)
167
168# Targets for nfscsi.spp
169$(TESTBUILDDIR)/nfscsi.spp: $(TOOLBINDIR)/gensprep$(EXEEXT) $(TESTSRCDATADIR)/nfs4_cs_prep_ci.txt
170	@echo Building nfscsi.icu
171	$(INVOKE) $(TOOLBINDIR)/gensprep -s $(TESTSRCDATADIR) $(ICU_DATA_OPT) -d $(TESTBUILDDIR) -b nfscsi -u 3.2.0 nfs4_cs_prep_ci.txt
172
173# Targets for nfscss.spp
174$(TESTBUILDDIR)/nfscss.spp: $(TOOLBINDIR)/gensprep$(EXEEXT) $(TESTSRCDATADIR)/nfs4_cs_prep_cs.txt
175	@echo Building nfscss.icu
176	$(INVOKE) $(TOOLBINDIR)/gensprep -s $(TESTSRCDATADIR) $(ICU_DATA_OPT) -d $(TESTBUILDDIR) -b nfscss -u 3.2.0 nfs4_cs_prep_cs.txt
177
178# Targets for nfscis.spp
179$(TESTBUILDDIR)/nfscis.spp: $(TOOLBINDIR)/gensprep$(EXEEXT) $(TESTSRCDATADIR)/nfs4_cis_prep.txt
180	@echo Building nfscis.spp
181	$(INVOKE) $(TOOLBINDIR)/gensprep -s $(TESTSRCDATADIR) $(ICU_DATA_OPT) -d $(TESTBUILDDIR) -b nfscis -k -n $(UNICODEDATADIR) -u 3.2.0 nfs4_cis_prep.txt
182
183# Targets for nfsmxs.spp
184$(TESTBUILDDIR)/nfsmxs.spp: $(TOOLBINDIR)/gensprep$(EXEEXT) $(TESTSRCDATADIR)/nfs4_mixed_prep_s.txt
185	@echo Building nfsmxs.spp
186	$(INVOKE) $(TOOLBINDIR)/gensprep -s $(TESTSRCDATADIR) $(ICU_DATA_OPT) -d $(TESTBUILDDIR) -b nfsmxs -k -n $(UNICODEDATADIR) -u 3.2.0 nfs4_mixed_prep_s.txt
187
188# Targets for nfsmxp.spp
189$(TESTBUILDDIR)/nfsmxp.spp: $(TOOLBINDIR)/gensprep$(EXEEXT) $(TESTSRCDATADIR)/nfs4_mixed_prep_p.txt
190	@echo Building nfsmxp.spp
191	$(INVOKE) $(TOOLBINDIR)/gensprep -s $(TESTSRCDATADIR) $(ICU_DATA_OPT) -d $(TESTBUILDDIR) -b nfsmxp -k -n $(UNICODEDATADIR) -u 3.2.0 nfs4_mixed_prep_p.txt
192
193$(TESTBUILDDIR)/%.cnv: $(TESTSRCDATADIR)/%.ucm $(TOOLBINDIR)/makeconv$(EXEEXT)
194	$(INVOKE) $(TOOLBINDIR)/makeconv --small -c -d $(TESTBUILDDIR) $(TESTSRCDATADIR)/$(<F)
195
196$(TESTBUILDDIR)/%.nrm: $(TESTSRCDATADIR)/%.txt $(TOOLBINDIR)/gennorm2$(EXEEXT)
197	$(INVOKE) $(TOOLBINDIR)/gennorm2 -s $(TESTSRCDATADIR) $(<F) -o $@
198
199$(TESTBUILDDIR)/%.res: $(TESTSRCDATADIR)/%.txt $(TOOLBINDIR)/genrb$(EXEEXT) $(DAT_FILES)
200	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -q -s $(TESTSRCDATADIR) $(ICU_DATA_OPT) -d $(TESTBUILDDIR) $(<F)
201
202$(TESTBUILDDIR)/iscii.res:  $(TESTSRCDATADIR)/iscii.bin $(TOOLBINDIR)/genrb$(EXEEXT)
203	@echo Testing genrb -e option
204	@ICU_DATA=$(BUILDDIR) $(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -s $(TESTSRCDATADIR) -eISCII,version=0 -d $(TESTBUILDDIR) $(<F) >/dev/null  || ( echo "WARNING: could not open ISCII - it may have been disabled." | tee $@ )
205	@echo Finished testing genrb -e option
206
207################################################################### TYP
208# TYP FILES
209
210$(TESTOUTDIR)/$(TESTDT)/nam.typ: $(TESTBUILDDIR)/te_IN.res
211	cp $< $@
212$(TESTBUILDDIR)/old_l_testtypes.res: $(TESTSRCDATADIR)/old_l_testtypes.res
213	cp $< $@
214$(TESTBUILDDIR)/old_e_testtypes.res: $(TESTSRCDATADIR)/old_e_testtypes.res
215	cp $< $@
216
217testdata: build-dir $(ALL_TEST_FILES) $(UNPACKAGEDTESTDATA)
218
219#$(ALL_TEST_FILES) $(TESTBUILDDIR)/testtable32.txt $(TESTBUILDDIR)/testdata.lst: build-dir
220
221packagetest: build-dir testdata pkgdata.inc $(TESTBUILDDIR)/testdata.lst 
222	$(PKGDATA_INVOKE) $(PKGDATA) -T $(TESTBUILDDIR) -d $(TESTOUTDIR) -s $(TESTBUILDDIR) -p $(TESTDATA) -m common $(TESTBUILDDIR)/testdata.lst
223
224build-dir: $(BUILD_DIRS)
225$(BUILD_DIRS):
226	-$(MKINSTALLDIRS) $(BUILD_DIRS)
227
228# Build the ICU4J testdata.jar.
229# Command line:
230#   (Run this from the output testdata folder which may not be .../source/test/testdata in an out-of-source build.)
231#   ~/svn.icu/trunk/source/test/testdata> make JAR=jar ICU4J_ROOT=~/svn.icu4j/trunk testdata.jar
232# You can omit the ICU4J_ROOT for just building the .jar files without copying them.
233# You can omit the JAR if it's just jar.
234JAR=jar
235
236# Build testdata.jar:
237# - swap the test data
238# - extract all data items
239# - package them into the .jar file
240$(OUTDIR)/icu4j/testdata.jar: build-dir testdata $(TESTOUTDIR)/testdata.dat
241	mkdir -p $(OUTDIR)/icu4j/com/ibm/icu/dev/data/testdata
242	$(INVOKE) $(TOOLBINDIR)/icupkg $(TESTOUTDIR)/testdata.dat -r test.icu -x '*' -tb -d $(OUTDIR)/icu4j/com/ibm/icu/dev/data/testdata
243	$(JAR) cf $(OUTDIR)/icu4j/testdata.jar -C $(OUTDIR)/icu4j com/ibm/icu/dev/data/testdata
244
245
246DEBUGUTILITIESDATA_DIR=main/tests/core/src/com/ibm/icu/dev/test/util
247DEBUGUTILITIESDATA_SRC=DebugUtilitiesData.java
248
249ICU4J_DATA=$(OUTDIR)/icu4j/src/$(DEBUGUTILITIESDATA_SRC) $(OUTDIR)/icu4j/testdata.jar
250
251$(OUTDIR)/icu4j/src/$(DEBUGUTILITIESDATA_SRC): $(GENTEST)
252	mkdir -p $(OUTDIR)/icu4j/src
253	$(INVOKE) $(GENTEST) -j -d $(OUTDIR)/icu4j/src
254
255ifdef ICU4J_ROOT
256
257icu4j-data-install: $(ICU4J_ROOT)/main/shared/data/testdata.jar $(ICU4J_ROOT)/$(DEBUGUTILITIESDATA_DIR)/$(DEBUGUTILITIESDATA_SRC)
258	@echo ICU4J test data installed in $(ICU4J_ROOT)
259
260$(ICU4J_ROOT)/main/shared/data/testdata.jar: $(OUTDIR)/icu4j/testdata.jar
261	mkdir -p $(ICU4J_ROOT)/main/shared/data
262	cp $(OUTDIR)/icu4j/testdata.jar $(ICU4J_ROOT)/main/shared/data
263
264$(ICU4J_ROOT)/$(DEBUGUTILITIESDATA_DIR)/$(DEBUGUTILITIESDATA_SRC): $(OUTDIR)/icu4j/src/$(DEBUGUTILITIESDATA_SRC)
265	mkdir -p $(ICU4J_ROOT)/$(DEBUGUTILITIESDATA_DIR)
266	cp $^ $@
267
268else
269
270icu4j-data-install: $(ICU4J_DATA)
271	@echo ICU4J data was built into $(OUTDIR)/icu4j
272	@echo '** Error:' ICU4J_ROOT was not set, could not install
273	exit 1
274
275endif
276
277icu4j-data: $(ICU4J_DATA)
278