################### Start of $RCSfile: Makefile.in,v $ ##################
#
# $Source: /home/alb/afbackup/afbackup-3.5.2.1/RCS/Makefile.in,v $
# $Id: Makefile.in,v 1.8 2007/11/14 21:12:23 alb Exp alb $
# $Date: 2007/11/14 21:12:23 $
# $Author: alb $
#
####### description ################################################
#
#
#
####################################################################

SHELL		=	/bin/sh

CC		=	@CC@

MAKECMD		=	make

STRIP		=	@STRIP@

OSNAME		=	@osname@

PACKAGE		=	@PACKAGE@
VERSION		=	@VERSION@

SUBDIRS		=	intl po

X_INCLUDE	=	.
X_LIBS		=	.

OPTIMIZE	=	@OPTIMIZE@
DEBUG		=	

INCLUDES	=	-I$(X_INCLUDE) @INCLUDES@ @DESINCLUDEPATH@ @ZLIB_INCLUDEPATH@
DEFINES		=	-D$(OSNAME) -DOSNAME=$(OSNAME) @SYSDEFINES@ \
				@DESDEFINES@ @ZLIB_DEFINES@

CPPFLAGS	=	$(INCLUDES) $(DEFINES) -DLOCALEDIR=\"$(LOCALEDIR)\" 

CFLAGS		=	$(DEBUG) $(OPTIMIZE) $(EXTRA_CFLAGS) @EXTRACFLAGS@

UTILSLIB	=	x_utils

X_HEADERS	=	crptauth.h	\
			fileutil.h	\
			mvals.h		\
			netutils.h	\
			packer.h	\
			sysutils.h	\
			genutils.h	\
			x_data.h	\
			x_defs.h	\
			x_errno.h	\
			x_regex.h	\
			x_timer.h	\
			x_types.h	\
			zutils.h

X_LIBTOOLS	=	prosname.sh	\
			prosspec.sh


BULIB		=	afbackup

LIBRARIES	=	-l$(BULIB) -l$(UTILSLIB) @LIBS@ @DESLIBPATH@ \
			@DESLIB@ @ZLIB_LIBPATH@ @ZLIB_LIB@ -lm @INTLLIBS@

LDFLAGS		=	-L$(X_LIBS) @LDFLAGS@ $(LIBRARIES) $(EXTRA_LD_FLAGS)

X_LIBSRCS	=	crptauth.c	\
			pack.c		\
			unpack.c	\
			genutils.c	\
			goptions.c	\
			fileutil.c	\
			x_regex.c	\
			mutils.c	\
			sysutils.c	\
			netutils.c	\
			timeutil.c	\
			typeutil.c	\
			safemem.c	\
			strlist.c	\
			ranges.c	\
			vars.c		\
			safewrap.c	\
			zutils.c

X_LIBOBJS	=	$(X_LIBSRCS:.c=.o)

BULIBSRCS	=	buutil.c	\
			prot.c

BULIBOBJS	=	$(BULIBSRCS:.c=.o)

CRYPTKEY	=	cryptkey.h

CL_HELPERS	=	__piper __packpats @DESCRPT@ @ZIP@
SV_HELPERS	=	__numset

PROGRAMS	=	afserver afmserver afclient cartready label_tape \
				full_backup $(CL_HELPERS) $(SV_HELPERS)

RESTRCLNTPROGS	=	afclient afbackup afrestore afverify copy_tape \
			full_backup incr_backup afbackout update_indexes \
			__descrpt
CLIENTPROGRAMS	=	$(RESTRCLNTPROGS) autocptapes afclientconfig \
			xafclientconfig xafrestore
RESTRSVRPROGS	=	afmserver afserver label_tape cartready changerready \
			cartis
SERVERPROGRAMS	=	$(RESTRSVRPROGS) afserverconfig cartagehandler \
			xafserverconfig xafserverstatus __inc_link __mt __numset

X_LIBRARY	=	lib$(UTILSLIB).a
BACKUPLIB	=	lib$(BULIB).a

BASELIBS	=	intllibs

TESTMAINSRCS	=	testmain.c
TESTMAINOBJS	=	$(TESTMAINSRCS:.c=.o)

SERVERSRCS	=	server.c
SERVEROBJS	=	$(SERVERSRCS:.c=.o)

MSERVERSRCS	=	mserver.c
MSERVEROBJS	=	$(MSERVERSRCS:.c=.o)

