This commit merges the BUILD_TWEAKS branch onto the trunk.  It has the
following improvements:

- Arch/OS/platform-specific files are now included/excluded via the
  preprocessor, rather than via the build system.  This is more consistent
  (we use the pre-processor for small arch/OS/platform-specific chunks
  within files) and makes the build system much simpler, as the sources for
  all programs are the same on all platforms.

- Vast amounts of cut+paste Makefile.am code has been factored out.  If a
  new platform is implemented, you need to add 11 extra Makefile.am lines.
  Previously it was over 100 lines.

- Vex has been autotoolised.  Dependency checking now works in Vex (no more
  incomplete builds).  Parallel builds now also work.  --with-vex no longer
  works;  it's little use and a pain to support.  VEX/Makefile is still in
  the Vex repository and gets overwritten at configure-time;  it should
  probably be renamed Makefile-gcc to avoid possible problems, such as
  accidentally committing a generated Makefile.  There's a bunch of hacky
  copying to deal with the fact that autotools don't handle same-named files
  in different directories.  Julian plans to rename the files to avoid this
  problem.

- Various small Makefile.am things have been made more standard automake
  style, eg. the use of pkginclude/pkglib prefixes instead of rolling our
  own.

- The existing five top-level Makefile.am include files have been
  consolidated into three.

- Most Makefile.am files now are structured more clearly, with comment
  headers separating sections, declarations relating to the same things next
  to each other, better spacing and layout, etc.

- Removed the unused exp-ptrcheck/tests/x86 directory.

- Renamed some XML files.

- Factored out some duplicated dSYM handling code.

- Split auxprogs/ into auxprogs/ and mpi/, which allowed the resulting
  Makefile.am files to be much more standard.

- Cleaned up m_coredump by merging a bunch of files that had been
  overzealously separated.

The net result is 630 fewer lines of Makefile.am code, or 897 if you exclude
the added Makefile.vex.am, or 997 once the hacky file copying for Vex is
removed.  And the build system is much simpler.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10364 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/cachegrind/Makefile.am b/cachegrind/Makefile.am
index f165e8d..04c798e 100644
--- a/cachegrind/Makefile.am
+++ b/cachegrind/Makefile.am
@@ -1,102 +1,68 @@
 include $(top_srcdir)/Makefile.tool.am
 
+#----------------------------------------------------------------------------
+# Headers, etc
+#----------------------------------------------------------------------------
+
 bin_SCRIPTS = cg_annotate
 
-noinst_HEADERS = cg_arch.h cg_sim.c cg_branchpred.c
+noinst_HEADERS = \
+	cg_arch.h \
+	cg_branchpred.c \
+	cg_sim.c
 
-noinst_PROGRAMS = 
-if VGCONF_PLATFORMS_INCLUDE_X86_LINUX
-noinst_PROGRAMS += cachegrind-x86-linux
-endif
-if VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX
-noinst_PROGRAMS += cachegrind-amd64-linux
-endif
-if VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX
-noinst_PROGRAMS += cachegrind-ppc32-linux
-endif
-if VGCONF_PLATFORMS_INCLUDE_PPC64_LINUX
-noinst_PROGRAMS += cachegrind-ppc64-linux
-endif
-if VGCONF_PLATFORMS_INCLUDE_PPC32_AIX5
-noinst_PROGRAMS += cachegrind-ppc32-aix5
-endif
-if VGCONF_PLATFORMS_INCLUDE_PPC64_AIX5
-noinst_PROGRAMS += cachegrind-ppc64-aix5
-endif
-if VGCONF_PLATFORMS_INCLUDE_X86_DARWIN
-noinst_PROGRAMS += cachegrind-x86-darwin
-endif
-if VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN
-noinst_PROGRAMS += cachegrind-amd64-darwin
-endif
+#----------------------------------------------------------------------------
+# cg_merge (built for the primary target only)
+#----------------------------------------------------------------------------
 
-# Build cg_merge for the primary target only.
 bin_PROGRAMS = cg_merge
+
 cg_merge_SOURCES = cg_merge.c
 cg_merge_CPPFLAGS  = $(AM_CPPFLAGS_PRI)
 cg_merge_CFLAGS    = $(AM_CFLAGS_PRI)
 cg_merge_CCASFLAGS = $(AM_CCASFLAGS_PRI)
 cg_merge_LDFLAGS   = $(AM_CFLAGS_PRI)
 
