From 1956f2b92393786554e89b6e92d315ed3fb6c314 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov <borisk@apache.org>
Date: Tue, 10 Nov 2009 12:50:48 +0000
Subject: [PATCH] Rework compilation of ICU message loader resources
 (XERCESC-1882).

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@834455 13f79535-47bb-0310-9956-ffa450edef68
---
 src/Makefile.am                               |   6 +-
 .../util/MsgLoaders/ICU/resources/Makefile.in | 136 +++---------------
 .../MsgLoaders/ICU/resources/resources.mak    |  53 -------
 .../ICU/resources/root_res_dummy.cpp          |  26 ----
 4 files changed, 24 insertions(+), 197 deletions(-)
 delete mode 100644 src/xercesc/util/MsgLoaders/ICU/resources/resources.mak
 delete mode 100644 src/xercesc/util/MsgLoaders/ICU/resources/root_res_dummy.cpp

diff --git a/src/Makefile.am b/src/Makefile.am
index 17eb8ba50..f95c481fd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -127,8 +127,6 @@ nobase_libxerces_c_la_HEADERS += ${msgicu_headers}
 AM_CPPFLAGS += -I${ICU_PREFIX}/include
 
 SUBDIRS += xercesc/util/MsgLoaders/ICU/resources
-libxerces_c_la_LIBADD += xercesc/util/MsgLoaders/ICU/resources/xercesc_messages.lo \
-xercesc/util/MsgLoaders/ICU/resources/root_res.lo
 endif
 
 if XERCES_USE_MSGLOADER_ICONV
@@ -1057,7 +1055,9 @@ msgicu_headers = \
 	xercesc/util/MsgLoaders/ICU/ICUMsgLoader.hpp
 
 msgicu_sources = \
-	xercesc/util/MsgLoaders/ICU/ICUMsgLoader.cpp
+	xercesc/util/MsgLoaders/ICU/ICUMsgLoader.cpp \
+        xercesc/util/MsgLoaders/ICU/resources/xercesc_messages.c \
+        xercesc/util/MsgLoaders/ICU/resources/root_res.c
 
 msgiconv_headers = \
 	xercesc/util/MsgLoaders/MsgCatalog/MsgCatalogLoader.hpp \
diff --git a/src/xercesc/util/MsgLoaders/ICU/resources/Makefile.in b/src/xercesc/util/MsgLoaders/ICU/resources/Makefile.in
index 1b7dfb024..470d8a337 100644
--- a/src/xercesc/util/MsgLoaders/ICU/resources/Makefile.in
+++ b/src/xercesc/util/MsgLoaders/ICU/resources/Makefile.in
@@ -14,148 +14,54 @@
 # limitations under the License.
 #
 
-# TODO:
-# @@ get rid of unused vars
-#
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 top_builddir = @top_builddir@
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 libdir = @libdir@
-ICU_PREFIX = @ICU_PREFIX@
-SHREXT = @SHREXT@
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
 mkdir_p = @mkdir_p@
 
-CC = @CC@
-CXX = @CXX@
-AR = @AR@
-RANLIB = @RANLIB@
-CPPFLAGS = @CPPFLAGS@
-CFLAGS = @CFLAGS@
-CXXFLAGS = @CXXFLAGS@
-LIBTOOL = @LIBTOOL@
-LDFLAGS = @LDFLAGS@
-
-BUILD_SHARED = @BUILD_SHARED@
-BUILD_STATIC = @BUILD_STATIC@
-
-include $(top_srcdir)/version.incl
+ICU_PREFIX = @ICU_PREFIX@
 
 GENRB=$(ICU_PREFIX)/bin/genrb
-PKGDATA=$(ICU_PREFIX)/bin/pkgdata
+GENCCODE=$(ICU_PREFIX)/sbin/genccode
+GENCMN=$(ICU_PREFIX)/sbin/gencmn
 
-# Add -v if you want to see more verbose output.
-#
-PKGDATAOPTS=-d . -M '"CC=$(CC)" "CXX=$(CXX)" "AR=$(AR)" "RANLIB=$(RANLIB)" \
-"CPPFLAGS=$(CPPFLAGS)" "CFLAGS=$(CFLAGS)" "CXXFLAGS=$(CXXFLAGS)" "LDFLAGS=$(LDFLAGS)"'
+include $(top_srcdir)/version.incl
 
 # Resource shortname
 PKGNAME=xercesc_messages_$(INTERFACE_VER_U)
 
 # Resource files.  Add new ones for additional locales here. Keep in sync
