Building in Parallel
In normal vala builds, all .c files are generated from all .vala files at one time and on one processor core.
Vala has recently gained the ability to generate a single .c file at a time from one .vala file (and a special modified form of vapi file for each other source file).
This has two main advantages. First, it allows for builds for Vala projects to be done fully in parallel. Second, it allows for incremental rebuilds (ie: make after only one source file has changed) to be substantially faster.
automake does not currently support this new way of building Vala programs, but you can introduce it into your project in one of two ways.
Understanding the Build Process
If you wish to include support for parallel Vala builds directly into your own Makefile then you need to understand how the process works.
The first thing that needs to be done is to create a "fast vapi" file for each input vala file. This is done as follows:
valac --fast-vapi=sourcefile.vapi sourcefile.vala
This generates a file called sourcefile.vapi that contains the information for the interfaces available in sourcefile.vala. The compilation stage for other files may depend on this information, so by using the fast vapi file instead, it is possible to avoid parsing the entire vala file every time.
Note that fast-vapi files are generated solely from the given source file -- no other source files or even system packages are consulted. Also note that the timestamp of the output file is only modified in the case that the contents actually change.
Building One vala File
The next thing that needs to be done is to generate a .c file for each .vala file, using the fast .vapi files from every other .vala file.
valac --pkg pkgname -C sourcefile.vala \ --use-fast-vapi=thissource.vapi \ --use-fast-vapi=thatsource.vapi \ --use-fast-vapi=othersource.vapi
This generates the sourcefile.c output file. The compilation reads only the files given on the commandline. Note specifically that no other vala files are read. This means that changing one .vala input file in a way that does not modify interfaces visible from other files results only in that one file being parsed and compiled.
Note that, as with non-parallel Vala builds, the timestamp of the .c file is only modified in the case that the contents actually change.
Of course, we may also need to rebuild a given source file if interfaces that it depends on have shifted.
For this reason, valac now has a --deps= option to output make-style dependency information. The name of the target used for the dependency information is the name of the dependency file itself. The dependency file always has its timestamp updated so it is a reasonable choice to use it as a stamp file to indicate that the .c file is up to date -- this is why the name of the dependency file is used as the target.
The entire process described above is implemented by a script (and Makefile) in Vala's git repository:
You should install these two files as bin/parvala and share/parvala/parvala.mk under the prefix of your choice.
If you want to write your own Makefile, parvala.mk provides a good starting point.
Note the use of the somewhat unusual order-only prerequisites feature of make (denoted by the | character).