--- Makefile.unix.orig	1997-03-12 09:52:59.000000000 +1100
+++ Makefile.unix	2012-03-23 23:44:54.000000000 +1100
@@ -28,7 +28,7 @@
 BINDIR = /usr/local/bin
 SCRIPTDIR = $(BINDIR)
 INCLUDEDIR = /usr/local/share/psutils
-PERL = /usr/local/bin/perl
+PERL = perl
 
 BINMODE = 0755
 MANMODE = 0644
@@ -39,7 +39,8 @@
 MANDIR = /usr/local/share/man/man$(MANEXT)
 
 CC = gcc
-CFLAGS = -DPAPER=\"$(PAPER)\" -DUNIX -O -Wall
+CPPFLAGS = -DPAPER=\"$(PAPER)\" -DUNIX
+CFLAGS = -Wall -Wextra $(EXTRA_CFLAGS)
 
 BIN = psbook psselect pstops epsffit psnup \
 	psresize
@@ -65,30 +66,30 @@
 epsffit.o: epsffit.c pserror.h patchlev.h
 
 epsffit: epsffit.o pserror.o
-	$(CC) $(CCFLAGS) -o epsffit pserror.o epsffit.o
+	$(CC) $(CFLAGS) -o epsffit pserror.o epsffit.o
 
 psnup: psnup.o psutil.o psspec.o pserror.o
-	$(CC) $(CCFLAGS) -o psnup psutil.o psspec.o pserror.o psnup.o
+	$(CC) $(CFLAGS) -o psnup psutil.o psspec.o pserror.o psnup.o
 
 psnup.o: psutil.h patchlev.h psspec.h pserror.h psnup.c
 
 psresize: psresize.o psutil.o pserror.o psspec.o
-	$(CC) $(CCFLAGS) -o psresize psutil.o psspec.o pserror.o psresize.o
+	$(CC) $(CFLAGS) -o psresize psutil.o psspec.o pserror.o psresize.o
 
 psresize.o: psutil.h patchlev.h psspec.h pserror.h psresize.c
 
 psbook: psbook.o psutil.o pserror.o
-	$(CC) $(CCFLAGS) -o psbook psutil.o pserror.o psbook.o
+	$(CC) $(CFLAGS) -o psbook psutil.o pserror.o psbook.o
 
 psbook.o: psutil.h patchlev.h pserror.h psbook.c
 
 psselect: psselect.o psutil.o pserror.o
-	$(CC) $(CCFLAGS) -o psselect psutil.o pserror.o psselect.o
+	$(CC) $(CFLAGS) -o psselect psutil.o pserror.o psselect.o
 
 psselect.o: psutil.h patchlev.h pserror.h psselect.c
 
 pstops: pstops.o psutil.o psspec.o pserror.o
-	$(CC) $(CCFLAGS) -o pstops psutil.o psspec.o pserror.o pstops.o
+	$(CC) $(CFLAGS) -o pstops psutil.o psspec.o pserror.o pstops.o
 
 pstops.o: psutil.h patchlev.h psspec.h pserror.h pstops.c
 
@@ -219,30 +220,30 @@
 install: install.bin install.script install.man install.include
 
 install.bin: $(BIN)
-	-mkdir $(BINDIR)
+	mkdir -p $(DESTDIR)$(BINDIR)
 	@for i in $(BIN); do \
 		echo Installing $$i; \
-		$(INSTALL) $$i $(BINDIR); \
+		$(INSTALL) $$i $(DESTDIR)$(BINDIR); \
 	done
 
 install.script: $(PERLSCRIPTS) $(SHELLSCRIPTS)
-	-mkdir $(SCRIPTDIR)
+	mkdir -p $(DESTDIR)$(SCRIPTDIR)
 	@for i in $(PERLSCRIPTS) $(SHELLSCRIPTS); do \
 		echo Installing $$i; \
-		$(INSTALL) $$i $(SCRIPTDIR); \
+		$(INSTALL) $$i $(DESTDIR)$(SCRIPTDIR); \
 	done
 
 install.include: $(INCLUDES)
-	-mkdir $(INCLUDEDIR)
+	mkdir -p $(DESTDIR)$(INCLUDEDIR)
 	@for i in $(INCLUDES); do \
 		echo Installing $$i; \
-		$(INSTALLMAN) $$i $(INCLUDEDIR); \
+		$(INSTALLMAN) $$i $(DESTDIR)$(INCLUDEDIR); \
 	done
 
 install.man: $(MANPAGES)
-	-mkdir $(MANDIR)
+	mkdir -p $(DESTDIR)$(MANDIR)
 	@for i in $(MANPAGES); do \
 		echo Installing manual page for $$i; \
-		$(INSTALLMAN) $$i $(MANDIR)/$$i; \
+		$(INSTALLMAN) $$i $(DESTDIR)$(MANDIR)/$$i; \
 	done
 
