diff --git a/.gitignore b/.gitignore
index d546609..5d6a78e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 config-host.*
+config-target.*
 i386
 *-softmmu
 *-darwin-user
diff --git a/Makefile b/Makefile
index bd180f9..7664c83 100644
--- a/Makefile
+++ b/Makefile
@@ -182,7 +182,7 @@ qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx

 clean:
 # avoid old build problems by removing potentially incorrect old files
-	rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
+	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
 	rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~
 	rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d
 	rm -f qemu-img-cmds.h
diff --git a/Makefile.target b/Makefile.target
index ede4008..ae88fc9 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -1,7 +1,7 @@
 # -*- Mode: makefile -*-

 include ../config-host.mak
-include config.mak
+include config-target.mak
 include $(SRC_PATH)/rules.mak

 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..516acee
--- /dev/null
+++ b/config.h
@@ -0,0 +1,3 @@
+
+#include "config-host.h"
+#include "config-target.h"
diff --git a/configure b/configure
index c2ccd8d..061156e 100755
--- a/configure
+++ b/configure
@@ -1774,8 +1774,8 @@ fi

 for target in $target_list; do
 target_dir="$target"
-config_mak=$target_dir/config.mak
-config_h=$target_dir/config.h
+config_target_mak=$target_dir/config-target.mak
+config_target_h=$target_dir/config-target.h
 target_arch2=`echo $target | cut -d '-' -f 1`
 target_bigendian="no"
 case "$target_arch2" in
@@ -1810,9 +1810,9 @@ case "$target" in
     ;;
 esac

-#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
+#echo "Creating $config_target_mak, $config_target_h and $target_dir/Makefile"

-test -f $config_h && mv $config_h ${config_h}~
+test -f $config_target_h && mv $config_target_h ${config_target_h}~

 mkdir -p $target_dir
 mkdir -p $target_dir/fpu
@@ -1828,13 +1828,13 @@ rm -f $target_dir/Makefile
 ln -s $source_path/Makefile.target $target_dir/Makefile


-echo "# Automatically generated by configure - do not modify" > $config_mak
+echo "# Automatically generated by configure - do not modify" > $config_target_mak

 bflt="no"
 elfload32="no"
 target_nptl="no"
 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
-echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_mak
+echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
 gdb_xml_files=""

 TARGET_ARCH="$target_arch2"
@@ -1875,20 +1875,20 @@ case "$target_arch2" in
   ;;
   mips|mipsel)
     TARGET_ARCH=mips
-    echo "TARGET_ABI_MIPSO32=y" >> $config_mak
+    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
     target_nptl="yes"
     target_phys_bits=64
   ;;
   mipsn32|mipsn32el)
     TARGET_ARCH=mipsn32
     TARGET_BASE_ARCH=mips
-    echo "TARGET_ABI_MIPSN32=y" >> $config_mak
+    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
     target_phys_bits=64
   ;;
   mips64|mips64el)
     TARGET_ARCH=mips64
     TARGET_BASE_ARCH=mips
-    echo "TARGET_ABI_MIPSN64=y" >> $config_mak
+    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
     target_phys_bits=64
   ;;
   ppc)
@@ -1913,7 +1913,7 @@ case "$target_arch2" in
     TARGET_ARCH=ppc64
     TARGET_BASE_ARCH=ppc
     TARGET_ABI_DIR=ppc
-    echo "TARGET_ABI32=y" >> $config_mak
+    echo "TARGET_ABI32=y" >> $config_target_mak
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
     target_phys_bits=64
   ;;
@@ -1935,7 +1935,7 @@ case "$target_arch2" in
     TARGET_ARCH=sparc64
     TARGET_BASE_ARCH=sparc
     TARGET_ABI_DIR=sparc
-    echo "TARGET_ABI32=y" >> $config_mak
+    echo "TARGET_ABI32=y" >> $config_target_mak
     target_phys_bits=64
   ;;
   *)
@@ -1943,26 +1943,26 @@ case "$target_arch2" in
     exit 1
   ;;
 esac
-echo "TARGET_ARCH=$TARGET_ARCH" >> $config_mak
+echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
 target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
-echo "TARGET_$target_arch_name=y" >> $config_mak
-echo "TARGET_ARCH2=$target_arch2" >> $config_mak
+echo "TARGET_$target_arch_name=y" >> $config_target_mak
+echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
 if [ "$TARGET_BASE_ARCH" = "" ]; then
   TARGET_BASE_ARCH=$TARGET_ARCH
 fi
-echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_mak
+echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
 if [ "$TARGET_ABI_DIR" = "" ]; then
   TARGET_ABI_DIR=$TARGET_ARCH
 fi
-echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_mak
+echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
 if [ $target_phys_bits -lt $hostlongbits ] ; then
   target_phys_bits=$hostlongbits
 fi
 case "$target_arch2" in
   i386|x86_64)
     if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
-      echo "CONFIG_XEN=y" >> $config_mak
+      echo "CONFIG_XEN=y" >> $config_target_mak
     fi
 esac
 case "$target_arch2" in
@@ -1974,28 +1974,28 @@ case "$target_arch2" in
       \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
       \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
       \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
-      echo "CONFIG_KVM=y" >> $config_mak
-      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
+      echo "CONFIG_KVM=y" >> $config_target_mak
+      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
     fi
 esac
-echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_mak
-echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_mak
+echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_target_mak
+echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
 if test "$target_bigendian" = "yes" ; then
-  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_mak
+  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
 fi
 if test "$target_softmmu" = "yes" ; then
