On Friday 19 August 2011, Daniel Neuberger wrote: > Is there any way to reliable escape the hash mark in automake? It seems > that using += causes multiple expansions and breaks it. > > This works: > > SOMEVAR = "\# some comment" > > This doesn't > > SOMEVAR = "\# some comment" > SOMEVAR += "other stuff" > Yes, automake strips what seems like a trailing comment when concatenating variables, to allow usages like:
EXTRA_DIST = autogen.sh # Bootstrap the package from git checkout. EXTRA_DIST += HACKING # Coding standards and hints for contributors. > So my current workaround is: > > HASHMARK = $(shell echo "\#") > SOMEVAR = "$(HASHMARK)some comment" > SOMEVAR += "other stuff" > Does the following works? HASHMARK = \# SOMEVAR = "$(HASHMARK)some comment" SOMEVAR += "other stuff" Anyway, consider that there is no portable way to place a literal `#' in a make variable; for example: $ cat > Makefile <<'END' foo = \# comment all:; @echo '$(foo)' END $ make # GNU and BSD make implementations work. # comment $ make # Solaris make does not. mksh: Fatal error in reader: Loop detected when expanding macro value `\# comment all:; @echo '$(foo)'' Current working directory /tmp $ cat > Makefile <<'END' # Try in another way. bar = "#" comment all:; @echo x'$(bar)'x END $ make # Solaris make. x"x HTH, Stefano
