$NetBSD$

--- Makefile.config.orig	2012-10-02 22:46:50.000000000 +0000
+++ Makefile.config
@@ -17,59 +17,62 @@
 #
 # the base of the Munin installation.
 #
-PREFIX     = $(DESTDIR)/opt/munin
+UPREFIX    = $(DESTDIR)$(PREFIX)
 
 # Where Munin keeps its configurations (server.conf, client.conf, ++)
-CONFDIR    = $(DESTDIR)/etc/opt/munin
+# CONFDIR   ?= $(UPREFIX)/etc/munin
+
+# Where pkgsrc installs example config files
+EGDIR      = $(UPREFIX)/share/examples/munin
 
 # Server only - where to put munin-cron
-BINDIR     = $(PREFIX)/bin
+BINDIR     = $(UPREFIX)/bin
 
 # Client only - where to put munin-node, munin-node-configure, and munin-run
-SBINDIR    = $(PREFIX)/sbin
+SBINDIR    = $(UPREFIX)/sbin
 
 # Where to put text and html documentation
-DOCDIR     = $(PREFIX)/doc
+DOCDIR     = $(UPREFIX)/share/doc/munin
 
 # Where to put man pages
-MANDIR     = $(PREFIX)/man
+MANDIR     = $(UPREFIX)/${PKGMANDIR}
 
 # Where to put internal binaries and plugin repository
-LIBDIR     = $(PREFIX)/lib
+LIBDIR     = $(UPREFIX)/lib/munin
 
 # Server only - Output directory
-HTMLDIR    = $(PREFIX)/www/docs
-CGIDIR     = $(PREFIX)/www/cgi
+HTMLDIR    = $(DESTDIR)${MUNIN_WWWDIR}/munin/data
+CGIDIR     = $(DESTDIR)${MUNIN_WWWDIR}/cgi-bin
 
 # Where to put internal data for master (RRD, internal files, ...)
-DBDIR      = $(DESTDIR)/var/opt/munin
+DBDIR      = ${MUNIN_DBDIR}
 
 # Where to put internal data for node (plugin state, ...)
-DBDIRNODE  = $(DESTDIR)/var/opt/munin-node
+DBDIRNODE  = $(DBDIR)
 
 # Client only - Where the spool files are written. Must be writable by
 # group "munin", and should be preserved between reboots
-SPOOLDIR   = $(DBDIR)/spool
+SPOOLDIR   = ${MUNIN_SPOOLDIR}
 
 # Client only - Where plugins should put their states. Must be writable by
 # group "munin", and should be preserved between reboots
 PLUGSTATE  = $(DBDIRNODE)/plugin-state
 
 # Where Munin should place its logs.
-LOGDIR     = $(PREFIX)/log/munin
+LOGDIR     = ${MUNIN_LOGDIR}
 
 # Location of PID files and other statefiles. On the server, must be
 # writable by the user "munin".
-STATEDIR   = $(DESTDIR)/var/run/munin
+STATEDIR   = ${MUNIN_STATEDIR}
 
 # The perl interpreter to use
-PERL       := $(shell which perl)
+PERL       := ${PERL5}
 
 # The python interpreter to use (used by some plugins)
-PYTHON     := /usr/bin/env python
+PYTHON     := ${PYTHONBIN}
 
 # The ruby interpreter to use (used by some plugins)
-RUBY       := /usr/bin/env ruby
+RUBY       := ${RUBY}
 
 # The java runtime to use (used by some plugins)
 JAVARUN    := /usr/bin/java
@@ -92,11 +95,11 @@ JAVALIBDIR = $(LIBDIR)
 GOODSH     := $(shell PATH=`getconf PATH 2>/dev/null || echo $(PATH)` LANG=C sh -c 'type sh | sed "s/.* //"')
 
 # Path of bash for bash specific plugins
-BASH       := /bin/bash
+BASH       := ${BASH}
 
 # Server only - Where to install the perl libraries
-PERLSITELIB := $(shell $(PERL) -V:sitelib | cut -d"'" -f2)
-PERLLIB    = $(DESTDIR)$(PERLSITELIB)
+PERLVENDORLIB := $(shell $(PERL) -V:vendorlib | cut -d"'" -f2)
+PERLLIB    = $(DESTDIR)$(PERLVENDORLIB)
 
 # Client only - Install plugins for this architecture
 # the LANG=C makes tr work as expected, not regarding any locale it
@@ -117,8 +120,8 @@ MKTEMP     := $(shell ./test-mktemp)
 VERSION    := $(shell ./getversion)
 
 # User to run munin as
-USER       := munin
-GROUP      := munin
+USER       := ${MUNIN_USER}
+GROUP      := ${MUNIN_GROUP}
 
 # Default user to run the plugins as
 PLUGINUSER := nobody
@@ -129,9 +132,10 @@ CGIUSER := nobody
 # Which command to use to check if the USER and GROUP to run Munin as, exists.
 # These will work on most modern OSes:
 #
-GETENT     := $(shell which getent || which true 2>/dev/null)
-CHECKUSER  := $(shell $(GETENT) passwd $(USER) >/dev/null 2>/dev/null || (echo "echo User $(USER) nonexistent. Create the user and retry; exit 2"))
-CHECKGROUP := $(shell $(GETENT) group $(GROUP) >/dev/null 2>/dev/null || (echo "echo Group $(GROUP) nonexistent. Create the group and retry; exit 2"))
+CHECKUSER  = $(shell grep $(USER) /etc/passwd >/dev/null 2>/dev/null || (echo "echo User $(USER) nonexistent. Create the user and retry; exit 2"))
+CHECKGROUP = $(shell grep $(GROUP) /etc/group >/dev/null 2>/dev/null || (echo "echo Group $(GROUP) nonexistent. Create the group and retry; exit 2"))
+
+
 
 # For OSX, comment out the previous two lines and comment in these
 #
