#
# Copyright 1996-2006 Sun Microsystems, Inc.  All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#

BUILDDIR = ../..

PACKAGE = java.text
PRODUCT = sun

include $(BUILDDIR)/common/Defs.gmk

#
# Files
#
include FILES_java.gmk

#
# Include
#
include $(BUILDDIR)/common/Classes.gmk

#
# Rules to add data files BreakIterator
#
GENBIDSRC = $(BUILDDIR)/tools/GenerateBreakIteratorData
GENBIDOUT = $(TEMPDIR)/tools/GenerateBreakIteratorData

# input
#
#   Notes: sun.text.resources.BreakIteratorRules no longer goes to runtime.
#     They are used at J2SE build phase in order to create $(BIFILES) which
#     are used on runtime instead.
#
BIRULES = $(SHARE_SRC)/classes/sun/text/resources/BreakIteratorRules.java
BIRULES_CLASS = $(GENBIDOUT)/sun/text/resources/BreakIteratorRules.class
BIINFO = $(SHARE_SRC)/classes/sun/text/resources/BreakIteratorInfo.java
BIINFO_CLASS = $(GENBIDOUT)/sun/text/resources/BreakIteratorInfo.class
UNICODE = $(BUILDDIR)/tools/UnicodeData/UnicodeData.txt

# output
BIFILES = $(CLASSBINDIR)/sun/text/resources/CharacterBreakIteratorData \
          $(CLASSBINDIR)/sun/text/resources/WordBreakIteratorData \
          $(CLASSBINDIR)/sun/text/resources/LineBreakIteratorData \
          $(CLASSBINDIR)/sun/text/resources/SentenceBreakIteratorData

# builder
BUILDER = $(GENBIDSRC)/GenerateBreakIteratorData.java \
          $(GENBIDSRC)/CharSet.java \
          $(GENBIDSRC)/CharacterCategory.java \
          $(GENBIDSRC)/DictionaryBasedBreakIteratorBuilder.java \
          $(GENBIDSRC)/RuleBasedBreakIteratorBuilder.java \
          $(GENBIDSRC)/SupplementaryCharacterData.java 
BUILDER_CLASS = $(GENBIDOUT)/GenerateBreakIteratorData.class \
                $(GENBIDOUT)/CharSet.class \
                $(GENBIDOUT)/CharacterCategory.class \
                $(GENBIDOUT)/DictionaryBasedBreakIteratorBuilder.class \
                $(GENBIDOUT)/RuleBasedBreakIteratorBuilder.class \
                $(GENBIDOUT)/SupplementaryCharacterData.class 

$(BUILDER_CLASS): $(BUILDER)
	$(prep-target)
	$(JAVAC_BOOT) -d $(GENBIDOUT) -sourcepath $(GENBIDSRC) $(BUILDER)
	@$(java-vm-cleanup)

$(BIRULES_CLASS): $(BIRULES)
	$(prep-target)
	$(JAVAC_BOOT) -d $(GENBIDOUT) \
		-sourcepath $(SHARE_SRC)/classes/sun/text/resources $(BIRULES)
	@$(java-vm-cleanup)

$(BIINFO_CLASS): $(BIINFO)
	$(prep-target)
	$(JAVAC_BOOT) -d $(GENBIDOUT) \
		-sourcepath $(SHARE_SRC)/classes/sun/text/resources $(BIINFO)
	@$(java-vm-cleanup)

$(BIFILES): $(BUILDER_CLASS) $(BIRULES_CLASS) $(BIINFO_CLASS) $(UNICODE)
	$(prep-target)
	$(MKDIR) -p  $(CLASSBINDIR)/sun/text/resources
	$(JAVA) -Xbootclasspath/p:$(GENBIDOUT) GenerateBreakIteratorData \
		-o $(CLASSBINDIR)/sun/text/resources -spec $(UNICODE)
	@$(java-vm-cleanup)

bifiles: $(BIFILES) $(CLASSBINDIR)/sun/text/resources/unorm.icu $(CLASSBINDIR)/sun/text/resources/uprops.icu

build: bifiles

clean::
	$(RM) -r $(GENBIDOUT) $(BIFILES)

#
# Extra rules to copy unorm.icu and uprops.icu
#
$(CLASSBINDIR)/sun/text/resources/unorm.icu : $(SHARE_SRC)/classes/sun/text/resources/unorm.icu
	$(install-file)

$(CLASSBINDIR)/sun/text/resources/uprops.icu : $(SHARE_SRC)/classes/sun/text/resources/uprops.icu
	$(install-file)

clean clobber::
	$(RM) -f $(CLASSBINDIR)/sun/text/resources/*.icu

