$NetBSD: patch-Makefile,v 1.1 2012/02/28 10:49:27 roy Exp $

Support conigurable installation location.
Man pages belong in section 8.

--- Makefile.orig	2010-09-21 16:22:09.000000000 +0000
+++ Makefile
@@ -1,6 +1,8 @@
 # user editable stuff:
-SBINDIR=/usr/sbin/
-BINDIR=/usr/bin/
+PREFIX?=/usr
+SBINDIR=$(PREFIX)/sbin/
+BINDIR=$(PREFIX)/bin/
+MANDIR=$(PREFIX)/share/man
 CONFIGDIR="/etc/powerdns/"
 OPTFLAGS?=-O3
 CXXFLAGS:= $(CXXFLAGS) -Wall $(OPTFLAGS) $(PROFILEFLAGS) $(ARCHFLAGS) -pthread
@@ -10,6 +12,13 @@ LDFLAGS:=$(LDFLAGS) $(ARCHFLAGS) -pthrea
 LINKCC=$(CXX)
 CC?=gcc
 
+INSTALL?=install
+SHAREMODE?=644
+MANMODE?=444
+INSTALL_DIR?=$(INSTALL) -d
+INSTALL_DATA?=$(INSTALL) -m $(SHAREMODE)
+INSTALL_MAN?=$(INSTALL) -m $(MANMODE)
+
 # Lua 5.1 settings
 
 # static dependencies
@@ -25,7 +34,7 @@ REC_CONTROL_OBJECTS=rec_channel.o rec_co
 	unix_utility.o logger.o qtype.o
 
 # what we need 
-all: message pdns_recursor rec_control 
+all: message pdns_recursor rec_control recursor.conf-dist
 
 # OS specific instructions
 -include sysdeps/$(shell uname).inc
@@ -52,6 +61,10 @@ endif
 
 LDFLAGS += $(PROFILEFLAGS) $(STATICFLAGS)
 
+recursor.conf-dist: pdns_recursor
+	@# Not cross-compile friendly :/
+	./pdns_recursor --config > $@
+
 message: 
 	@echo
 	@echo PLEASE READ: If you get an error mentioning \#include '<boost/something.hpp>', please read README
@@ -70,16 +83,14 @@ basic_checks: 
 	 fi
 
 install: all
-	-mkdir -p $(DESTDIR)/$(SBINDIR)
-	mv pdns_recursor $(DESTDIR)/$(SBINDIR)
-	strip $(DESTDIR)/$(SBINDIR)/pdns_recursor
-	mkdir -p $(DESTDIR)/$(BINDIR)
-	mv rec_control $(DESTDIR)/$(BINDIR)
-	strip $(DESTDIR)/$(BINDIR)/rec_control
-	-mkdir -p $(DESTDIR)/$(CONFIGDIR)
-	$(DESTDIR)/$(SBINDIR)/pdns_recursor --config > $(DESTDIR)/$(CONFIGDIR)/recursor.conf-dist
-	-mkdir -p $(DESTDIR)/usr/share/man/man1
-	cp pdns_recursor.1 rec_control.1 $(DESTDIR)/usr/share/man/man1
+	$(INSTALL_DIR) $(DESTDIR)/$(SBINDIR)
+	$(INSTALL) pdns_recursor $(DESTDIR)/$(SBINDIR)
+	$(INSTALL_DIR) $(DESTDIR)/$(BINDIR)
+	$(INSTALL) rec_control $(DESTDIR)/$(BINDIR)
+	$(INSTALL_DIR) $(DESTDIR)/$(CONFIGDIR)
+	$(INSTALL_DATA) recursor.conf-dist $(DESTDIR)/$(CONFIGDIR)
+	$(INSTALL_DIR) $(DESTDIR)/$(MANDIR)/man8
+	$(INSTALL_MAN) pdns_recursor.8 rec_control.8 $(DESTDIR)/$(MANDIR)/man8
 	$(OS_SPECIFIC_INSTALL)	
 
 clean: binclean
@@ -94,7 +105,7 @@ dep:
 -include dep
 
 optional:
-	mkdir optional
+	$(INSTALL_DIR) optional
 
 pdns_recursor: optional $(OPTIONALS) $(PDNS_RECURSOR_OBJECTS) 
 	$(LINKCC) $(PDNS_RECURSOR_OBJECTS) $(wildcard optional/*.o) $(LDFLAGS) -o $@