CARTRDYSRCS	=	cartready.c
CARTRDYOBJS	=	$(CARTRDYSRCS:.c=.o)

LABELTAPESRCS	=	label_tape.c
LABELTAPEOBJS	=	$(LABELTAPESRCS:.c=.o)

CLIENTSRCS	=	client.c
CLIENTOBJS	=	$(CLIENTSRCS:.c=.o)

FULLBUSRCS	=	full_backup.c
FULLBUOBJS	=	$(FULLBUSRCS:.c=.o)

TESTCLIENTSRCS	=	testclient.c
TESTCLIENTOBJS	=	$(TESTCLIENTSRCS:.c=.o)

SERVERCONFFILE	=	server.conf
CLIENTCONFFILE	=	client.conf

CHANGERCONFFILE	=	changer.conf

CLIENTLIBDIR	=	@clientlibdir@
CLIENTBINDIR	=	@clientbindir@
CLIENTVARDIR	=	@clientvardir@
CLIENTMANDIR	=	@clientmandir@
CLIENTCONFDIR	=	@clientconfdir@
SERVERLIBDIR	=	@serverlibdir@
SERVERBINDIR	=	@serverbindir@
SERVERVARDIR	=	@servervardir@
SERVERMANDIR	=	@servermandir@
SERVERCONFDIR	=	@serverconfdir@
SERVERINITDIR	=	$(SERVERCONFDIR)/init.d
SERVERREXECDIR	=	@REXECDIR@
COMMONDIR	=	@commondir@
COMMONDATADIR	=	@commondatadir@
COMMONSHLIBDIR	=	@commonshlibdir@

# Where to install locale stuff
prefix		=	@prefix@
datadir		=	$(COMMONDATADIR)
LOCALEDIR	=	$(datadir)/locale

CLIENTMANFILES	=	afclient.X	\
			afrestore.X	\
			afverify.X	\
			full_backup.X	\
			incr_backup.X	\
			copy_tape.X	\
			update_indexes.X	\
			xafrestore.X	\
			afclient.conf.X
SERVERMANFILES	=	afserver.X	\
			afmserver.X	\
			cartis.X	\
			cartready.X	\
			label_tape.X	\
			cart_ctl.X	\
			afserver.conf.X

SRCMANSUFFIX	=	8
DESTMANSUFFIX	=	8
CLIENTMANSRCS	=	$(CLIENTMANFILES:.X=.8)
SERVERMANSRCS	=	$(SERVERMANFILES:.X=.8)
#					     ^ this must be $(SRCMANSUFFIX)

INSTALL		=	cp

.c.o:	config.h
	$(CC) -c $(CPPFLAGS) $(CFLAGS) $<

all::	$(PROGRAMS) potfiles

server:	afserver potfiles
	@:

afserver:	$(CRYPTKEY) $(BACKUPLIB) $(X_LIBRARY) $(BASELIBS) $(SERVEROBJS) $(MSERVEROBJS) $(CARTRDYOBJS) $(LABELTAPEOBJS) xserverconfig xserverstatus $(SV_HELPERS)
	$(CC) -o afserver $(SERVEROBJS) $(LDFLAGS)
	$(CC) -o afmserver $(MSERVEROBJS) $(LDFLAGS)
	$(CC) -o cartready $(CARTRDYOBJS) $(LDFLAGS)
	$(CC) -o label_tape $(LABELTAPEOBJS) $(LDFLAGS)

$(SERVEROBJS):	$(CRYPTKEY)

cartready:	$(BACKUPLIB) $(X_LIBRARY) $(BASELIBS) $(CARTRDYOBJS)
	$(CC) -o cartready $(CARTRDYOBJS) $(LDFLAGS)

label_tape:	$(BACKUPLIB) $(X_LIBRARY) $(BASELIBS) $(LABELTAPEOBJS)
	$(CC) -o label_tape $(LABELTAPEOBJS) $(LDFLAGS)

client:	afclient potfiles
	@:

afclient:	$(CRYPTKEY) $(BACKUPLIB) $(X_LIBRARY) $(BASELIBS) $(CLIENTOBJS) $(FULLBUOBJS) xclientconfig xrestore $(CL_HELPERS)
	$(CC) -o afclient $(CLIENTOBJS) $(LDFLAGS)
	$(CC) -o full_backup $(FULLBUOBJS) $(LDFLAGS)

