[GRASS-dev] Indented comments in Makefile not compatible with make-3.82

William Kyngesburye woklist at kyngchaos.com
Fri Jun 1 06:55:55 PDT 2012


When I created the modbuild thing way back when, that multiline sed replacement did not work (It does work directly in the Terminal).  I *think* it ended up as run together on one line.  Maybe there was a problem with the OS X make at the time.  I haven't looked at it since.

On Jun 1, 2012, at 2:28 AM, Glynn Clements wrote:

> 
> Daniel Macks wrote:
> 
>> The problem appears to be just after the above "sed" command, where
>> macosx/modbuild/Makefile has:
>> 
>>     @# until I figure out how to get sed to replace with multiple lines in a
>>     @# makefile, GRASS_APP required for modbuild, ie no default to /Applications
>>     @#-e 's#^GISBASE.*#ifdef GRASS_APP\
>>     @#GISBASE = $$(GRASS_APP)/Contents/MacOS\
>>     @#else\
>>     @#GISBASE = $(INST_DIR_MACOSX)\
>>     @#endif#g'
>>     @# html.make needs a little change
>> 
>> Why is it even looking at the syntax of a comment? The commented-out
>> section is confusing because it's a hybrid of makefile-recipe quiet
>> tags (@), makefile commenting (#), and makefile and shell
>> line-continuations (). The new make is known to be stricter about
>> several types of makefile syntax, so maybe you've triggered one of
>> those? The use of the apparently non-standard "@#" in general does
>> not seem to be the problem, or else the modbuild recipe would have
>> crashed even earlier, so it must be related to the multilining in
>> them. Changing the commented-out sed chunk to use standard
>> commenting (non-indented leading #) works for me:
> 
> Make parses the above as four shell commands:
> 
> # until I figure out how to get sed to replace with multiple lines in a
> 
> # makefile, GRASS_APP required for modbuild, ie no default to /Applications
> 
> #-e 's#^GISBASE.*#ifdef GRASS_APP\
> @#GISBASE = $$(GRASS_APP)/Contents/MacOS\
> @#else\
> @#GISBASE = $(INST_DIR_MACOSX)\
> @#endif#g'
> 
> @# html.make needs a little change
> 
> For the third one (which is causing the problem), the entire block is
> executed as a single command, including the backslash-newline pairs
> and the @ at the start of each line other than the first.
> 
> It's the leading @ which causes the problem; a # only begins a comment
> when it appears at the beginning of a word:
> 
> 	$ pwd #asdfasdf
> 	/home/glynn
> 	$ pwd#asdfasdf
> 	bash: pwd#asdfasdf: command not found
> 
> Also, backslash-newline elimination isn't performed within comments.
> 
> Consequently, the shell parses the string as two commands:
> 
> 	#-e 's#^GISBASE.*#ifdef GRASS_APP\
> 
> 	@#GISBASE = $$(GRASS_APP)/Contents/MacOS @#else @#GISBASE = $(INST_DIR_MACOSX) @#endif#g'
> 
> The first is a comment, the second isn't. The comment swallows the
> opening single quote, so what should be the closing quote is actually
> the opening quote. The fact that the actual command is gibberish
> doesn't matter, because the shell never gets beyond the first phases
> of parsing, due to the mismatched quote.
> 
> Removing the leading '@' from each continuation line should suffice,
> i.e.:
> 
> 	@# until I figure out how to get sed to replace with multiple lines in a
> 	@# makefile, GRASS_APP required for modbuild, ie no default to /Applications
> 	@#-e 's#^GISBASE.*#ifdef GRASS_APP\
> 	#GISBASE = $$(GRASS_APP)/Contents/MacOS\
> 	#else\
> 	#GISBASE = $(INST_DIR_MACOSX)\
> 	#endif#g'
> 	# html.make needs a little change
> 
> BTW, I'm not sure why this is commented out; the sed expression should
> actually work as-is, i.e.:
> 
> 	-e 's#^GISBASE.*#ifdef GRASS_APP\
> 	GISBASE = $$(GRASS_APP)/Contents/MacOS\
> 	else\
> 	GISBASE = $(INST_DIR_MACOSX)\
> 	endif#g'
> 
> Make should pass backslash-newline through to the shell, the shell
> should pass it through to sed (being in a single-quoted string), and
> sed recognises backslash-newline as a literal newline in the
> replacement of an 's' command.
> 
> -- 
> Glynn Clements <glynn at gclements.plus.com>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"Mon Dieu! but they are all alike.  Cheating, murdering, lying, fighting, and all for things that the beasts of the jungle would not deign to possess - money to purchase the effeminate pleasures of weaklings.  And yet withal bound down by silly customs that make them slaves to their unhappy lot while firm in the belief that they be the lords of creation enjoying the only real pleasures of existence....

- the wisdom of Tarzan




More information about the grass-dev mailing list