--- foo2zjs/Makefile.orig	2007-09-17 11:32:03.640123808 -0500
+++ foo2zjs/Makefile	2007-09-17 13:28:58.741027655 -0500
@@ -18,8 +18,8 @@
 SHAREXQX=$(PREFIX)/share/foo2xqx
 SHARELAVA=$(PREFIX)/share/foo2lava
 SHAREQPDL=$(PREFIX)/share/foo2qpdl
-MANDIR=$(PREFIX)/share/man
-DOCDIR=$(PREFIX)/share/doc/foo2zjs/
+MANDIR=$(PREFIX)/man
+DOCDIR=$(PREFIX)/doc/foo2zjs/
 
 # Pathnames for referenced packages...
 FOODB=/usr/share/foomatic/db/source
@@ -422,59 +422,35 @@
 	#
 	# Install driver, wrapper, and development tools
 	#
-	install -c $(PROGS) $(SHELLS) $(BIN)/
+	install -d -m 0755 $(DESTDIR)/$(BIN)
+	install -c $(PROGS) $(SHELLS) $(DESTDIR)/$(BIN)/
 	if [ "$(BINPROGS)" != "" ]; then \
-	    install -c $(BINPROGS) /bin/; \
+	    install -d -m 0755 $(DESTDIR)/bin ; \
+	    install -c $(BINPROGS) $(DESTDIR)/bin/; \
 	fi
 	#
 	# Install gamma correction files.  These are just templates,
 	# and don't actually do anything right now.  If anybody wants
 	# to tune them or point me at a process for doing that, please...
 	#
-	install -d $(SHAREZJS)/
-	install -c -m 644 gamma.ps $(SHAREZJS)/
-	install -c -m 644 gamma-lookup.ps $(SHAREZJS)/
-	install -d $(SHAREOAK)/
-	install -d $(SHAREHP)/
-	install -d $(SHAREXQX)/
-	install -d $(SHARELAVA)/
+	install -d $(DESTDIR)/$(SHAREZJS)/
+	install -c -m 644 gamma.ps $(DESTDIR)/$(SHAREZJS)/
+	install -c -m 644 gamma-lookup.ps $(DESTDIR)/$(SHAREZJS)/
+	install -d $(DESTDIR)/$(SHAREOAK)/
+	install -d $(DESTDIR)/$(SHAREHP)/
+	install -d $(DESTDIR)/$(SHAREXQX)/
+	install -d $(DESTDIR)/$(SHARELAVA)/
 
 install-foo:
 	#
-	# Remove obsolete foomatic database files from previous versions
-	#
-	rm -f $(FOODB)/opt/foo2zjs-Media.xml
-	rm -f $(FOODB)/opt/foo2zjs-PaperSize.xml
-	rm -f $(FOODB)/opt/foo2zjs-Source.xml
-	rm -f $(FOODB)/opt/foo2zjs-DitherPPI.xml
-	#
 	# Install current database files
 	#
-	@if [ -d $(FOODB) ]; then \
-	    for dir in driver printer opt; do \
-		echo install -m 644 foomatic-db/$$dir/*.xml $(FOODB)/$$dir/; \
-		install -c -m 644 foomatic-db/$$dir/*.xml $(FOODB)/$$dir/; \
-	    done \
-	else \
-	    echo "***"; \
-	    echo "*** WARNING! You don't have directory $(FOODB)/"; \
-	    echo "*** If you want support for foomatic printer configuration,";\
-	    echo "*** then you will have to manually install these files..."; \
-	    echo "***"; \
-	    ls foomatic-db/*/*.xml | sed 's/^/	/'; \
-	    echo "***"; \
-	    echo "*** ... wherever foomatic is stashed on your machine."; \
-	    echo "***"; \
-	fi
-	#
-	# Clear foomatic cache and rebuild database if needed
+	for dir in driver printer opt; do \
+	    install -d 0755 $(DESTDIR)/$(FOODB)/$$dir ; \
+	    echo install -m 644 foomatic-db/$$dir/*.xml $(DESTDIR)/$(FOODB)/$$dir/; \
+	    install -c -m 644 foomatic-db/$$dir/*.xml $(DESTDIR)/$(FOODB)/$$dir/; \
+	done 
 	#
-	rm -rf /var/cache/foomatic/*/*
-	rm -f /var/cache/foomatic/printconf.pickle
-	if [ -d /var/cache/foomatic/compiled ]; then \
-	    cd /var/cache/foomatic/compiled; \
-	    foomatic-combo-xml -O >overview.xml; \
-	fi
 
 install-icc2ps:
 	#
