diff -ru qemu-0.7.1.orig/Makefile qemu-0.7.1/Makefile
--- qemu-0.7.1.orig/Makefile	Sun Jul 24 13:52:08 2005
+++ qemu-0.7.1/Makefile	Fri Aug  5 11:46:04 2005
@@ -18,12 +18,16 @@
 	$(MAKE) -C $$d $@ || exit 1 ; \
         done
 ifdef CONFIG_KQEMU
+ifdef CONFIG_FREEBSD
+	make -C kqemu -f Makefile.freebsd
+else
 ifdef CONFIG_WIN32
 	$(MAKE) -C kqemu -f Makefile.winnt
 else
 	$(MAKE) -C kqemu
 endif
 endif
+endif
 
 qemu-img$(EXESUF): qemu-img.c block.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c
 	$(CC) -DQEMU_TOOL $(CFLAGS) $(LDFLAGS) $(DEFINES) -o $@ $^ -lz $(LIBS)
@@ -40,8 +44,16 @@
 	$(MAKE) -C $$d $@ || exit 1 ; \
         done
 ifdef CONFIG_KQEMU
+ifdef CONFIG_FREEBSD
+	rm -f kqemu/kqemu.ko kqemu/kqemu-freebsd.o
+else
+ifdef CONFIG_WIN32
+	$(MAKE) -C kqemu -f Makefile.winnt clean
+else
 	$(MAKE) -C kqemu clean
 endif
+endif
+endif
 
 distclean: clean
 	rm -f config-host.mak config-host.h
@@ -74,7 +86,11 @@
 	$(MAKE) -C $$d $@ || exit 1 ; \
         done
 ifdef CONFIG_KQEMU
+ifdef CONFIG_FREEBSD
+	cp kqemu/kqemu.ko $(modulesdir)
+else
 	cd kqemu ; ./install.sh
+endif
 endif
 
 # various test targets
diff -ru qemu-0.7.1.orig/configure qemu-0.7.1/configure
--- qemu-0.7.1.orig/configure	Sun Jul 24 13:52:08 2005
+++ qemu-0.7.1/configure	Fri Aug  5 11:35:31 2005
@@ -275,7 +275,15 @@
 
 if test -z "$sdl" ; then
 
-sdl_config="sdl-config"
+if test "$bsd" = "yes" ; then
+    if test -n "${SDL_CONFIG}" ; then
+        sdl_config="${SDL_CONFIG}"
+    else
+        sdl_config="sdl11-config"
+    fi
+else
+    sdl_config="sdl-config"
+fi
 sdl=no
 sdl_static=no
 
@@ -366,7 +374,12 @@
 if test -z "$prefix" ; then
     prefix="/usr/local"
 fi
-mandir="$prefix/share/man"
+if test "$bsd" = "yes" ; then
+    mandir="$prefix/man"
+    modulesdir="$prefix/modules"
+else
+    mandir="$prefix/share/man"
+fi
 datadir="$prefix/share/qemu"
 docdir="$prefix/share/doc/qemu"
 bindir="$prefix/bin"
@@ -419,6 +432,9 @@
 echo "binary directory  $bindir"
 if test "$mingw32" = "no" ; then
 echo "Manual directory  $mandir"
+if test "$bsd" = "yes" ; then
+echo "Modules directory  $modulesdir"
+fi
 echo "ELF interp prefix $interp_prefix"
 fi
 echo "Source path       $source_path"
@@ -475,6 +491,9 @@
 echo "prefix=$prefix" >> $config_mak
 echo "bindir=$bindir" >> $config_mak
 echo "mandir=$mandir" >> $config_mak
+if test "$bsd" = "yes" ; then
+echo "modulesdir=$modulesdir" >> $config_mak
+fi
 echo "datadir=$datadir" >> $config_mak
 echo "docdir=$docdir" >> $config_mak
 echo "#define CONFIG_QEMU_SHAREDIR \"$datadir\"" >> $config_h
