# Install variables
prefix=@prefix@

#Pilot flags (include dir), and Libraries
PILOT_FLAGS=@PILOT_FLAGS@
PILOT_LIBS=@PILOT_LIBS@

#set CC to your compiler
CC = @CC@

# CC options
CCDEFINES = @DEFS@
CFLAGS = @cflags@

# CC options
OPTIONS = @ccoptions@ $(CFLAGS)

# GTK+ flags
GTKFLAGS = @GTK_CFLAGS@
# GTK+ libs
GTKLIBS = @GTK_LIBS@

# Targets
all: libplugin.h libplugin.la libexpense.so

libexpense.so: expense.o
	../libtool --mode=link \
	$(CC) $(OPTIONS) -o libexpense.la \
	expense.lo ../libplugin.lo \
	-rpath $(prefix)/lib/jpilot/plugins \
	-version-info 1:1
#	-L. -lplugin
#	ld -shared -ldl -o libexpense.so expense.o -L. -lplugin

expense.o: expense.c libplugin.h
	../libtool --mode=compile \
	$(CC) $(OPTIONS) $(GTKFLAGS) $(PILOT_FLAGS) -c expense.c

libplugin.h: ../libplugin.h
	rm -f libplugin.h; ln -s ../libplugin.h libplugin.h; \

libplugin.la: ../libplugin.c
	rm -f libplugin.la; ln -s ../libplugin.la libplugin.la; \
	cd ..; make libplugin

clean: 
	rm -f *.o *~ config.cache .libs/* *.so *.so.? *.so.?.? *.lo

distclean: clean
	rm -f config.status config.log *.so Makefile

#
# This is a global install.  You can also install per user in
# ~/.jpilot/plugins
#
install:
	./install-sh -d -m 755 $(prefix)/lib/jpilot; \
	./install-sh -d -m 755 $(prefix)/lib/jpilot/plugins; \
	../libtool --mode=install ./install-sh \
	libexpense.la $(prefix)/lib/jpilot/plugins

uninstall:
	rm -f $(prefix)/lib/jpilot/plugins/libexpense.so*
