#
# Simple Makefile for building test FD plugins for Bacula
#
# Copyright (C) 2000-2015 by Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
#
@MCOMMON@


# No optimization for now for easy debugging

FDDIR=../../filed
SRCDIR=../..
LIBDIR=../../lib

.SUFFIXES:    .c .lo

.c.lo:
	$(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) -I${SRCDIR} -I${FDDIR} -DTEST_PROGRAM -c $<

all: bpipe-fd.la test-plugin-fd.la test-deltaseq-fd.la

example-plugin-fd.lo: example-plugin-fd.c ${FDDIR}/fd_plugins.h
	$(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) $(CFLAGS) -I../.. -I${FDDIR} -c example-plugin-fd.c

example-plugin-fd.la: Makefile example-plugin-fd$(DEFAULT_OBJECT_TYPE)
	$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -shared example-plugin-fd.lo -o $@ -rpath $(plugindir) -module -export-dynamic -avoid-version

bpipe-fd.lo: bpipe-fd.c ${FDDIR}/fd_plugins.h
	$(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) $(CFLAGS) -I../.. -I${FDDIR} -c bpipe-fd.c

bpipe-fd.la: Makefile bpipe-fd$(DEFAULT_OBJECT_TYPE)
	$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -shared bpipe-fd.lo -o $@ -rpath $(plugindir) -module -export-dynamic -avoid-version 

test-deltaseq-fd.lo: test-deltaseq-fd.c ${FDDIR}/fd_plugins.h fd_common.h
	$(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) $(CFLAGS) -I../.. -I${FDDIR} -c test-deltaseq-fd.c

test-deltaseq-fd.la: Makefile test-deltaseq-fd$(DEFAULT_OBJECT_TYPE)
	$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -shared test-deltaseq-fd.lo -o $@ -rpath $(plugindir) -module -export-dynamic -avoid-version 

test-plugin-fd.lo: test-plugin-fd.c ${FDDIR}/fd_plugins.h
	$(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) $(CFLAGS) -I../.. -I${FDDIR} -c test-plugin-fd.c

test-plugin-fd.la: Makefile test-plugin-fd$(DEFAULT_OBJECT_TYPE)
	$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -shared test-plugin-fd.lo -o $@ -rpath $(plugindir) -module -export-dynamic -avoid-version 

install: all
	$(MKDIR) $(DESTDIR)$(plugindir)
	$(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) bpipe-fd.la $(DESTDIR)$(plugindir)
	$(RMF) $(DESTDIR)$(plugindir)/bpipe-fd.la

install-test-plugin: all
	$(MKDIR) $(DESTDIR)$(plugindir)
	$(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) test-plugin-fd.la $(DESTDIR)$(plugindir)
	$(RMF) $(DESTDIR)$(plugindir)/test-plugin-fd.la
	$(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) test-deltaseq-fd.la $(DESTDIR)$(plugindir)
	$(RMF) $(DESTDIR)$(plugindir)/test-deltaseq-fd.la

libtool-clean:
	@find . -name '*.lo' -print | xargs $(LIBTOOL_CLEAN) $(RMF)
	@$(RMF) *.la
	@$(RMF) -r .libs _libs

clean:	libtool-clean
	@rm -f main *.so *.o 1 2 3

distclean: clean
	@rm -f Makefile *.la *.lo
	@rm -rf .libs

libtool-uninstall:
	$(LIBTOOL_UNINSTALL) $(RMF) $(DESTDIR)$(plugindir)/bpipe-fd.so

uninstall: @LIBTOOL_UNINSTALL_TARGET@

depend:
