--- Makefile.old	2005-02-01 03:11:04.000000000 -0500
+++ Makefile	2005-02-01 03:12:06.000000000 -0500
@@ -3,12 +3,22 @@
 INSTALL_DIR=/usr/local/bin
 MAN_DIR=/usr/local/man/man1
 ETC_DIR=/etc
+.ifdef DESTROOT_DIR
+TARGET_INSTALL_DIR=$(DESTROOT_DIR)/$(INSTALL_DIR)
+TARGET_MAN_DIR=$(DESTROOT_DIR)/$(MAN_DIR)
+TARGET_ETC_DIR=$(DESTROOT_DIR)/$(ETC_DIR)
+.else
+TARGET_INSTALL_DIR=$(INSTALL_DIR)
+TARGET_MAN_DIR=$(MAN_DIR)
+TARGET_ETC_DIR=$(ETC_DIR)
+.endif
 VERSION=1.0.4
 DIST_FILES=COPYING INSTALL Makefile README \
 	colordiff.pl colordiffrc colordiffrc-lightbg BUGS TODO CHANGES colordiff.1
-TMPDIR=colordiff-${VERSION}
-TARBALL=${TMPDIR}.tar.gz
+TMPDIR=colordiff-$(VERSION)
+TARBALL=$(TMPDIR).tar.gz
 
+.PHONY: install
 
 doc: colordiff.xml
 	xmlto -vv man colordiff.xml
@@ -22,23 +32,22 @@
 
 etc:
 	sed -e "s%/etc%$(ETC_DIR)%g" colordiff.pl > colordiff.pl.for.install
+	sed -e "s%/etc%$(ETC_DIR)%g" colordiff.1 > colordiff.1.for.install
 
 install: etc
-	install -D colordiff.pl.for.install ${INSTALL_DIR}/colordiff
-	install -D colordiff.1 ${MAN_DIR}/colordiff.1
-	if [ -f ${ETC_DIR}/colordiffrc ]; then \
-	  mv -f ${ETC_DIR}/colordiffrc ${ETC_DIR}/colordiffrc.old; \
+	install colordiff.pl.for.install $(TARGET_INSTALL_DIR)/colordiff
+	install colordiff.1.for.install $(TARGET_MAN_DIR)/colordiff.1
+	if [ -f $(TARGET_ETC_DIR)/colordiffrc ]; then \
+	  mv -f $(TARGET_ETC_DIR)/colordiffrc $(TARGET_ETC_DIR)/colordiffrc.old; \
 	fi
-	cp colordiffrc ${ETC_DIR}/colordiffrc
-	chown root.root ${ETC_DIR}/colordiffrc
-	chmod 644 ${ETC_DIR}/colordiffrc
-	rm -f colordiff.pl.for.install
+	cp colordiffrc-lightbg $(TARGET_ETC_DIR)/colordiffrc
+	rm -f colordiff.pl.for.install colordiff.1.for.install
 
 dist:
-	mkdir ${TMPDIR}
-	cp -p ${DIST_FILES} ${TMPDIR}
-	tar -zcvf ${TARBALL} ${TMPDIR}
-	rm -fR ${TMPDIR}
+	mkdir $(TMPDIR)
+	cp -p $(DIST_FILES) $(TMPDIR)
+	tar -zcvf $(TARBALL) $(TMPDIR)
+	rm -fR $(TMPDIR)
 
 clean:
 	rm -f README colordiff.1 colordiff.html
