# Makefile for the native parts of the au.com.pharos.gdbm
# Java package.
# Modified by kjdon 2005

# Copyright (C) 1997 by Pharos IP Pty Ltd
#
# 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.

#srcdir=@srcdir@
libdir=@libdir@

CC=@CC@
CFLAGS=-c @CFLAGS@ @ARCH_DEP_FLAGS@ $(INC) -DWRAPPER_VERSION=\"$(WRAPPER_VERSION)\" 
#PKG=@PKG@
GDBM_LIBS=@GDBM_LIBPATH@ -lgdbm
LIBS= $(GDBM_LIBS) @LIBS@
LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@
JNIPREFIX=@JNIPREFIX@
JNICFLAGS=@JNICFLAGS@
JNILDFLAGS=@JNILDFLAGS@
JNISUFFIX=@JNISUFFIX@
JNIINC=@JNIINC@
INC=-I. -I$(JAVA_HOME)/include @GDBM_INCLUDE@ @JNIINC@


# TODO: Build versioned shared libraries?

# TODO: Build shared libraries in a way that will work on different
# platforms -- mbp

WRAPPER_VERSION=0005
NATIVE_LIB=$(JNIPREFIX)gdbmjava.$(JNISUFFIX)

all: $(NATIVE_LIB)

$(NATIVE_LIB): au_com_pharos_gdbm_GdbmFile.h gdbmjava.o Makefile
	$(CC) $(LDFLAGS) $(JNILDFLAGS) -o $(NATIVE_LIB) gdbmjava.o $(LIBS)

gdbmjava.o: gdbmjava.c	
	$(CC) $(INC) $(CFLAGS) $(JNICFLAGS) $?

clean:	
	rm -f  *.o $(NATIVE_LIB) 

distclean: clean
	rm -f Makefile

install: 
	cp $(NATIVE_LIB) $(libdir)/
