#
#  Bacula Director Makefile
#
#  Version $Id: Makefile.in,v 1.31.8.1 2004/06/20 11:43:02 kerns Exp $
#  
@MCOMMON@

srcdir =	.
VPATH = 	.
.PATH:		.

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

DEBUG=@DEBUG@

first_rule: all
dummy:

#
SVRSRCS = dird.c admin.c authenticate.c \
	  autoprune.c backup.c bsr.c \
	  catreq.c dird_conf.c expand.c \
	  fd_cmds.c getmsg.c inc_conf.c job.c \
	  jobq.c mountreq.c msgchan.c next_vol.c newvol.c \
	  recycle.c restore.c run_conf.c \
	  scheduler.c sql_cmds.c \
	  ua_acl.c ua_cmds.c ua_dotcmds.c \
	  ua_query.c \
	  ua_input.c ua_label.c ua_output.c ua_prune.c \
	  ua_purge.c ua_restore.c ua_run.c \
	  ua_select.c ua_server.c \
	  ua_status.c ua_tree.c verify.c
SVROBJS = dird.o admin.o authenticate.o \
	  autoprune.o backup.o bsr.o \
	  catreq.o dird_conf.o expand.o \
	  fd_cmds.o getmsg.o inc_conf.o job.o \
	  jobq.o mountreq.o msgchan.o next_vol.o newvol.o \
	  recycle.o restore.o run_conf.o \
	  scheduler.o sql_cmds.o \
	  ua_acl.o ua_cmds.o ua_dotcmds.o \
	  ua_query.o \
	  ua_input.o ua_label.o ua_output.o ua_prune.o \
	  ua_purge.o ua_restore.o ua_run.o \
	  ua_select.o ua_server.o \
	  ua_status.o ua_tree.o verify.o

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

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

# inference rules
.c.o:
	$(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $<
#-------------------------------------------------------------------------
all: Makefile bacula-dir @STATIC_DIR@
	@echo "==== Make of dird is good ===="
	@echo " "

bacula-dir:  $(SVROBJS) ../lib/libbac.a ../cats/libsql.a ../findlib/libfind.a
	$(CXX) $(WLDFLAGS) $(LDFLAGS) -L../lib -L../cats -L../findlib -o $@ $(SVROBJS) \
	      -lsql -lbac -lfind -lm $(DLIB) $(DB_LIBS) $(LIBS) 

static-bacula-dir:  $(SVROBJS) ../lib/libbac.a ../cats/libsql.a ../findlib/libfind.a
	$(CXX) $(WLDFLAGS) $(LDFLAGS) -static -L../lib -L../cats -L../findlib -o $@ $(SVROBJS) \
	      -lsql -lbac -lfind -lm $(DLIB) $(DB_LIBS) $(LIBS) 
	strip $@


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

clean:
	@$(RMF) dird bacula-dir core core.* a.out *.o *.bak *~ *.intpro *.extpro 1 2 3
	@$(RMF) static-bacula-dir

realclean: clean
	@$(RMF) tags bacula-dir.conf

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)

install: all
	$(INSTALL_PROGRAM) bacula-dir $(DESTDIR)$(sbindir)/bacula-dir
	@srcconf=bacula-dir.conf; \
	if  test -f ${DESTDIR}${sysconfdir}/$$srcconf; then \
	   destconf=$$srcconf.new; \
	   echo "  ==> Found existing $$srcconf, installing new conf file as $$destconf"; \
	else \
	   destconf=$$srcconf; \
	fi; \
	echo "${INSTALL_CONFIG} $$srcconf ${DESTDIR}${sysconfdir}/$$destconf"; \
	${INSTALL_CONFIG} $$srcconf ${DESTDIR}${sysconfdir}/$$destconf
	if  test -f ${DESTDIR}${scriptdir}/query.sql; then \
	   $(MV) -f ${DESTDIR}${scriptdir}/query.sql ${DESTDIR}${scriptdir}/query.sql.save; \
	fi 
	${INSTALL_DATA} query.sql ${DESTDIR}${scriptdir}/query.sql
	@if test -f static-bacula-dir; then \
	   $(INSTALL_PROGRAM) static-bacula-dir $(DESTDIR)$(sbindir)/static-bacula-dir; \
	fi


uninstall:
	(cd $(DESTDIR)$(sbindir); $(RMF) bacula-dir)
	(cd $(DESTDIR)$(sysconfdir); $(RMF) bacula-dir.conf bacula-dir.conf.new)
	(cd $(DESTDIR)$(scriptdir); $(RMF) query.sql)



# 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) $(XINC) -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