$(CLIENTOBJS):	$(CRYPTKEY)

$(CRYPTKEY):	ask_for_key
	@sh ./ask_for_key

potfiles: intllibs
	(cd po; $(MAKE) datadir=\"$(datadir)\" all)

intllibs:
	(cd intl; $(MAKE) all)

__piper:	__piper.o $(BACKUPLIB) $(X_LIBRARY)
	$(CC) -o __piper __piper.o $(LDFLAGS)

__packpats:	__packpats.o $(BACKUPLIB) $(X_LIBRARY)
	$(CC) -o __packpats __packpats.o $(LDFLAGS)

__numset:	__numset.o $(BACKUPLIB) $(X_LIBRARY)
	$(CC) -o __numset __numset.o $(LDFLAGS)

__descrpt:	$(CRYPTKEY) __descrpt.o $(BACKUPLIB) $(X_LIBRARY)
	$(CC) -o __descrpt __descrpt.o $(LDFLAGS)

__z:	__z.o $(BACKUPLIB) $(X_LIBRARY)
	$(CC) -o __z __z.o $(LDFLAGS)

$(BACKUPLIB):	$(BULIBOBJS)
	ar rcv $(BACKUPLIB) $(BULIBOBJS)
	if [ _@ranlib@ != _ ] ; then @ranlib@ $(BACKUPLIB) ; fi

$(X_LIBRARY):	$(X_LIBOBJS)
	ar rcv $(X_LIBRARY) $(X_LIBOBJS)
	if [ _@ranlib@ != _ ] ; then @ranlib@ $(X_LIBRARY) ; fi

$(UTILSLIB)::	$(X_LIBRARY) $(BASELIBS)

install.$(UTILSLIB): $(UTILSLIB)
	- mkdir -p @utilsincdir@ @utilsincdir@/$(OSNAME) @utilslibdir@ \
		@utilslibdir@/$(OSNAME) @utilsbindir@
	for i in $(X_HEADERS) ; do /bin/rm -f @utilsincdir@/$$i ; \
		$(INSTALL) $$i @utilsincdir@/$$i ; done
	for i in $(X_LIBRARY) ; do /bin/rm -f @utilslibdir@/$(OSNAME)/$$i ; \
		$(INSTALL) $$i @utilslibdir@/$(OSNAME)/$$i ; done
	/bin/rm -f @utilsincdir@/lconf.h @utilsincdir@/$(OSNAME)/lconf.h
	$(INSTALL) lconf.h @utilsincdir@/$(OSNAME)/lconf.h
	$(INSTALL) lconf.gen.h @utilsincdir@/lconf.h
	for i in $(X_LIBTOOLS) ; do /bin/rm -f @utilsbindir@/$$i ; \
		$(INSTALL) $$i @utilsbindir@/$$i ; done
	if [ _"@INTLDEPS@" != _ ] ; then \
		mkdir -p @utilslibdir@/$(OSNAME)/gnuintl && \
		$(INSTALL) @INTLDEPS@ @utilslibdir@/$(OSNAME)/gnuintl/`basename @INTLDEPS@` ; \
	fi
	if [ _"@INTL_HEADER@" != _ ] ; then \
		mkdir -p @utilsincdir@/$(OSNAME)/gnuintl/intl && \
		$(INSTALL) @INTL_HEADER@ @utilsincdir@/$(OSNAME)/gnuintl/intl/`basename @INTL_HEADER@` ; \
	fi

uninstall.$(UTILSLIB):
	if [ _"@INTL_HEADER@" != _ ] ; then \
		/bin/rm -f @utilsincdir@/$(OSNAME)/gnuintl/@INTL_HEADER@ ; \
		rmdir `dirname @utilsincdir@/$(OSNAME)/gnuintl/@INTL_HEADER@` >/dev/null 2>&1 ; \
	fi
	-rmdir @utilsincdir@/$(OSNAME)/gnuintl >/dev/null 2>&1
	if [ _"@INTLDEPS@" != _ ] ; then \
		/bin/rm -f @utilslibdir@/$(OSNAME)/gnuintl/@INTLDEPS@ ; \
		rmdir `dirname @utilslibdir@/$(OSNAME)/gnuintl/@INTLDEPS@` >/dev/null 2>&1 ; \
	fi
	-rmdir @utilslibdir@/$(OSNAME)/gnuintl ) >/dev/null 2>&1
	for i in $(X_LIBTOOLS) ; do \
		/bin/rm -f @utilsbindir@/$$i ; \
	done
	- rm -f @utilsincdir@/lconf.h @utilsincdir@/$(OSNAME)/lconf.h
	for i in $(X_LIBRARY) ; do \
		/bin/rm -f @utilslibdir@/$(OSNAME)/$$i ; \
	done
	for i in $(X_HEADERS) ; do \
		/bin/rm -f @utilsincdir@/$$i ; \
	done
	- rmdir @utilsbindir@		>/dev/null 2>&1
	- rmdir @utilslibdir@/$(OSNAME)	>/dev/null 2>&1
	- rmdir @utilslibdir@		>/dev/null 2>&1
	- rmdir @utilsincdir@/$(OSNAME)	>/dev/null 2>&1
	- rmdir @utilsincdir@		>/dev/null 2>&1

