Automake: for each target compiler

I am using a custom compilation chain and I have multiple targets that need to be compiled, however they need to be compiled using different cxx compilers. Can this be used with automake? It seems impossible to do something like:

target_CXX = ...


Ideally I would like something like:

target1_SOURCES = ...
target2_SOURCES = ...

target1_CXX = ...
target1_CXXFLAGS = ..

target2_CXX = ...
targer2_CXXFLAGS = ...


Or even better in fact, having target1 use specific target1_CXX and target2 using the normal CXX flag.

Target1 should be noinst and only generate object files. These object files must then be used in target2 (defined using LDADD) to generate the complete binary.



source to share

1 answer

What you describe can be done with autotools, but not so easily. By default, autotools uses only one toolchain (target chain of a node, for example CC


etc.). You can also use build a tool chain .

What you would need to do in this situation would be very similar to that AX_PROG_CXX_FOR_BUILD

(the toolchain build macro referenced above and its dependent macros). Basically, it makes another copy of all the C ++ compiler tests with a different set of output variables.

Then something like:

$(target1_OBJECTS) := $(
$(target1_OBJECTS) : CXX = $(CXX_FOR_BUILD)
$(target1_OBJECTS) : CXXFLAGS = $(target1_CXXFLAGS)


target2_LDADD = $(target1_OBJECTS)


can work to tie them together.



All Articles