1#
2# Simple Makefile for building test FD plugins for Bacula
3#
4# Copyright (C) 2000-2015 by Kern Sibbald
5# License: BSD 2-Clause; see file LICENSE-FOSS
6#
7#
8@MCOMMON@
9
10# No optimization for now for easy debugging
11
12FDDIR=../../../filed
13SRCDIR=../../..
14LIBDIR=../../../lib
15FDPLUGDIR=..
16
17topdir = @BUILD_DIR@
18working_dir=@working_dir@
19thisdir = src/plugins/fd/docker
20
21DOCKERSRC = dkid.c dkinfo.c dkcommctx.c docker-fd.c
22DOCKERSRCH = dkid.h dkinfo.h dkcommctx.h docker-fd.h
23DOCKEROBJ = $(DOCKERSRC:.c=.lo)
24
25.SUFFIXES:    .c .lo
26
27all: docker-fd.la
28
29.c.lo:
30	@echo "Compiling $< ..."
31	$(NO_ECHO)$(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) $(CFLAGS) -I${SRCDIR} -I${FDDIR} -I${FDPLUGDIR} -DWORKDIR=\"$(DESTDIR)$(working_dir)\" -c $<
32
33%.lo: %.c %.h Makefile
34	@echo "Compiling $< ..."
35	$(NO_ECHO)$(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) $(CPPFLAGS) $(CFLAGS) -I${SRCDIR} -I${FDDIR} -I${FDPLUGDIR} -DWORKDIR=\"$(DESTDIR)$(working_dir)\" -c $(@:.lo=.c)
36
37$(FDPLUGDIR)/pluglib.lo:
38	$(MAKE) -C $(FDPLUGDIR) pluglib.lo
39
40docker-fd.la: Makefile $(DOCKEROBJ) $(FDPLUGDIR)/pluglib.lo $(DOCKERSRCH)
41	@echo "Linking $(@:.la=.so) ..."
42	$(NO_ECHO)$(LIBTOOL_LINK) --silent $(CXX) $(LDFLAGS) -shared $^ -o $@ -rpath $(plugindir) -module -export-dynamic -avoid-version
43
44$(LIBDIR)/unittests.o: $(LIBDIR)/unittests.c
45	$(MAKE) -C $(LIBDIR) unittests.o
46
47test_dkid: Makefile dkid.c $(LIBDIR)/unittests.o
48	$(RMF) dkid.o
49	$(CXX) -DTEST_PROGRAM $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(SRCDIR) -I$(LIBDIR) $(DINCLUDE) $(CFLAGS) dkid.c
50	$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -L$(LIBDIR) -o $@ dkid.o $(LIBDIR)/unittests.o $(DLIB) -lbac -lm $(LIBS) $(OPENSSL_LIBS)
51	$(RMF) dkid.o
52
53install: all
54	$(MKDIR) $(DESTDIR)$(plugindir)
55	$(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) docker-fd.la $(DESTDIR)$(plugindir)
56	$(NO_ECHO)$(RMF) $(DESTDIR)$(plugindir)/docker-fd.la
57
58install-test-plugin: all
59	$(MKDIR) $(DESTDIR)$(plugindir)
60	$(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) docker-fd.la $(DESTDIR)$(plugindir)
61	$(NO_ECHO)$(RMF) $(DESTDIR)$(plugindir)/docker-fd.la
62	$(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) test_docker $(DESTDIR)$(sbindir)
63
64Makefile: Makefile.in $(topdir)/config.status
65	cd $(topdir) \
66	  && CONFIG_FILES=$(thisdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
67
68libtool-clean:
69	@find . -name '*.lo' -print | xargs $(LIBTOOL_CLEAN) $(RMF)
70	@$(RMF) *.la
71	@$(RMF) -r .libs _libs
72
73test_docker-clean:
74	@$(RMF) test_docker
75
76clean:	libtool-clean test_docker-clean
77	@rm -f main *.so *.o
78
79distclean: clean
80	@rm -f Makefile *.la *.lo
81	@rm -rf .libs
82
83libtool-uninstall:
84	$(LIBTOOL_UNINSTALL) $(RMF) $(DESTDIR)$(plugindir)/docker-fd.so
85	$(LIBTOOL_UNINSTALL) $(RMF) $(DESTDIR)$(plugindir)/test_docker
86
87uninstall: @LIBTOOL_UNINSTALL_TARGET@
88
89depend:
90