DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (d38398e5144e)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940
## Makefile.in for ICU data
## Copyright (C) 2016 and later: Unicode, Inc. and others.
## License & terms of use: http://www.unicode.org/copyright.html
## Copyright (c) 1999-2015, International Business Machines Corporation and
## others. All Rights Reserved.

## Source directory information
srcdir = @srcdir@
top_srcdir = @top_srcdir@

# So that you have $(top_builddir)/config.status
top_builddir = ..

## All the flags and other definitions are included here.
include $(top_builddir)/icudefs.mk

## Build directory information
# So that  $(top_builddir)/$(subdir) ~= "here"
subdir = data

#lib icu data for link
LIB_ICUDATA_NAME=$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX)
LIB_STATIC_ICUDATA_NAME=$(LIBSICU)$(DATA_STUBNAME)$(ICULIBSUFFIX)

# Allow Windows to override these options
ifeq ($(PKGDATA_OPTS),)
PKGDATA_OPTS = -O $(top_builddir)/data/icupkg.inc
endif
ifeq ($(PKGDATA_VERSIONING),)
PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION)
endif

# This allows all the data to be in one directory
ifeq ($(PKGDATA_MODE),dll)
ICUPKGDATA_OUTDIR = $(LIBDIR)
else
ifeq ($(PKGDATA_MODE),static)
ICUPKGDATA_OUTDIR = $(LIBDIR)
else
ICUPKGDATA_OUTDIR = $(OUTDIR)
endif
endif

CURDIR:=$(CURR_FULL_DIR)
# current directory should not be blank
ifeq ($(CURDIR),)
CURDIR=.
endif
ifeq ($(OS390BATCH),1)
PKGDATA = $(TOOLBINDIR)/pkgdata $(PKGDATA_OPTS) -z -q -c -s $(CURDIR)/out/build/$(ICUDATA_PLATFORM_NAME) -d $(ICUPKGDATA_OUTDIR)
else
PKGDATA = $(TOOLBINDIR)/pkgdata $(PKGDATA_OPTS) -q -c -s $(CURDIR)/out/build/$(ICUDATA_PLATFORM_NAME) -d $(ICUPKGDATA_OUTDIR)
endif
OS390_PDS_NAME = -z -L $(BATCH_STUB_TARGET)

ifeq ($(OS390_STUBDATA),1)
OS390PKG=package390
OS390INSTALL=install390

# Additional data for 390
OS390LIST=$(OUTTMPDIR)/icudata390.lst
OUTTMPDIR_390STUB=$(top_builddir)/data/out/tmp_390stub
endif

ifeq ($(OS390BATCH),1)
CPPFLAGS += -Wc,'ros,roc'
endif

# OBJDATADIR must be a short path (with ..'s) to the data.

ifeq ($(top_srcdir),..)
SRCDATADIR=.
else
SRCDATADIR=$(top_srcdir)/data
endif
ifeq ($(top_builddir),..)
OUTDIR=./out
else
OUTDIR=$(top_builddir)/data/out
endif

OUTTMPDIR=$(OUTDIR)/tmp
MAINBUILDDIR=$(OUTDIR)/build
BUILDDIR=$(MAINBUILDDIR)/$(ICUDATA_PLATFORM_NAME)
UNICODEDATADIR=$(SRCDATADIR)/unidata
LOCSRCDIR=$(SRCDATADIR)/locales
CURRSRCDIR=$(SRCDATADIR)/curr
CURRBLDDIR=$(BUILDDIR)/curr
LANGSRCDIR=$(SRCDATADIR)/lang
LANGBLDDIR=$(BUILDDIR)/lang
REGIONSRCDIR=$(SRCDATADIR)/region
REGIONBLDDIR=$(BUILDDIR)/region
ZONESRCDIR=$(SRCDATADIR)/zone
ZONEBLDDIR=$(BUILDDIR)/zone
UNITSRCDIR=$(SRCDATADIR)/unit
UNITBLDDIR=$(BUILDDIR)/unit
COLSRCDIR=$(SRCDATADIR)/coll
COLBLDDIR=$(BUILDDIR)/coll
RBNFSRCDIR=$(SRCDATADIR)/rbnf
RBNFBLDDIR=$(BUILDDIR)/rbnf
TRANSLITSRCDIR=$(SRCDATADIR)/translit
TRANSLITBLDDIR=$(BUILDDIR)/translit
MISCSRCDIR=$(SRCDATADIR)/misc
BRKSRCDIR=$(SRCDATADIR)/brkitr
BRKBLDDIR=$(BUILDDIR)/brkitr
DICTSRCDIR=$(BRKSRCDIR)/dictionaries
BRKRULESRCDIR=$(BRKSRCDIR)/rules
MISCSRCDIR=$(SRCDATADIR)/misc
UCMSRCDIR=$(SRCDATADIR)/mappings
SPREPSRCDIR=$(SRCDATADIR)/sprep
COMINCDIR=$(top_srcdir)/common/unicode
SRCLISTDEPS=Makefile $(srcdir)/Makefile.in
BUILD_DIRS=$(OUTDIR) $(MAINBUILDDIR) $(BUILDDIR) $(CURRBLDDIR) $(LANGBLDDIR) $(REGIONBLDDIR) $(ZONEBLDDIR) $(UNITBLDDIR) $(BRKBLDDIR) $(COLBLDDIR) $(RBNFBLDDIR) $(TRANSLITBLDDIR) $(OUTTMPDIR) $(OUTTMPDIR_390STUB) $(OUTTMPDIR)/$(CURR_TREE) $(OUTTMPDIR)/$(LANG_TREE) $(OUTTMPDIR)/$(REGION_TREE) $(OUTTMPDIR)/$(ZONE_TREE) $(OUTTMPDIR)/$(UNIT_TREE) $(OUTTMPDIR)/$(COLLATION_TREE) $(OUTTMPDIR)/$(RBNF_TREE) $(OUTTMPDIR)/$(TRANSLIT_TREE) $(OUTTMPDIR)/$(BREAK_TREE)

# relative lib links from pkgdata are the same as for tmp
TOOLDIR=$(top_builddir)/tools

## List of phony targets
.PHONY : all all-local all-recursive install install-local install-files	\
install-recursive clean clean-local clean-recursive distclean		\
distclean-local distclean-recursive dist dist-local dist-recursive	\
check check-local check-recursive clean-resindex icudata.jar	\
check-exhaustive

## Clear suffix list
.SUFFIXES :

## List of standard targets
all: all-local
install: all-local install-local 
clean: clean-local
distclean : distclean-local
dist: 
check: all

check-exhaustive: check

-include Makefile.local


distclean-local: clean
	$(RMV) Makefile

all-local: build-dir icupkg.inc build-local packagedata $(POST_DATA_BUILD) $(OS390PKG)

dist-local:

clean-map:
	-test -z *.map || $(RMV) *.map

clean-local: cleanpackage cleanfiles clean-map
	$(RMV) build-dir* build-local packagedata uni-core-data

cleanfiles:
	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)

