Index: configure
--- configure.orig	2008-12-08 18:49:13 +0100
+++ configure	2008-12-09 08:30:04 +0100
@@ -33479,6 +33479,7 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
+#include <netdb.h>
 int
 main ()
 {
Index: libguile/__scm.h
--- libguile/__scm.h.orig	2008-12-08 18:42:53 +0100
+++ libguile/__scm.h	2008-12-09 08:30:04 +0100
@@ -427,7 +427,8 @@
  * that all the state of the process is contained in the stack.
  */
 
-#if defined (sparc) || defined (__sparc__) || defined (__sparc)
+#if (defined (sparc) || defined (__sparc__) || defined (__sparc)) && \
+    (!defined(__FreeBSD__))
 # define SCM_FLUSH_REGISTER_WINDOWS asm("ta 3")
 #else
 # define SCM_FLUSH_REGISTER_WINDOWS /* empty */
Index: libguile/filesys.c
--- libguile/filesys.c.orig	2008-12-08 18:42:54 +0100
+++ libguile/filesys.c	2008-12-09 08:30:04 +0100
@@ -883,7 +883,7 @@
   if (!SCM_DIR_OPEN_P (port))
     SCM_MISC_ERROR ("Directory ~S is not open.", scm_list_1 (port));
 
-#if HAVE_READDIR_R
+#if defined(HAVE_READDIR_R) && defined(__linux__)
   /* As noted in the glibc manual, on various systems (such as Solaris) the
      d_name[] field is only 1 char and you're expected to size the dirent
      buffer for readdir_r based on NAME_MAX.  The SCM_MAX expressions below
Index: libguile/gc_os_dep.c
--- libguile/gc_os_dep.c.orig	2008-12-04 19:30:41 +0100
+++ libguile/gc_os_dep.c	2008-12-09 08:30:04 +0100
@@ -115,6 +115,14 @@
 #    define NETBSD
 #    define mach_type_known
 # endif
+# if defined(__FreeBSD__) && defined(__sparc__)
+#    define FREEBSD
+#    include <machine/frame.h>
+#    define ALIGNMENT 8
+#    define CPP_WORDSZ 64
+#    define ALIGN_DOUBLE
+#    define mach_type_known
+# endif
 # if defined(__NetBSD__) && defined(__powerpc__)
 #    define POWERPC
 #    define NETBSD
@@ -249,7 +257,21 @@
 #    define ARM32
 #    define mach_type_known
 # endif
-# if defined(__alpha) || defined(__alpha__)
+# if defined(__FreeBSD__) && defined(__ia64__)
+#    define FREEBSD
+#    define IA64
+#    define mach_type_known
+# endif
+# if defined(__FreeBSD__) && defined(__amd64__)
+#    define FREEBSD
+#    define AMD64
+#    define mach_type_known
+# endif
+# if defined(__FreeBSD__) && defined(__alpha__)
+#   define FREEBSD
+#   define ALPHA
+#   define mach_type_known
+# elif defined(__alpha) || defined(__alpha__)
 #   define ALPHA
 #   if !defined(LINUX) && !defined (NETBSD)
 #     define OSF1	/* a.k.a Digital Unix */
@@ -1158,6 +1180,13 @@
 #   endif
 # endif
 
+# ifdef AMD64
+#   define MACH_TYPE "AMD64"
+#   define ALIGN_DOUBLE
+#   define ALIGNMENT 8
+#   define USE_GENERIC_PUSH_REGS
+# endif
+
 # ifdef IA64
 #   define MACH_TYPE "IA64"
 #   define ALIGN_DOUBLE
@@ -1503,7 +1532,7 @@
 #   include <setjmp.h>
 #endif
 
-#ifdef FREEBSD
+#if defined(FREEBSD) && defined(I386)
 #  include <machine/trap.h>
 #endif
 
