]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/data/Makefile.in
ICU-64252.0.1.tar.gz
[apple/icu.git] / icuSources / data / Makefile.in
index 461e37d814a107fef43be90b3c2a105e3d642328..778b6c7affa28916cd366854fc44f46b8343733d 100644 (file)
@@ -1,5 +1,7 @@
 ## Makefile.in for ICU data
 ## Makefile.in for ICU data
-## Copyright (c) 1999-2004, International Business Machines Corporation and
+## 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
 ## others. All Rights Reserved.
 
 ## Source directory information
@@ -32,13 +34,37 @@ endif
 ifeq ($(PKGDATA_MODE),dll)
 ICUPKGDATA_OUTDIR = $(LIBDIR)
 else
 ifeq ($(PKGDATA_MODE),dll)
 ICUPKGDATA_OUTDIR = $(LIBDIR)
 else
+ifeq ($(PKGDATA_MODE),static)
+ICUPKGDATA_OUTDIR = $(LIBDIR)
+else
 ICUPKGDATA_OUTDIR = $(OUTDIR)
 endif
 ICUPKGDATA_OUTDIR = $(OUTDIR)
 endif
+endif
 
 
-top_builddir_from_tmp = $(patsubst ..%,../..%,$(top_builddir))
 CURDIR:=$(CURR_FULL_DIR)
 CURDIR:=$(CURR_FULL_DIR)
-PKGDATA = $(BINDIR)/pkgdata $(PKGDATA_OPTS) -q -c -s $(CURDIR)/out/build/$(ICUDATA_PLATFORM_NAME) -d $(ICUPKGDATA_OUTDIR)
+# 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.
 
 
 # OBJDATADIR must be a short path (with ..'s) to the data.
 
@@ -54,22 +80,14 @@ OUTDIR=$(top_builddir)/data/out
 endif
 
 OUTTMPDIR=$(OUTDIR)/tmp
 endif
 
 OUTTMPDIR=$(OUTDIR)/tmp
-BUILDDIR=$(OUTDIR)/build/$(ICUDATA_PLATFORM_NAME)
-UNICODEDATADIR=$(SRCDATADIR)/unidata
-LOCSRCDIR=$(SRCDATADIR)/locales
-COLSRCDIR=$(SRCDATADIR)/coll
-COLBLDDIR=$(BUILDDIR)/coll
-RBNFSRCDIR=$(SRCDATADIR)/rbnf
-RBNFBLDDIR=$(BUILDDIR)/rbnf
-TRANSLITSRCDIR=$(SRCDATADIR)/translit
-TRANSLITBLDDIR=$(BUILDDIR)/translit
-MISCSRCDIR=$(SRCDATADIR)/misc
-BRKSRCDIR=$(SRCDATADIR)/brkitr
+MAINBUILDDIR=$(OUTDIR)/build
+BUILDDIR=$(MAINBUILDDIR)/$(ICUDATA_PLATFORM_NAME)
 MISCSRCDIR=$(SRCDATADIR)/misc
 MISCSRCDIR=$(SRCDATADIR)/misc
-UCMSRCDIR=$(SRCDATADIR)/mappings
-COMINCDIR=$(top_srcdir)/common/unicode
 SRCLISTDEPS=Makefile $(srcdir)/Makefile.in
 SRCLISTDEPS=Makefile $(srcdir)/Makefile.in
-BUILD_DIRS=$(OUTDIR) $(BUILDDIR) $(COLBLDDIR) $(RBNFBLDDIR) $(TRANSLITBLDDIR) $(TESTOUTDIR) $(TESTBUILDDIR) $(OUTTMPDIR) $(OUTTMPDIR_390STUB) $(OUTTMPDIR)/$(COLLATION_TREE) $(OUTTMPDIR)/$(RBNF_TREE) $(OUTTMPDIR)/$(TRANSLIT_TREE)
+
+# Variable names for rules.mk
+OUT_DIR=$(BUILDDIR)
+TMP_DIR=$(OUTTMPDIR)
 
 # relative lib links from pkgdata are the same as for tmp
 TOOLDIR=$(top_builddir)/tools
 
 # relative lib links from pkgdata are the same as for tmp
 TOOLDIR=$(top_builddir)/tools