-# with the file RESLIST and don't forget to add the object file below.
+# with the file RESLIST and don't forget to add the .lo entry in top-level
+# Makefile.am.
 #
 RESFILES=root.res
 
 # list of resource bundles  - keep in sync with RESFILES
+#
 RESLIST=$(srcdir)/res-file-list.txt
 
-#
-#
 .PHONY: all
-all: xercesc_messages.lo
+all: $(RESFILES:.res=_res.c) xercesc_messages.c
 
-# ICU makefiles use .o and .ao for non-PIC object file extensions
-# on different platforms. We need to account for that. Also on some
-# platforms ICU produces root_res.o. Overall, this is one hairy hack
-# to make ICU work with libtool. If you know of a better way to handle
-# this do let us (c-dev@xerces.apache.org) know.
-#
-xercesc_messages.lo: $(RESFILES)
-ifeq ($(BUILD_SHARED),yes)
-	@rm -f $(PKGNAME)_dat.o root_res.o
-	$(PKGDATA) --name $(PKGNAME) --mode dll $(PKGDATAOPTS) $(RESLIST)
-	mv $(PKGNAME)_dat.o $(PKGNAME)_dat-pic.o
-	@if test -f root_res.o; then mv root_res.o root_res-pic.o; fi
-endif
-ifeq ($(BUILD_STATIC),yes)
-	@rm -f $(PKGNAME)_dat.o $(PKGNAME)_dat.ao root_res.o root_res.ao
-	$(PKGDATA) --name $(PKGNAME) --mode static $(PKGDATAOPTS) $(RESLIST)
-	@if test -f $(PKGNAME)_dat.ao; then mv $(PKGNAME)_dat.ao $(PKGNAME)_dat.o; fi
-	@if test -f root_res.ao; then mv root_res.ao root_res.o; fi
-endif
-	@echo "# $@ - a libtool object file" >$@
-	@echo "# Generated by `$(LIBTOOL) --version | \
-sed -e 's/^\([^ ]*\) (GNU \(.*\)) \(.*\)$$/\1 - GNU \2 \3/' -e q`" >>$@
-	@echo "" >>$@
-ifeq ($(BUILD_SHARED),yes)
-	@echo "pic_object='$(PKGNAME)_dat-pic.o'" >>$@
-else
-	@echo "pic_object=none" >>$@
-endif
-ifeq ($(BUILD_STATIC),yes)
-	@echo "non_pic_object='$(PKGNAME)_dat.o'" >>$@
-else
-	@echo "non_pic_object=none" >>$@
-endif
-	@echo "# root_res.lo - a libtool object file" >root_res.lo
-	@echo "# Generated by `$(LIBTOOL) --version | \
-sed -e 's/^\([^ ]*\) (GNU \(.*\)) \(.*\)$$/\1 - GNU \2 \3/' -e q`" >>root_res.lo
-	@echo "" >>root_res.lo
-ifeq ($(BUILD_SHARED),yes)
-	@echo "pic_object='root_res-pic.o'" >>root_res.lo
-else
-	@echo "pic_object=none" >>root_res.lo
-endif
-ifeq ($(BUILD_STATIC),yes)
-	@echo "non_pic_object='root_res.o'" >>root_res.lo
-else
-	@echo "non_pic_object=none" >>root_res.lo
-endif
-	@if test ! -f root_res-pic.o -a ! -f root_res.o; then \
-$(LIBTOOL) --quiet --tag=CXX --mode=compile $(CXX) $(CPPFLAGS) $(CXXFLAGS) \
--c -o root_res.lo root_res_dummy.cpp; fi
+xercesc_messages.c: $(RESLIST)
+	$(GENCMN) --name $(PKGNAME) -S $(PKGNAME)_dat.c -d . $<
+	@mv $(PKGNAME)_dat.c xercesc_messages.c
 
+.PRECIOUS: %_res.c
+%_res.c: $(srcdir)/%.res
+	$(GENCCODE) --name $(PKGNAME) -d . $<
+
+.PRECIOUS: %.res
 %.res: $(srcdir)/%.txt
 	$(GENRB) $^
 
