$NetBSD: patch-aa,v 1.5 2013/09/10 14:37:50 joerg Exp $

--- Makefile.defs.orig	2004-07-27 11:38:33.000000000 +0000
+++ Makefile.defs
@@ -85,9 +85,14 @@ man-prefix = $(basedir)$(prefix)
 ut-prefix = $(basedir)$(prefix)
 
 # dirs
-cfg-dir = etc/ser/
+cfg-dir = ser/
+eg-dir  = $(EGDIR)/
 bin-dir = sbin/
 modules-dir = lib/ser/modules/
+ifeq (1, 1)
+	doc-dir = share/doc/ser
+	man-dir = $(PKGMANDIR)
+else
 ifeq ($(OS), linux)
 	doc-dir = share/doc/ser/
 	man-dir = share/man/
@@ -104,6 +109,10 @@ ifeq ($(OS), netbsd)
 	doc-dir = share/doc/ser
 	man-dir = man/
 else
+ifeq ($(OS), dragonfly)
+	doc-dir = share/doc/ser
+	man-dir = man/
+else
 ifeq ($(OS), darwin)
 	doc-dir = share/doc/ser/
 	man-dir = man/
@@ -115,9 +124,11 @@ endif
 endif
 endif
 endif
+endif
+endif
 ut-prefix = bin/
 # target dirs for various stuff
-cfg-target = $(prefix)/$(cfg-dir)
+cfg-target = $(PKG_SYSCONFDIR)/
 modules-target = $(prefix)/$(modules-dir)
 
 
@@ -133,10 +144,10 @@ endif
 INSTALL-TOUCH = touch          # used to create the file first (good to 
                                #  make solaris install work)
 # INSTALL-CFG = $(INSTALL) -m 644
-INSTALL-BIN = $(INSTALL) -m 755
-INSTALL-MODULES = $(INSTALL) -m 755
-INSTALL-DOC = $(INSTALL) -m 644
-INSTALL-MAN = $(INSTALL) -m 644
+INSTALL-BIN = $(INSTALL) -c -m 755
+INSTALL-MODULES = $(INSTALL) -c -m 755
+INSTALL-DOC = $(INSTALL) -c -m 644
+INSTALL-MAN = $(INSTALL) -c -m 644
 
 #set some vars from the environment (and not make builtins)
 CC   := $(shell echo "$${CC}")
@@ -173,6 +184,19 @@ ifneq (,$(findstring gcc, $(CC_LONGVER))
 				 	's/3\../3.0/')
 endif
 
+ifneq (,$(findstring clang, $(CC_LONGVER)))
+	CC_NAME=gcc
+	CC_VER=$(CC) $(shell $(CC) --version|head -n 1| \
+				 sed -e 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/' -e 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
+	# sun sed is a little brain damaged => this complicated expression
+	MKDEP=$(CC) -MM 
+	#transform gcc version into 2.9x or 3.0
+	CC_SHORTVER=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
+				 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
+				 sed -e 's/2\.9.*/2.9x/' -e 's/3\..\..*/3.0/' -e \
+				 	's/3\../3.0/')
+endif
+
 ifneq (, $(findstring Sun, $(CC_LONGVER)))
 	CC_NAME=suncc
 	CC_SHORTVER=$(shell echo "$(CC_LONGVER)"|head -n 1| \
@@ -384,6 +408,10 @@ ifeq ($(ARCH), i386)
 	use_fast_lock=yes
 endif
 
+ifeq ($(ARCH), amd64)
+	use_fast_lock=yes
+endif
+
 ifeq ($(ARCH), sparc64)
 ifeq 	($(CC_NAME), gcc)
 	use_fast_lock=yes
@@ -639,6 +667,7 @@ ifeq	($(CC_NAME), suncc)
 endif
 
 endif #mode=release
+LDFLAGS+= -L${BUILDLINK_PREFIX.pthread}/lib ${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.pthread}/lib
 
 
 #*FLAGS used for compiling the modules
@@ -743,6 +772,19 @@ ifeq ($(OS), netbsd)
 	LIBS= -lfl 
 endif
 
+ifeq ($(OS), dragonfly)
+	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
+		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL
+	ifneq ($(found_lock_method), yes)
+		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
+		found_lock_method=yes
+		LIBS= -pthread -lfl  #dlopen is in libc
+	else
+		LIBS= -lfl  #dlopen is in libc
+	endif
+	YACC=yacc
+endif
+
 # OS X support, same as freebsd
 ifeq ($(OS), darwin)
 	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