@@ -78,7 +96,8 @@ TOOLDIR=$(top_builddir)/tools
 .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     \
 .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 build-local clean-resindex build-dir
+check check-local check-recursive clean-resindex icudata.jar   \
+check-exhaustive
 
 ## Clear suffix list
 .SUFFIXES :
 
 ## Clear suffix list
 .SUFFIXES :
@@ -89,22 +108,17 @@ install: all-local install-local
 clean: clean-local
 distclean : distclean-local
 dist: 
 clean: clean-local
 distclean : distclean-local
 dist: 
-check: all
+check: all check-local
 
 
+check-exhaustive: check
 
 
-distclean-local: clean
-       $(RMV) Makefile
+-include Makefile.local
 
 
-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
+distclean-local: clean
+       $(RMV) Makefile
 
 
-all-local: build-dir icupkg.inc build-local packagedata $(POST_DATA_BUILD) $(OS390PKG)
+all-local: icupkg.inc build-local packagedata $(POST_DATA_BUILD) $(OS390PKG)
 
 dist-local:
 
 
 dist-local:
 
@@ -112,33 +126,79 @@ clean-map:
        -test -z *.map || $(RMV) *.map
 
 clean-local: cleanpackage cleanfiles clean-map
        -test -z *.map || $(RMV) *.map
 
 clean-local: cleanpackage cleanfiles clean-map
+       $(RMV) $(OUTDIR) build-local packagedata uni-core-data
 
 cleanfiles:
        test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
 
 cleanpackage:
        $(RMV) $(OUTDIR)
 
 cleanfiles:
        test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
 
 cleanpackage:
        $(RMV) $(OUTDIR)
