Automake allows to define dependencies based on targets (like a library libui.a or sources ui.c). But how can I add a dependency on a .vapi? (This dependency might be needed, because app is using some code from libui.)
If I just add a dependency on the library level, make fails when looking for the library while generating the C-Code. Look at the following example:
app_SOURCES = main.vala app_LIBADD = libA.a libB.a
In the above example main.vala already needs informations about libA and libB when valac is generating the C-Code. But this doesn't work in a parallel build, when libA or libB's vapi is not yet generated.
So I needed to tell automake/make somehow to depend on the .vapi files of libA/libB - but how? Automake doesn't know about vapis and doesn't provide any targets for them.
But it seems as this can be solved like this: You can tell automake to depend on the .c file corresponding to your .vala (and so .vapi) file, as the .c file is generated at the same time the vapi is generated. And - oh wonder - automake has targets for the c files generated by valac, therefor it's possible to use the .c files as dependencies when you mention them in the _SOURCES part of the target in question.
app_SOURCES = main.vala libA.c libB.c app_LIBADD = libA.a libB.a
Adding the .c files to the sources doesn't do any harm, but allows app to depend on the availability of (a) the vapis and (b) the libs for libA and libB. So dependencies on both levels (code generation and linking).
Have a look at this Makefile.am for my real world example.
There is a high probability that I've missunderstood or forgot something. Hints and comments are welcome.
Post a Comment