* When 'variable expansion' at Command Section, is processed at GNUMake --------------------------------------------------------------------- In GNUMake source code, command line section of each Target seems to be expanded at 'new_job()' function. In detail, 'for-loop part' under '/* Expand the command lines and store the results in LINES. */' comment. And then, first command line is fetched at 'job_next_command()' function. Then, when 'job slot(in case of using mutlple job)' is available, this command line that expansion is done, is executed on newly created child process. new_job - expand command line variables (line-by-line) - waiting until job slot is available. - job is executed.. Note that all variables in command section, are expanded before processing first command line. Note that, variables in pre-requisites and dependencies are expanded before expanding command line section. So, following gnumake code is dangerous. out/target-file: <...> ./generate-target-file.sh $@ ./postprocess.sh $(shell readlink -e $@) [ Issue ] "$(shell ...) function" part is expanded before "./generate-target-file.sh" is executed. So, af the first build, 'out/target-file' doesn't exist, "readlink -e $@" return empty string. And this may lead to unexpected result.

--- should be modified like below out/target-file: <...> ./generate-target-file.sh $@ ./postprocess.sh $$(readlink -e $@)


+ Recent posts