# Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# \"Software\"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions: The above copyright notice and this
# permission notice shall be included in all copies or substantial
# portions of the Software.
# 
# 
# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
# THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
# ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
# 
# 
# Except as contained in this notice, the names of The Open Group and/or
# Sun Microsystems, Inc. shall not be used in advertising or otherwise to
# promote the sale, use or other dealings in this Software without prior
# written authorization from The Open Group and/or Sun Microsystems,
# Inc., as applicable.
# 
# 
# X Window System is a trademark of The Open Group
# 
# OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
# logo, LBX, X Window System, and Xinerama are trademarks of the Open
# Group. All other trademarks and registered trademarks mentioned herein
# are the property of their respective owners. No right, title or
# interest in or to any trademark, service mark, logo or trade name of
# Sun Microsystems, Inc. or its licensors is granted.

ifdef ALT_JDK13_HOME
    JDK13_HOME = $(ALT_JDK13_HOME)
else
    JDK13_HOME = /usr/java/j2sdk1.5.0
endif

ifdef ALT_J2RE_HOME
    J2RE_HOME = $(ALT_J2RE_HOME)
else
    J2RE_HOME = /usr/java/j2redefault
endif

TOPDIR = $(shell cd ../../..; pwd)

SHARE_SRC = $(TOPDIR)/iiimjcf/jdk13_iiimf_adapter
IIIMF_SRC = $(shell cd $(SHARE_SRC)/classes; pwd)
SOURCES = $(shell cd $(IIIMF_SRC); ls sun/awt/im/iiimp/*.java com/sun/iiim/*.java)

mkinstalldirs = $(SHARE_SRC)/build/mkinstalldirs

CLASSDESTDIR = $(shell pwd)/classes

JARLIBDIR = $(shell pwd)/lib

VPATH.java = $(SHARE_SRC)/classes

vpath %.java $(VPATH.java)

vpath %.class $(CLASSDSTDIR)

SOURCEPATH = $(VPATH.java)

JAVAC = $(JDK13_HOME)/bin/javac -deprecation
JAR = $(JDK13_HOME)/bin/jar

FILES_java = $(SOURCES)

all: iiimf.jar

FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class)

LWE_SYNTAX = $(shell cd $(IIIMF_SRC); ls sun/awt/im/iiimp/*.lwesyntax)

$(CLASSDESTDIR) $(JARLIBDIR) : 
	mkdir -p $@

$(CLASSDESTDIR)/%.class: $(SHARE_SRC)/classes/%.java
	@echo $? >> .classes.list

.delete.classlist:
	$(RM) .classes.list

.compile.classlist:
	if [ -s .classes.list ] ; \
	then $(JAVAC) -d $(CLASSDESTDIR) -classpath \
	$(CLASSDESTDIR):$(JDK13_HOME)/jre/lib/rt.jar \
	$(shell if [ -s .classes.list ] ; then cat .classes.list; fi) ; \
	fi

.add.syntaxlist:
	cd $(CLASSDESTDIR); rm -f $(LWE_SYNTAX) ; \
	cd $(SHARE_SRC)/classes ; cp $(LWE_SYNTAX) \
	$(CLASSDESTDIR)/sun/awt/im/iiimp

.jar.classes:
	cd classes; $(JAR) cvf ../lib/iiimf.jar sun com META-INF

classes: $(CLASSDESTDIR) .delete.classlist $(FILES_class) .compile.classlist \
	.add.syntaxlist

iiimf.jar: classes $(JARLIBDIR) .jar.classes

clean:
	$(RM) -rf classes/sun classes/com .classes.* lib

install: iiimf.jar
	$(mkinstalldirs) $(DESTDIR)$(J2RE_HOME)/lib/ext
	rm -f $(DESTDIR)$(J2RE_HOME)/lib/ext/iiimf.jar
	cp lib/iiimf.jar $(DESTDIR)$(J2RE_HOME)/lib/ext
