Index: ioemu/Makefile
===================================================================
--- ioemu.orig/Makefile	2007-05-09 13:42:55.000000000 +0100
+++ ioemu/Makefile	2007-05-09 13:42:58.000000000 +0100
@@ -1,6 +1,9 @@
 # Makefile for QEMU.
 
-include config-host.mak
+XEN_ROOT=../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+-include config-host.mak
 
 .PHONY: all clean distclean dvi info install install-doc tar tarbin \
 	speed test test2 html dvi info
@@ -32,9 +35,11 @@
 endif
 endif
 
+TOOLS=
+
 all: $(TOOLS) $(DOCS) recurse-all
 
-subdir-%: dyngen$(EXESUF)
+subdir-%:
 	$(MAKE) -C $(subst subdir-,,$@) all
 
 recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS))
@@ -51,7 +56,7 @@
 	rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS *.pod *~ */*~
 	$(MAKE) -C tests clean
 	for d in $(TARGET_DIRS); do \
-	$(MAKE) -C $$d $@ || exit 1 ; \
+	[ -d $$d ] && $(MAKE) -C $$d $@ || exit 0 ; \
         done
 
 distclean: clean
@@ -67,25 +72,25 @@
 
 install-doc: $(DOCS)
 	mkdir -p "$(DESTDIR)$(docdir)"
-	$(INSTALL) -m 644 qemu-doc.html  qemu-tech.html "$(DESTDIR)$(docdir)"
+	$(INSTALL_DATA) -m 644 qemu-doc.html  qemu-tech.html "$(DESTDIR)$(docdir)"
 ifndef CONFIG_WIN32
 	mkdir -p "$(DESTDIR)$(mandir)/man1"
-	$(INSTALL) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
+	$(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
 endif
 
 install: all $(if $(BUILD_DOCS),install-doc)
 	mkdir -p "$(DESTDIR)$(bindir)"
-	$(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)"
-	mkdir -p "$(DESTDIR)$(datadir)"
-	for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
-		video.x openbios-sparc32 linux_boot.bin pxe-ne2k_pci.bin \
-		pxe-rtl8139.bin pxe-pcnet.bin; do \
-		$(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
-	done
+#	$(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)"
+#	mkdir -p "$(DESTDIR)$(datadir)"
+#	for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
+#		video.x openbios-sparc32 linux_boot.bin pxe-ne2k_pci.bin \
+#		pxe-rtl8139.bin pxe-pcnet.bin; do \
+#		$(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
+#	done
 ifndef CONFIG_WIN32
 	mkdir -p "$(DESTDIR)$(datadir)/keymaps"
 	for x in $(KEYMAPS); do \
-		$(INSTALL) -m 644 $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
+		$(INSTALL_DATA) -m 644 $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
 	done
 endif
 	for d in $(TARGET_DIRS); do \
@@ -97,7 +102,7 @@
 	$(MAKE) -C tests $@
 
 TAGS: 
-	etags *.[ch] tests/*.[ch]
+	etags *.[ch] target-i386-dm/*.[ch] hw/*.[ch]
 
 cscope:
 	rm -f ./cscope.*
@@ -115,11 +120,11 @@
 	texi2dvi $<
 
 qemu.1: qemu-doc.texi
-	$(SRC_PATH)/texi2pod.pl $< qemu.pod
+	perl -w $(SRC_PATH)/texi2pod.pl $< qemu.pod
 	pod2man --section=1 --center=" " --release=" " qemu.pod > $@
 
 qemu-img.1: qemu-img.texi
-	$(SRC_PATH)/texi2pod.pl $< qemu-img.pod
+	perl -w $(SRC_PATH)/texi2pod.pl $< qemu-img.pod
 	pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@
 
 info: qemu-doc.info qemu-tech.info
Index: ioemu/Makefile.target
===================================================================
--- ioemu.orig/Makefile.target	2007-05-09 13:42:55.000000000 +0100
+++ ioemu/Makefile.target	2007-05-09 13:42:58.000000000 +0100
@@ -1,5 +1,8 @@
 include config.mak
 
+XEN_ROOT=../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
 TARGET_BASE_ARCH:=$(TARGET_ARCH)
 ifeq ($(TARGET_ARCH), x86_64)
 TARGET_BASE_ARCH:=i386
@@ -10,9 +13,11 @@
 ifeq ($(TARGET_ARCH), sparc64)
 TARGET_BASE_ARCH:=sparc
 endif
-TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
+TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)$(TARGET_SUB)
 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
 CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH)
+CPPFLAGS+= -I$(XEN_ROOT)/tools/libxc
+CPPFLAGS+= -I$(XEN_ROOT)/tools/xenstore
 ifdef CONFIG_DARWIN_USER
 VPATH+=:$(SRC_PATH)/darwin-user
 CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
@@ -23,6 +28,10 @@
 endif
 BASE_CFLAGS=
 BASE_LDFLAGS=
+SSE2 := $(call cc-option,$(CC),-msse2,)
+ifeq ($(SSE2),-msse2)
+CFLAGS += -DUSE_SSE2=1 -msse2
+endif
 #CFLAGS+=-Werror
 LIBS=
 HELPER_CFLAGS=$(CFLAGS)
@@ -181,8 +190,12 @@
 
 #########################################################
 
-CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+CPPFLAGS+=-D_GNU_SOURCE
+# -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
 LIBS+=-lm
+LIBS+=-L../../libxc -lxenctrl -lxenguest
+LIBS+=-L../../xenstore -lxenstore
+LIBS+=-lpthread
 ifndef CONFIG_USER_ONLY
 LIBS+=-lz
 endif
@@ -311,7 +324,7 @@
 all: $(PROGS)
 
 $(QEMU_USER): $(OBJS)
-	$(CC) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^  $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^  $(LIBS)
 ifeq ($(ARCH),alpha)
 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
 # the address space (31 bit so sign extending doesn't matter)
@@ -574,10 +587,16 @@
 clean:
 	rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
 
+distclean: clean
+	rm -rf config.mak config.h
+
 install: all 
+	mkdir -p "$(DESTDIR)$(bindir)" "$(DESTDIR)$(configdir)"
 ifneq ($(PROGS),)
-	$(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
+	$(INSTALL_PROG) $(PROGS) "$(DESTDIR)$(bindir)"
 endif
+	$(INSTALL_PROG) $(TARGET_PATH)/qemu-dm.debug "$(DESTDIR)$(bindir)"
+	$(INSTALL_PROG) $(TARGET_PATH)/qemu-ifup "$(DESTDIR)$(configdir)"
 
 ifneq ($(wildcard .depend),)
 include .depend
Index: ioemu/configure
===================================================================
--- ioemu.orig/configure	2007-05-09 13:42:55.000000000 +0100
+++ ioemu/configure	2007-05-09 13:42:58.000000000 +0100
@@ -18,8 +18,8 @@
 
 # default parameters
 prefix=""
-interp_prefix="/usr/gnemul/qemu-%M"
 static="no"
+libdir="lib"
 cross_prefix=""
 cc="gcc"
 gcc3_search="yes"
@@ -67,6 +67,7 @@
   ;;
   x86_64|amd64)
     cpu="x86_64"
+    libdir="lib64"
   ;;
   *)
     cpu="unknown"
@@ -92,7 +93,7 @@
 profiler="no"
 cocoa="no"
 check_gfx="yes"
-check_gcc="yes"
+check_gcc="no"
 softmmu="yes"
 linux_user="no"
 darwin_user="no"
@@ -433,6 +434,8 @@
     exit 1
 fi
 
+kqemu="no"
+
 if test -z "$cross_prefix" ; then
 
 # ---
@@ -569,14 +572,16 @@
 datadir="$prefix"
 docdir="$prefix"
 bindir="$prefix"
+configdir=""
 else
 if test -z "$prefix" ; then
     prefix="/usr/local"
 fi
 mandir="$prefix/share/man"
-datadir="$prefix/share/qemu"
+datadir="$prefix/share/xen/qemu"
 docdir="$prefix/share/doc/qemu"
-bindir="$prefix/bin"
+bindir="$prefix/$libdir/xen/bin"
+configdir="/etc/xen"
 fi
 
 echo "Install prefix    $prefix"
@@ -647,6 +652,8 @@
 echo "mandir=$mandir" >> $config_mak
 echo "datadir=$datadir" >> $config_mak
 echo "docdir=$docdir" >> $config_mak
+echo "configdir=$configdir" >> $config_mak
+echo "LIBDIR=$libdir" >> $config_mak
 echo "#define CONFIG_QEMU_SHAREDIR \"$datadir\"" >> $config_h
 echo "MAKE=$make" >> $config_mak
 echo "INSTALL=$install" >> $config_mak
@@ -843,7 +850,7 @@
 # don't use ln -sf as not all "ln -sf" over write the file/link
 #
 rm -f $target_dir/Makefile
-ln -s $source_path/Makefile.target $target_dir/Makefile
+ln -s ../Makefile.target $target_dir/Makefile
 
 
 echo "# Automatically generated by configure - do not modify" > $config_mak
@@ -857,6 +864,12 @@
 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
 echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
 
+target_sub=
+if expr $target : '.*-dm' > /dev/null ; then
+  target_sub=-dm
+fi
+echo "TARGET_SUB=${target_sub}" >> $config_mak
+
 if test "$target_cpu" = "i386" ; then
   echo "TARGET_ARCH=i386" >> $config_mak
   echo "#define TARGET_ARCH \"i386\"" >> $config_h
@@ -935,6 +948,9 @@
   echo "CONFIG_DARWIN_USER=yes" >> $config_mak
   echo "#define CONFIG_DARWIN_USER 1" >> $config_h
 fi
+if expr $target : '.*-dm' > /dev/null ; then
+  echo "#define CONFIG_DM 1" >> $config_h
+fi
 
 if test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" -o "$target_cpu" = "sparc" -o "$target_cpu" = "sparc64" -o "$target_cpu" = "m68k"; then
   echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