install:: install.client install.server install.client.man install.server.man

uninstall:: uninstall.client uninstall.server uninstall.client.man uninstall.server.man uninstall.$(UTILSLIB) uninstall.common

install.client: client full_backup install.client.man install.l10n
	- mkdir -p $(CLIENTBINDIR) $(CLIENTLIBDIR) $(CLIENTVARDIR) $(CLIENTCONFDIR) $(COMMONSHLIBDIR)
	- rm -f $(CLIENTBINDIR)/afclient
	$(INSTALL) afclient $(CLIENTBINDIR)/afclient
	- $(STRIP) $(CLIENTBINDIR)/afclient
	- rm -f $(CLIENTBINDIR)/backup $(CLIENTBINDIR)/afbackup
	ln -s afclient $(CLIENTBINDIR)/afbackup
	$(INSTALL) full_backup $(CLIENTBINDIR)/full_backup
	- $(STRIP) $(CLIENTBINDIR)/full_backup
	- rm -f $(CLIENTBINDIR)/incr_backup $(CLIENTBINDIR)/print_errors \
		$(CLIENTBINDIR)/afrestore $(CLIENTBINDIR)/afbackout \
		$(CLIENTBINDIR)/afverify $(CLIENTBINDIR)/copy_tape \
		$(CLIENTBINDIR)/update_indexes \
		$(CLIENTBINDIR)/clientconfig \
		$(CLIENTBINDIR)/afclientconfig \
		$(CLIENTBINDIR)/xclientconfig \
		$(CLIENTBINDIR)/xafclientconfig \
		$(CLIENTBINDIR)/xafrestore \
		$(CLIENTBINDIR)/xrestore \
		$(CLIENTBINDIR)/autocptapes
	ln -s full_backup $(CLIENTBINDIR)/incr_backup
	ln -s full_backup $(CLIENTBINDIR)/afverify
	ln -s full_backup $(CLIENTBINDIR)/copy_tape
	ln -s full_backup $(CLIENTBINDIR)/afbackout
	ln -s full_backup $(CLIENTBINDIR)/update_indexes
	ln -s afbackout $(CLIENTBINDIR)/afrestore
	$(INSTALL) clientconfig $(CLIENTBINDIR)/afclientconfig
	ln -s afclientconfig $(CLIENTBINDIR)/clientconfig
	$(INSTALL) xclientconfig $(CLIENTBINDIR)/xafclientconfig
	ln -s xafclientconfig $(CLIENTBINDIR)/xclientconfig
	$(INSTALL) xrestore $(CLIENTBINDIR)/xafrestore
	ln -s xafrestore $(CLIENTBINDIR)/xrestore
	$(INSTALL) autocptapes $(CLIENTBINDIR)/autocptapes
	- rm -f $(CLIENTBINDIR)/__packpats $(CLIENTBINDIR)/__piper
	$(INSTALL) __packpats $(CLIENTBINDIR)/__packpats
	$(INSTALL) __piper $(CLIENTBINDIR)/__piper
	$(STRIP) $(CLIENTBINDIR)/__piper
	if [ ! -z "@DESCRPT@" ] ; then \
		rm -f $(CLIENTBINDIR)/@DESCRPT@ ; \
		$(INSTALL) "@DESCRPT@" $(CLIENTBINDIR)/@DESCRPT@ ; \
		$(STRIP) $(CLIENTBINDIR)/@DESCRPT@ ; fi
	if [ ! -z "@ZIP@" ] ; then \
		rm -f $(CLIENTBINDIR)/@ZIP@ ; \
		$(INSTALL) "@ZIP@" $(CLIENTBINDIR)/@ZIP@ ; \
		$(STRIP) $(CLIENTBINDIR)/@ZIP@ ; fi
	- rm -f $(COMMONSHLIBDIR)/aftcllib.tcl $(CLIENTLIBDIR)/aftcllib.tcl
	$(INSTALL) aftcllib.tcl $(COMMONSHLIBDIR)/aftcllib.tcl
	chmod 644 $(COMMONSHLIBDIR)/aftcllib.tcl
	if [ -f $(CLIENTLIBDIR)/@clientconf@ ] ; then \
		if [ `ls -ld $(CLIENTLIBDIR)/@clientconf@ | cut -c1` != l ] ; then \
			/bin/mv $(CLIENTLIBDIR)/@clientconf@ $(CLIENTCONFDIR)/@clientconf@ ; \
			ln -s $(CLIENTCONFDIR)/@clientconf@ $(CLIENTLIBDIR)/@clientconf@ ; \
		fi \
	fi
	if [ ! -f $(CLIENTCONFDIR)/@clientconf@ ] ; then $(INSTALL) $(CLIENTCONFFILE) $(CLIENTCONFDIR)/@clientconf@ ; fi
	for cp in $(CLIENTPROGRAMS) ; do \
		if [ -f $(CLIENTBINDIR)/$$cp ] ; then \
		    chmod 755 $(CLIENTBINDIR)/$$cp ; fi ; done
	for cp in $(RESTRCLNTPROGS) ; do \
		if [ -f $(CLIENTBINDIR)/$$cp ] ; then \
		    chmod 700 $(CLIENTBINDIR)/$$cp ; fi ; done

