# Native support for zip Java library
#
# 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) $(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@ @ZIP_LIBRARIES@
KVER=		@KVER@
OBJEXT=		@OBJEXT@
LIBEXT=		@LIBEXT@

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

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

OBJECT.UTIL.ZIP=\
		Adler32$(OBJEXT) \
		CRC32$(OBJEXT) \
		Deflater$(OBJEXT) \
		Inflater$(OBJEXT)

OBJECT=		$(OBJECT.UTIL.ZIP)

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: $(SOURCES)
		echo '#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)' > external_wrappers.h
		sed -n $(WRAPPER_CMD) $(srcdir)/*.c >> external_wrappers.h
		echo '#endif /* defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) */' >> 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:         $(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 $(LLIB)
		touch lib.exp

@INC_DEPEND@
