Apache OpenOffice (AOO) Bugzilla – Issue 70168
dmake cannot handle $ in prerequisites
Last modified: 2013-08-07 15:34:52 UTC
If you run the following example: ---- makefile.mk ---- SHELL*:=/bin/sh SHELLFLAGS*:=-ce all : my$$try1.xx echo all ./my$$try1.xx : echo try1 ---- makefile.mk ---- you get: dmake: Error: -- `myry1.xx' not found, and can't be made The problem lies in the dynamic macro expansion in Make(), around line 451 in make.c. The prerequisite is expanded (to treat nested macro expressions) as long as $'s are present. This unfortunately fails for literal $ characters: $$<something> -> $<something> -> "" This bug is independent of issue 69742 but while testing the target normalization I realized that prerequisites with $ didn't work.
Created attachment 39626 [details] Patch for dmake
There was a problem in Make() that repeated the expansion of a prerequisite until no $ was found anymore - nested macros don't need special treatment, Expand() takes care of this. This patch obsoletes the DYNAMICNESTINGLEVEL macro. It's still there but unused. But even with this patch literal $ characters are problematic. At the Def_cell() level it's impossible to destinquish between a dynamic prerequisite and a literal $ in the filename, so targets with $ are not normalized. This is a new feature anyway, but $ in target definitions should be avoided as this could also mean a synatx error when trying to use a late expanded macro name as a target. Currently only a warning is issued, but maybe this should be an Error.
Created attachment 39639 [details] Patch for dmake
Committed to dmake47.
Please verify.
fetched me the makefile from the testcase: ---- makefile.mk ---- SHELL*:=/bin/sh SHELLFLAGS*:=-ce DYNPRQS=a$$xx1 a$$xx2 all : $$(DYNPRQS) a$$$$xx3 echo all a$$xx1 : echo a1:$@ a$$xx2 : echo a2:$@ a$$xx3 : echo a3:$@ ---- makefile.mk ---- four dollar signs in a row when using it in prerequisites - ok, looks strange but so be it. but looking at the echo output, e.g. a3:ax3 instead of the expected a3:a$xx3 it makes me wonder if there is any sense in using literal $ in targets at all. currently you won't even be able to address the target name in the receipt... and i never saw the warning mentioned...
The $@ gets expanded one final time when creating the recipe. I just played with the code that creates the dynamic macros and there seems to be a small bug in it that defines the @ macro as "not yet expanded" (M_EXPANDED is missing). I cannot imagine a case where a target is being build but there are still unexpanded variables in the targets name. So this will be fixed in dmake48.
taking it "as is". won't hit too many people ;)
Oh, and I somehow decided not to commit the mentioned warning. If we want it we have to replace the * FIXME: Here would be the place to add a sanity check. */ line in dmake/rulparse.c with something like if( strchr(tok, '$') ) Warning( "The use of target names containing $ [%s] characters is discouraged.", tok );
seen in MWS
Reopen because of bug discovered in issue 80352.
Change owner
The code was really intended to clear F_MARK again after the dynamic prerequisite generation is done. I fixed that, but not clearing it didn't create any problems because the F_MARK flag is not used again later in the code.
Please verify
.
dmake 4.11 is in use now