-# Let the corresponding tools (pkgdata, libtool) clean up their own
-# files. pkgdata does not remove the .dat and README file for some
-# reason.
-#
-clean:
-	rm -f xercesc_messages.lo root_res.lo
-ifeq ($(BUILD_SHARED),yes)
-	$(PKGDATA) --name $(PKGNAME) --mode dll --clean $(PKGDATAOPTS) $(RESLIST)
-	rm -f $(PKGNAME)_dat-pic.o root_res-pic.o
-	rm -rf .libs
-endif
-ifeq ($(BUILD_STATIC),yes)
-	$(PKGDATA) --name $(PKGNAME) --mode static --clean $(PKGDATAOPTS) $(RESLIST)
-	rm -f README_$(PKGNAME).txt root_res.o
-endif
-	rm -f $(RESFILES)
-	rm -f $(PKGNAME).dat
-
-# Distclean is invoked even if we are not building with ICU.
-# As a result, we cannot use pkgdata to clean up.
+# Clean
 #
-distclean:
-	rm -f xercesc_messages.lo root_res.lo
-	rm -f lib$(PKGNAME).so
-	rm -f lib$(PKGNAME).a
-	rm -f $(PKGNAME)_dat*.o root_res*.o
-	rm -f $(PKGNAME)*.lst
-	rm -f $(PKGNAME)*.mak
-	rm -f $(RESFILES)
-	rm -f $(PKGNAME).dat
-	rm -f README_$(PKGNAME).txt
-	rm -rf .libs
-
+clean distclean:
+	rm -f $(RESFILES) $(RESFILES:.res=_res.c) xercesc_messages.c
 #
 #
 .PHONY: check
@@ -166,12 +72,12 @@ check: all
 distdir:
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	list='res-file-list.txt root.txt Makefile.in resources.mak root_res_dummy.cpp'; \
+	list='res-file-list.txt root.txt Makefile.in'; \
 	  dist_files=`for file in $$list; do echo $$file; done | \
 	  sed -e "s|^$$srcdirstrip/||;t" \
 	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
 	case $$dist_files in \
-	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+	  */*) $(mkdir_p) `echo "$$dist_files" | \
 			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
 			   sort -u` ;; \
 	esac; \
diff --git a/src/xercesc/util/MsgLoaders/ICU/resources/resources.mak b/src/xercesc/util/MsgLoaders/ICU/resources/resources.mak
deleted file mode 100644
index 99f81f668..000000000
--- a/src/xercesc/util/MsgLoaders/ICU/resources/resources.mak
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Copyright (c) 2003 IBM, Inc.
-#
-#  File:     resources.mak
-#  Location: <xercesc_root>\src\xercesc\util\MsgLoaders\ICU\resources
-#
-#  Windows nmake makefile for compiling (and packaging) the resources
-#  for ICU message loader.
-#
-#  List of resource files to be built.
-#
-#    . When adding a resource source (.txt) file for a new locale,
-#           the corresponding .res file must be added to this list,
-#    . AND to the file res-file-list-wins.txt
-#
-#  keep synchronous with ICUMsgLoader.cpp
-#
-
-# for VER
-include ..\..\..\..\..\..\version.incl
-
-RESFILES= root.res
-
-PKGNAME       = xercesc_messages_$(INTERFACE_VER_U)
-TARGET_DLL    = $(PKGNAME).DLL
-TARGET_LIB    = $(PKGNAME).lib
-
-GENRB    = $(ICUROOT)\bin\genrb.exe
-PKGDATA  = $(ICUROOT)\bin\pkgdata
-REN      = ren
-
-#
-#  File name extensions for inference rule matching.
-#    clear out the built-in ones (for .c and the like), and add
-#    the definition for .txt to .res.
-#
-.SUFFIXES :
-.SUFFIXES : .txt
-
-#
-#  Inference rule, for compiling a .txt file into a .res file.
-#
-.txt.res:
-	$(GENRB) -d . $*.txt
-
-#
-#  all - nmake starts here by default
-#
-all: $(TARGET_DLL)
-
-$(TARGET_DLL): $(RESFILES)
-	$(PKGDATA) --name $(PKGNAME) -v -O R:$(ICUROOT) --mode dll -d . res-file-list.txt
-
diff --git a/src/xercesc/util/MsgLoaders/ICU/resources/root_res_dummy.cpp b/src/xercesc/util/MsgLoaders/ICU/resources/root_res_dummy.cpp
deleted file mode 100644
index 1d6ea4c2f..000000000
--- a/src/xercesc/util/MsgLoaders/ICU/resources/root_res_dummy.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * $Id: BitSet.cpp 474935 2006-11-14 19:41:33Z amassari $
- */
-
-// Dummy file to create root_res.o when ICU does not produce one.
-//
-static void root_res_dummy ()
-{
-}
-- 
GitLab