# Native support for Management Java library
#
# Copyright (c) 1998
#	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) $(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=	libmanagement
LIB=		$(LIBNAME)$(LIBEXT)
LIBV=		$(LIBNAME)$(LIBEXT).$(KVER)

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

OBJECT.KAFFE.MANAGEMENT=\
		Classpath$(OBJEXT)

OBJECT=		$(OBJECT.KAFFE.MANAGEMENT)

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

all:		$(LIB)

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

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

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

.SUFFIXES: .d

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

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

distclean:	clean
		rm -f Makefile .depend

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

derived-files:

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

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

@INC_DEPEND@