cleanpackage:
	$(RMV) $(OUTDIR)
	$(RMV) $(LIBDIR)/*$(LIB_ICUDATA_NAME)*.$(SO)* $(LIBDIR)/$(LIB_STATIC_ICUDATA_NAME).$(A)

check-local:

# Find out if we have a source archive.
# If we have that, then use that instead of building everything from scratch.
ICUDATA_SOURCE_ARCHIVE = $(wildcard $(srcdir)/in/$(ICUDATA_PLATFORM_NAME).dat)
ifeq ($(ICUDATA_SOURCE_ARCHIVE),)
ICUDATA_ARCHIVE = $(firstword $(wildcard $(srcdir)/in/$(ICUDATA_BASENAME_VERSION)*.dat))
# We don't have the data in the current endianess or charset.
# See if we can find data of any archive type,
# and convert it to the current type.
ifneq ($(ICUDATA_ARCHIVE),)
ICUDATA_SOURCE_ARCHIVE = $(OUTDIR)/$(ICUDATA_PLATFORM_NAME).dat
$(ICUDATA_SOURCE_ARCHIVE): $(ICUDATA_ARCHIVE) $(OUTDIR)
	$(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $(ICUDATA_ARCHIVE) $(ICUDATA_SOURCE_ARCHIVE)
endif
else
ifneq ($(ENABLE_STATIC),YES)
ifeq ($(PKGDATA_MODE),common)
# We have a source data common archive in the native endianess,
# and it's what we want to build. Try to not run any of ICU's tools.
ICUDATA_SOURCE_IS_NATIVE_TARGET=YES
endif
endif
endif

packagedata: icupkg.inc $(PKGDATA_LIST) build-local
ifneq ($(ENABLE_STATIC),)
ifeq ($(PKGDATA_MODE),dll)
	$(PKGDATA_INVOKE) $(PKGDATA) -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -p $(ICUDATA_NAME) $(PKGDATA_LIBSTATICNAME) -m static $(PKGDATA_VERSIONING) $(PKGDATA_LIST)
endif
endif
ifneq ($(ICUDATA_SOURCE_IS_NATIVE_TARGET),YES)
	$(PKGDATA_INVOKE) $(PKGDATA) -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -p $(ICUDATA_NAME) -m $(PKGDATA_MODE) $(PKGDATA_VERSIONING) $(PKGDATA_LIBNAME) $(PKGDATA_LIST)
else
	$(INSTALL_DATA) $(ICUDATA_SOURCE_ARCHIVE) $(OUTDIR)
endif
	echo timestamp > $@

## Install ICU data.
install-local: $(PKGDATA_LIST) ./icupkg.inc packagedata $(OS390INSTALL)
	$(MKINSTALLDIRS) $(TMPDATADIR) $(DESTDIR)$(ICUPKGDATA_DIR)
ifeq ($(PKGDATA_MODE),files)
	$(MKINSTALLDIRS) $(ICUPKGDATA_DIR)/$(ICUDATA_NAME)
	$(MKINSTALLDIRS) $(ICUPKGDATA_DIR)/$(ICUDATA_NAME)/$(CURR_TREE)
	$(MKINSTALLDIRS) $(ICUPKGDATA_DIR)/$(ICUDATA_NAME)/$(LANG_TREE)
	$(MKINSTALLDIRS) $(ICUPKGDATA_DIR)/$(ICUDATA_NAME)/$(REGION_TREE)
	$(MKINSTALLDIRS) $(ICUPKGDATA_DIR)/$(ICUDATA_NAME)/$(ZONE_TREE)
	$(MKINSTALLDIRS) $(ICUPKGDATA_DIR)/$(ICUDATA_NAME)/$(UNIT_TREE)
	$(MKINSTALLDIRS) $(ICUPKGDATA_DIR)/$(ICUDATA_NAME)/$(BREAK_TREE)
	$(MKINSTALLDIRS) $(ICUPKGDATA_DIR)/$(ICUDATA_NAME)/$(COLLATION_TREE)
	$(MKINSTALLDIRS) $(ICUPKGDATA_DIR)/$(ICUDATA_NAME)/$(RBNF_TREE)
	$(MKINSTALLDIRS) $(ICUPKGDATA_DIR)/$(ICUDATA_NAME)/$(TRANSLIT_TREE)
endif
ifneq ($(ENABLE_STATIC),)
ifeq ($(PKGDATA_MODE),dll)
	$(PKGDATA_INVOKE) $(PKGDATA) -m static -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -s $(BUILDDIR) -p $(ICUDATA_NAME) $(PKGDATA_LIBSTATICNAME) $(PKGDATA_LIST) -I $(ICUPKGDATA_INSTALL_LIBDIR)
endif
endif
ifneq ($(ICUDATA_SOURCE_IS_NATIVE_TARGET),YES)
	$(PKGDATA_INVOKE) $(PKGDATA) -m $(PKGDATA_MODE) $(PKGDATA_VERSIONING) -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -s $(BUILDDIR) -p $(ICUDATA_NAME) $(PKGDATA_LIBNAME) $(PKGDATA_LIST) -I $(ICUPKGDATA_INSTALL_DIR)
else
	$(INSTALL_DATA) $(ICUDATA_SOURCE_ARCHIVE) $(DESTDIR)$(ICUPKGDATA_DIR)
endif


####
####
#### 390 support
install390: package390
	$(MKINSTALLDIRS) $(TMPDATADIR) $(DESTDIR)$(libdir)
	$(INVOKE) $(PKGDATA) -s $(BUILDDIR)$(STUB_SUFFIX) -T $(OUTTMPDIR_390STUB) -p $(ICUDATA_NAME)$(STUB_SUFFIX) $(PKGDATA_LIBNAME)$(STUB_SUFFIX) -e $(ICUDATA_ENTRY_POINT) $(OS390LIST) -m dll $(PKGDATA_VERSIONING) -I $(DESTDIR)$(ICUPKGDATA_DIR)
ifeq ($(PKGDATA_MODE),dll)
	$(INSTALL-L) $(ICUPKGDATA_OUTDIR)/$(FINAL_IMPORT_LIB) $(DESTDIR)$(ICUPKGDATA_DIR)/$(FINAL_IMPORT_LIB)
endif

#### $(LIB_ICUDATA_NAME)$(STUB_SUFFIX) is the subset data for batch mode
package390: $(OUTTMPDIR)/icudata390.lst $(PKGDATA_LIST) ./icupkg.inc packagedata
	ln -s $(ICUDATA_NAME) $(OUTDIR)/build/$(ICUDATA_NAME)$(STUB_SUFFIX)
	$(INVOKE) $(PKGDATA) -s $(BUILDDIR)$(STUB_SUFFIX) -T $(OUTTMPDIR_390STUB) -p $(ICUDATA_NAME)$(STUB_SUFFIX) $(PKGDATA_LIBNAME)$(STUB_SUFFIX) -e $(ICUDATA_ENTRY_POINT) $(OS390LIST) -m dll $(PKGDATA_VERSIONING)
	cp $(ICUPKGDATA_OUTDIR)/$(LIB_ICUDATA_NAME)$(STUB_SUFFIX).$(SO) $(top_builddir)/stubdata/$(LIB_ICUDATA_NAME)$(STUB_SUFFIX).$(SO)


##### Define all the data files. the build rule that depends on them is below.
# X_FILES_SHORT = just the base names (for lists)
# X_FILES = full paths (for dependency)

## DAT files - Misc. data files.
#  2005-may-05 Removed Unicode properties files (unorm.icu, uprops.icu, ucase.icu, ubidi.icu)
#  from data build. See Jitterbug 4497. (makedata.mak revision 1.117)
#  2010-dec Removed pnames.icu.
# These are now hardcoded in ICU4C and only loaded in ICU4J.
#
DAT_FILES_SHORT=unames.icu cnvalias.icu coll/ucadata.icu nfkc.nrm nfkc_cf.nrm uts46.nrm
DAT_FILES=$(DAT_FILES_SHORT:%=$(BUILDDIR)/%)

## BRK files
BREAK_TREE=brkitr
-include $(BRKSRCDIR)/brkfiles.mk
-include $(BRKSRCDIR)/brklocal.mk
ALL_BRK_SOURCE= $(BRK_SOURCE) $(BRK_SOURCE_LOCAL)
BRK_FILES_SHORT=$(ALL_BRK_SOURCE:%.txt=$(BREAK_TREE)/%.brk)
BRK_FILES=$(ALL_BRK_SOURCE:%.txt=$(BRKBLDDIR)/%.brk)
ifdef BRK_DICT_SOURCE
ALL_DICT_SOURCE=$(BRK_DICT_SOURCE) $(BRK_DICT_SOURCE_LOCAL)
DICT_FILES_SHORT=$(ALL_DICT_SOURCE:%.txt=$(BREAK_TREE)/%.dict)
DICT_FILES=$(ALL_DICT_SOURCE:%.txt=$(BRKBLDDIR)/%.dict)
endif
ifdef BRK_RES_SOURCE
BRS_SRC= root.txt $(BRK_RES_SOURCE) $(BRK_RES_SOURCE_LOCAL)
BRS_SRC_FILES = $(BRS_SRC:%=$(BRKSRCDIR)/%)
INSTALLED_BRS_FILES = $(BRK_RES_SOURCE:%.txt=%)  $(BRK_RES_SOURCE_LOCAL:%.txt=%)
endif

## Confusables (Spoofing) files
ALL_CFU_SOURCE=$(UNICODEDATADIR)/confusables.txt $(UNICODEDATADIR)/confusablesWholeScript.txt
CFU_FILES_SHORT=confusables.cfu
CFU_FILES=$(BUILDDIR)/$(CFU_FILES_SHORT)

## UCM files
-include $(UCMSRCDIR)/ucmcore.mk
-include $(UCMSRCDIR)/ucmfiles.mk
-include $(UCMSRCDIR)/ucmebcdic.mk
-include $(UCMSRCDIR)/ucmlocal.mk
ALL_UCM_SOURCE=ibm-37_P100-1995.ucm ibm-1047_P100-1995.ucm $(UCM_SOURCE_CORE) $(UCM_SOURCE_FILES) $(UCM_SOURCE_EBCDIC) $(UCM_SOURCE_LOCAL)
UCM_FILES = $(ALL_UCM_SOURCE:%=$(SRCDATADIR)/%)
CNV_FILES = $(ALL_UCM_SOURCE:%.ucm=$(BUILDDIR)/%.cnv)
CNV_FILES_SHORT = $(ALL_UCM_SOURCE:%.ucm=%.cnv)
UCM_SOURCE_SPECIAL=$(UCM_SOURCE_EBCDIC_IGNORE_SISO) $(UCM_SOURCE_EBCDIC_IGNORE_SISO_LOCAL)
UCM_FILES_SPECIAL=$(UCM_SOURCE_SPECIAL:%=$(UCMSRCDIR)/%) 
CNV_FILES_SPECIAL=$(UCM_SOURCE_SPECIAL:%.ucm=$(BUILDDIR)/%.cnv) 
CNV_FILES_SHORT_SPECIAL=$(UCM_SOURCE_SPECIAL:%.ucm=%.cnv) 

## RES files
-include $(LOCSRCDIR)/resfiles.mk
-include $(CURRSRCDIR)/resfiles.mk
-include $(LANGSRCDIR)/resfiles.mk
-include $(REGIONSRCDIR)/resfiles.mk
-include $(ZONESRCDIR)/resfiles.mk
-include $(UNITSRCDIR)/resfiles.mk
-include $(COLSRCDIR)/colfiles.mk
-include $(RBNFSRCDIR)/rbnffiles.mk
-include $(TRANSLITSRCDIR)/trnsfiles.mk
-include $(LOCSRCDIR)/reslocal.mk
-include $(CURRSRCDIR)/reslocal.mk
-include $(LANGSRCDIR)/reslocal.mk
-include $(REGIONSRCDIR)/reslocal.mk
-include $(ZONESRCDIR)/reslocal.mk
-include $(UNITSRCDIR)/reslocal.mk
-include $(COLSRCDIR)/collocal.mk
-include $(BRKSRCDIR)/brslocal.mk
-include $(RBNFSRCDIR)/rbnflocal.mk
-include $(TRANSLITSRCDIR)/trnslocal.mk
ifdef GENRB_SOURCE
RES_SRC= root.txt $(GENRB_SOURCE) $(GENRB_ALIAS_SOURCE) $(GENRB_SOURCE_LOCAL) $(GENRB_ALIAS_SOURCE_LOCAL)
RES_SRC_FILES = $(RES_SRC:%=$(LOCSRCDIR)/%)
INSTALLED_RB_FILES = $(GENRB_SOURCE:%.txt=%) $(GENRB_SOURCE_LOCAL:%.txt=%)
endif
ifdef CURR_SOURCE
CURR_SRC= root.txt supplementalData.txt $(CURR_SOURCE) $(CURR_ALIAS_SOURCE) $(CURR_SOURCE_LOCAL)
CURR_SRC_FILES = $(CURR_SRC:%=$(CURRSRCDIR)/%)
INSTALLED_CURR_FILES = $(CURR_SOURCE:%.txt=%)  $(CURR_SOURCE_LOCAL:%.txt=%)
endif
ifdef LANG_SOURCE
LANG_SRC= root.txt $(LANG_SOURCE) $(LANG_ALIAS_SOURCE) $(LANG_SOURCE_LOCAL)
LANG_SRC_FILES = $(LANG_SRC:%=$(LANGSRCDIR)/%)
INSTALLED_LANG_FILES = $(LANG_SOURCE:%.txt=%)  $(LANG_SOURCE_LOCAL:%.txt=%)
endif
ifdef REGION_SOURCE
REGION_SRC= root.txt $(REGION_SOURCE) $(REGION_ALIAS_SOURCE) $(REGION_SOURCE_LOCAL)
REGION_SRC_FILES = $(REGION_SRC:%=$(REGIONSRCDIR)/%)
INSTALLED_REGION_FILES = $(REGION_SOURCE:%.txt=%)  $(REGION_SOURCE_LOCAL:%.txt=%)
endif
ifdef ZONE_SOURCE
ZONE_SRC= root.txt $(ZONE_SOURCE) $(ZONE_ALIAS_SOURCE) $(ZONE_SOURCE_LOCAL) tzdbNames.txt
ZONE_SRC_FILES = $(ZONE_SRC:%=$(ZONESRCDIR)/%)
INSTALLED_ZONE_FILES = $(ZONE_SOURCE:%.txt=%)  $(ZONE_SOURCE_LOCAL:%.txt=%)
endif
ifdef UNIT_SOURCE
UNIT_SRC= root.txt $(UNIT_SOURCE) $(UNIT_ALIAS_SOURCE) $(UNIT_SOURCE_LOCAL)
UNIT_SRC_FILES = $(UNIT_SRC:%=$(UNITSRCDIR)/%)
INSTALLED_UNIT_FILES = $(UNIT_SOURCE:%.txt=%)  $(UNIT_SOURCE_LOCAL:%.txt=%)
endif
ifdef COLLATION_SOURCE
COL_SRC= root.txt $(COLLATION_SOURCE) $(COLLATION_ALIAS_SOURCE) $(COLLATION_SOURCE_LOCAL)
COL_SRC_FILES = $(COL_SRC:%=$(COLSRCDIR)/%)
INSTALLED_COL_FILES = $(COLLATION_SOURCE:%.txt=%)  $(COLLATION_SOURCE_LOCAL:%.txt=%)
endif
ifdef RBNF_SOURCE
RBNF_SRC= root.txt $(RBNF_SOURCE) $(RBNF_ALIAS_SOURCE) $(RBNF_SOURCE_LOCAL)
RBNF_SRC_FILES = $(RBNF_SRC:%=$(RBNFSRCDIR)/%)
INSTALLED_RBNF_FILES = $(RBNF_SOURCE:%.txt=%)  $(RBNF_SOURCE_LOCAL:%.txt=%)
endif
ifdef TRANSLIT_SOURCE
TRANSLIT_SRC= $(TRANSLIT_SOURCE) $(TRANSLIT_ALIAS_SOURCE) $(TRANSLIT_SOURCE_LOCAL)
TRANSLIT_SRC_FILES = $(TRANSLIT_SRC:%=$(TRANSLITSRCDIR)/%)
INSTALLED_TRANSLIT_FILES = $(TRANSLIT_SOURCE:%.txt=%)  $(TRANSLIT_SOURCE_LOCAL:%.txt=%)
endif
GENRBOPTS=-k

## MISC files
-include $(MISCSRCDIR)/miscfiles.mk
-include $(MISCSRCDIR)/misclocal.mk
MSC_SOURCE= $(MISC_SOURCE) $(MISC_SOURCE_LOCAL)
MSC_SRC_FILES=$(MSC_SOURCE:%=$(MISCSRCDIR)/%)

ifeq ($(ENABLE_SO_VERSION_DATA),1)
ifeq ($(PKGDATA_MODE),dll)
SO_VERSION_DATA = $(OUTTMPDIR)/icudata.res
$(SO_VERSION_DATA) : $(MISCSRCDIR)/icudata.rc
ifeq ($(MSYS_RC_MODE),1)
	rc.exe -i$(srcdir)/../common -i$(top_builddir)/common -fo$@ $(CPPFLAGS) $<
else
	rc.exe /i$(srcdir)/../common /i$(top_builddir)/common /fo$@ $(CPPFLAGS) $(SOURCE_FILE)
endif
endif
endif

INDEX_NAME=res_index
INDEX_FILE=$(OUTTMPDIR)/$(INDEX_NAME).txt

ALL_RES_SRC= $(RES_SRC) $(TRNS_SOURCE) $(MSC_SOURCE)
RES_FILES = $(ALL_RES_SRC:%.txt=$(BUILDDIR)/%.res) $(BUILDDIR)/$(INDEX_NAME).res $(BUILDDIR)/pool.res
RES_FILES_SHORT = $(ALL_RES_SRC:%.txt=%.res) $(INDEX_NAME).res pool.res
PKGDATA_LIST = $(OUTTMPDIR)/icudata.lst

CURR_TREE=curr
CURR_INDEX_FILE=$(OUTTMPDIR)/$(CURR_TREE)/$(INDEX_NAME).txt
CURR_FILES = $(CURR_SRC:%.txt=$(CURRBLDDIR)/%.res) $(CURRBLDDIR)/$(INDEX_NAME).res $(CURRBLDDIR)/pool.res
CURR_FILES_SHORT = $(CURR_SRC:%.txt=$(CURR_TREE)/%.res) $(CURR_TREE)/$(INDEX_NAME).res $(CURR_TREE)/pool.res

LANG_TREE=lang
LANG_INDEX_FILE=$(OUTTMPDIR)/$(LANG_TREE)/$(INDEX_NAME).txt
LANG_FILES = $(LANG_SRC:%.txt=$(LANGBLDDIR)/%.res) $(LANGBLDDIR)/$(INDEX_NAME).res $(LANGBLDDIR)/pool.res
LANG_FILES_SHORT = $(LANG_SRC:%.txt=$(LANG_TREE)/%.res) $(LANG_TREE)/$(INDEX_NAME).res $(LANG_TREE)/pool.res

REGION_TREE=region
REGION_INDEX_FILE=$(OUTTMPDIR)/$(REGION_TREE)/$(INDEX_NAME).txt
REGION_FILES = $(REGION_SRC:%.txt=$(REGIONBLDDIR)/%.res) $(REGIONBLDDIR)/$(INDEX_NAME).res $(REGIONBLDDIR)/pool.res
REGION_FILES_SHORT = $(REGION_SRC:%.txt=$(REGION_TREE)/%.res) $(REGION_TREE)/$(INDEX_NAME).res $(REGION_TREE)/pool.res

ZONE_TREE=zone
ZONE_INDEX_FILE=$(OUTTMPDIR)/$(ZONE_TREE)/$(INDEX_NAME).txt
ZONE_FILES = $(ZONE_SRC:%.txt=$(ZONEBLDDIR)/%.res) $(ZONEBLDDIR)/$(INDEX_NAME).res $(ZONEBLDDIR)/pool.res
ZONE_FILES_SHORT = $(ZONE_SRC:%.txt=$(ZONE_TREE)/%.res) $(ZONE_TREE)/$(INDEX_NAME).res $(ZONE_TREE)/pool.res

UNIT_TREE=unit
UNIT_INDEX_FILE=$(OUTTMPDIR)/$(UNIT_TREE)/$(INDEX_NAME).txt
UNIT_FILES = $(UNIT_SRC:%.txt=$(UNITBLDDIR)/%.res) $(UNITBLDDIR)/$(INDEX_NAME).res $(UNITBLDDIR)/pool.res
UNIT_FILES_SHORT = $(UNIT_SRC:%.txt=$(UNIT_TREE)/%.res) $(UNIT_TREE)/$(INDEX_NAME).res $(UNIT_TREE)/pool.res

COLLATION_TREE=coll
COLLATION_INDEX_FILE=$(OUTTMPDIR)/$(COLLATION_TREE)/$(INDEX_NAME).txt
COLLATION_INDEX_RES=$(COLBLDDIR)/$(INDEX_NAME).res
COLLATION_INDEX_RES_SHORT=$(COLLATION_TREE)/$(INDEX_NAME).res
COLLATION_FILES = $(COL_SRC:%.txt=$(COLBLDDIR)/%.res) $(COLLATION_INDEX_RES)
COLLATION_FILES_SHORT = $(COL_SRC:%.txt=$(COLLATION_TREE)/%.res)

BRK_RES_INDEX_FILE=$(OUTTMPDIR)/$(BREAK_TREE)/$(INDEX_NAME).txt
BRK_RES_INDEX_RES=$(BRKBLDDIR)/$(INDEX_NAME).res
BRK_RES_INDEX_RES_SHORT=$(BREAK_TREE)/$(INDEX_NAME).res
BRK_RES_FILES = $(BRS_SRC:%.txt=$(BRKBLDDIR)/%.res) $(BRK_RES_INDEX_RES)
BRK_RES_FILES_SHORT = $(BRS_SRC:%.txt=$(BREAK_TREE)/%.res)

RBNF_TREE=rbnf
RBNF_INDEX_FILE=$(OUTTMPDIR)/$(RBNF_TREE)/$(INDEX_NAME).txt
RBNF_INDEX_RES=$(RBNFBLDDIR)/$(INDEX_NAME).res
RBNF_INDEX_RES_SHORT=$(RBNF_TREE)/$(INDEX_NAME).res
RBNF_FILES = $(RBNF_SRC:%.txt=$(RBNFBLDDIR)/%.res) $(RBNF_INDEX_RES)
RBNF_FILES_SHORT = $(RBNF_SRC:%.txt=$(RBNF_TREE)/%.res)

TRANSLIT_TREE=translit
#TRANSLIT_INDEX_FILE=$(OUTTMPDIR)/$(TRANSLIT_TREE)/$(INDEX_NAME).txt
#TRANSLIT_INDEX_RES=$(TRANSLITBLDDIR)/$(INDEX_NAME).res
#TRANSLIT_INDEX_RES_SHORT=$(TRANSLIT_TREE)/$(INDEX_NAME).res
TRANSLIT_FILES = $(TRANSLIT_SRC:%.txt=$(TRANSLITBLDDIR)/%.res)
TRANSLIT_FILES_SHORT = $(TRANSLIT_SRC:%.txt=$(TRANSLIT_TREE)/%.res)

## SPP files
-include $(SPREPSRCDIR)/sprepfiles.mk
-include $(SPREPSRCDIR)/spreplocal.mk
ALL_SPREP_SOURCE=$(SPREP_SOURCE) $(SPREP_SOURCE_LOCAL)
SPREP_FILES = $(ALL_SPREP_SOURCE:%.txt=$(BUILDDIR)/%.spp)
SPREP_FILES_SHORT = $(ALL_SPREP_SOURCE:%.txt=%.spp)

## All generated files
ALL_FILES = $(DAT_FILES) $(CNV_FILES) $(CNV_FILES_SPECIAL) $(BRK_FILES) $(DICT_FILES) $(RES_FILES) $(INDEX_RES_FILE) $(CURR_FILES) $(LANG_FILES) $(REGION_FILES) $(ZONE_FILES) $(UNIT_FILES) $(COLLATION_FILES) $(BRK_RES_FILES) $(RBNF_FILES) $(TRANSLIT_FILES) $(SPREP_FILES) $(CFU_FILES)
ALL_INDEX_SRC_FILES = $(PKGDATA_LIST) $(INDEX_FILE) $(CURR_INDEX_FILE) $(LANG_INDEX_FILE) $(REGION_INDEX_FILE) $(ZONE_INDEX_FILE) $(UNIT_INDEX_FILE) $(COLLATION_INDEX_FILE) $(BRK_RES_INDEX_FILE) $(RBNF_INDEX_FILE)
# a list to use in the .lst files (package-relative)
COLL_FILES_LIST=$(COLLATION_FILES_SHORT) $(COLLATION_INDEX_RES_SHORT)
BRK_FILES_LIST=$(BRK_FILES_SHORT) $(BRK_RES_FILES_SHORT) $(BRK_RES_INDEX_RES_SHORT) $(DICT_FILES_SHORT)
LOCALE_FILES_LIST= $(RES_FILES_SHORT) $(LANG_FILES_SHORT) $(REGION_FILES_SHORT) $(ZONE_FILES_SHORT) $(UNIT_FILES_SHORT)
MISC_FILES_LIST=$(DAT_FILES_SHORT) $(CNV_FILES_SHORT) $(CNV_FILES_SHORT_SPECIAL) $(CURR_FILES_SHORT) $(RBNF_FILES_SHORT) $(RBNF_INDEX_RES_SHORT) $(TRANSLIT_FILES_SHORT) $(SPREP_FILES_SHORT) $(CFU_FILES_SHORT)
UNI_CORE_DATA=pnames.icu uprops.icu ucase.icu ubidi.icu nfc.nrm
UNI_CORE_TARGET_DATA=$(UNI_CORE_DATA:%=$(BUILDDIR)/%)

ifneq ($(INCLUDE_UNI_CORE_DATA),)
MISC_FILES_LIST+=$(UNI_CORE_DATA)
build-local: uni-core-data
	echo timestamp > $@
endif

#####################################################
# General data build rules

## Files to remove for 'make clean'
CLEANFILES = *~ icupkg.inc *.x

ifeq ($(ICUDATA_SOURCE_ARCHIVE),)
build-local: build-dir $(SO_VERSION_DATA) $(ALL_FILES) $(PKGDATA_LIST) $(OS390LIST)
	echo timestamp > $@
$(PKGDATA_LIST): $(SRCLISTDEPS)
	@echo "generating $@ (list of data files)"
	@-$(RMV) $@
	@for file in $(COLL_FILES_LIST); do \
	  echo $$file >> $@; \
	done;
	@for file in $(BRK_FILES_LIST); do \
	  echo $$file >> $@; \
	done;
	@for file in $(LOCALE_FILES_LIST); do \
	  echo $$file >> $@; \
	done;
	@for file in $(MISC_FILES_LIST); do \
	  echo $$file >> $@; \
	done;
else
build-local: build-dir $(SO_VERSION_DATA) $(PKGDATA_LIST) $(OS390LIST)
	echo timestamp > $@
$(PKGDATA_LIST): $(SRCLISTDEPS) $(ICUDATA_SOURCE_ARCHIVE)
ifneq ($(ICUDATA_SOURCE_IS_NATIVE_TARGET),YES)
	@echo "Unpacking $(ICUDATA_SOURCE_ARCHIVE) and generating $@ (list of data files)"
	@-$(RMV) $@
	$(INVOKE) $(TOOLBINDIR)/icupkg -d $(BUILDDIR) --list -x \* $(ICUDATA_SOURCE_ARCHIVE) -o $@
else
	@echo "$@" > $@
endif
endif


$(BUILD_DIRS): build-dir

build-dir:
	@-$(RMV) $@
	echo timestamp > $@.tmp
	@list='$(BUILD_DIRS)'; \
	for dir in $$list; do \
	  if ! test -d $$dir; then \
	    echo $(MKINSTALLDIRS) $(BUILD_DIRS); \
	    $(MKINSTALLDIRS) $(BUILD_DIRS); \
	  fi; \
	done
	mv $@.tmp $@

# The | is an order-only prerequisite. This helps when the -j option is used,
# and we don't want the files to be built before the directories are built.
ifneq ($(filter order-only,$(.FEATURES)),)
$(ALL_FILES) $(ALL_INDEX_SRC_FILES): | build-dir
endif

# Now, sections for building each kind of data.

####################################################    DAT
# DAT FILES

# cnvalias.icu
$(BUILDDIR)/cnvalias.icu: $(UCMSRCDIR)/convrtrs.txt $(TOOLBINDIR)/gencnval$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/gencnval -d $(BUILDDIR) $(UCMSRCDIR)/convrtrs.txt

# Targets for prebuilt Unicode data
$(BUILDDIR)/%.icu: $(SRCDATADIR)/in/%.icu
	$(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $< $@

$(BUILDDIR)/%.nrm: $(SRCDATADIR)/in/%.nrm
	$(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $< $@

$(BUILDDIR)/coll/ucadata.icu: $(SRCDATADIR)/in/coll/ucadata-unihan.icu
	$(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $< $@

####################################################    SPP
# SPP FILES

$(BUILDDIR)/%.spp: $(SPREPSRCDIR)/%.txt $(TOOLBINDIR)/gensprep$(TOOLEXEEXT) $(BUILDDIR)/unames.icu
	$(INVOKE) $(TOOLBINDIR)/gensprep -d $(BUILDDIR) -i $(BUILDDIR) -s $(SPREPSRCDIR) -b $(@F:%.spp=%) -m $(UNICODEDATADIR) -u 3.2.0 $(<F)

####################################################    BRK
# BRK FILES

$(BRKBLDDIR)/%.brk: $(BRKRULESRCDIR)/%.txt $(TOOLBINDIR)/genbrk$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genbrk -c -i $(BUILDDIR) -r $< -o $@

####################################################    DICT
# DICT FILES

# .dict file generated regardless of whether dictionary file exists

$(BRKBLDDIR)/%.dict: $(TOOLBINDIR)/gendict$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/gendict --uchars -c -i $(BUILDDIR) $(DICTSRCDIR)/$(*F).txt $@

$(BRKBLDDIR)/thaidict.dict: $(TOOLBINDIR)/gendict$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/gendict --bytes --transform offset-0x0e00 -c -i $(BUILDDIR) $(DICTSRCDIR)/thaidict.txt $(BRKBLDDIR)/thaidict.dict

$(BRKBLDDIR)/laodict.dict: $(TOOLBINDIR)/gendict$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/gendict --bytes --transform offset-0x0e80 -c -i $(BUILDDIR) $(DICTSRCDIR)/laodict.txt $(BRKBLDDIR)/laodict.dict

$(BRKBLDDIR)/burmesedict.dict: $(TOOLBINDIR)/gendict$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/gendict --bytes --transform offset-0x1000 -c -i $(BUILDDIR) $(DICTSRCDIR)/burmesedict.txt $(BRKBLDDIR)/burmesedict.dict

# TODO: figure out why combining characters are here?
$(BRKBLDDIR)/khmerdict.dict: $(TOOLBINDIR)/gendict$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/gendict --bytes --transform offset-0x1780 -c -i $(BUILDDIR) $(DICTSRCDIR)/khmerdict.txt $(BRKBLDDIR)/khmerdict.dict

####################################################    CFU
# CFU FILES
#    Note: gencfu requires two input files to produce a single output file.
#          There will be exactly one target file and two source files.
#          The $(word n, ...) selects the nth word from the following stuff.
#          There must be a nicer way to do this.

$(CFU_FILES): $(ALL_CFU_SOURCE) $(TOOLBINDIR)/gencfu$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) echo ALL_CFU_SOURCE: $(ALL_CFU_SOURCE)
	$(INVOKE) echo CFU_FILES: $(CFU_FILES)
	$(INVOKE) echo CFU_FILES_SHORT: $(CFU_FILES_SHORT)
	$(INVOKE) $(TOOLBINDIR)/gencfu -c -i $(BUILDDIR) -r $(word 1,$(ALL_CFU_SOURCE)) -w $(word 2,$(ALL_CFU_SOURCE)) -o $@


####################################################    CNV
# CNV FILES
$(CNV_FILES_SPECIAL) : $(UCM_FILES_SPECIAL) $(TOOLBINDIR)/makeconv$(TOOLEXEEXT) 
	$(INVOKE) $(TOOLBINDIR)/makeconv --ignore-siso-check -c -d $(BUILDDIR) $(UCMSRCDIR)/$(@F:%.cnv=%.ucm) 
$(BUILDDIR)/%.cnv: $(UCMSRCDIR)/%.ucm $(TOOLBINDIR)/makeconv$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/makeconv -c -d $(BUILDDIR) $(UCMSRCDIR)/$(<F)

####################################################    RES
# RES FILES

### curr res
$(CURRBLDDIR)/%.res: $(CURRSRCDIR)/%.txt  $(TOOLBINDIR)/genrb$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genrb --usePoolBundle $(GENRBOPTS) -i $(BUILDDIR) -s $(CURRSRCDIR) -d $(CURRBLDDIR) $(<F)

# copy the curr/pool.res file from the source folder to the build output folder
# and swap it to native endianness
$(CURRBLDDIR)/pool.res: $(CURRSRCDIR)/pool.res
	$(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $(CURRSRCDIR)/pool.res $(CURRBLDDIR)/pool.res

$(CURRBLDDIR)/$(INDEX_NAME).res: $(OUTTMPDIR)/$(CURR_TREE)/$(INDEX_NAME).txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(OUTTMPDIR)/$(CURR_TREE) -d $(CURRBLDDIR) $(INDEX_NAME).txt

$(CURR_INDEX_FILE): $(SRCLISTDEPS)
	@echo "generating $@ (list of installed currency name locales)"; \
	$(RMV) $@; \
	echo "// Warning this file is automatically generated" > $@; \
	echo "$(INDEX_NAME):table(nofallback) {" >> $@; \
	echo "    InstalledLocales {" >> $@; \
	for file in $(INSTALLED_CURR_FILES); do \
	  echo "        $$file {\"\"}" >> $@; \
	done; \
	echo "    }" >> $@; \
	echo "}" >> $@;

### lang res
$(LANGBLDDIR)/%.res: $(LANGSRCDIR)/%.txt  $(TOOLBINDIR)/genrb$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genrb --usePoolBundle $(GENRBOPTS) -i $(BUILDDIR) -s $(LANGSRCDIR) -d $(LANGBLDDIR) $(<F)

# copy the lang/pool.res file from the source folder to the build output folder
# and swap it to native endianness
$(LANGBLDDIR)/pool.res: $(LANGSRCDIR)/pool.res
	$(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $(LANGSRCDIR)/pool.res $(LANGBLDDIR)/pool.res

$(LANGBLDDIR)/$(INDEX_NAME).res: $(OUTTMPDIR)/$(LANG_TREE)/$(INDEX_NAME).txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(OUTTMPDIR)/$(LANG_TREE) -d $(LANGBLDDIR) $(INDEX_NAME).txt

$(LANG_INDEX_FILE): $(SRCLISTDEPS)
	@echo "generating $@ (list of installed language name locales)"; \
	$(RMV) $@; \
	echo "// Warning this file is automatically generated" > $@; \
	echo "$(INDEX_NAME):table(nofallback) {" >> $@; \
	echo "    InstalledLocales {" >> $@; \
	for file in $(INSTALLED_LANG_FILES); do \
	  echo "        $$file {\"\"}" >> $@; \
	done; \
	echo "    }" >> $@; \
	echo "}" >> $@;

### region res
$(REGIONBLDDIR)/%.res: $(REGIONSRCDIR)/%.txt  $(TOOLBINDIR)/genrb$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genrb --usePoolBundle $(GENRBOPTS) -i $(BUILDDIR) -s $(REGIONSRCDIR) -d $(REGIONBLDDIR) $(<F)

# copy the region/pool.res file from the source folder to the build output folder
# and swap it to native endianness
$(REGIONBLDDIR)/pool.res: $(REGIONSRCDIR)/pool.res
	$(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $(REGIONSRCDIR)/pool.res $(REGIONBLDDIR)/pool.res

$(REGIONBLDDIR)/$(INDEX_NAME).res: $(OUTTMPDIR)/$(REGION_TREE)/$(INDEX_NAME).txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(OUTTMPDIR)/$(REGION_TREE) -d $(REGIONBLDDIR) $(INDEX_NAME).txt

$(REGION_INDEX_FILE): $(SRCLISTDEPS)
	@echo "generating $@ (list of installed region name locales)"; \
	$(RMV) $@; \
	echo "// Warning this file is automatically generated" > $@; \
	echo "$(INDEX_NAME):table(nofallback) {" >> $@; \
	echo "    InstalledLocales {" >> $@; \
	for file in $(INSTALLED_REGION_FILES); do \
	  echo "        $$file {\"\"}" >> $@; \
	done; \
	echo "    }" >> $@; \
	echo "}" >> $@;

### zone res
$(ZONEBLDDIR)/%.res: $(ZONESRCDIR)/%.txt  $(TOOLBINDIR)/genrb$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genrb --usePoolBundle $(GENRBOPTS) -i $(BUILDDIR) -s $(ZONESRCDIR) -d $(ZONEBLDDIR) $(<F)

# copy the zone/pool.res file from the source folder to the build output folder
# and swap it to native endianness
$(ZONEBLDDIR)/pool.res: $(ZONESRCDIR)/pool.res
	$(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $(ZONESRCDIR)/pool.res $(ZONEBLDDIR)/pool.res

$(ZONEBLDDIR)/$(INDEX_NAME).res: $(OUTTMPDIR)/$(ZONE_TREE)/$(INDEX_NAME).txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(OUTTMPDIR)/$(ZONE_TREE) -d $(ZONEBLDDIR) $(INDEX_NAME).txt

$(ZONE_INDEX_FILE): $(SRCLISTDEPS)
	@echo "generating $@ (list of installed time zone name locales)"; \
	$(RMV) $@; \
	echo "// Warning this file is automatically generated" > $@; \
	echo "$(INDEX_NAME):table(nofallback) {" >> $@; \
	echo "    InstalledLocales {" >> $@; \
	for file in $(INSTALLED_ZONE_FILES); do \
	  echo "        $$file {\"\"}" >> $@; \
	done; \
	echo "    }" >> $@; \
	echo "}" >> $@;

### unit res
$(UNITBLDDIR)/%.res: $(UNITSRCDIR)/%.txt  $(TOOLBINDIR)/genrb$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genrb --usePoolBundle $(GENRBOPTS) -i $(BUILDDIR) -s $(UNITSRCDIR) -d $(UNITBLDDIR) $(<F)

# copy the unit/pool.res file from the source folder to the build output folder
# and swap it to native endianness
$(UNITBLDDIR)/pool.res: $(UNITSRCDIR)/pool.res
	$(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $(UNITSRCDIR)/pool.res $(UNITBLDDIR)/pool.res

$(UNITBLDDIR)/$(INDEX_NAME).res: $(OUTTMPDIR)/$(UNIT_TREE)/$(INDEX_NAME).txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(OUTTMPDIR)/$(UNIT_TREE) -d $(UNITBLDDIR) $(INDEX_NAME).txt

$(UNIT_INDEX_FILE): $(SRCLISTDEPS)
	@echo "generating $@ (list of installed time zone name locales)"; \
	$(RMV) $@; \
	echo "// Warning this file is automatically generated" > $@; \
	echo "$(INDEX_NAME):table(nofallback) {" >> $@; \
	echo "    InstalledLocales {" >> $@; \
	for file in $(INSTALLED_UNIT_FILES); do \
	  echo "        $$file {\"\"}" >> $@; \
	done; \
	echo "    }" >> $@; \
	echo "}" >> $@;

### collation res
$(COLBLDDIR)/%.res: $(COLSRCDIR)/%.txt  $(TOOLBINDIR)/genrb$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(COLSRCDIR) -d $(COLBLDDIR) $(<F)

$(COLBLDDIR)/$(INDEX_NAME).res: $(OUTTMPDIR)/$(COLLATION_TREE)/$(INDEX_NAME).txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(OUTTMPDIR)/$(COLLATION_TREE) -d $(COLBLDDIR) $(INDEX_NAME).txt

$(COLLATION_INDEX_FILE): $(SRCLISTDEPS)
	@echo "generating $@ (list of installed collation locales)"; \
	$(RMV) $@; \
	echo "// Warning this file is automatically generated" > $@; \
	echo "$(INDEX_NAME):table(nofallback) {" >> $@; \
	echo "    InstalledLocales {" >> $@; \
	for file in $(INSTALLED_COL_FILES); do \
	  echo "        $$file {\"\"}" >> $@; \
	done; \
	echo "    }" >> $@; \
	echo "}" >> $@;

### brk res
$(BRKBLDDIR)/%.res: $(BRKSRCDIR)/%.txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT) $(BRK_FILES) $(DICT_FILES) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(BRKSRCDIR) -d $(BRKBLDDIR) $(<F)

$(BRKBLDDIR)/$(INDEX_NAME).res: $(OUTTMPDIR)/$(BREAK_TREE)/$(INDEX_NAME).txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(OUTTMPDIR)/$(BREAK_TREE) -d $(BRKBLDDIR) $(INDEX_NAME).txt

$(BRK_RES_INDEX_FILE): $(SRCLISTDEPS)
	@echo "generating $@ (list of installed break locales)"; \
	$(RMV) $@; \
	echo "// Warning this file is automatically generated" > $@; \
	echo "$(INDEX_NAME):table(nofallback) {" >> $@; \
	echo "    InstalledLocales {" >> $@; \
	for file in $(INSTALLED_BRS_FILES); do \
	  echo "        $$file {\"\"}" >> $@; \
	done; \
	echo "    }" >> $@; \
	echo "}" >> $@;

### RBNF res
$(RBNFBLDDIR)/%.res: $(RBNFSRCDIR)/%.txt  $(TOOLBINDIR)/genrb$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(RBNFSRCDIR) -d $(RBNFBLDDIR) $(<F)

$(RBNFBLDDIR)/$(INDEX_NAME).res: $(OUTTMPDIR)/$(RBNF_TREE)/$(INDEX_NAME).txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(OUTTMPDIR)/$(RBNF_TREE) -d $(RBNFBLDDIR) $(INDEX_NAME).txt

$(RBNF_INDEX_FILE): $(SRCLISTDEPS)
	@echo "generating $@ (list of installed RBNF locales)"; \
	$(RMV) $@; \
	echo "// Warning this file is automatically generated" > $@; \
	echo "$(INDEX_NAME):table(nofallback) {" >> $@; \
	echo "    InstalledLocales {" >> $@; \
	for file in $(INSTALLED_RBNF_FILES); do \
	  echo "        $$file {\"\"}" >> $@; \
	done; \
	echo "    }" >> $@; \
	echo "}" >> $@;

### TRANSLIT res
$(TRANSLITBLDDIR)/%.res: $(TRANSLITSRCDIR)/%.txt  $(TOOLBINDIR)/genrb$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(TRANSLITSRCDIR) -d $(TRANSLITBLDDIR) $(<F)

### normal (locale) res
all-RES:  $(RES_FILES)

$(BUILDDIR)/%.res: $(LOCSRCDIR)/%.txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT) $(DAT_FILES)
	$(INVOKE) $(TOOLBINDIR)/genrb --usePoolBundle $(GENRBOPTS) -i $(BUILDDIR) -s $(LOCSRCDIR) -d $(BUILDDIR) $(<F)

# copy the locales/pool.res file from the source folder to the build output folder
# and swap it to native endianness
$(BUILDDIR)/pool.res: $(LOCSRCDIR)/pool.res
	$(INVOKE) $(TOOLBINDIR)/icupkg -t$(ICUDATA_CHAR) $(LOCSRCDIR)/pool.res $(BUILDDIR)/pool.res

# if the tzcode directory contains a new tzdata*.tar.gz file, use it for zoneinfo
ifeq ($(TZDATA),)
TZDATA = $(firstword $(wildcard $(top_builddir)/tools/tzcode/tzdata*.tar.gz) $(wildcard $(top_srcdir)/tools/tzcode/tzdata*.tar.gz))
endif

ifneq ($(TZDATA),)

TZCODE_DIR=$(top_builddir)/tools/tzcode
ZONEINFO=$(TZCODE_DIR)/zoneinfo64.txt

# Override the normal genrb for zoneinfo to always pull from
# icu/source/tools/tzcode/zoneinfo64.txt
$(BUILDDIR)/zoneinfo64.res: $(ZONEINFO) $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	@echo Note: $(MISCSRCDIR)/zoneinfo.txt is IGNORED because $(TZDATA) is present.
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -q -i $(BUILDDIR) -d $(BUILDDIR) $(ZONEINFO)

# Create the tzcode tool and zoneinfo as needed.
$(ZONEINFO): $(TZDATA)
	@echo "$(MAKE)[$(MAKELEVEL)]: Making \`$(ZONEINFO)' in \`$(TZCODE_DIR)'"; \
	(cd $(TZCODE_DIR) && $(MAKE)) || exit; \

# end of zoneinfo-generation
endif

# zoneinfo has some issues. Ignore some warnings with -q
$(BUILDDIR)/%.res: $(MISCSRCDIR)/%.txt $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -q -i $(BUILDDIR) -s $(MISCSRCDIR) -d $(BUILDDIR) $(<F)



$(INDEX_FILE): $(SRCLISTDEPS)
	@echo "generating $@ (list of installed locales)"; \
	$(RMV) $@; \
	echo "// Warning this file is automatically generated" > $@; \
	echo "$(INDEX_NAME):table(nofallback) {" >> $@; \
        echo "    CLDRVersion { \"$(GENRB_CLDR_VERSION)\" }" >> $@; \
	echo "    InstalledLocales {" >> $@; \
	for file in $(INSTALLED_RB_FILES); do \
	  echo "        $$file {\"\"}" >> $@; \
	done; \
	echo "    }" >> $@; \
	echo "}" >> $@;

clean-resindex:
	-$(RMV) $(BUILDDIR)/$(INDEX_NAME).txt $(PKGDATA_LIST)

$(BUILDDIR)/$(INDEX_NAME).res: $(INDEX_FILE) $(TOOLBINDIR)/genrb$(TOOLEXEEXT)
	$(INVOKE) $(TOOLBINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -d $(BUILDDIR) $(INDEX_FILE)

# The core Unicode properties files (pnames.icu, uprops.icu, ucase.icu, ubidi.icu)
# are hardcoded in the common DLL and therefore not included in the data package any more.
# They are not built by default but need to be built for ICU4J data and for getting the .c source files
# when updating the Unicode data.
uni-core-data: build-dir $(UNI_CORE_TARGET_DATA)
	@echo Unicode .icu files built to $(BUILDDIR)
	echo timestamp > $@

# Build the ICU4J icudata.jar.
# Command line:
#   (Run this from the output data folder which may not be .../source/data in an out-of-source build.)
#   ~/svn.icu/trunk/source/data> make JAR=jar ICU4J_ROOT=~/svn.icu4j/trunk icudata.jar
# You can omit the ICU4J_ROOT for just building the .jar files without copying them.
# You can omit the JAR if it's just jar.
JAR=jar

# For building the testdata.jar see ../test/testdata/Makefile.

ICU4J_TZDATA=$(OUTDIR)/icu4j/icutzdata.jar
ICU4J_TZDATA_FILES=zoneinfo64 metaZones timezoneTypes windowsZones
ICU4J_DATA_DIRNAME=com/ibm/icu/impl/data/$(ICUDATA_BASENAME_VERSION)b
ICU4J_TZDATA_PATHS=$(ICU4J_TZDATA_FILES:%="$(ICU4J_DATA_DIRNAME)/%.res")

# generate icu4j-related data to $(OUTDIR)/icu4j/com/ibm/icu/impl/data/...
generate-data: build-dir packagedata $(OUTTMPDIR)/$(ICUDATA_PLATFORM_NAME).dat uni-core-data
	mkdir -p $(OUTDIR)/icu4j/$(ICU4J_DATA_DIRNAME)
	mkdir -p $(OUTDIR)/icu4j/tzdata/$(ICU4J_DATA_DIRNAME)
	echo $(UNI_CORE_DATA) > $(OUTDIR)/icu4j/add.txt
	$(INVOKE) $(TOOLBINDIR)/icupkg $(OUTTMPDIR)/$(ICUDATA_PLATFORM_NAME).dat $(OUTDIR)/icu4j/$(ICUDATA_BASENAME_VERSION)b.dat -a $(OUTDIR)/icu4j/add.txt -s $(BUILDDIR) -x '*' -tb -d $(OUTDIR)/icu4j/$(ICU4J_DATA_DIRNAME)
	mv $(ICU4J_TZDATA_PATHS:%=$(OUTDIR)/icu4j/%) "$(OUTDIR)/icu4j/tzdata/$(ICU4J_DATA_DIRNAME)"

$(OUTDIR)/icu4j/icutzdata.jar: generate-data
	$(JAR) cf $(OUTDIR)/icu4j/icutzdata.jar -C $(OUTDIR)/icu4j/tzdata $(ICU4J_DATA_DIRNAME)/

# Build icudata.jar:
# - add the uni-core-data to the ICU package
# - swap the ICU data
# - extract all data items
# - package them into the .jar file
$(OUTDIR)/icu4j/icudata.jar: generate-data
	$(JAR) cf $(OUTDIR)/icu4j/icudata.jar -C $(OUTDIR)/icu4j $(ICU4J_DATA_DIRNAME)/

ICU4J_DATA=$(OUTDIR)/icu4j/icudata.jar

ifdef ICU4J_ROOT

ICU4J_DATA_INSTALLED=$(ICU4J_ROOT)/main/shared/data/icudata.jar $(ICU4J_ROOT)/main/shared/data/icutzdata.jar

$(ICU4J_ROOT)/main/shared/data/icudata.jar: $(OUTDIR)/icu4j/icudata.jar
	mkdir -p $(ICU4J_ROOT)/main/shared/data
	cp $(OUTDIR)/icu4j/icudata.jar $(ICU4J_ROOT)/main/shared/data

$(ICU4J_ROOT)/main/shared/data/icutzdata.jar: $(OUTDIR)/icu4j/icutzdata.jar
	mkdir -p $(ICU4J_ROOT)/main/shared/data
	cp $(OUTDIR)/icu4j/icutzdata.jar $(ICU4J_ROOT)/main/shared/data

icu4j-data-install: $(ICU4J_DATA_INSTALLED)

else

icu4j-data-install: icu4j-data
	@echo data is built into $(OUTDIR)/icu4j
	@echo '** Error:' ICU4J_ROOT was not set, could not install
	exit 1

endif

icu4j-data: $(ICU4J_DATA) $(ICU4J_TZDATA)


###################################################################
Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
	cd $(top_builddir) \
	&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status

icupkg.inc: pkgdataMakefile
	$(MAKE) -f pkgdataMakefile

pkgdataMakefile:
	cd $(top_builddir) \
	&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status

###########
########### 390 (z/OS) support
UCMFILES390=ebcdic-xml-us.ucm ibm-37_P100-1995.ucm ibm-1047_P100-1995.ucm ibm-4909_P100-1999.ucm
# used to depend on pnames.icu uprops.icu ucase.icu ubidi.icu
# These are now hardcoded in ICU4C and only loaded in ICU4J.
ALLFILES390=cnvalias.icu $(UCMFILES390:.ucm=.cnv)

$(OUTTMPDIR)/icudata390.lst: $(SRCLISTDEPS)
	@echo "generating $@ (list of 390 data files)"
	@-$(RMV) $@
	@for file in $(ALLFILES390); do \
	  echo $$file >> $@; \
	done;

ifeq ($(POST_DATA_BUILD), os400-data-rebind)
os400-data-rebind: $(LIBICUUC)

$(LIBICUUC): $(LIBICUDT)
	$(RMV) $(LIBICUUC)
	(cd ../common && $(MAKE) RECURSIVE=YES) || exit;
endif