I’m experiencing behavior where a gmake $(shell) construct that works in my local environment fails under certain conditions when running within Travis CI invoked from github. When invoking the gmake construct
$(shell echo ‘{gen}’ | sed -e “s#{gen}#$(GEN)#”)
as part of a make action, it works fine both in my local Debian environment and inside CI. But when invoking it to set a Makefile variable:
SPECSRC = $(shell echo ‘{gen}’ | sed -e “s#{gen}#$(GEN)#”)
it still works locally, but fails when [executed under Travis:
mf.test:11: *** unterminated call to function ‘shell’: missing ‘)’. Stop.
I’ve checked some obvious things - both are running /bin/bash in their respective environments, and there are very close (not identical) gmake / sed / bash versions in the two environments. Alternate sed-expression separators like ‘@’ instead of ‘#’ (see mf.test below) do not help.
The issue arises from differing versions of GNU Make on Travis. Your makefile syntax isn’t universally compatible across GNU Make versions, specifically due to the handling of the comment character # in variable/function references in some older GNU Make versions.
To ensure portability in your makefile, encapsulate the comment character # within a variable like so:
Additionally, it’s generally inadvisable to use recursive assignment = with $(shell ...). In most cases, you should opt for simple assignment := instead. This recommendation, however, is not directly related to the issue you’re facing.
So to add additional files into the RPM package, I have added a custom install_script in the RPM spec file. This script copies files from the build directory into RPM_BUILD_ROOT. For example: