###############################################################################
#									      #
# 			The Undelete System		                      #
#									      #
###############################################################################

# Use this when debugging.
#CFLAGS="-g -Wall -I ../include -pipe"

CFLAGS=	"-O3 -Wall -I ../include -pipe"

# If the GNU utilities are installed with some prefix on your system,
# change this (eg. when GNU install  = ginstall on your system, use G=g)
G=

# Directory where user files will be placed.
BIN=	/usr/bin
# Directory where system files (root only) will be placed.
SBIN=	/usr/sbin
# Directory where man files will be placed
MAN=	/usr/man
# Directory where text files will be placed under $(TXT)/undelete
TXT=	/usr/doc

###############################################################################

default:
	@(echo)
	@(echo "       Please read the \`INSTALL' file before compiling !")
	@(echo)

include/config.h:
	@(echo)
	@(echo "       You must copy \`dist_config.h' to \`include/config.h'") 
	@(echo "       and edit it to suit your needs.")
	@(echo; false)

###############################################################################

all: include/config.h include/blocksize.h
	@(cd shared;	$(MAKE) CFLAGS=$(CFLAGS))
	@(cd deld;	$(MAKE) CFLAGS=$(CFLAGS))
	@(cd del;	$(MAKE) CFLAGS=$(CFLAGS))
	@(cd undel;	$(MAKE) CFLAGS=$(CFLAGS))
	@(cd dquota;	$(MAKE) CFLAGS=$(CFLAGS))
	@(cd eddquota;	$(MAKE) CFLAGS=$(CFLAGS))
	@(cd repdquota;	$(MAKE) CFLAGS=$(CFLAGS))

include/blocksize.h:
	gcc -O3 blocksize.c -o bl
	@(echo "#ifndef _BLOCKSIZE_H_"     >  include/blocksize.h)
	@(echo "#define _BLOCKSIZE_H_"     >> include/blocksize.h)
	@(echo                             >> include/blocksize.h)
	@(echo "#define BLOCK_ADJUST `bl`" >> include/blocksize.h)
	@(echo                             >> include/blocksize.h)
	@(echo "#endif"                    >> include/blocksize.h)
	rm -f bl

install: all
	@(echo) 
	@(echo "        Only \`root' should do this !") 
	@(echo)
	@(echo "Installing executables...")
	$(G)install -s -m 0750 deld/deld           $(SBIN)/deld
	$(G)install -s -m 0755 del/del             $(BIN)/del
	$(G)install -s -m 0755 undel/undel         $(BIN)/undel
	$(G)install -s -m 0755 dquota/dquota       $(BIN)/dquota
	$(G)install -s -m 4750 eddquota/eddquota   $(SBIN)/eddquota
	$(G)install -s -m 4750 repdquota/repdquota $(SBIN)/repdquota
	@(echo)
	@(echo "Installing man-pages...")
	$(G)install -d $(MAN)/man1
	$(G)install -d $(MAN)/man8
	$(G)install man/*.1 $(MAN)/man1
	$(G)install man/*.8 $(MAN)/man8
	@(echo)
	@(echo "Installing docs and sample config files...")
	$(G)install -d $(TXT)/undelete
	$(G)install -m 0644 COPYING	 	$(TXT)/undelete/COPYING
	$(G)install -m 0644 README		$(TXT)/undelete/README
	$(G)install -m 0644 TECHNICAL.DOC	$(TXT)/undelete/TECHNICAL.DOC
	$(G)install -m 0644 config.deld*	$(TXT)/undelete
	@(echo)
	@(echo "        All files are installed.")
	@(echo "        It would be advisable to add \`$(SBIN)/deld' to one")
	@(echo "        of the system's startup files so the deamon will be")
	@(echo "        started every time the system boots.")
	@(echo)
	@(echo "	It might be wise to chmod your /tmp directory to 1777")
	@(echo)

###############################################################################

clean:
	@(cd shared;	$(MAKE) clean)
	@(cd deld;	$(MAKE) clean)
	@(cd del;	$(MAKE) clean)
	@(cd undel;	$(MAKE) clean)
	@(cd dquota;	$(MAKE) clean)
	@(cd eddquota;	$(MAKE) clean)
	@(cd repdquota;	$(MAKE) clean)


distclean: clean
	@(rm -f include/config.h include/blocksize.h)
	-@(cd deld/gzip; $(MAKE) distclean)

###############################################################################