uninstall.client: uninstall.client.man
	- rm -f $(COMMONSHLIBDIR)/aftcllib.tcl
	if [ ! -z "@ZIP@" ] ; then rm -f $(CLIENTBINDIR)/@ZIP@ ; fi
	if [ ! -z "@DESCRPT@" ] ; then rm -f $(CLIENTBINDIR)/@DESCRPT@ ; fi
	- rm -f $(CLIENTBINDIR)/__packpats $(CLIENTBINDIR)/__piper
	- rm -f $(CLIENTBINDIR)/autocptapes
	- rm -f $(CLIENTBINDIR)/xrestore
	- rm -f $(CLIENTBINDIR)/xafrestore
	- rm -f $(CLIENTBINDIR)/xclientconfig
	- rm -f $(CLIENTBINDIR)/xafclientconfig
	- rm -f $(CLIENTBINDIR)/clientconfig
	- rm -f $(CLIENTBINDIR)/afclientconfig
	- rm -f $(CLIENTBINDIR)/afrestore
	- rm -f $(CLIENTBINDIR)/update_indexes
	- rm -f $(CLIENTBINDIR)/afbackout
	- rm -f $(CLIENTBINDIR)/copy_tape
	- rm -f $(CLIENTBINDIR)/afverify
	- rm -f $(CLIENTBINDIR)/incr_backup
	- rm -f $(CLIENTBINDIR)/print_errors
	- rm -f $(CLIENTBINDIR)/full_backup
	- rm -f $(CLIENTBINDIR)/afbackup
	- rm -f $(CLIENTBINDIR)/backup
	- rm -f $(CLIENTBINDIR)/afclient
	- rmdir $(CLIENTBINDIR) 
	- rmdir $(CLIENTVARDIR) 
	if [ -f $(CLIENTCONFDIR)/@clientconf@ ] ; then \
		cp -ip $(CLIENTCONFDIR)/@clientconf@ /tmp/@clientconf@.cl.bak ; \
		/bin/rm -f $(CLIENTCONFDIR)/@clientconf@ ; \
		echo "INFO: A backup of your client configuration is in /tmp/@clientconf@.cl.bak" ; \
	  fi
	if [ -f $(CLIENTLIBDIR)/@clientconf@ ] ; then \
		cp -ip $(CLIENTLIBDIR)/@clientconf@ /tmp/@clientconf@.cl.lbak ; \
		/bin/rm -f $(CLIENTLIBDIR)/@clientconf@ ; \
		echo "INFO: A backup of your client configuration is in /tmp/@clientconf@.cl.lbak" ; \
	  fi
	- rmdir $(CLIENTCONFDIR) 
	- rmdir $(CLIENTLIBDIR) 
	- D="$(CLIENTBINDIR)" ; \
	  while [ "$$D" != / ] ; do \
	    D=`dirname "$$D"` ; \
	    rmdir "$$D" >/dev/null 2>&1 ; \
	  done

