Index: bdb/mutex/mut_fcntl.c
--- bdb/mutex/mut_fcntl.c.orig	2006-11-03 03:15:45 +0100
+++ bdb/mutex/mut_fcntl.c	2006-11-27 18:12:12 +0100
@@ -101,7 +101,7 @@
 
 		/* Acquire an exclusive kernel lock. */
 		k_lock.l_type = F_WRLCK;
-		if (fcntl(dbenv->lockfhp->fd, F_SETLKW, &k_lock))
+		if (fcntl(dbenv->lockfhp->fd, F_SETLKW, &k_lock) == -1)
 			return (__os_get_errno());
 
 		/* If the resource is still available, it's ours. */
@@ -112,7 +112,7 @@
 
 		/* Release the kernel lock. */
 		k_lock.l_type = F_UNLCK;
-		if (fcntl(dbenv->lockfhp->fd, F_SETLK, &k_lock))
+		if (fcntl(dbenv->lockfhp->fd, F_SETLK, &k_lock) == -1)
 			return (__os_get_errno());
 
 		/*
Index: bdb/os/os_open.c
--- bdb/os/os_open.c.orig	2006-11-03 03:17:24 +0100
+++ bdb/os/os_open.c	2006-11-27 18:12:12 +0100
@@ -93,7 +93,7 @@
 	if (LF_ISSET(DB_OSO_TRUNC))
 		oflags |= O_TRUNC;
 
-#ifdef HAVE_O_DIRECT
+#if defined(HAVE_O_DIRECT) && defined(__FreeBSD__)
 	if (LF_ISSET(DB_OSO_DIRECT))
 		oflags |= O_DIRECT;
 #endif
Index: include/Makefile.in
--- include/Makefile.in.orig	2006-11-03 03:18:30 +0100
+++ include/Makefile.in	2006-11-27 18:12:12 +0100
@@ -343,14 +343,14 @@
 			errmsg.h my_global.h my_net.h my_alloc.h \
 			my_getopt.h sslopt-longopts.h my_dir.h typelib.h \
 			sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
-			sql_state.h mysql_time.h $(BUILT_SOURCES)
+			sql_state.h mysql_time.h my_aes.h rijndael.h $(BUILT_SOURCES)
 
 noinst_HEADERS = config-win.h config-os2.h config-netware.h \
 			nisam.h heap.h merge.h my_bitmap.h\
 			myisam.h myisampack.h myisammrg.h ft_global.h\
 			mysys_err.h my_base.h help_start.h help_end.h \
-			my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \
-			my_aes.h my_tree.h hash.h thr_alarm.h \
+			my_nosys.h my_alarm.h queues.h sha1.h \
+			my_tree.h hash.h thr_alarm.h \
 			thr_lock.h t_ctype.h violite.h md5.h \
 			mysql_version.h.in my_handler.h my_time.h
 
Index: include/my_global.h
--- include/my_global.h.orig	2006-11-03 03:17:10 +0100
+++ include/my_global.h	2006-11-27 18:12:12 +0100
@@ -718,9 +718,8 @@
 #define FLT_MAX		((float)3.40282346638528860e+38)
 #endif
 
-#if !defined(HAVE_ISINF) && !defined(isinf)
+#undef isinf
 #define isinf(X)    0
-#endif
 
 /*
   Max size that must be added to a so that we know Size to make
Index: libmysql/Makefile.in
--- libmysql/Makefile.in.orig	2006-11-03 03:18:31 +0100
+++ libmysql/Makefile.in	2006-11-27 18:12:12 +0100
@@ -213,6 +213,7 @@
 DARWIN_MWCC_FALSE = @DARWIN_MWCC_FALSE@
 DARWIN_MWCC_TRUE = @DARWIN_MWCC_TRUE@
 DEFS = -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
+			-DETCDIR="\"$(MYSQLETCdir)\"" \
 			-DDATADIR="\"$(MYSQLDATAdir)\"" \
 			-DSHAREDIR="\"$(MYSQLSHAREdir)\"" $(target_defs)
 
@@ -427,6 +428,7 @@
 INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
 		$(openssl_includes) @ZLIB_INCLUDES@
 
+MYSQLETCdir = $(sysconfdir)
 MYSQLDATAdir = $(localstatedir)
 MYSQLSHAREdir = $(pkgdatadir)
 MYSQLBASEdir = $(prefix)
Index: libmysql_r/Makefile.in
--- libmysql_r/Makefile.in.orig	2006-11-03 03:18:32 +0100
+++ libmysql_r/Makefile.in	2006-11-27 18:12:12 +0100
@@ -210,6 +210,7 @@
 DARWIN_MWCC_FALSE = @DARWIN_MWCC_FALSE@
 DARWIN_MWCC_TRUE = @DARWIN_MWCC_TRUE@
 DEFS = -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
+			-DETCDIR="\"$(MYSQLETCdir)\"" \
 			-DDATADIR="\"$(MYSQLDATAdir)\"" \
 			-DSHAREDIR="\"$(MYSQLSHAREdir)\"" $(target_defs)
 
@@ -425,6 +426,7 @@
 		-I$(top_builddir)/include -I$(top_srcdir)/include \
 		$(openssl_includes) @ZLIB_INCLUDES@
 
+MYSQLETCdir = $(sysconfdir)
 MYSQLDATAdir = $(localstatedir)
 MYSQLSHAREdir = $(pkgdatadir)
 MYSQLBASEdir = $(prefix)
Index: mysys/Makefile.in
--- mysys/Makefile.in.orig	2006-11-03 03:18:37 +0100
+++ mysys/Makefile.in	2006-11-27 18:12:12 +0100
@@ -194,6 +194,7 @@
 DARWIN_MWCC_FALSE = @DARWIN_MWCC_FALSE@
 DARWIN_MWCC_TRUE = @DARWIN_MWCC_TRUE@
 DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
+			-DETCDIR="\"$(MYSQLETCdir)\"" \
 			-DDATADIR="\"$(MYSQLDATAdir)\"" \
 			-DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
 			-DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
@@ -406,6 +407,7 @@
 vio_dir = @vio_dir@
 vio_libs = @vio_libs@
 zlib_dir = @zlib_dir@
+MYSQLETCdir = $(sysconfdir)
 MYSQLDATAdir = $(localstatedir)
 MYSQLSHAREdir = $(pkgdatadir)
 MYSQLBASEdir = $(prefix)
Index: mysys/default.c
--- mysys/default.c.orig	2006-11-03 03:16:23 +0100
+++ mysys/default.c	2006-11-27 18:12:12 +0100
@@ -48,7 +48,7 @@
 #elif defined(__NETWARE__)
 "sys:/etc/",
 #else
-"/etc/",
+ETCDIR,
 #endif
 #ifdef DATADIR
 DATADIR,
Index: scripts/mysql_config.sh
--- scripts/mysql_config.sh.orig	2006-11-03 03:16:02 +0100
+++ scripts/mysql_config.sh	2006-11-27 18:15:41 +0100
@@ -98,9 +98,9 @@
 
 # Create options 
 # We intentionally add a space to the beginning and end of lib strings, simplifies replace later
-libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
+libs=" $ldflags -L$pkglibdir -lmysqlclient -lmysys @ZLIB_DEPS@ @NON_THREADED_LIBS@"
 libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
-libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@ "
+libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r -lmysys @ZLIB_DEPS@ @LIBS@ @openssl_libs@ "
 embedded_libs=" $ldflags -L$pkglibdir -lmysqld @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@ "
 
 cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
Index: scripts/mysql_create_system_tables.sh
--- scripts/mysql_create_system_tables.sh.orig	2006-11-03 03:15:41 +0100
+++ scripts/mysql_create_system_tables.sh	2006-11-27 18:12:12 +0100
@@ -71,9 +71,6 @@
   c_d="$c_d ) engine=MyISAM"
   c_d="$c_d CHARACTER SET utf8 COLLATE utf8_bin"
   c_d="$c_d comment='Database privileges';"
-  
-  i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
-  INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');"
 fi
 
 if test ! -f $mdata/host.frm
@@ -150,17 +147,13 @@
   then
     i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
     INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
-    REPLACE INTO user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
-    INSERT INTO user (host,user) values ('localhost','');
-    INSERT INTO user (host,user) values ('$hostname','');"
+    REPLACE INTO user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);"
   else
     i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);"
     if test "$windows" = "0"
     then
       i_u="$i_u
-           INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
-           INSERT INTO user (host,user) values ('$hostname','');
-           INSERT INTO user (host,user) values ('localhost','');"
+           INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);"
     else
       i_u="$i_u
 	   INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);"
Index: scripts/mysqld_safe.sh
--- scripts/mysqld_safe.sh.orig	2006-11-03 03:15:43 +0100
+++ scripts/mysqld_safe.sh	2006-11-27 18:12:12 +0100
@@ -150,7 +150,7 @@
 # Next try where the source installs put it
 elif test -d $MY_BASEDIR_VERSION/var/mysql
 then
-  DATADIR=$MY_BASEDIR_VERSION/var
+  DATADIR=$MY_BASEDIR_VERSION/var/mysql
 # Or just give up and use our compiled-in default
 else
   DATADIR=@localstatedir@
