#
# Bacula Tools Makefile
#
# Version $Id: Makefile.in,v 1.16.2.1 2004/06/20 11:43:04 kerns Exp $
#
@MCOMMON@

srcdir =	.
VPATH = 	.
.PATH:		.

# one up
basedir = ..
# top dir
topdir = ../..
# this dir relative to top dir
thisdir = src/tools

DEBUG=@DEBUG@

first_rule: all
dummy:

#

FINDOBJS = testfind.o

# these are the objects that are changed by the .configure process
EXTRAOBJS = @OBJLIST@

DIRCONFOBJS = ../dird/dird_conf.o ../dird/run_conf.o ../dird/inc_conf.o

.SUFFIXES:	.c .o
.PHONY:
.DONTCARE:

# inference rules
.c.o:
	$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $<
#-------------------------------------------------------------------------
all: Makefile bsmtp dbcheck testfind testls 
	@echo "==== Make of tools is good ===="
	@echo " "

bsmtp:	bsmtp.o ../lib/libbac.a        
	$(CXX) $(LDFLAGS) -L../lib -o $@ bsmtp.o -lbac -lm $(DLIB) $(LIBS) 

dbcheck: dbcheck.o ../lib/libbac.a ../cats/libsql.a $(DIRCONFOBJS)
	$(CXX) $(LDFLAGS) -L../lib -L../cats -o $@ dbcheck.o $(DIRCONFOBJS) -lsql -lbac -lm $(DB_LIBS) $(LIBS) 

testfind: ../findlib/libfind.a ../lib/libbac.a $(FINDOBJS)
	$(CXX) -g $(LDFLAGS) -L. -L../lib -L../findlib -o $@ $(FINDOBJS) \
	  $(DLIB) -lfind -lbac -lm $(LIBS) 

testls: ../findlib/libfind.a ../lib/libbac.a testls.o
	$(CXX) -g $(LDFLAGS) -L. -L../lib -L../findlib -o $@ testls.o \
	  $(DLIB) -lfind -lbac -lm $(LIBS) 

Makefile: $(srcdir)/Makefile.in $(topdir)/config.status
	cd $(topdir) \
	  && CONFIG_FILES=$(thisdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status

clean:
	@$(RMF) bsmtp core core.* a.out *.o *.bak *~ *.intpro *.extpro 1 2 3
	@$(RMF) testfind dbcheck testls

realclean: clean
	@$(RMF) tags

distclean: realclean
	if test $(srcdir) = .; then $(MAKE) realclean; fi
	(cd $(srcdir); $(RMF) Makefile; $(RMF) -r CVS)

devclean: realclean
	if test $(srcdir) = .; then $(MAKE) realclean; fi
	(cd $(srcdir); $(RMF) Makefile)

# Allow non-root execution of bsmtp for non-root Directors
install: bsmtp
	$(INSTALL_PROGRAM) bsmtp $(DESTDIR)$(sbindir)/bsmtp	 
	chmod 755 $(DESTDIR)$(sbindir)/bsmtp
	$(INSTALL_PROGRAM) dbcheck $(DESTDIR)$(sbindir)/dbcheck      

uninstall:
	(cd $(DESTDIR)$(sbindir); $(RMF) bsmtp)
	(cd $(DESTDIR)$(sbindir); $(RMF) dbcheck)



# Semi-automatic generation of dependencies:
# Use gcc -MM because X11 `makedepend' doesn't work on all systems
# and it also includes system headers.
# `semi'-automatic since dependencies are generated at distribution time.

depend:
	@$(MV) Makefile Makefile.bak
	@$(SED) "/^# DO NOT DELETE:/,$$ d" Makefile.bak > Makefile
	@$(ECHO) "# DO NOT DELETE: nice dependency list follows" >> Makefile
	@$(CC) -S -M $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >> Makefile
	@if test -f Makefile ; then \
	    $(RMF) Makefile.bak; \
	else \
	   $(MV) Makefile.bak Makefile; \
	   echo -e "Something went wrong\n\a"; \
	fi

# -----------------------------------------------------------------------
# DO NOT DELETE: nice dependency list follows