-       $(RMV) $(LIBDIR)/$(LIB_ICUDATA_NAME)*.$(SO)* $(LIBDIR)/$(LIB_STATIC_ICUDATA_NAME).$(A)
+       $(RMV) $(LIBDIR)/*$(LIB_ICUDATA_NAME)*.$(SO)* $(LIBDIR)/$(LIB_STATIC_ICUDATA_NAME).$(A)
 
 check-local:
 
 check-local:
+       PYTHONPATH=$(srcdir) @PYTHON@ -m buildtool.test
+
+# 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
 
 
-# During this INVOKE we only want to use stubdata.
-# We don't want to try to write over files that we are using.
-PKGDATA_INVOKE:=$(subst $(LIBDIR):$(top_builddir)/stubdata,$(top_builddir)/stubdata:$(LIBDIR),$(INVOKE)) $(PKGDATA_INVOKE_OPTS)
-
-packagedata: icupkg.inc $(OUTTMPDIR)/icudata.lst build-local
+packagedata: icupkg.inc $(PKGDATA_LIST) build-local
 ifneq ($(ENABLE_STATIC),)
 ifneq ($(ENABLE_STATIC),)
-       $(PKGDATA_INVOKE) $(PKGDATA) -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -p $(ICUDATA_NAME) $(PKGDATA_LIBSTATICNAME) -m static $(OUTTMPDIR)/icudata.lst
+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
 endif
-       $(PKGDATA_INVOKE) $(PKGDATA) -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -p $(ICUDATA_NAME) -m $(PKGDATA_MODE) $(PKGDATA_VERSIONING) $(PKGDATA_LIBNAME) $(OUTTMPDIR)/icudata.lst
+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 ICU data.
-install-local: $(OUTTMPDIR)/icudata.lst ./icupkg.inc packagedata $(OS390INSTALL)
+install-local: $(PKGDATA_LIST) ./icupkg.inc packagedata $(OS390INSTALL)
        $(MKINSTALLDIRS) $(TMPDATADIR) $(DESTDIR)$(ICUPKGDATA_DIR)
        $(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),)
 ifneq ($(ENABLE_STATIC),)
-       $(PKGDATA_INVOKE) $(PKGDATA) -m static -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -s $(BUILDDIR) -p $(ICUDATA_NAME) $(PKGDATA_LIBSTATICNAME) $(OUTTMPDIR)/icudata.lst -I $(ICUPKGDATA_INSTALL_LIBDIR)
+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
 endif
-       $(PKGDATA_INVOKE) $(PKGDATA) -m $(PKGDATA_MODE) $(PKGDATA_VERSIONING) -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -s $(BUILDDIR) -p $(ICUDATA_NAME) $(PKGDATA_LIBNAME) $(OUTTMPDIR)/icudata.lst -I $(ICUPKGDATA_INSTALL_DIR)
 
 
 ####
 
 
 ####
@@ -148,271 +208,166 @@ 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)
        $(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)/$(LIB_ICUDATA_NAME)$(STUB_SUFFIX)$(SO_TARGET_VERSION)$(IMPORT_LIB_EXT) $(DESTDIR)$(ICUPKGDATA_DIR)/$(LIB_ICUDATA_NAME)$(STUB_SUFFIX)$(SO_TARGET_VERSION)$(IMPORT_LIB_EXT)
+       $(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
 endif
 
 #### $(LIB_ICUDATA_NAME)$(STUB_SUFFIX) is the subset data for batch mode
-package390: $(OUTTMPDIR)/icudata390.lst $(OUTTMPDIR)/icudata.lst ./icupkg.inc packagedata
+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)
 
 
        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.
-DAT_FILES_SHORT=uprops.icu ucase.icu pnames.icu unames.icu unorm.icu cnvalias.icu ucadata.icu invuca.icu uidna.spp 
-DAT_FILES=$(DAT_FILES_SHORT:%=$(BUILDDIR)/%)
-
-## BRK files
--include $(BRKSRCDIR)/brkfiles.mk
--include $(BRKSRCDIR)/brklocal.mk
-ALL_BRK_SOURCE=char.txt title.txt word.txt $(BRK_SOURCE) $(BRK_SOURCE_LOCAL)
-BRK_FILES_SHORT=$(ALL_BRK_SOURCE:%.txt=%.brk)
-BRK_FILES=$(BRK_FILES_SHORT:%=$(BUILDDIR)/%)
-
-## 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)
-
-## RES files
--include $(LOCSRCDIR)/resfiles.mk
--include $(COLSRCDIR)/colfiles.mk
--include $(RBNFSRCDIR)/rbnffiles.mk
--include $(TRANSLITSRCDIR)/trnsfiles.mk
--include $(LOCSRCDIR)/reslocal.mk
--include $(COLSRCDIR)/collocal.mk
--include $(RBNFSRCDIR)/rbnflocal.mk
--include $(TRANSLITSRCDIR)/translocal.mk
-RES_SRC= root.txt $(GENRB_SOURCE) $(GENRB_ALIAS_SOURCE) $(GENRB_SOURCE_LOCAL)
-RES_SRC_FILES = $(RES_SRC:%=$(LOCSRCDIR)/%)
-INSTALLED_RB_FILES = $(GENRB_SOURCE:%.txt=%) $(GENRB_SOURCE_LOCAL:%.txt=%)
-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=%)
-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=%)
-INSTALLED_TRANSLIT_FILES = $(TRANSLIT_SOURCE:%.txt=%)  $(TRANSLIT_SOURCE_LOCAL:%.txt=%)
-TRANSLIT_SRC= root.txt $(TRANSLIT_SOURCE) $(TRANSLIT_ALIAS_SOURCE) $(TRANSLIT_SOURCE_LOCAL)
-TRANSLIT_SRC_FILES = $(TRANSLIT_SRC:%=$(TRANSLITSRCDIR)/%)
-INSTALLED_TRANSLIT_FILES = $(TRANSLIT_SOURCE:%.txt=%)  $(TRANSLIT_SOURCE_LOCAL:%.txt=%)
-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)/%)
+## Include the main build rules for data files
+include $(top_builddir)/$(subdir)/rules.mk
+
 
 ifeq ($(ENABLE_SO_VERSION_DATA),1)
 ifeq ($(PKGDATA_MODE),dll)
 SO_VERSION_DATA = $(OUTTMPDIR)/icudata.res
 $(SO_VERSION_DATA) : $(MISCSRCDIR)/icudata.rc
 
 ifeq ($(ENABLE_SO_VERSION_DATA),1)
 ifeq ($(PKGDATA_MODE),dll)
 SO_VERSION_DATA = $(OUTTMPDIR)/icudata.res
 $(SO_VERSION_DATA) : $(MISCSRCDIR)/icudata.rc
-       rc.exe /i$(srcdir)/../common /fo$@ $(SOURCE_FILE)
+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
 
 endif
 endif
 
-ALL_RES_SRC= $(RES_SRC) $(TRNS_SOURCE) $(MSC_SOURCE)
-RES_FILES = $(ALL_RES_SRC:%.txt=$(BUILDDIR)/%.res)
-RES_FILES_SHORT = $(ALL_RES_SRC:%.txt=%.res)
-
-INDEX_NAME=res_index
-INDEX_FILE=$(OUTTMPDIR)/$(INDEX_NAME).txt
-INDEX_RES_FILE=$(INDEX_FILE:$(OUTTMPDIR)/%.txt=$(BUILDDIR)/%.res)
-INDEX_RES_FILE_SHORT=$(INDEX_FILE:$(OUTTMPDIR)/%.txt=%.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)
-
-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)
-
-## All generated files
-ALL_FILES = $(DAT_FILES) $(CNV_FILES) $(BRK_FILES) $(RES_FILES) $(INDEX_RES_FILE) $(COLLATION_FILES) $(RBNF_FILES) $(TRANSLIT_FILES)
-# a list to use in the .lst files (package-relative)
-ALL_FILES_LIST = $(DAT_FILES_SHORT) $(CNV_FILES_SHORT) $(BRK_FILES_SHORT) $(RES_FILES_SHORT) $(INDEX_RES_FILE_SHORT) $(COLLATION_FILES_SHORT) $(COLLATION_INDEX_RES_SHORT) $(RBNF_FILES_SHORT) $(RBNF_INDEX_RES_SHORT) $(TRANSLIT_FILES_SHORT)
+PKGDATA_LIST = $(TMP_DIR)/icudata.lst
+
 
 #####################################################
 # General data build rules
 
 ## Files to remove for 'make clean'
 
 #####################################################
 # General data build rules
 
 ## Files to remove for 'make clean'
-CLEANFILES = *~ icupkg.inc
+CLEANFILES = *~ icupkg.inc *.x
 
 
-$(OUTTMPDIR)/icudata.lst: $(SRCLISTDEPS)
-       @echo "generating $@ (list of data files)"
+ifeq ($(ICUDATA_SOURCE_ARCHIVE),)
+build-local: $(SO_VERSION_DATA) $(ICUDATA_ALL_OUTPUT_FILES) $(PKGDATA_LIST) $(OS390LIST)
+       echo timestamp > $@
+else
+build-local: $(SO_VERSION_DATA) $(PKGDATA_LIST) $(OS390LIST)
+       echo timestamp > $@
+$(PKGDATA_LIST): $(SRCLISTDEPS) $(ICUDATA_SOURCE_ARCHIVE)
+ifneq ($(ICUDATA_SOURCE_IS_NATIVE_TARGET),YES)
+       $(MKINSTALLDIRS) $(OUTTMPDIR) $(BUILDDIR)
+       @echo "Unpacking $(ICUDATA_SOURCE_ARCHIVE) and generating $@ (list of data files)"
        @-$(RMV) $@
        @-$(RMV) $@
-       @for file in $(ALL_FILES_LIST); do \
-         echo $$file >> $@; \
-       done;
+       $(INVOKE) $(TOOLBINDIR)/icupkg -d $(BUILDDIR) --list -x \* $(ICUDATA_SOURCE_ARCHIVE) -o $@
+else
+       @echo "$@" > $@
+endif
+endif
+
 
 
-build-local: build-dir $(SO_VERSION_DATA) $(ALL_FILES) $(OUTTMPDIR)/icudata.lst $(OS390LIST)
+# 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
+
+# TODO(ICU-20466): Make the TZDATA override part of Python buildtool
+ifneq ($(TZDATA),)
+
+TZCODE_DIR=$(top_builddir)/tools/tzcode
+ZONEINFO=$(TZCODE_DIR)/zoneinfo64.txt
 
 
-build-dir: $(BUILD_DIRS)
-$(BUILD_DIRS):
-       -$(MKINSTALLDIRS) $(BUILD_DIRS)
+# Override the normal genrb for zoneinfo to always pull from
+# icu/source/tools/tzcode/zoneinfo64.txt
+$(BUILDDIR)/zoneinfo64.res: $(ZONEINFO) $(TOOLBINDIR)/genrb$(TOOLEXEEXT) | $(BUILDDIR)/cnvalias.icu
+       @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
+
+# 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: packagedata $(OUTTMPDIR)/$(ICUDATA_PLATFORM_NAME).dat
+       mkdir -p $(OUTDIR)/icu4j/$(ICU4J_DATA_DIRNAME)
+       mkdir -p $(OUTDIR)/icu4j/tzdata/$(ICU4J_DATA_DIRNAME)
+       $(INVOKE) $(TOOLBINDIR)/icupkg $(OUTTMPDIR)/$(ICUDATA_PLATFORM_NAME).dat $(OUTDIR)/icu4j/$(ICUDATA_BASENAME_VERSION)b.dat -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
+# TODO(ICU-20466): Move this to Python
+# NOTE: If you get the error "No rule to make target 'out/build/icudt64l/uprops.icu'",
+# you need to reconfigure with unicore data.  See icu4j-readme.txt
+$(OUTDIR)/icu4j/icudata.jar: generate-data | $(OUT_DIR)/uprops.icu
+       $(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)
 
 
-# Now, sections for building each kind of data.
-
-####################################################    DAT
-# DAT FILES
-
-# uprops.icu
-$(BUILDDIR)/uprops.icu: $(UNICODEDATADIR)/UnicodeData.txt $(UNICODEDATADIR)/BidiMirroring.txt $(BINDIR)/genprops$(EXEEXT) $(BUILDDIR)/$(ICUDT)pnames.icu
-       $(INVOKE) $(BINDIR)/genprops -s $(UNICODEDATADIR) -i $(BUILDDIR) -d $(BUILDDIR) -u $(UNICODE_VERSION)
-
-# ucase.icu
-$(BUILDDIR)/ucase.icu: $(UNICODEDATADIR)/UnicodeData.txt $(BINDIR)/gencase$(EXEEXT)
-       $(INVOKE) $(BINDIR)/gencase -s $(UNICODEDATADIR) -i $(BUILDDIR) -d $(BUILDDIR) -u $(UNICODE_VERSION)
-
-# pnames.icu
-$(BUILDDIR)/pnames.icu: $(UNICODEDATADIR)/PropertyAliases.txt $(UNICODEDATADIR)/PropertyValueAliases.txt $(UNICODEDATADIR)/Blocks.txt $(COMINCDIR)/uscript.h $(COMINCDIR)/uchar.h $(BINDIR)/genpname$(EXEEXT)
-       $(INVOKE) $(BINDIR)/genpname -d $(BUILDDIR)
-
-# unorm.icu
-$(BUILDDIR)/unorm.icu: $(UNICODEDATADIR)/UnicodeData.txt $(UNICODEDATADIR)/DerivedNormalizationProps.txt $(UNICODEDATADIR)/BidiMirroring.txt $(BINDIR)/gennorm$(EXEEXT) $(BUILDDIR)/$(ICUDT)pnames.icu $(BUILDDIR)/$(ICUDT)uprops.icu $(BUILDDIR)/$(ICUDT)ucase.icu
-       $(INVOKE) $(BINDIR)/gennorm -s $(UNICODEDATADIR) -i $(BUILDDIR) -d $(BUILDDIR) -u $(UNICODE_VERSION)
-
-# ucadata.icu
-$(BUILDDIR)/ucadata.icu $(BUILDDIR)/$(ICUDT)invuca.icu: $(UNICODEDATADIR)/FractionalUCA.txt $(BINDIR)/genuca$(EXEEXT) $(BUILDDIR)/$(ICUDT)unorm.icu $(BUILDDIR)/$(ICUDT)ucase.icu
-       $(INVOKE) $(BINDIR)/genuca -s $(UNICODEDATADIR) -d $(BUILDDIR) -i $(BUILDDIR) 
-
-# unames.icu
-$(BUILDDIR)/unames.icu: $(UNICODEDATADIR)/UnicodeData.txt $(BINDIR)/gennames$(EXEEXT)
-       $(INVOKE) $(BINDIR)/gennames -1 -d $(BUILDDIR) $(UNICODEDATADIR)/UnicodeData.txt -u $(UNICODE_VERSION)
-
-# cnvalias.icu
-$(BUILDDIR)/cnvalias.icu: $(UCMSRCDIR)/convrtrs.txt $(BINDIR)/gencnval$(EXEEXT)
-       $(INVOKE) $(BINDIR)/gencnval -d $(BUILDDIR) $(UCMSRCDIR)/convrtrs.txt
-
-# uidna.spp
-$(BUILDDIR)/uidna.spp: $(MISCSRCDIR)/NamePrepProfile.txt $(BINDIR)/gensprep$(EXEEXT) $(BUILDDIR)/uprops.icu $(BUILDDIR)/unames.icu $(BUILDDIR)/pnames.icu
-       $(INVOKE) $(BINDIR)/gensprep -d $(BUILDDIR) -i $(BUILDDIR) -s $(MISCSRCDIR) -b uidna -n $(UNICODEDATADIR) -u 3.2.0 -k NamePrepProfile.txt
-
-####################################################    BRK
-# BRK FILES
-
-thaidict.brk: $(SRCDATADIR)/thaidict.brk
-       $(RMV) $@ && ln -s $(BUILDDIR) $@
-
-$(BUILDDIR)/%.brk: $(BRKSRCDIR)/%.txt $(BINDIR)/genbrk$(EXEEXT) $(DAT_FILES)
-       $(INVOKE) $(BINDIR)/genbrk -c -i $(BUILDDIR) -r $< -o $@
-
-####################################################    CNV
-# CNV FILES
-$(BUILDDIR)/%.cnv: $(UCMSRCDIR)/%.ucm $(BINDIR)/makeconv$(EXEEXT)
-       $(INVOKE) $(BINDIR)/makeconv -c -d $(BUILDDIR) $(UCMSRCDIR)/$(<F)
-
-####################################################    RES
-# RES FILES
-
-### collation res
-$(COLBLDDIR)/%.res: $(COLSRCDIR)/%.txt  $(BINDIR)/genrb$(EXEEXT) $(DAT_FILES)
-       $(INVOKE) $(BINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(COLSRCDIR) -d $(COLBLDDIR) $(<F)
-
-$(COLBLDDIR)/$(INDEX_NAME).res: $(OUTTMPDIR)/$(COLLATION_TREE)/$(INDEX_NAME).txt $(BINDIR)/genrb$(EXEEXT)
-       $(INVOKE) $(BINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(OUTTMPDIR)/$(COLLATION_TREE) -d $(COLBLDDIR) $(INDEX_NAME).txt
-
-$(OUTTMPDIR)/$(COLLATION_TREE)/$(INDEX_NAME).txt: $(SRCLISTDEPS)
-       @echo "generating $@ (list of installed collation locales)"; \
-       $(RMV) $@; \
-       echo "// Warning this file is automatically generated" > $@; \
-       echo "$(INDEX_NAME) {" >> $@; \
-       echo "    InstalledLocales {" >> $@; \
-       for file in $(INSTALLED_COL_FILES); do \
-         echo "        $$file {\"\"}" >> $@; \
-       done; \
-       echo "    }" >> $@; \
-       echo "}" >> $@;
-
-### RBNF res
-$(RBNFBLDDIR)/%.res: $(RBNFSRCDIR)/%.txt  $(BINDIR)/genrb$(EXEEXT) $(DAT_FILES)
-       $(INVOKE) $(BINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(RBNFSRCDIR) -d $(RBNFBLDDIR) $(<F)
-
-$(RBNFBLDDIR)/$(INDEX_NAME).res: $(OUTTMPDIR)/$(RBNF_TREE)/$(INDEX_NAME).txt $(BINDIR)/genrb$(EXEEXT)
-       $(INVOKE) $(BINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(OUTTMPDIR)/$(RBNF_TREE) -d $(RBNFBLDDIR) $(INDEX_NAME).txt
-
-$(OUTTMPDIR)/$(RBNF_TREE)/$(INDEX_NAME).txt: $(SRCLISTDEPS)
-       @echo "generating $@ (list of installed RBNF locales)"; \
-       $(RMV) $@; \
-       echo "// Warning this file is automatically generated" > $@; \
-       echo "$(INDEX_NAME) {" >> $@; \
-       echo "    InstalledLocales {" >> $@; \
-       for file in $(INSTALLED_RBNF_FILES); do \
-         echo "        $$file {\"\"}" >> $@; \
-       done; \
-       echo "    }" >> $@; \
-       echo "}" >> $@;
-
-### TRANSLIT res
-$(TRANSLITBLDDIR)/%.res: $(TRANSLITSRCDIR)/%.txt  $(BINDIR)/genrb$(EXEEXT) $(DAT_FILES)
-       $(INVOKE) $(BINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(TRANSLITSRCDIR) -d $(TRANSLITBLDDIR) $(<F)
-  
-### normal (locale) res
-all-RES:  $(RES_FILES)
-
-$(BUILDDIR)/%.res: $(LOCSRCDIR)/%.txt $(BINDIR)/genrb$(EXEEXT) $(DAT_FILES)
-       $(INVOKE) $(BINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -s $(LOCSRCDIR) -d $(BUILDDIR) $(<F)
-
-# zoneinfo has some issues. Ignore some warnings with -q
-$(BUILDDIR)/%.res: $(MISCSRCDIR)/%.txt $(BINDIR)/genrb$(EXEEXT)
-       $(INVOKE) $(BINDIR)/genrb $(GENRBOPTS) -q -i $(BUILDDIR) -s $(MISCSRCDIR) -d $(BUILDDIR) $(<F)
-
-$(OUTTMPDIR)/$(INDEX_NAME).txt: $(SRCLISTDEPS)
-       @echo "generating $@ (list of installed locales)"; \
-       $(RMV) $@; \
-       echo "// Warning this file is automatically generated" > $@; \
-       echo "$(INDEX_NAME) {" >> $@; \
-       echo "    InstalledLocales {" >> $@; \
-       for file in $(INSTALLED_RB_FILES); do \
-         echo "        $$file {\"\"}" >> $@; \
-       done; \
-       echo "    }" >> $@; \
-       echo "}" >> $@;
-
-clean-resindex:
-       -$(RMV) $(BUILDDIR)/$(INDEX_NAME).txt $(OUTTMPDIR)/icudata.lst
-
-$(INDEX_RES_FILE): $(INDEX_FILE) $(BINDIR)/genrb$(EXEEXT)
-       $(INVOKE) $(BINDIR)/genrb $(GENRBOPTS) -i $(BUILDDIR) -d $(BUILDDIR) $(INDEX_FILE)
 
 ###################################################################
 Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
        cd $(top_builddir) \
        && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
 
 
 ###################################################################
 Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
        cd $(top_builddir) \
        && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
 
-icupkg.inc: $(srcdir)/icupkg.inc.in  $(top_builddir)/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
        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
-ALLFILES390=uprops.icu ucase.icu pnames.icu unorm.icu cnvalias.icu $(UCMFILES390:.ucm=.cnv)
+# 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)"
 
 $(OUTTMPDIR)/icudata390.lst: $(SRCLISTDEPS)
        @echo "generating $@ (list of 390 data files)"