title: how to compile MPI and non-MPI version of the same program with automake?
body: <p>I have a C++ code that can be compiled with MPI support depending on a
  certain preprocessor flag; missing the appropriate flag, the sources
  compile to a non-parallel version.</p>
  
  <p>I would like to setup the Makefile.am so that it compiles <em>both</em> the
  MPI-parallel <em>and</em> the sequential version, if an option to
  <code>./configure</code> is given.</p>
  
  <p>Here's the catch: MPI has its own C++ compiler wrapper, and insists
  that sources are compiled and linked using it rather than the standard
  C++ compiler.  If I were to write the Makefile myself, I would have to
  do something like this:</p>
  
  <pre><code>myprog.seq: myprog.cxx
      $(CXX) ... myprog.cxx
  
  myprog.mpi: myprog.cxx
      $(MPICXX) -DWITH_MPI ... myprog.cxx
  </code></pre>
  
  <p>Is there a way to tell automake that it has to use $(MPICXX) instead
  of $(CXX) when compiling the MPI-enabled version of the program?</p>