@@ -534,6 +553,9 @@
   echo "#define WORDS_BIGENDIAN 1" >> $config_h
 fi
 echo "#define HOST_LONG_BITS $hostlongbits" >> $config_h
+if test "$targetos" = "FreeBSD" ; then
+  echo "CONFIG_FREEBSD=yes" >> $config_mak
+fi
 if test "$mingw32" = "yes" ; then
   echo "CONFIG_WIN32=yes" >> $config_mak
   echo "#define CONFIG_WIN32 1" >> $config_h
diff -ru qemu-0.7.1.orig/fpu/softfloat-native.h qemu-0.7.1/fpu/softfloat-native.h
--- qemu-0.7.1.orig/fpu/softfloat-native.h	Sun Jul 24 13:52:08 2005
+++ qemu-0.7.1/fpu/softfloat-native.h	Wed Aug  3 00:15:19 2005
@@ -36,9 +36,9 @@
 #if defined(_BSD) && !defined(__APPLE__)
 enum {
     float_round_nearest_even = FP_RN,
-    float_round_down         = FE_RM,
-    float_round_up           = FE_RP,
-    float_round_to_zero      = FE_RZ
+    float_round_down         = FP_RM,
+    float_round_up           = FP_RP,
+    float_round_to_zero      = FP_RZ
 };
 #elif defined(__arm__)
 enum {
diff -ru qemu-0.7.1.orig/osdep.c qemu-0.7.1/osdep.c
--- qemu-0.7.1.orig/osdep.c	Sun Jul 24 13:52:08 2005
+++ qemu-0.7.1/osdep.c	Wed Aug  3 00:16:18 2005
@@ -277,6 +277,8 @@
 #include <windows.h>
 #elif defined(_BSD)
 #include <stdlib.h>
+#include <sys/param.h>
+#include <sys/mount.h>
 #else
 #include <malloc.h>
 #endif
@@ -323,7 +325,9 @@
 
 #elif defined(USE_KQEMU)
 
+#ifndef _BSD
 #include <sys/vfs.h>
+#endif
 #include <sys/mman.h>
 #include <fcntl.h>
 
diff -ru qemu-0.7.1.orig/qemu.1 qemu-0.7.1/qemu.1
--- qemu-0.7.1.orig/qemu.1	Sun Jul 24 13:52:08 2005
+++ qemu-0.7.1/qemu.1	Fri Aug  5 04:18:49 2005
@@ -296,6 +296,10 @@
 Note that a \s-1SAMBA\s0 server must be installed on the host \s-1OS\s0 in
 \&\fI/usr/sbin/smbd\fR. \s-1QEMU\s0 was tested succesfully with smbd version
 2.2.7a from the Red Hat 9.
+.IP "\fB\-smb\-conf file\fR" 4
+.IX Item "-smb-conf file"
+Specify a user SAMBA configuration file. This file will be appended to the
+default smb.conf created by -smb option. It is useful for printer setting.
 .IP "\fB\-redir [tcp|udp]:host\-port:[guest\-host]:guest\-port\fR" 4
 .IX Item "-redir [tcp|udp]:host-port:[guest-host]:guest-port"
 When using the user mode network stack, redirect incoming \s-1TCP\s0 or \s-1UDP\s0
diff -ru qemu-0.7.1.orig/sdl.c qemu-0.7.1/sdl.c
--- qemu-0.7.1.orig/sdl.c	Sun Jul 24 13:52:08 2005
+++ qemu-0.7.1/sdl.c	Wed Aug  3 01:28:49 2005
@@ -114,9 +114,9 @@
    0xb5,      /* 112  Divide */
    0xb8,      /* 113  Alt-R  */
    0xc6,      /* 114  Break  */   
-   0x0,         /* 115 */
-   0x0,         /* 116 */
-   0x0,         /* 117 */
+   0xdb,         /* 115 windows left button */
+   0xdc,         /* 116 windows right button */
+   0xdd,         /* 117 right menu button */
    0x0,         /* 118 */
    0x0,         /* 119 */
    0x70,         /* 120 Hiragana_Katakana */
diff -ru qemu-0.7.1.orig/vl.c qemu-0.7.1/vl.c
--- qemu-0.7.1.orig/vl.c	Sun Jul 24 13:52:08 2005
+++ qemu-0.7.1/vl.c	Fri Aug  5 04:05:38 2005
@@ -105,6 +105,12 @@
 /* XXX: use a two level table to limit memory usage */
 #define MAX_IOPORTS 65536
 
+#ifdef _BSD
+#define SMBD "/usr/local/sbin/smbd"
+#else
+#define SMBD "/usr/bin/smbd"
+#endif
+
 const char *bios_dir = CONFIG_QEMU_SHAREDIR;
 char phys_ram_file[1024];
 CPUState *global_env;
@@ -1544,7 +1550,7 @@
 }
 
 /* automatic user mode samba server configuration */
