* 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 $@)
'Domain > Software' 카테고리의 다른 글
[GNUMake] GNUMake variable expansion - dependency section (0) | 2015.03.19 |
---|---|
[GNUMake] 'shell' function (0) | 2015.03.19 |
Apache에 다양한 service를 올릴때 주의할 점. (0) | 2014.10.27 |
[Tip] 시간 차(delta) 측정을 위한 코드에서 사용할 수 있는 아~주~ 작은 tip - ex. JAVA (0) | 2013.05.23 |
[SW] 확~ 다가오는 각종 명언들... (0) | 2011.11.23 |