diff --git a/icu4c/source/common/Makefile.in b/icu4c/source/common/Makefile.in index dbe30ed5ae0..b3fb587ee92 100644 --- a/icu4c/source/common/Makefile.in +++ b/icu4c/source/common/Makefile.in @@ -68,6 +68,11 @@ LDFLAGS += $(LDFLAGSICUUC) # for plugin configuration CPPFLAGS += "-DDEFAULT_ICU_PLUGINS=\"$(libdir)/icu\" " +# for icu data location +ifeq ($(PKGDATA_MODE),common) +CPPFLAGS += "-DU_ICU_DATA_DEFAULT_DIR=\"$(ICUDATA_DIR)\"" +endif + # $(LIBICUDT) is either stub data or the real DLL common data. LIBS = $(LIBICUDT) $(DEFAULT_LIBS) diff --git a/icu4c/source/common/putil.c b/icu4c/source/common/putil.c index cc474304428..667ef2934e7 100644 --- a/icu4c/source/common/putil.c +++ b/icu4c/source/common/putil.c @@ -1184,10 +1184,20 @@ u_getDataDirectory(void) { path=getenv("ICU_DATA"); # endif - /* ICU_DATA_DIR may be set as a compile option */ -# ifdef ICU_DATA_DIR + /* ICU_DATA_DIR may be set as a compile option. + * U_ICU_DATA_DEFAULT_DIR is provided and is set by ICU at compile time + * and is used only when data is built in archive mode eliminating the need + * for ICU_DATA_DIR to be set. U_ICU_DATA_DEFAULT_DIR is set to the installation + * directory of the data dat file. Users should use ICU_DATA_DIR if they want to + * set their own path. + */ +#if defined(ICU_DATA_DIR) || defined(U_ICU_DATA_DEFAULT_DIR) if(path==NULL || *path==0) { +# ifdef ICU_DATA_DIR path=ICU_DATA_DIR; +# else + path=U_ICU_DATA_DEFAULT_DIR; +# endif #if defined(U_DARWIN) && TARGET_IPHONE_SIMULATOR simulator_root=getenv("IPHONE_SIMULATOR_ROOT"); if (simulator_root != NULL) {