-void net_slirp_smb(const char *exported_dir)
+void net_slirp_smb(const char *exported_dir, const char *user_conf)
 {
     char smb_conf[1024];
     char smb_cmdline[1024];
@@ -1589,11 +1595,20 @@
             smb_dir,
             exported_dir
             );
+    if(user_conf){
+	    FILE *f2 = fopen(user_conf, "r");
+	    char buf[1024];
+
+	    if(f2){
+		    while(!feof(f2) && fgets(buf, 1024, f2))
+			    fprintf(f, "%s", buf);
+		    fclose(f2);
+	    }
+    }
     fclose(f);
     atexit(smb_exit);
 
-    snprintf(smb_cmdline, sizeof(smb_cmdline), "/usr/sbin/smbd -s %s",
-             smb_conf);
+    snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s", SMBD, smb_conf);
     
     slirp_add_exec(0, smb_cmdline, 4, 139);
 }
@@ -2830,6 +2845,7 @@
            "-tftp prefix    allow tftp access to files starting with prefix [-user-net]\n"
 #ifndef _WIN32
            "-smb dir        allow SMB access to files in 'dir' [-user-net]\n"
+           "-smb-conf file  append 'file' to SMB configuration (useful for printer setting)\n"
 #endif
            "-redir [tcp|udp]:host-port:[guest-host]:guest-port\n"
            "                redirect TCP or UDP connections from host to guest [-user-net]\n"
@@ -2917,6 +2933,7 @@
     QEMU_OPTION_user_net,
     QEMU_OPTION_tftp,
     QEMU_OPTION_smb,
+    QEMU_OPTION_smb_conf,
     QEMU_OPTION_redir,
     QEMU_OPTION_dummy_net,
 
@@ -2982,6 +2999,7 @@
     { "tftp", HAS_ARG, QEMU_OPTION_tftp },
 #ifndef _WIN32
     { "smb", HAS_ARG, QEMU_OPTION_smb },
+    { "smb-conf", HAS_ARG, QEMU_OPTION_smb_conf },
 #endif
     { "redir", HAS_ARG, QEMU_OPTION_redir },
 #endif
@@ -3120,6 +3138,9 @@
     int parallel_device_index;
     const char *loadvm = NULL;
     QEMUMachine *machine;
+#ifndef _WIN32
+    const char *opt_smb = NULL, *opt_smb_conf = NULL;
+#endif
 
 #if !defined(CONFIG_SOFTMMU)
     /* we never want that malloc() uses mmap() */
@@ -3361,7 +3382,10 @@
                 break;
 #ifndef _WIN32
             case QEMU_OPTION_smb:
-		net_slirp_smb(optarg);
+		opt_smb = optarg;
+                break;
+            case QEMU_OPTION_smb_conf:
+		opt_smb_conf = optarg;
                 break;
 #endif
             case QEMU_OPTION_user_net:
@@ -3521,6 +3545,10 @@
             }
         }
     }
+#ifndef _WIN32
+    if(opt_smb)
+	    net_slirp_smb(opt_smb, opt_smb_conf);
+#endif
 
     linux_boot = (kernel_filename != NULL);
         
