#
# MICO --- a free CORBA implementation
# Copyright (C) 1997 Kay Roemer & Arno Puder
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Send comments and/or bug reports to:
#                mico@informatik.uni-frankfurt.de
#

all: .depend Converter.jar client

DIR_PREFIX=../../../

include ../../../../MakeVars

.SUFFIXES: .idl

%.h %.cc: %.idl
	$(IDL) -I. $(IDL_INCL) -DprimaryKey=_primaryKey \
               --ifdef-prefix=$(subst /,_,$(<D)) $<
	mv $(*F).cc $(<D)
	mv $(*F).h $(<D)

CXXFLAGS  := $(COS_CXXFLAGS) $(CXXFLAGS)
LDLIBS    := $(COS_LDLIBS) $(LDLIBS)
LDFLAGS   := $(COS_LDFLAGS) $(LDFLAGS)
DEPS      := $(COS_DEPS) $(DEPS)

IDL_INCL="-I$(MICO_HOME)/include/mico -I$(MICO_HOME)/include"

IDL_FILES= examples/Converter.idl \
           examples/ConverterHome.idl \
           javax/ejb/EJBHome.idl \
           javax/ejb/EJBMetaData.idl \
           javax/ejb/HomeHandle.idl \
           javax/ejb/RemoveException.idl \
           javax/ejb/RemoveEx.idl \
           javax/ejb/Handle.idl \
           javax/ejb/EJBObject.idl \
           javax/ejb/CreateException.idl \
           javax/ejb/CreateEx.idl \
           java/lang/Throwable.idl \
           java/lang/ThrowableEx.idl \
           java/lang/Exception.idl \
           java/lang/Ex.idl \
           java/lang/Object.idl

examples/Converter.idl: examples/Converter.class
	rmic -classpath $(JBOSS_HOME)/client/jboss-j2ee.jar:. \
             -idl -noValueMethods examples.Converter

examples/ConverterHome.idl: examples/ConverterHome.class
	rmic -classpath $(JBOSS_HOME)/client/jboss-j2ee.jar:. \
             -idl -noValueMethods examples.ConverterHome

Converter.jar: examples/Converter.class examples/ConverterHome.class \
               examples/ConverterBean.class \
               META-INF/ejb-jar.xml META-INF/jboss.xml
	jar cf Converter.jar $+

client: client.o $(subst .idl,.o,$(IDL_FILES)) $(DEPS)
	$(LD) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) $(subst .idl,.o,$(IDL_FILES)) $< -o $@

client.o: client.cc $(subst .idl,.h,$(IDL_FILES))

clean:
	rm -f .depend core client *.o *.jar `find . -name '*~' -print`
	rm -f examples/*.idl examples/*.cc examples/*.h examples/*.o
	rm -f examples/corba/*.java examples/corba/*.class examples/corba/*.o
	rm -f examples/corba/*.h examples/corba/*.cc examples/*.class 
	rm -rf java javax org

install:
	$(IDIRCMD) $(SHARED_INSTDIR)/doc/mico/examples/interop/jboss/jdk1.3.x/converter-ejb/META-INF
	$(IDIRCMD) $(SHARED_INSTDIR)/doc/mico/examples/interop/jboss/jdk1.3.x/converter-ejb/examples
	$(ISRCCMD) Makefile $(SHARED_INSTDIR)/doc/mico/examples/interop/jboss/jdk1.3.x/converter-ejb
	$(ISRCCMD) client.cc $(SHARED_INSTDIR)/doc/mico/examples/interop/jboss/jdk1.3.x/converter-ejb
	$(ISCRIPTCMD) run-client $(SHARED_INSTDIR)/doc/mico/examples/interop/jboss/jdk1.3.x/converter-ejb
	$(ISRCCMD) META-INF/ejb-jar.xml $(SHARED_INSTDIR)/doc/mico/examples/interop/jboss/jdk1.3.x/converter-ejb/META-INF
	$(ISRCCMD) META-INF/jboss.xml $(SHARED_INSTDIR)/doc/mico/examples/interop/jboss/jdk1.3.x/converter-ejb/META-INF
	$(ISRCCMD) examples/Converter.java $(SHARED_INSTDIR)/doc/mico/examples/interop/jboss/jdk1.3.x/converter-ejb/examples
	$(ISRCCMD) examples/ConverterBean.java $(SHARED_INSTDIR)/doc/mico/examples/interop/jboss/jdk1.3.x/converter-ejb/examples
	$(ISRCCMD) examples/ConverterHome.java $(SHARED_INSTDIR)/doc/mico/examples/interop/jboss/jdk1.3.x/converter-ejb/examples

