VPATH=		@srcdir@
srcdir=		@srcdir@
prefix=		@prefix@
exec_prefix=	@exec_prefix@
libdir=		@libdir@
CC=		@CC@
LD=		@LD@
AR=		@AR@
RANLIB=		@RANLIB@
INCLUDES=	-I$(srcdir) -I../../../../include -I$(srcdir)/../../../../include -I../../../../config -I$(srcdir)/../../../../config -I$(srcdir)/../../../../kaffe/kaffevm -I$(srcdir)/../../../tjwassoc.co.uk/APIcore/lib/java.lang.reflect.stubs
CFLAGS=		@CFLAGS@
MY_ENGINE_CFLAGS=`echo '$(ENGINE_CFLAGS)' | sed -e s%/jit%/../../../../kaffe/kaffevm/jit%g -e s%/intrp%/../../../../kaffe/kaffevm/intrp%g`
ALL_CFLAGS=	$(CFLAGS) @KAFFEVMFLAGS@ $(INCLUDES) $(MY_ENGINE_CFLAGS)
INSTALL=	@INSTALL@
INSTALL_DATA=	@INSTALL_DATA@
MKDIR=		@MKDIR@
LN=		@LN_S@
DLLTOOL=	@DLLTOOL@
PIC=		@PIC@
LDFLAGS=	@LIBSHARE@
LIBS=		@LIBS@
LDTAIL=		@LDTAIL@ @STD_LIBRARIES@
KVER=		@KVER@
OBJEXT=		@OBJEXT@
LIBEXT=		@LIBEXT@
PATHSEP=	@PATHSEP@

LIBREV=	0.1
LIBNAME=	libguarana
LIB=		$(LIBNAME)$(LIBEXT).$(LIBREV)
LLIB=		$(LIBNAME)$(LIBEXT)

OBJECT =\
		GuaraNative.o \
		Guarana.o \
		GuaranaStub.o \
		Operation.o \
		OperationStub.o \
		OperationFactoryInternal.o \
		OperationFactoryInternalStub.o \
		Result.o \
		ResultStub.o

all:		$(LLIB)

$(LLIB):	$(LIB)
		rm -f $(LLIB)
		$(LN) $(LIB) $(LLIB)

$(LIB):		$(OBJECT) lib.exp
		@LINKLIB@

.c$(OBJEXT):
		$(CC) $(ALL_CFLAGS) -c $(PIC) $<

clean::
		rm -f $(LLIB) $(LIB) $(OBJECT) lib.exp

distclean:	clean
		rm -f Makefile

install::
		test -d $(libdir) || $(MKDIR) $(libdir)
		$(INSTALL_DATA) $(LIB) $(libdir)/$(LIB)
		rm -f $(libdir)/$(LLIB)
		$(LN) $(LIB) $(libdir)/$(LLIB)

lib.exp:
		$(DLLTOOL) --def $(srcdir)/`echo $(LIBNAME) | sed 's/^lib/libkaffe_/'`.def --output-exp lib.exp --output-lib $(LIBNAME).a --dllname $(LLIB)
		touch lib.exp

#--------------------------------------------------------------------------
# Build stubs.

CLASSPATH=	../../../javasoft.com/APIcore/classes/classes.zip$(PATHSEP)../classes/guarana.jar
KAFFEH=		kaffeh
PROG_JAVAH=	$(KAFFEH) -classpath "$(CLASSPATH)"

JAVAH_INCLUDE=\
		BR.unicamp.Guarana.Guarana \
		BR.unicamp.Guarana.Operation \
		BR.unicamp.Guarana.OperationFactoryInternal \
		BR.unicamp.Guarana.Result

JAVAH_STUB=\
		BR.unicamp.Guarana.Guarana \
		BR.unicamp.Guarana.Operation \
		BR.unicamp.Guarana.OperationFactoryInternal \
		BR.unicamp.Guarana.Result

stubs:
		cd $(srcdir) && $(PROG_JAVAH) -base $(JAVAH_INCLUDE)
		cd $(srcdir) && $(PROG_JAVAH) -postfix Stub -base -stubs $(JAVAH_STUB)

@engine_frag@