+#----------------------------------------------------------------------------
+# cachegrind-<platform>
+#----------------------------------------------------------------------------
 
-CACHEGRIND_SOURCES_COMMON = cg_main.c
-CACHEGRIND_SOURCES_X86 = cg-x86.c
-CACHEGRIND_SOURCES_AMD64 = cg-amd64.c
-CACHEGRIND_SOURCES_PPC32 = cg-ppc32.c
-CACHEGRIND_SOURCES_PPC64 = cg-ppc64.c
+noinst_PROGRAMS  = cachegrind-@VGCONF_ARCH_PRI@-@VGCONF_OS@
+if VGCONF_HAVE_PLATFORM_SEC
+noinst_PROGRAMS += cachegrind-@VGCONF_ARCH_SEC@-@VGCONF_OS@
+endif
 
-cachegrind_x86_linux_SOURCES      = $(CACHEGRIND_SOURCES_COMMON) $(CACHEGRIND_SOURCES_X86)
-cachegrind_x86_linux_CPPFLAGS     = $(AM_CPPFLAGS_X86_LINUX)
-cachegrind_x86_linux_CFLAGS       = $(AM_CFLAGS_X86_LINUX)
-cachegrind_x86_linux_DEPENDENCIES = $(COREGRIND_LIBS_X86_LINUX)
-cachegrind_x86_linux_LDADD        = $(TOOL_LDADD_X86_LINUX)
-cachegrind_x86_linux_LDFLAGS      = $(TOOL_LDFLAGS_X86_LINUX)
+CACHEGRIND_SOURCES_COMMON = \
+	cg_main.c \
+	cg-x86-amd64.c \
+	cg-ppc32.c \
+	cg-ppc64.c
 
