$OpenBSD: patch-Makefile,v 1.19 2009/03/29 22:23:35 sthen Exp $
--- Makefile.orig	Sat Nov 29 16:58:29 2008
+++ Makefile	Wed Feb 18 20:05:57 2009
@@ -35,6 +35,7 @@ export ASTVARRUNDIR
 export MODULES_DIR
 export ASTSPOOLDIR
 export ASTVARLIBDIR
+export ASTDBDIR
 export ASTDATADIR
 export ASTLOGDIR
 export ASTLIBDIR
@@ -82,7 +83,7 @@ ASTCFLAGS+=$(COPTS)
 ASTLDFLAGS+=$(LDOPTS)
 
 #Uncomment this to see all build commands instead of 'quiet' output
-#NOISY_BUILD=yes
+NOISY_BUILD=yes
 
 # Create OPTIONS variable
 OPTIONS=
@@ -95,7 +96,7 @@ ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
 OVERWRITE=y
 
 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
-DEBUG=-g3
+DEBUG?=-g3
 
 # Staging directory
 # Files are copied here temporarily during the install process
@@ -130,6 +131,7 @@ else
 ifneq ($(findstring BSD,$(OSARCH)),)
   ASTVARLIBDIR=$(prefix)/share/asterisk
   ASTVARRUNDIR=$(localstatedir)/run/asterisk
+  ASTDBDIR=$(localstatedir)/db/asterisk
 else
   ASTVARLIBDIR=$(localstatedir)/lib/asterisk
 endif
@@ -158,8 +160,10 @@ HTTP_CGIDIR=/var/www/cgi-bin
 # The file /etc/asterisk.makeopts will also be included but can be overridden
 # by the file in your home directory.
 
+ifneq ($(OSARCH),OpenBSD)
 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
+endif
 
 MOD_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
 OTHER_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
@@ -198,8 +202,10 @@ ifeq ($(OSARCH),linux-gnu)
 endif
 
 ifeq ($(findstring -save-temps,$(ASTCFLAGS)),)
+ifneq ($(OSARCH),OpenBSD)
 ASTCFLAGS+=-pipe
 endif
+endif
 
 ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
 
@@ -219,9 +225,11 @@ ifneq ($(findstring BSD,$(OSARCH)),)
   ASTLDFLAGS+=-L/usr/local/lib
 endif
 
+ifneq ($(OSARCH),OpenBSD)
 ifneq ($(PROC),ultrasparc)
   ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
 endif
+endif
 
 ifeq ($(PROC),ppc)
   ASTCFLAGS+=-fsigned-char
@@ -581,6 +589,7 @@ samples: adsi
 		echo "astetcdir => $(ASTETCDIR)" ; \
 		echo "astmoddir => $(MODULES_DIR)" ; \
 		echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
+		echo "astdbdir => $(ASTDBDIR)" ; \
 		echo "astdatadir => $(ASTDATADIR)" ; \
 		echo "astagidir => $(AGI_DIR)" ; \
 		echo "astspooldir => $(ASTSPOOLDIR)" ; \
@@ -611,16 +620,16 @@ samples: adsi
 		echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
 		echo ";transmit_silence = yes ; Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated" ; \
 		echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
-		echo ";runuser = asterisk ; The user to run as" ; \
-		echo ";rungroup = asterisk ; The group to run as" ; \
+		echo "runuser = _asterisk ; The user to run as" ; \
+		echo "rungroup = _asterisk ; The group to run as" ; \
 		echo ";dahdichanname = yes ; Channels created by chan_dahdi will be called 'DAHDI', otherwise 'Zap'" ; \
 		echo "" ; \
 		echo "; Changing the following lines may compromise your security." ; \
-		echo ";[files]" ; \
-		echo ";astctlpermissions = 0660" ; \
-		echo ";astctlowner = root" ; \
-		echo ";astctlgroup = apache" ; \
-		echo ";astctl = asterisk.ctl" ; \
+		echo "[files]" ; \
+		echo "astctlpermissions = 0660" ; \
+		echo "astctlowner = _asterisk" ; \
+		echo "astctlgroup = wheel" ; \
+		echo "astctl = asterisk.ctl" ; \
 		) > $(DESTDIR)$(ASTCONFPATH) ; \
 	else \
 		echo "Skipping asterisk.conf creation"; \