install.server: server cartready label_tape install.server.man install.l10n
	- mkdir -p $(SERVERBINDIR) $(SERVERVARDIR) $(SERVERLIBDIR) $(SERVERCONFDIR) $(SERVERINITDIR) $(COMMONSHLIBDIR) $(SERVERREXECDIR)
	- rm -f $(SERVERBINDIR)/afserver $(SERVERBINDIR)/afmserver \
		$(SERVERBINDIR)/cartready $(SERVERBINDIR)/cartis \
		$(SERVERBINDIR)/label_tape $(SERVERBINDIR)/cart_ctl \
		$(SERVERBINDIR)/changerready \
		$(SERVERBINDIR)/__mt \
		$(SERVERBINDIR)/__inc_link \
		$(SERVERBINDIR)/serverconfig \
		$(SERVERBINDIR)/afserverconfig \
		$(SERVERBINDIR)/xafserverconfig \
		$(SERVERBINDIR)/xserverconfig \
		$(SERVERBINDIR)/xserverstatus
	$(INSTALL) afserver $(SERVERBINDIR)/afserver
	$(INSTALL) afmserver $(SERVERBINDIR)/afmserver
	$(INSTALL) cartready label_tape __mt __inc_link $(SERVERBINDIR)
	- $(STRIP) $(SERVERBINDIR)/afserver $(SERVERBINDIR)/cartready $(SERVERBINDIR)/label_tape
	ln -s label_tape $(SERVERBINDIR)/cart_ctl
	ln -s label_tape $(SERVERBINDIR)/cartis
	ln -s cartready $(SERVERBINDIR)/changerready
	$(INSTALL) serverconfig $(SERVERBINDIR)/afserverconfig
	ln -s afserverconfig $(SERVERBINDIR)/serverconfig
	$(INSTALL) xserverconfig $(SERVERBINDIR)/xafserverconfig
	ln -s xafserverconfig $(SERVERBINDIR)/xserverconfig
	$(INSTALL) xserverstatus $(SERVERBINDIR)/xafserverstatus
	ln -s xafserverstatus $(SERVERBINDIR)/xserverstatus
	- rm -f $(COMMONSHLIBDIR)/aftcllib.tcl $(SERVERLIBDIR)/aftcllib.tcl
	$(INSTALL) aftcllib.tcl $(COMMONSHLIBDIR)/aftcllib.tcl
	chmod 644 $(COMMONSHLIBDIR)/aftcllib.tcl
	chmod u+s $(SERVERBINDIR)/cartready
	$(INSTALL) init.afbackup $(SERVERINITDIR)/afbackup
	chmod 755 $(SERVERINITDIR)/afbackup
	- rm -f $(SERVERBINDIR)/__numset
	$(INSTALL) __numset $(SERVERBINDIR)/__numset
	if [ ! -f $(SERVERBINDIR)/cartagehandler ] ; then $(INSTALL) cartagehandler $(SERVERBINDIR)/cartagehandler ; fi
	for sp in $(SERVERPROGRAMS) ; do \
		if [ -f $(SERVERBINDIR)/$$sp ] ; then \
		    chmod 755 $(SERVERBINDIR)/$$sp ; fi ; done
	for sp in $(RESTRSVRPROGS) ; do \
		if [ -f $(SERVERBINDIR)/$$sp ] ; then \
		    chmod 700 $(SERVERBINDIR)/$$sp ; fi ; done
	if [ -f $(SERVERLIBDIR)/@serverconf@ ] ; then \
		if [ `ls -ld $(SERVERLIBDIR)/@serverconf@ | cut -c1` != l ] ; then \
			/bin/mv $(SERVERLIBDIR)/@serverconf@ $(SERVERCONFDIR)/@serverconf@ ; \
			ln -s $(SERVERCONFDIR)/@serverconf@ $(SERVERLIBDIR)/@serverconf@ ; \
		fi \
	fi
	if [ ! -f $(SERVERCONFDIR)/@serverconf@ ] ; then $(INSTALL) $(SERVERCONFFILE) $(SERVERCONFDIR)/@serverconf@ ; fi
	if [ ! -f $(SERVERCONFDIR)/$(CHANGERCONFFILE) ] ; then $(INSTALL) $(CHANGERCONFFILE) $(SERVERCONFDIR)/$(CHANGERCONFFILE) ; fi
	-touch $(SERVERVARDIR)/readonly_tapes