-cachegrind_amd64_linux_SOURCES      = $(CACHEGRIND_SOURCES_COMMON) $(CACHEGRIND_SOURCES_AMD64)
-cachegrind_amd64_linux_CPPFLAGS     = $(AM_CPPFLAGS_AMD64_LINUX)
-cachegrind_amd64_linux_CFLAGS       = $(AM_CFLAGS_AMD64_LINUX)
-cachegrind_amd64_linux_DEPENDENCIES = $(COREGRIND_LIBS_AMD64_LINUX)
-cachegrind_amd64_linux_LDADD        = $(TOOL_LDADD_AMD64_LINUX)
-cachegrind_amd64_linux_LDFLAGS      = $(TOOL_LDFLAGS_AMD64_LINUX)
+cachegrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_SOURCES      = \
+	$(CACHEGRIND_SOURCES_COMMON)
+cachegrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CPPFLAGS     = \
+	$(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
+cachegrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS       = \
+	$(AM_CFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
+cachegrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_DEPENDENCIES = \
+	$(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_PRI_CAPS@)
+cachegrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDADD        = \
+	$(TOOL_LDADD_@VGCONF_PLATFORM_PRI_CAPS@)
+cachegrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS      = \
+	$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
+if VGCONF_HAVE_PLATFORM_SEC
+cachegrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_SOURCES      = \
+	$(CACHEGRIND_SOURCES_COMMON)
+cachegrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CPPFLAGS     = \
+	$(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
+cachegrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS       = \
+	$(AM_CFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
+cachegrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_DEPENDENCIES = \
+	$(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_SEC_CAPS@)
+cachegrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDADD        = \
+	$(TOOL_LDADD_@VGCONF_PLATFORM_SEC_CAPS@)
+cachegrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS      = \
+	$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
+endif
 
-cachegrind_ppc32_linux_SOURCES      = $(CACHEGRIND_SOURCES_COMMON) $(CACHEGRIND_SOURCES_PPC32)
-cachegrind_ppc32_linux_CPPFLAGS     = $(AM_CPPFLAGS_PPC32_LINUX)
-cachegrind_ppc32_linux_CFLAGS       = $(AM_CFLAGS_PPC32_LINUX)
-cachegrind_ppc32_linux_DEPENDENCIES = $(COREGRIND_LIBS_PPC32_LINUX)
-cachegrind_ppc32_linux_LDADD        = $(TOOL_LDADD_PPC32_LINUX)
-cachegrind_ppc32_linux_LDFLAGS      = $(TOOL_LDFLAGS_PPC32_LINUX)
 
-cachegrind_ppc64_linux_SOURCES      = $(CACHEGRIND_SOURCES_COMMON) $(CACHEGRIND_SOURCES_PPC64)
-cachegrind_ppc64_linux_CPPFLAGS     = $(AM_CPPFLAGS_PPC64_LINUX)
-cachegrind_ppc64_linux_CFLAGS       = $(AM_CFLAGS_PPC64_LINUX)
-cachegrind_ppc64_linux_DEPENDENCIES = $(COREGRIND_LIBS_PPC64_LINUX)
-cachegrind_ppc64_linux_LDADD        = $(TOOL_LDADD_PPC64_LINUX)
-cachegrind_ppc64_linux_LDFLAGS      = $(TOOL_LDFLAGS_PPC64_LINUX)
-
-cachegrind_ppc32_aix5_SOURCES      = $(CACHEGRIND_SOURCES_COMMON) $(CACHEGRIND_SOURCES_PPC32)
-cachegrind_ppc32_aix5_CPPFLAGS     = $(AM_CPPFLAGS_PPC32_AIX5)
-cachegrind_ppc32_aix5_CFLAGS       = $(AM_CFLAGS_PPC32_AIX5)
-cachegrind_ppc32_aix5_DEPENDENCIES = $(COREGRIND_LIBS_PPC32_AIX5)
-cachegrind_ppc32_aix5_LDADD        = $(TOOL_LDADD_PPC32_AIX5)
-cachegrind_ppc32_aix5_LDFLAGS      = $(TOOL_LDFLAGS_PPC32_AIX5)
-
-cachegrind_ppc64_aix5_SOURCES      = $(CACHEGRIND_SOURCES_COMMON) $(CACHEGRIND_SOURCES_PPC64)
-cachegrind_ppc64_aix5_CPPFLAGS     = $(AM_CPPFLAGS_PPC64_AIX5)
-cachegrind_ppc64_aix5_CFLAGS       = $(AM_CFLAGS_PPC64_AIX5)
-cachegrind_ppc64_aix5_DEPENDENCIES = $(COREGRIND_LIBS_PPC64_AIX5)
-cachegrind_ppc64_aix5_LDADD        = $(TOOL_LDADD_PPC64_AIX5)
-cachegrind_ppc64_aix5_LDFLAGS      = $(TOOL_LDFLAGS_PPC64_AIX5)
-
-cachegrind_x86_darwin_SOURCES      = $(CACHEGRIND_SOURCES_COMMON) $(CACHEGRIND_SOURCES_X86)
-cachegrind_x86_darwin_CPPFLAGS     = $(AM_CPPFLAGS_X86_DARWIN)
-cachegrind_x86_darwin_CFLAGS       = $(AM_CFLAGS_X86_DARWIN)
-cachegrind_x86_darwin_DEPENDENCIES = $(COREGRIND_LIBS_X86_DARWIN)
-cachegrind_x86_darwin_LDADD        = $(TOOL_LDADD_X86_DARWIN)
-cachegrind_x86_darwin_LDFLAGS      = $(TOOL_LDFLAGS_X86_DARWIN)
-
-cachegrind_amd64_darwin_SOURCES      = $(CACHEGRIND_SOURCES_COMMON) $(CACHEGRIND_SOURCES_AMD64)
-cachegrind_amd64_darwin_CPPFLAGS     = $(AM_CPPFLAGS_AMD64_DARWIN)
-cachegrind_amd64_darwin_CFLAGS       = $(AM_CFLAGS_AMD64_DARWIN)
-cachegrind_amd64_darwin_DEPENDENCIES = $(COREGRIND_LIBS_AMD64_DARWIN)
-cachegrind_amd64_darwin_LDADD        = $(TOOL_LDADD_AMD64_DARWIN)
-cachegrind_amd64_darwin_LDFLAGS      = $(TOOL_LDFLAGS_AMD64_DARWIN)
diff --git a/cachegrind/cg-amd64.c b/cachegrind/cg-amd64.c
deleted file mode 100644
index 9b0c653..0000000
--- a/cachegrind/cg-amd64.c
+++ /dev/null
@@ -1,35 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- AMD64-specific definitions.                       cg-amd64.c ---*/
-/*--------------------------------------------------------------------*/
-
-/*
-   This file is part of Cachegrind, a Valgrind tool for cache
-   profiling programs.
-
-   Copyright (C) 2002-2009 Nicholas Nethercote
-      njn@valgrind.org
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307, USA.
-
-   The GNU General Public License is contained in the file COPYING.
-*/
-
-#include "cg-x86.c"
-
-/*--------------------------------------------------------------------*/
-/*--- end                                                          ---*/
-/*--------------------------------------------------------------------*/
diff --git a/cachegrind/cg-ppc32.c b/cachegrind/cg-ppc32.c
index 570e208..bfd5d5e 100644
--- a/cachegrind/cg-ppc32.c
+++ b/cachegrind/cg-ppc32.c
@@ -28,6 +28,8 @@
    The GNU General Public License is contained in the file COPYING.
 */
 
+#if defined(VGA_ppc32)
+
 #include "pub_tool_basics.h"
 #include "pub_tool_libcbase.h"
 #include "pub_tool_libcassert.h"
@@ -59,6 +61,8 @@
    }
 }
 
+#endif // defined(VGA_ppc32)
+
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/
 /*--------------------------------------------------------------------*/
diff --git a/cachegrind/cg-ppc64.c b/cachegrind/cg-ppc64.c
index beb1f34..5b6e99f 100644
--- a/cachegrind/cg-ppc64.c
+++ b/cachegrind/cg-ppc64.c
@@ -28,6 +28,8 @@
    The GNU General Public License is contained in the file COPYING.
 */
 
+#if defined(VGA_ppc64)
+
 #include "pub_tool_basics.h"
 #include "pub_tool_libcbase.h"
 #include "pub_tool_libcassert.h"
@@ -59,6 +61,8 @@
    }
 }
 
