#
# Copyright 2004-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.
#

#
# Makefile for building the CodePointInputMethod
#

BUILDDIR = ../../..
DEMOS    = CodePointIM

# identify this as a demo/jfc/CodePointIM product - used to identify
# a unique name for OBJDIR
PRODUCT = demo/jfc/CodePointIM

include $(BUILDDIR)/common/Defs.gmk

#
# What do we compile?
#
DEMODST  = $(DEMODIR)/jfc/CodePointIM
DEMOSRC  = $(SHARE_SRC)/demo/jfc/CodePointIM
include FILES.gmk

#
# Activate some hooks so Classes.gmk looks elsewhere for sources, and
# dumps classes where we want.
#
SOURCEPATH              = $(DEMOSRC)

# use "simple expansion" (GNU Make 6.2) for setting BOOTCLASSPATH 
# because CLASSBINDIR is changed a few lines down:
BOOTCLASSPATH           := $(CLASSBINDIR)

DEMOJAR	                = $(DEMODST)/CodePointIM.jar
ALT_CLASSES_DISPOSITION = src resources docs $(DEMOJAR)
ALT_CLASSBINDIR         = $(TEMPDIR)/class
CLASSDESTDIR            = $(ALT_CLASSBINDIR)
CLASSBINDIR             = $(ALT_CLASSBINDIR)

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

build: src resources docs $(DEMOJAR)

#
# Sources.
#
SRCSRC = $(DEMOSRC)
SRCDST = $(DEMODST)/src
FILES_src = $(FILES_java:%.java=$(SRCDST)/%.java)

src: $(FILES_src)

$(SRCDST)/%.java: $(SRCSRC)/%.java
	$(install-file)

#
# Resources.
#
FILES_res = $(FILES_resources:%.properties=$(SRCDST)/%.properties)

resources: $(FILES_res)

$(SRCDST)/%.properties: $(SRCSRC)/%.properties
	$(install-file)

#
# Docs.
#
FILES_doc = $(FILES_readme:%.html=$(DEMODST)/%.html)

docs: $(FILES_doc)

$(DEMODST)/%.html: $(DEMOSRC)/%.html
	$(install-file)

#
# Jar file.
#
DESCRIPTOR_DIR = $(TEMPDIR)/class/META-INF/services
DESCRIPTOR = $(DEMOSRC)/java.awt.im.spi.InputMethodDescriptor
RESOURCES_DIR = $(TEMPDIR)/class/resources
RESOURCES = $(FILES_resources:%.properties=$(DEMOSRC)/%.properties)

jar: $(DEMODST)/CodePointIM.jar

$(DEMODST)/CodePointIM.jar: $(DESCRIPTOR) $(FILES_class) $(FILES_java:%.java=$(DEMOSRC)/%.java) $(RESOURCES)
	$(ECHO) Main-Class: CodePointIM > $(TEMPDIR)/manifest
	$(MKDIR) -p $(DESCRIPTOR_DIR) $(RESOURCES_DIR)
	$(CP) -f $(DESCRIPTOR) $(DESCRIPTOR_DIR)
	$(CP) -f $(RESOURCES) $(RESOURCES_DIR)
	$(JAR) -cvfm $@ $(TEMPDIR)/manifest -C $(TEMPDIR)/class . \
	     $(JAR_JFLAGS)
	$(RM) $(TEMPDIR)/manifest
	@$(java-vm-cleanup)

