autotools_run_tool() from autotools.eclass contains these lines: # most of the time, there will only be one run, but if there are # more, make sure we get unique log filenames if [[ -e ${STDERR_TARGET} ]] ; then STDERR_TARGET="${T}/$1-$$.out" fi However this does not accomplish what it is intended for. $$ is the PID of the current process. All ebuild functions are executed within a single bash process, so every invocation of that function will run with the same PID. Thus you can have up to two different output files, after which all subsequent calls will overwrite the preceding output. One solution would be STDERR_TARGET="$(mktemp "${T}/$1-XXXXX")" to create an arbitrarily named temporary file. As mktemp is part of coreutils, it should be available to every ebuild. Another option would be numbering the files, to give reproducible names and easier association from names to executed commands: if [[ -e ${STDERR_TARGET} ]] ; then local i=2 while [[ -e "${T}/$1-${i}.out" ]]; do : $((++i)) done STDERR_TARGET="${T}/$1-${i}.out" fi Your choice which of these solutions you prefer.
mktemp isnt portable. we do have emktemp already, but i'd prefer monotonic increasing number so that the result is predictable. http://sources.gentoo.org/eclass/autotools.eclass?r1=1.103&r2=1.104