+#endif
+
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/
 /*--------------------------------------------------------------------*/
diff --git a/cachegrind/cg-x86.c b/cachegrind/cg-x86-amd64.c
similarity index 98%
rename from cachegrind/cg-x86.c
rename to cachegrind/cg-x86-amd64.c
index be5eb82..821a8c7 100644
--- a/cachegrind/cg-x86.c
+++ b/cachegrind/cg-x86-amd64.c
@@ -1,6 +1,6 @@
 
 /*--------------------------------------------------------------------*/
-/*--- x86-specific (and AMD64-specific) definitions.      cg-x86.c ---*/
+/*--- x86- and AMD64-specific definitions.          cg-x86-amd64.c ---*/
 /*--------------------------------------------------------------------*/
 
 /*
@@ -28,6 +28,8 @@
    The GNU General Public License is contained in the file COPYING.
 */
 
+#if defined(VGA_x86) || defined(VGA_amd64)
+
 #include "pub_tool_basics.h"
 #include "pub_tool_cpuid.h"
 #include "pub_tool_libcbase.h"
@@ -347,6 +349,8 @@
    }
 }
 
+#endif // defined(VGA_x86) || defined(VGA_amd64)
+
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/
 /*--------------------------------------------------------------------*/
diff --git a/cachegrind/tests/Makefile.am b/cachegrind/tests/Makefile.am
index f7f12a7..e21d52d 100644
--- a/cachegrind/tests/Makefile.am
+++ b/cachegrind/tests/Makefile.am
@@ -8,9 +8,9 @@
 
 DIST_SUBDIRS = x86 .
 
-noinst_SCRIPTS = filter_stderr filter_cachesim_discards
+dist_noinst_SCRIPTS = filter_stderr filter_cachesim_discards
 
-EXTRA_DIST = $(noinst_SCRIPTS) \
+EXTRA_DIST = \
 	chdir.vgtest chdir.stderr.exp \
 	clreq.vgtest clreq.stderr.exp \
 	dlclose.vgtest dlclose.stderr.exp dlclose.stdout.exp \
diff --git a/cachegrind/tests/x86/Makefile.am b/cachegrind/tests/x86/Makefile.am
index 12d96e9..1d141ef 100644
--- a/cachegrind/tests/x86/Makefile.am
+++ b/cachegrind/tests/x86/Makefile.am
@@ -1,9 +1,9 @@
 
 include $(top_srcdir)/Makefile.tool-tests.am
 
-noinst_SCRIPTS = filter_stderr
+dist_noinst_SCRIPTS = filter_stderr
 
-EXTRA_DIST = $(noinst_SCRIPTS) \
+EXTRA_DIST = \
 	fpu-28-108.vgtest fpu-28-108.stderr.exp
 
 check_PROGRAMS = \