# Native support for standard Java libraries
#
# Copyright (c) 1996, 1997
#	Transvirtual Technologies, Inc.  All rights reserved.
#
# See the file "lib-license.terms" for information on usage and redistribution 
# of this file. 

@VPATHOPT@=	@srcdir@
srcdir=		@srcdir@
prefix=		@prefix@
exec_prefix=	@exec_prefix@
nativedir=	@nativedir@
INSTROOT=	@INSTROOT@
CC=		@CC@
LD=		@LD@
AR=		@AR@
RANLIB=		@RANLIB@
INCLUDES=	-I$(srcdir) -I../../../include -I$(srcdir)/../../../include -I../../../config -I$(srcdir)/../../../config
CPPFLAGS=	@CPPFLAGS@
CFLAGS=		@CFLAGS@
ALL_CFLAGS=	$(INCLUDES) $(CPPFLAGS) $(CFLAGS) @KAFFEVMFLAGS@ $(EXTRA_CFLAGS)
INSTALL=	@INSTALL@
INSTALL_DATA=	@INSTALL_DATA@
MKDIR=		@MKDIR@
LN=		@LN_S@
DLLTOOL=	@DLLTOOL@
DEPTOOL=	@DEPTOOL@
PIC=		@PIC@
LDFLAGS=	@LIBSHARE@ @LDFLAGS@
LIBS=		@LIBS@
LDTAIL=		@LDTAIL@ @STD_LIBRARIES@
KVER=		@KVER@
OBJEXT=		@OBJEXT@
LIBEXT=		@LIBEXT@

LIBNAME=	libnative
LIB=		$(LIBNAME)$(LIBEXT).$(KVER)
LLIB=		$(LIBNAME)$(LIBEXT)

WRAPPER_CMD=	"s%^\([Jj]ava_[^(]*\).*$$%KAFFE_NATIVE(\1)%p"

OBJECT.IO=\
		FileDescriptor$(OBJEXT) \
		FileInputStream$(OBJEXT) \
		FileOutputStream$(OBJEXT) \
		File$(OBJEXT) \
		ObjectInputStream$(OBJEXT) \
		ObjectOutputStream$(OBJEXT) \
		ObjectStreamClass$(OBJEXT) \
		RandomAccessFile$(OBJEXT)

OBJECT.LANG=\
		ClassLoader$(OBJEXT) \
		Class$(OBJEXT) \
		Compiler$(OBJEXT) \
		Double$(OBJEXT) \
		Float$(OBJEXT) \
		Math$(OBJEXT) \
		Object$(OBJEXT) \
		Runtime$(OBJEXT) \
		SecurityManager$(OBJEXT) \
		String$(OBJEXT) \
		System$(OBJEXT) \
		Thread$(OBJEXT) \
		Throwable$(OBJEXT) \
		UNIXProcess$(OBJEXT) \
		CharToByteDefault$(OBJEXT) \
		ByteToCharDefault$(OBJEXT) \
		ZipFile$(OBJEXT)

OBJECT.LANG.REFLECT=\
		Array$(OBJEXT) \
		Constructor$(OBJEXT) \
		Field$(OBJEXT) \
		Method$(OBJEXT)

OBJECT.TEXT=\
		DateFormat$(OBJEXT)

OBJECT.TEST=\
		TestNative$(OBJEXT)

OBJECT=		$(OBJECT.LANG) $(OBJECT.LANG.REFLECT) \
		$(OBJECT.IO) $(OBJECT.TEXT) $(OBJECT.TEST)

DEPENDS=        $(OBJECT:@OBJEXT@=.d)
SOURCES=        $(OBJECT:@OBJEXT@=.c)

all:		$(LLIB)

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

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

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

external_wrappers.h: external_wrappers.h.debug $(SOURCES)
		sed -n $(WRAPPER_CMD) $(srcdir)/*.c > external_wrappers.h
		cat $(srcdir)/external_wrappers.h.debug >> external_wrappers.h

.SUFFIXES: .d
 
.c.d: 
		$(DEPTOOL) $(ALL_CFLAGS) $< > $@

clean:
		rm -f $(LLIB) $(LIB) $(OBJECT) lib.exp
		rm -f $(DEPENDS) .depend external_wrappers.h
		touch .depend

distclean:	clean
		rm -f Makefile .depend

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

derived-files:	

depend:		external_wrappers.h $(DEPENDS)
		rm -f .depend
		cat $(DEPENDS) > .depend

lib.exp:
		$(DLLTOOL) --def $(srcdir)/$(LIBNAME).def --output-exp lib.exp --output-lib $(LIBNAME).a --dllname $(LLIB)
		touch lib.exp

@INC_DEPEND@
