Autotools: compiling two C++ files with two compilers...

Federico Zenith <[email protected]>
Newsgroups gmane.comp.gnu.utils
Message-ID <[email protected]>
Hi all,
sorry if the question may be lame, but it's my first package with
Autotools...

In short, I have some C++ files that have to be compiled. One accepts g++,
the others have to use mkoctfile, that is a wrapper used by GNU Octave to
compile a dynamically-linked function that one can later use in Octave.

I have tried redefining the CXX variable (as it is done in a configure.base
file in Octave-Forge project: is that an old autoconf stuff?), and now I am
pretty much trying to add a GNU-Make rule (without the various autotools
magic). Yet, this really should not be this difficult: I want to compile a
file with a compiler and another file with another compiler. I must be
missing something big time!

The files are in a src/ dir; this is my current src/Makefile.am:
(don't worry about the libfuelcell.la thing, it's the only thing that works
like a charm)
-------------------
LDADD = ../lib/libfuelcell.la
AM_CPPFLAGS = -I$(srcdir)/../lib

noinst_PROGRAMS = polariser

if MKOCTFILE
noinst_PROGRAMS += correlationMatrix
endif

polariser_SOURCES = polariser.cpp
correlationMatrix_SOURCES = correlationMatrix.cpp
--------------------
Of course this crashes at build time, as correlationMatrix.cpp cannot be
built directly with g++.

My idea would be to compile polariser.cpp with g++ and correlationMatrix.cpp
with mkoctfile (the shell command is usually "mkoctfile
correlationMatrix.cpp, which generates a correlationMatrix.oct file).

Variable MKOCTFILE is defined in configure.ac with:
--------------------
AC_CHECK_PROG([MKOCTFILE], [mkoctfile], [mkoctfile])
test -z "$MKOCTFILE" && AC_MSG_WARN([Dynamically linked functions need
Octave's mkoctfile to compile.])
AM_CONDITIONAL([MKOCTFILE], [test "$MKOCTFILE" = mkoctfile])
--------------------

Can anyone point me to how I define my own build rules in a Makefile.am? If
I try to define something like:
-------------------
correlationMatrix: correlationMatrix.cpp
        mkoctfile $(srcdir)/correlationMatrix.cpp
-------------------
I get complaints from autoreconf --install about correlationMatrix
overriding correlationMatrix$(EXEEXT), and instructions to change the
target to the latter (which however does not change much, I still get the
error only written once instead of twice).

Thanks!
-Federico
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.