diff --git a/.gitignore b/.gitignore index 53864ca13c..6accd63f22 100644 --- a/.gitignore +++ b/.gitignore @@ -98,7 +98,9 @@ icu4c/source/extra/uconv/*.d icu4c/source/extra/uconv/Debug icu4c/source/extra/uconv/Makefile icu4c/source/extra/uconv/Release +icu4c/source/extra/uconv/pkgdata.inc icu4c/source/extra/uconv/uconv +icu4c/source/extra/uconv/uconv.1 icu4c/source/extra/uconv/uconvmsg icu4c/source/extra/ustdio/*.d icu4c/source/extra/ustdio/Debug diff --git a/icu4c/source/extra/uconv/.cvsignore b/icu4c/source/extra/uconv/.cvsignore index 8d2cf1002d..cba7273a65 100644 --- a/icu4c/source/extra/uconv/.cvsignore +++ b/icu4c/source/extra/uconv/.cvsignore @@ -4,4 +4,5 @@ Debug Release Makefile uconvmsg - +uconv.1 +pkgdata.inc diff --git a/icu4c/source/extra/uconv/Makefile.in b/icu4c/source/extra/uconv/Makefile.in index 26125bd91e..964dbf1011 100644 --- a/icu4c/source/extra/uconv/Makefile.in +++ b/icu4c/source/extra/uconv/Makefile.in @@ -7,6 +7,10 @@ ## Makefile.in for ICU - uconv ## Steven R. Loomis +## Set the following to 'YES' to statically link uconv's data. +UCONVMSG_STATIC=YES +############################################################## + srcdir=@srcdir@ top_srcdir=@top_srcdir@ @@ -14,14 +18,16 @@ top_builddir = ../.. subdir = extra/uconv include $(top_builddir)/icudefs.mk - + +MSGNAME=uconvmsg + ## Platform-specific setup include @platform_make_fragment@ # RESSRC comes from resfiles.mk include $(srcdir)/resfiles.mk -RESDIR=uconvmsg +RESDIR=$(MSGNAME) RESFILES=$(RESSRC:%.txt=$(RESDIR)/%.res) ## @@ -47,13 +53,20 @@ endif LDFLAGS = @LDFLAGS@ $(RPATHLDFLAGS) LIBS = $(LIBICUI18N) $(LIBICUUC) @LIBS@ @LIB_M@ +ifeq ($(UCONVMSG_STATIC),YES) +LIBS += -L$(MSGNAME) -l$(MSGNAME) +CPPFLAGS += -DUCONVMSG_STATIC=$(MSGNAME) -I$(RESDIR) +UCONVMSG_LIB=$(RESDIR)/lib$(MSGNAME).a +UCONVMSG_HDR=$(RESDIR)/$(MSGNAME).h +endif + OBJECTS = uconv.o uwmsg.o DEPS = $(OBJECTS:.o=.d) ## List of phony targets .PHONY : all all-local install install-local clean clean-local \ -distclean distclean-local dist dist-local check check-local resfiles package-resfiles install-resfiles install-man +distclean resclean distclean-local dist dist-local check check-local resfiles package-resfiles install-resfiles install-man ## Clear suffix list .SUFFIXES : @@ -76,9 +89,11 @@ install-target: all-local dist-local: -clean-local: +clean-local: resclean test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) $(RESFILES) $(RMV) $(OBJECTS) $(TARGET) + +resclean: $(RMV) $(RESDIR) distclean-local: clean-local @@ -94,13 +109,20 @@ pkgdata.inc: $(srcdir)/pkgdata.inc.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status -$(TARGET) : $(OBJECTS) - $(LINK.cc) -o $@ $^ $(LIBS) +$(TARGET) : $(OBJECTS) $(UCONVMSG_LIB) + $(LINK.cc) -o $@ $^ $(LIBS) $(LDFLAGS) resfiles: $(RESFILES) package-resfiles + +ifeq ($(UCONVMSG_STATIC),YES) +$(UCONVMSG_HDR) $(UCONVMSG_LIB): resfiles +uconv.o: $(UCONVMSG_HDR) +endif + + package-resfiles: $(RESDIR)/$(RESDIR).lst pkgdata.inc - $(INVOKE) $(top_builddir)/tools/pkgdata/pkgdata -p $(RESDIR) -O pkgdata.inc -m common -d uconvmsg -T $(RESDIR) $(RESDIR)/$(RESDIR).lst + $(INVOKE) $(top_builddir)/tools/pkgdata/pkgdata -p $(RESDIR) -O pkgdata.inc -m static -d $(RESDIR) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst $(RESDIR)/$(RESDIR).lst: Makefile pkgdata.inc $(srcdir)/resfiles.mk @$(MKINSTALLDIRS) $(RESDIR) @@ -109,9 +131,11 @@ $(RESDIR)/$(RESDIR).lst: Makefile pkgdata.inc $(srcdir)/resfiles.mk echo `pwd`/$$file >> $@; \ done; +ifneq ($(UCONVMSG_STATIC),YES) install-resfiles: $(RESFILES) $(MKINSTALLDIRS) $(DESTDIR)$(ICUDATA_DIR) - $(INVOKE) $(top_builddir)/tools/pkgdata/pkgdata -p $(RESDIR) -O pkgdata.inc -m common -d uconvmsg -I $(DESTDIR)$(ICUDATA_DIR) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst + $(INVOKE) $(top_builddir)/tools/pkgdata/pkgdata -p $(RESDIR) -O pkgdata.inc -m static -d $(RESDIR) -I $(DESTDIR)$(ICUDATA_DIR) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst +endif $(RESDIR)/%.res: $(srcdir)/%.txt @$(MKINSTALLDIRS) $(RESDIR) diff --git a/icu4c/source/extra/uconv/pkgdata.inc.in b/icu4c/source/extra/uconv/pkgdata.inc.in index db117bf22f..d349ab7b97 100644 --- a/icu4c/source/extra/uconv/pkgdata.inc.in +++ b/icu4c/source/extra/uconv/pkgdata.inc.in @@ -44,6 +44,7 @@ PACKAGE=@PACKAGE@ VERSION=@VERSION@ CC=@CC@ CXX=@CXX@ +RANLIB=@RANLIB@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ diff --git a/icu4c/source/extra/uconv/uconv.cpp b/icu4c/source/extra/uconv/uconv.cpp index 30c0aa04ee..077c5da093 100644 --- a/icu4c/source/extra/uconv/uconv.cpp +++ b/icu4c/source/extra/uconv/uconv.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -37,6 +38,10 @@ #include #endif +#ifdef UCONVMSG_STATIC +# include "uconvmsg.h" +#endif + #define DEFAULT_BUFSZ 4096 static UResourceBundle *gBundle = 0; /* Bundle containing messages. */ @@ -56,6 +61,17 @@ static void initMsg(const char *pname) { ps = 1; + /* Set up our static data - if any */ +#ifdef UCONVMSG_STATIC + udata_install_uconvmsg(&err); + if (U_FAILURE(err)) { + fprintf(stderr, "%s: warning, problem installing our static resource bundle data uconvmsg: %s - trying anyways.\n", + pname, u_errorName(err)); + err = U_ZERO_ERROR; /* It may still fail */ + } +#endif + + /* Get messages. */ strcpy(dataPath, u_getDataDirectory());