Out of tree build. Partial fix for Bug 333628.

Patch by Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>.
Partial fix. make && make check now works with builddir != srcdir.
But make regtest doesn't yet.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13949 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/Makefile.all.am b/Makefile.all.am
index d4be312..96eb840 100644
--- a/Makefile.all.am
+++ b/Makefile.all.am
@@ -117,6 +117,7 @@
 	-I$(top_srcdir) \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/VEX/pub \
+	-I$(top_builddir)/VEX/pub \
 	-DVGA_@VGCONF_ARCH_PRI@=1 \
 	-DVGO_@VGCONF_OS@=1 \
 	-DVGP_@VGCONF_ARCH_PRI@_@VGCONF_OS@=1 \
@@ -126,6 +127,7 @@
 	-I$(top_srcdir) \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/VEX/pub \
+	-I$(top_builddir)/VEX/pub \
 	-DVGA_@VGCONF_ARCH_SEC@=1 \
 	-DVGO_@VGCONF_OS@=1 \
 	-DVGP_@VGCONF_ARCH_SEC@_@VGCONF_OS@=1 \
diff --git a/Makefile.am b/Makefile.am
index 2426b5c..eae5172 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,12 +65,12 @@
 default.supp: $(DEFAULT_SUPP_FILES)
 	echo "# This is a generated file, composed of the following suppression rules:" > default.supp
 	echo "# " $(DEFAULT_SUPP_FILES) >> default.supp
-	cat $(DEFAULT_SUPP_FILES) >> default.supp
+	cat $^ >> default.supp
 
 ## Preprend @PERL@ because tests/vg_regtest isn't executable
 ## Ensure make exits with error if PERL fails or post_regtest_checks fails.
 regtest: check
-	gdbserver_tests/make_local_links $(GDB)
+	$(top_srcdir)/gdbserver_tests/make_local_links $(GDB)
 	if @PERL@ tests/vg_regtest gdbserver_tests $(TOOLS) $(EXP_TOOLS) ; then \
 	   tests/post_regtest_checks $(abs_top_srcdir) gdbserver_tests $(TOOLS) $(EXP_TOOLS); \
 	else \
diff --git a/Makefile.tool-tests.am b/Makefile.tool-tests.am
index 299ba7b..6521afb 100644
--- a/Makefile.tool-tests.am
+++ b/Makefile.tool-tests.am
@@ -5,6 +5,7 @@
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include \
 		-I$(top_srcdir)/coregrind -I$(top_builddir)/include \
 		-I$(top_srcdir)/VEX/pub \
+		-I$(top_builddir)/VEX/pub \
 		-DVGA_@VGCONF_ARCH_PRI@=1 \
 		-DVGO_@VGCONF_OS@=1 \
 		-DVGP_@VGCONF_ARCH_PRI@_@VGCONF_OS@=1 \
diff --git a/Makefile.vex.am b/Makefile.vex.am
index 5adbae8..41690e1 100644
--- a/Makefile.vex.am
+++ b/Makefile.vex.am
@@ -79,11 +79,12 @@
 			    pub/libvex_guest_mips32.h \
 			    pub/libvex_guest_mips64.h
 	rm -f auxprogs/genoffsets.s
+	$(mkdir_p) auxprogs pub
 	$(CC) $(CFLAGS) \
 	      $(LIBVEX_CFLAGS) \
 	      $(AM_CFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) \
 				-O -S -o auxprogs/genoffsets.s \
-					 auxprogs/genoffsets.c
+					 $(srcdir)/auxprogs/genoffsets.c
 	grep xyzzy auxprogs/genoffsets.s | grep "^#define" \
 	   | sed "s/xyzzy\\$$//g" \
 	   | sed "s/xyzzy#//g" \
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index 99f767c..c3ba6bb 100644
--- a/coregrind/Makefile.am
+++ b/coregrind/Makefile.am
@@ -640,7 +640,7 @@
 
 BUILT_SOURCES += fixup_macho_loadcmds
 fixup_macho_loadcmds: fixup_macho_loadcmds.c
-	$(CC) -g -Wall -o fixup_macho_loadcmds fixup_macho_loadcmds.c
+	$(CC) -g -Wall -o $@ $<
 
 CLEANFILES += fixup_macho_loadcmds