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.

I would like to setup the Makefile.am so that it compiles both the MPI-parallel and the sequential version, if an option to ./configure is given.

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:

myprog.seq: myprog.cxx
    $(CXX) ... myprog.cxx

myprog.mpi: myprog.cxx
    $(MPICXX) -DWITH_MPI ... myprog.cxx

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?

Edit
Report