@@ -486,28 +462,28 @@
 	#
 	# Install prebuilt CRD files (from m2300w project)
 	#
-	install -d $(SHAREZJS)/
-	install $(LPuid) $(LPgid) -m 775 -d $(SHAREZJS)/crd/
+	install -d $(DESTDIR)$(SHAREZJS)/
+	install $(LPuid) $(LPgid) -m 775 -d $(DESTDIR)/$(SHAREZJS)/crd/
 	for i in crd/zjs/*.*; do \
-	    install -c -m 644 $$i $(SHAREZJS)/crd/; \
+	    install -c -m 644 $$i $(DESTDIR)/$(SHAREZJS)/crd/; \
 	done
 	#
 	# Install prebuilt CRD files for CLP-300/CLP-600
 	#
-	install -d $(SHAREQPDL)/
-	install $(LPuid) $(LPgid) -m 775 -d $(SHAREQPDL)/crd/
+	install -d $(DESTDIR)$(SHAREQPDL)/
+	install $(LPuid) $(LPgid) -m 775 -d $(DESTDIR)/$(SHAREQPDL)/crd/
 	for i in crd/qpdl/*cms* crd/qpdl/*.ps; do \
-	    install -c -m 644 $$i $(SHAREQPDL)/crd/; \
+	    install -c -m 644 $$i $(DESTDIR)/$(SHAREQPDL)/crd/; \
 	done
 
 install-psfiles:
 	#
 	# Install prebuilt psfiles files (from m2300w project)
 	#
-	install -d $(SHAREHP)/
-	install $(LPuid) $(LPgid) -m 775 -d $(SHAREHP)/psfiles/
+	install -d $(DESTDIR)$(SHAREHP)/
+	install $(LPuid) $(LPgid) -m 775 -d $(DESTDIR)/$(SHAREHP)/psfiles/
 	for i in psfiles/*.*; do \
-	    install -c -m 644 $$i $(SHAREHP)/psfiles/; \
+	    install -c -m 644 $$i $(DESTDIR)/$(SHAREHP)/psfiles/; \
 	done
 
 install-extra:
@@ -517,79 +493,62 @@
 	# Get files from the printer manufacturer, i.e. www.minolta-qms.com,
 	# or use the "./getweb" convenience script.
 	#
-	install -d $(SHAREZJS)/
+	install -d $(DESTDIR)/$(SHAREZJS)/
 	# foo2zjs ICM files (if any)
-	install $(LPuid) $(LPgid) -m 775 -d $(SHAREZJS)/icm/
+	install $(LPuid) $(LPgid) -m 775 -d $(DESTDIR)/$(SHAREZJS)/icm/
 	for i in DL*.icm CP*.icm km2430*.icm; do \
 	    if [ -f $$i ]; then \
-		install -c -m 644 $$i $(SHAREZJS)/icm/; \
+		install -c -m 644 $$i $(DESTDIR)/$(SHAREZJS)/icm/; \
 	    fi; \
 	done
 	# foo2zjs Firmware files (if any)
-	install $(LPuid) $(LPgid) -m 775 -d $(SHAREZJS)/firmware/
+	install $(LPuid) $(LPgid) -m 775 -d $(DESTDIR)/$(SHAREZJS)/firmware/
 	for i in sihp*.img; do \
 	    if [ -f $$i ]; then \
 		base=`basename $$i .img`; \
 		./arm2hpdl $$i >$$base.dl; \
-		install -c -m 644 $$base.dl $(SHAREZJS)/firmware/; \
+		install -c -m 644 $$base.dl $(DESTDIR)/$(SHAREZJS)/firmware/; \
 	    fi; \
 	done
 	# foo2oak ICM files (if any)
-	install $(LPuid) $(LPgid) -m 775 -d $(SHAREOAK)/icm/
+	install $(LPuid) $(LPgid) -m 775 -d $(DESTDIR)/$(SHAREOAK)/icm/
 	# foo2hp ICM files (if any)
-	install $(LPuid) $(LPgid) -m 775 -d $(SHAREHP)/icm/
+	install $(LPuid) $(LPgid) -m 775 -d $(DESTDIR)/$(SHAREHP)/icm/
 	for i in hpclj26*.icm km2430*.icm; do \
 	    if [ -f $$i ]; then \
-		install -c -m 644 $$i $(SHAREHP)/icm/; \
+		install -c -m 644 $$i $(DESTDIR)/$(SHAREHP)/icm/; \
 	    fi; \
 	done
 	# foo2lava ICM files (if any)
-	install $(LPuid) $(LPgid) -m 775 -d $(SHARELAVA)/icm/
+	install $(LPuid) $(LPgid) -m 775 -d $(DESTDIR)/$(SHARELAVA)/icm/
 	for i in km2530*.icm; do \
 	    if [ -f $$i ]; then \
-		install -c -m 644 $$i $(SHARELAVA)/icm/; \
+		install -c -m 644 $$i $(DESTDIR)/$(SHARELAVA)/icm/; \
 	    fi; \
 	done
 	# foo2qpdl ICM files (if any)
-	install $(LPuid) $(LPgid) -m 775 -d $(SHAREQPDL)/icm/
+	install $(LPuid) $(LPgid) -m 775 -d $(DESTDIR)/$(SHAREQPDL)/icm/
 	for i in samclp300*.icm; do \
 	    if [ -f $$i ]; then \
-		install -c -m 644 $$i $(SHAREQPDL)/icm/; \
+		install -c -m 644 $$i $(DESTDIR)/$(SHAREQPDL)/icm/; \
 	    fi; \
 	done
 
 MODEL=/usr/share/cups/model
-LOCALMODEL=/usr/local/share/cups/model
 PPD=/usr/share/ppd
 install-ppd:
 	#
 	# Install PPD files for CUPS
 	#
-	if [ -d $(PPD) ]; then \
-	    find $(PPD) -name '*foo2zjs*' | xargs rm -f; \
-	    find $(PPD) -name '*foo2hp*' | xargs rm -f; \
-	    find $(PPD) -name '*foo2xqx*' | xargs rm -f; \
-	    find $(PPD) -name '*foo2lava*' | xargs rm -f; \
-	    find $(PPD) -name '*foo2qpdl*' | xargs rm -f; \
-            [ -d $(PPD)/foo2zjs ] || mkdir $(PPD)/foo2zjs; \
-	    cd PPD; \
-	    for ppd in *.ppd; do \
-		gzip < $$ppd > $(PPD)/foo2zjs/$$ppd.gz; \
-	    done; \
-	fi
 	if [ -d $(MODEL) ]; then \
+	    install -d 0755 $(DESTDIR)/$(MODEL)/; \
 	    cd PPD; \
 	    for ppd in *.ppd; do \
-		gzip < $$ppd > $(MODEL)/$$ppd.gz; \
-	    done; \
-	elif [ -d $(LOCALMODEL) ]; then \
-	    cd PPD; \
-	    for ppd in *.ppd; do \
-		gzip < $$ppd > $(LOCALMODEL)/$$ppd.gz; \
+		gzip < $$ppd > $(DESTDIR)/$(MODEL)/$$ppd.gz; \
 	    done; \
 	fi
 
-USBDIR=/etc/hotplug/usb
+USBDIR=/lib/udev
 UDEVDIR=/etc/udev/rules.d
 RULES=hplj10xx.rules
 install-hotplug: install-hotplug-test install-hotplug-prog
@@ -610,18 +569,14 @@
 	#
 
 install-hotplug-prog:
-	if [ -d $(UDEVDIR) ]; then \
-	    install -c -m 644 $(RULES) $(UDEVDIR)/11-$(RULES); \
-	fi
-	[ -d $(USBDIR) ] || install -d -m 755 $(USBDIR)/
-	install -c -m 755 hplj1000 $(USBDIR)/
-	ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hplj1005
-	ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hplj1018
-	ln -sf $(USBDIR)/hplj1000 $(USBDIR)/hplj1020
-	$(USBDIR)/hplj1000 install-usermap
-	$(USBDIR)/hplj1005 install-usermap
-	$(USBDIR)/hplj1018 install-usermap
-	$(USBDIR)/hplj1020 install-usermap
+	install -d -m 0755 $(DESTDIR)/$(UDEVDIR)/
+	install -c -m 644 $(RULES) $(DESTDIR)/$(UDEVDIR)/11-$(RULES); \
+	install -d -m 755 $(DESTDIR)/$(USBDIR)
+	install -c -m 755 hplj1000 $(DESTDIR)/$(USBDIR)/
+	cd $(DESTDIR)/$(USBDIR) ; ln -sf hplj1000 hplj1005
+	cd $(DESTDIR)/$(USBDIR) ; ln -sf hplj1000 hplj1018
+	cd $(DESTDIR)/$(USBDIR) ; ln -sf hplj1000 hplj1020
+
 
 cups:	FRC
 	if [ -x /etc/init.d/cups ]; then \
@@ -915,26 +870,26 @@
 	#
 	# Install manual pages
 	#
-	install -d -m 755 $(MANDIR)
-	install -d -m 755 $(MANDIR)/man1/
-	install -c -m 644 foo2zjs.1 $(MANDIR)/man1/
-	install -c -m 644 foo2zjs-wrapper.1 $(MANDIR)/man1/
-	install -c -m 644 zjsdecode.1 $(MANDIR)/man1/
-	install -c -m 644 foo2oak.1 $(MANDIR)/man1/
-	install -c -m 644 foo2oak-wrapper.1 $(MANDIR)/man1/
-	install -c -m 644 oakdecode.1 $(MANDIR)/man1/
-	install -c -m 644 foo2hp.1 $(MANDIR)/man1/
-	install -c -m 644 foo2hp2600-wrapper.1 $(MANDIR)/man1/
-	install -c -m 644 xqxdecode.1 $(MANDIR)/man1/
-	install -c -m 644 foo2xqx.1 $(MANDIR)/man1/
-	install -c -m 644 foo2xqx-wrapper.1 $(MANDIR)/man1/
-	install -c -m 644 lavadecode.1 $(MANDIR)/man1/
-	install -c -m 644 foo2lava.1 $(MANDIR)/man1/
-	install -c -m 644 foo2lava-wrapper.1 $(MANDIR)/man1/
-	install -c -m 644 qpdldecode.1 $(MANDIR)/man1/
-	install -c -m 644 foo2qpdl.1 $(MANDIR)/man1/
-	install -c -m 644 foo2qpdl-wrapper.1 $(MANDIR)/man1/
-	install -c -m 644 opldecode.1 $(MANDIR)/man1/
+	install -d -m 755 $(DESTDIR)/$(MANDIR)
+	install -d -m 755 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2zjs.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2zjs-wrapper.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 zjsdecode.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2oak.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2oak-wrapper.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 oakdecode.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2hp.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2hp2600-wrapper.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 xqxdecode.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2xqx.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2xqx-wrapper.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 lavadecode.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2lava.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2lava-wrapper.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 qpdldecode.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2qpdl.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 foo2qpdl-wrapper.1 $(DESTDIR)/$(MANDIR)/man1/
+	install -c -m 644 opldecode.1 $(DESTDIR)/$(MANDIR)/man1/
 
 doc: README INSTALL manual.pdf
 
@@ -942,13 +897,13 @@
 	#
 	# Install documentation
 	#
-	install -d -m 755 $(DOCDIR)
-	install -c -m 644 manual.pdf $(DOCDIR)
-	install -c -m 644 COPYING $(DOCDIR)
-	install -c -m 644 INSTALL $(DOCDIR)
-	install -c -m 644 INSTALL.osx $(DOCDIR)
-	install -c -m 644 README $(DOCDIR)
-	install -c -m 644 ChangeLog $(DOCDIR)
+	install -d -m 755 $(DESTDIR)/$(DOCDIR)
+	install -c -m 644 manual.pdf $(DESTDIR)/$(DOCDIR)
+	install -c -m 644 COPYING $(DESTDIR)/$(DOCDIR)
+	install -c -m 644 INSTALL $(DESTDIR)/$(DOCDIR)
+	install -c -m 644 INSTALL.osx $(DESTDIR)/$(DOCDIR)
+	install -c -m 644 README $(DESTDIR)/$(DOCDIR)
+	install -c -m 644 ChangeLog $(DESTDIR)/$(DOCDIR)
 
 GROFF=/usr/local/test/bin/groff
 GROFF=groff