uninstall.server: uninstall.rclient uninstall.server.man
	if [ -f $(SERVERBINDIR)/cartagehandler ] ; then /bin/rm -f $(SERVERBINDIR)/cartagehandler ; fi
	if [ -f $(SERVERVARDIR)/readonly_tapes ] ; then \
		if [ `wc -c < $(SERVERVARDIR)/readonly_tapes` -eq 0 ] ; then \
			/bin/rm -f $(SERVERVARDIR)/readonly_tapes ; \
		fi fi
	- rm -f $(SERVERBINDIR)/__numset
	- rm -f $(COMMONSHLIBDIR)/aftcllib.tcl
	- rm -f $(SERVERLIBDIR)/aftcllib.tcl
	- rm -f $(SERVERBINDIR)/xserverstatus
	- rm -f $(SERVERBINDIR)/xafserverstatus
	- rm -f $(SERVERBINDIR)/xserverconfig
	- rm -f $(SERVERBINDIR)/xafserverconfig
	- rm -f $(SERVERBINDIR)/serverconfig
	- rm -f $(SERVERBINDIR)/afserverconfig
	- rm -f $(SERVERBINDIR)/changerready
	- rm -f $(SERVERBINDIR)/cartis
	- rm -f $(SERVERBINDIR)/cart_ctl
	- rm -f $(SERVERBINDIR)/cartready 
	- rm -f $(SERVERBINDIR)/label_tape 
	- rm -f $(SERVERBINDIR)/__mt 
	- rm -f $(SERVERBINDIR)/__inc_link
	- rm -f $(SERVERBINDIR)/afmserver
	- rm -f $(SERVERBINDIR)/afserver
	- rmdir $(SERVERBINDIR) >/dev/null 2>&1
	- rmdir $(SERVERVARDIR) >/dev/null 2>&1
	- rm -f $(SERVERINITDIR)/afbackup >/dev/null 2>&1
	- rmdir $(SERVERINITDIR)
	if [ -f $(SERVERCONFDIR)/$(CHANGERCONFFILE) ] ; then /bin/rm -f $(SERVERCONFDIR)/$(CHANGERCONFFILE) ; fi
	if [ -f $(SERVERCONFDIR)/@serverconf@ ] ; then \
		cp -ip $(SERVERCONFDIR)/@serverconf@ /tmp/@serverconf@.sv.bak ; \
		/bin/rm -f $(SERVERCONFDIR)/@serverconf@ ; \
		echo "INFO: A backup of your server configuration is in /tmp/@serverconf@.sv.bak" ; \
	  fi
	if [ -f $(SERVERLIBDIR)/@serverconf@ ] ; then \
		cp -ip $(SERVERLIBDIR)/@serverconf@ /tmp/@serverconf@.sv.lbak ; \
		/bin/rm -f $(SERVERLIBDIR)/@serverconf@ ; \
		echo "INFO: A backup of your server configuration is in /tmp/@serverconf@.sv.lbak" ; \
	  fi
	- rmdir $(SERVERLIBDIR) >/dev/null 2>&1
	- rmdir $(SERVERCONFDIR) >/dev/null 2>&1
	- rmdir $(SERVERREXECDIR) >/dev/null 2>&1
	- D="$(SERVERBINDIR)" ; \
	  while [ "$$D" != / ] ; do \
	    D=`dirname "$$D"` ; \
	    rmdir "$$D" >/dev/null 2>&1 ; \
	  done

install.rclient: install.server install.client install.rexeclinks

uninstall.rclient: uninstall.rexeclinks

install.userrestore:
	/bin/rm -f $(CLIENTBINDIR)/afrestore $(CLIENTBINDIR)/afbackout \
		$(CLIENTBINDIR)/update_indexes
	/bin/cp $(CLIENTBINDIR)/full_backup $(CLIENTBINDIR)/afrestore
	ln -s afrestore $(CLIENTBINDIR)/afbackout
	ln -s afrestore $(CLIENTBINDIR)/update_indexes
	chmod 755 $(CLIENTBINDIR)/afrestore $(CLIENTBINDIR)/xafrestore
	chmod u+s $(CLIENTBINDIR)/afrestore

