diff --git a/xen/scripts/Makefile.host b/xen/scripts/Makefile.host
index d6c358095ee8..d083c6dbca76 100644
--- a/xen/scripts/Makefile.host
+++ b/xen/scripts/Makefile.host
@@ -8,7 +8,7 @@ target-stem = $(basename $(patsubst $(obj)/%,%,$@))
 quiet_cmd_flex = LEX     $@
       cmd_flex = $(LEX) -o$@ -L $<
 
-$(obj)/%.lex.c: $(src)/%.l FORCE
+$(obj)/%.lex.c: $(srctree)/$(src)/%.l FORCE
 	$(call if_changed,flex)
 
 # YACC
@@ -16,7 +16,7 @@ $(obj)/%.lex.c: $(src)/%.l FORCE
 quiet_cmd_bison = YACC    $(basename $@).[ch]
       cmd_bison = $(YACC) -o $(basename $@).c --defines=$(basename $@).h -t -l $<
 
-$(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
+$(obj)/%.tab.c $(obj)/%.tab.h: $(srctree)/$(src)/%.y FORCE
 	$(call if_changed,bison)
 
 # ==========================================================================
@@ -56,6 +56,11 @@ host-cmulti	:= $(foreach m,$(__hostprogs),\
 
 # Object (.o) files compiled from .c files
 host-cobjs	:= $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
+# from generated .c files
+host-cobjs-generated	:= $(sort $(foreach m,$(__hostprogs),$($(m)-objs-generated)))
+ifndef building_out_of_srctree
+host-cobjs += $(host-cobjs-generated)
+endif
 
 # C++ code
 # C++ executables compiled from at least one .cc file
@@ -72,6 +77,9 @@ host-cxxshobjs	:= $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
 host-csingle	:= $(addprefix $(obj)/,$(host-csingle))
 host-cmulti	:= $(addprefix $(obj)/,$(host-cmulti))
 host-cobjs	:= $(addprefix $(obj)/,$(host-cobjs))
+ifdef building_out_of_srctree
+host-cobjs-generated	:= $(addprefix $(obj)/,$(host-cobjs-generated))
+endif
 host-cxxmulti	:= $(addprefix $(obj)/,$(host-cxxmulti))
 host-cxxobjs	:= $(addprefix $(obj)/,$(host-cxxobjs))
 host-cshlib	:= $(addprefix $(obj)/,$(host-cshlib))
@@ -104,25 +112,30 @@ hostcxx_flags  = -Wp,-MD,$(depfile) $(_hostcxx_flags)
 quiet_cmd_host-csingle 	= HOSTCC  $@
       cmd_host-csingle	= $(HOSTCC) $(hostc_flags) $(HOSTLDFLAGS) -o $@ $< \
 		$(HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
-$(host-csingle): $(obj)/%: $(src)/%.c FORCE
+$(host-csingle): $(obj)/%: $(srctree)/$(src)/%.c FORCE
 	$(call if_changed_dep,host-csingle)
 
 # Link an executable based on list of .o files, all plain c
 # host-cmulti -> executable
 quiet_cmd_host-cmulti	= HOSTLD  $@
       cmd_host-cmulti	= $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
-			  $(addprefix $(obj)/, $($(target-stem)-objs)) \
+			  $(foreach o,objs objs-generated, \
+			  $(addprefix $(obj)/, $($(target-stem)-$(o)))) \
 			  $(HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
 $(host-cmulti): FORCE
 	$(call if_changed,host-cmulti)
-$(call multi-depend, $(host-cmulti), , -objs)
+$(call multi-depend, $(host-cmulti), , -objs -objs-generated)
 
 # Create .o file from a single .c file
 # host-cobjs -> .o
 quiet_cmd_host-cobjs	= HOSTCC  $@
       cmd_host-cobjs	= $(HOSTCC) $(hostc_flags) -c -o $@ $<
-$(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE
+$(host-cobjs): $(obj)/%.o: $(srctree)/$(src)/%.c FORCE
 	$(call if_changed_dep,host-cobjs)
+ifdef building_out_of_srctree
+$(host-cobjs-generated): $(obj)/%.o: $(obj)/%.c FORCE
+	$(call if_changed_dep,host-cobjs)
+endif
 
 # Link an executable based on list of .o files, a mixture of .c and .cc
 # host-cxxmulti -> executable
@@ -138,14 +151,14 @@ $(call multi-depend, $(host-cxxmulti), , -objs -cxxobjs)
 # Create .o file from a single .cc (C++) file
 quiet_cmd_host-cxxobjs	= HOSTCXX $@
       cmd_host-cxxobjs	= $(HOSTCXX) $(hostcxx_flags) -c -o $@ $<
-$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE
+$(host-cxxobjs): $(obj)/%.o: $(srctree)/$(src)/%.cc FORCE
 	$(call if_changed_dep,host-cxxobjs)
 
 # Compile .c file, create position independent .o file
 # host-cshobjs -> .o
 quiet_cmd_host-cshobjs	= HOSTCC  -fPIC $@
       cmd_host-cshobjs	= $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $<
-$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
+$(host-cshobjs): $(obj)/%.o: $(srctree)/$(src)/%.c FORCE
 	$(call if_changed_dep,host-cshobjs)
 
 # Compile .c file, create position independent .o file
@@ -155,7 +168,7 @@ $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
 # host-cxxshobjs -> .o
 quiet_cmd_host-cxxshobjs	= HOSTCXX -fPIC $@
       cmd_host-cxxshobjs	= $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
-$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
+$(host-cxxshobjs): $(obj)/%.o: $(srctree)/$(src)/%.c FORCE
 	$(call if_changed_dep,host-cxxshobjs)
 
 # Link a shared library, based on position independent .o files
@@ -180,3 +193,6 @@ $(call multi-depend, $(host-cxxshlib), .so, -objs)
 
 targets += $(host-csingle)  $(host-cmulti) $(host-cobjs)\
 	   $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
+ifdef building_out_of_srctree
+targets += $(host-cobjs-generated)
+endif
diff --git a/xen/tools/kconfig/Makefile b/xen/tools/kconfig/Makefile
index b7b9a419ad59..c2ecf4b36652 100644
--- a/xen/tools/kconfig/Makefile
+++ b/xen/tools/kconfig/Makefile
@@ -146,8 +146,9 @@ help:
 
 # ===========================================================================
 # object files used by all kconfig flavours
-common-objs	:= confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \
+common-objs	:= confdata.o expr.o  preprocess.o \
 		   symbol.o
+common-objs-generated := lexer.lex.o parser.tab.o
 
 $(obj)/lexer.lex.o: $(obj)/parser.tab.h
 HOSTCFLAGS_lexer.lex.o	:= -I $(srctree)/$(src)
@@ -156,10 +157,12 @@ HOSTCFLAGS_parser.tab.o	:= -I $(srctree)/$(src)
 # conf: Used for defconfig, oldconfig and related targets
 hostprogs-y	+= conf
 conf-objs	:= conf.o $(common-objs)
+conf-objs-generated := $(common-objs-generated)
 
 # nconf: Used for the nconfig target based on ncurses
 hostprogs-y	+= nconf
 nconf-objs	:= nconf.o nconf.gui.o $(common-objs)
+nconf-objs-generated := $(common-objs-generated)
 
 HOSTLDLIBS_nconf	= $(shell . $(obj)/nconf-cfg && echo $$libs)
 HOSTCFLAGS_nconf.o	= $(shell . $(obj)/nconf-cfg && echo $$cflags)
@@ -172,6 +175,7 @@ hostprogs-y	+= mconf
 lxdialog	:= $(addprefix lxdialog/, \
 		     checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
 mconf-objs	:= mconf.o $(lxdialog) $(common-objs)
+mconf-objs-generated	:= $(common-objs-generated)
 
 HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
 $(foreach f, mconf.o $(lxdialog), \
@@ -183,6 +187,7 @@ $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
 hostprogs-y	+= qconf
 qconf-cxxobjs	:= qconf.o
 qconf-objs	:= images.o $(common-objs)
+qconf-objs-generated	:= $(common-objs-generated)
 
 HOSTLDLIBS_qconf	= $(shell . $(obj)/qconf-cfg && echo $$libs)
 HOSTCXXFLAGS_qconf.o	= $(shell . $(obj)/qconf-cfg && echo $$cflags)
@@ -192,12 +197,13 @@ $(obj)/qconf.o: $(obj)/qconf-cfg $(obj)/qconf.moc
 quiet_cmd_moc = MOC     $@
       cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) -i $< -o $@
 
-$(obj)/%.moc: $(src)/%.h $(obj)/qconf-cfg
+$(obj)/%.moc: $(srctree)/$(src)/%.h $(obj)/qconf-cfg
 	$(call cmd,moc)
 
 # gconf: Used for the gconfig target based on GTK+
 hostprogs-y	+= gconf
 gconf-objs	:= gconf.o images.o $(common-objs)
+gconf-objs-generated	:= $(common-objs-generated)
 
 HOSTLDLIBS_gconf    = $(shell . $(obj)/gconf-cfg && echo $$libs)
 HOSTCFLAGS_gconf.o  = $(shell . $(obj)/gconf-cfg && echo $$cflags)
@@ -207,7 +213,7 @@ $(obj)/gconf.o: $(obj)/gconf-cfg
 # check if necessary packages are available, and configure build flags
 filechk_conf_cfg = $(CONFIG_SHELL) $<
 
-$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
+$(obj)/%conf-cfg: $(srctree)/$(src)/%conf-cfg.sh FORCE
 	$(call filechk,conf_cfg)
 
 clean-files += *conf-cfg
