On some systems the requested amount of memory causes OOM killer
to kill the process (instead of returning ENOMEM).
For now, we never try to use more than half of available
physical memory.
This patch duplicates part of the code because following
switch to non-recursive automake is not easily fixable without this change.
(Automake cannot use top_srcdir anymore in this context.)