uninstall.userrestore:
	rm -f $(CLIENTBINDIR)/update_indexes
	rm -f $(CLIENTBINDIR)/afbackout
	rm -f $(CLIENTBINDIR)/afrestore

install.rexeclinks:
	( for i in full_backup incr_backup afverify afrestore copy_tape update_indexes ; do rm -f $(SERVERREXECDIR)/"$$i" ; ln -s $(CLIENTBINDIR)/"$$i" $(SERVERREXECDIR)/"$$i" ; done )

uninstall.rexeclinks:
	( for i in full_backup incr_backup afverify afrestore copy_tape update_indexes ; do rm -f $(SERVERREXECDIR)/"$$i" ; done )

install.client.man: $(CLIENTMANSRCS)
	- mkdir -p $(CLIENTMANDIR)/man$(DESTMANSUFFIX)
	( for mansrc in $(CLIENTMANSRCS) ; do destfile=`echo $$mansrc|sed 's/[.]'$(SRCMANSUFFIX)'$$/.'$(DESTMANSUFFIX)/g` ; $(INSTALL) $$mansrc $(CLIENTMANDIR)/man$(DESTMANSUFFIX)/$$destfile ; done )

uninstall.client.man:
	( for mansrc in $(CLIENTMANSRCS) ; do destfile=`echo $$mansrc|sed 's/[.]'$(SRCMANSUFFIX)'$$/.'$(DESTMANSUFFIX)/g` ; /bin/rm -f $(CLIENTMANDIR)/man$(DESTMANSUFFIX)/$$destfile ; done )
	- rmdir $(CLIENTMANDIR)/man$(DESTMANSUFFIX) $(CLIENTMANDIR) >/dev/null 2>&1

install.server.man: $(SERVERMANSRCS)
	- mkdir -p $(SERVERMANDIR)/man$(DESTMANSUFFIX)
	( for mansrc in $(SERVERMANSRCS) ; do destfile=`echo $$mansrc|sed 's/[.]'$(SRCMANSUFFIX)'$$/.'$(DESTMANSUFFIX)/g` ; $(INSTALL) $$mansrc $(SERVERMANDIR)/man$(DESTMANSUFFIX)/$$destfile ; done )

uninstall.server.man:
	( for mansrc in $(SERVERMANSRCS) ; do destfile=`echo $$mansrc|sed 's/[.]'$(SRCMANSUFFIX)'$$/.'$(DESTMANSUFFIX)/g` ; /bin/rm -f $(SERVERMANDIR)/man$(DESTMANSUFFIX)/$$destfile ; done )
	- rmdir $(SERVERMANDIR)/man$(DESTMANSUFFIX) $(SERVERMANDIR) >/dev/null 2>&1

install.l10n: potfiles
	(cd po; $(MAKE) datadir=\"$(datadir)\" install)

uninstall.common: uninstall.l10n
	- rmdir $(COMMONSHLIBDIR)
	- D="$(COMMONSHLIBDIR)" ; \
	  while [ "$$D" != / ] ; do \
	    D=`dirname "$$D"` ; \
	    rmdir "$$D" >/dev/null 2>&1 ; \
	  done
	-find $(COMMONDIR) $(COMMONDATADIR) $(COMMONSHLIBDIR) -depth -type d \
		-exec rmdir {} \; >/dev/null 2>&1

uninstall.l10n:
	(cd po; $(MAKE) datadir=\"$(datadir)\" uninstall)

xclientconfig: xcc
	./build_shwish $? > $@
	chmod +x $@

xserverconfig: xsc
	./build_shwish $? > $@
	chmod +x $@

xserverstatus: xss
	./build_shwish $? > $@
	chmod +x $@

xrestore: xrs
	./build_shwish $? > $@
	chmod +x $@

clean::
	- for subdir in $(SUBDIRS) ; do (cd $$subdir && $(MAKE) clean ) ; done
	- rm -f *% *.o *.a *~ core* *_

veryclean: clean
	- rm -f $(PROGRAMS)

distclean: clean
	- for subdir in $(SUBDIRS) ; do (cd $$subdir && $(MAKE) distclean ) ; done
	- rm -f $(PROGRAMS) $(CRYPTKEY) xclientconfig xserverconfig xrestore xserverstatus
	- rm -f config.cache config.log config.status config.setup Install.cache
	- rm -f `/bin/ls *.in|sed 's/[.]in$$//g'|grep -v configure` confdefs.h