-  echo "CONFIG_SOFTMMU=y" >> $config_mak
-  echo "LIBS+=$libs_softmmu" >> $config_mak
+  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
+  echo "LIBS+=$libs_softmmu" >> $config_target_mak
 fi
 if test "$target_user_only" = "yes" ; then
-  echo "CONFIG_USER_ONLY=y" >> $config_mak
+  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
 fi
 if test "$target_linux_user" = "yes" ; then
-  echo "CONFIG_LINUX_USER=y" >> $config_mak
+  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
 fi
 if test "$target_darwin_user" = "yes" ; then
-  echo "CONFIG_DARWIN_USER=y" >> $config_mak
+  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
 fi
 list=""
 if test ! -z "$gdb_xml_files" ; then
@@ -2003,33 +2003,33 @@ if test ! -z "$gdb_xml_files" ; then
     list="$list $source_path/gdb-xml/$x"
   done
 fi
-echo "TARGET_XML_FILES=$list" >> $config_mak
+echo "TARGET_XML_FILES=$list" >> $config_target_mak

 case "$target_arch2" in
   arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
-    echo "CONFIG_SOFTFLOAT=y" >> $config_mak
+    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
     ;;
   *)
-    echo "CONFIG_NOSOFTFLOAT=y" >> $config_mak
+    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
     ;;
 esac

 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
-  echo "TARGET_HAS_BFLT=y" >> $config_mak
+  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
 fi
 if test "$target_user_only" = "yes" \
         -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
-  echo "CONFIG_USE_NPTL=y" >> $config_mak
+  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
 fi
 # 32 bit ELF loader in addition to native 64 bit loader?
 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
-  echo "TARGET_HAS_ELFLOAD32=y" >> $config_mak
+  echo "TARGET_HAS_ELFLOAD32=y" >> $config_target_mak
 fi
 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
-  echo "CONFIG_USE_GUEST_BASE=y" >> $config_mak
+  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
 fi
 if test "$target_bsd_user" = "yes" ; then
-  echo "CONFIG_BSD_USER=y" >> $config_mak
+  echo "CONFIG_BSD_USER=y" >> $config_target_mak
 fi

 # generate QEMU_CFLAGS/LDFLAGS for targets
@@ -2048,40 +2048,40 @@ cflags="-I\$(SRC_PATH)/fpu $cflags"
 for i in $ARCH $TARGET_BASE_ARCH ; do
   case "$i" in
   alpha)
-    echo "CONFIG_ALPHA_DIS=y"  >> $config_mak
+    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
   ;;
   arm)
-    echo "CONFIG_ARM_DIS=y"  >> $config_mak
+    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
   ;;
   cris)
-    echo "CONFIG_CRIS_DIS=y"  >> $config_mak
+    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
   ;;
   hppa)
-    echo "CONFIG_HPPA_DIS=y"  >> $config_mak
+    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
   ;;
   i386|x86_64)
-    echo "CONFIG_I386_DIS=y"  >> $config_mak
+    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
   ;;
   m68k)
-    echo "CONFIG_M68K_DIS=y"  >> $config_mak
+    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
   ;;
   microblaze)
-    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_mak
+    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
   ;;
   mips*)
-    echo "CONFIG_MIPS_DIS=y"  >> $config_mak
+    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
   ;;
   ppc*)
-    echo "CONFIG_PPC_DIS=y"  >> $config_mak
+    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
   ;;
   s390)
-    echo "CONFIG_S390_DIS=y"  >> $config_mak
+    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
   ;;
   sh4)
-    echo "CONFIG_SH4_DIS=y"  >> $config_mak
+    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
   ;;
   sparc*)
-    echo "CONFIG_SPARC_DIS=y"  >> $config_mak
+    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
   ;;
   esac
 done
@@ -2110,18 +2110,18 @@ fi
 if test "$target_softmmu" = "yes" -a \( \
         "$TARGET_ARCH" = "microblaze" -o \
         "$TARGET_ARCH" = "cris" \) ; then
-  echo "CONFIG_NEED_MMU=y" >> $config_mak
+  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
 fi

 if test "$gprof" = "yes" ; then
-  echo "TARGET_GPROF=yes" >> $config_mak
+  echo "TARGET_GPROF=yes" >> $config_target_mak
   if test "$target_linux_user" = "yes" ; then
     cflags="-p $cflags"
     ldflags="-p $ldflags"
   fi
   if test "$target_softmmu" = "yes" ; then
     ldflags="-p $ldflags"
-    echo "GPROF_CFLAGS=-p" >> $config_mak
+    echo "GPROF_CFLAGS=-p" >> $config_target_mak
   fi
 fi

@@ -2158,18 +2158,18 @@ if test "$target_softmmu" = "yes" ; then
   esac
 fi

-echo "LDFLAGS+=$ldflags" >> $config_mak
-echo "QEMU_CFLAGS+=$cflags" >> $config_mak
+echo "LDFLAGS+=$ldflags" >> $config_target_mak
+echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak

-echo "#include \"../config-host.h\"" > $config_h
+echo "#include \"../config-host.h\"" > $config_target_h

-/bin/sh $source_path/create_config < $config_mak >> $config_h
+/bin/sh $source_path/create_config < $config_target_mak >> $config_target_h

-if test -f ${config_h}~ ; then
-  if cmp -s $config_h ${config_h}~ ; then
-    mv ${config_h}~ $config_h
+if test -f ${config_target_h}~ ; then
+  if cmp -s $config_target_h ${config_target_h}~ ; then
+    mv ${config_target_h}~ $config_target_h
   else
-    rm ${config_h}~
+    rm ${config_target_h}~
   fi
 fi

