make/common/MakeBase.gmk
changeset 42134 bbcdb49521b1
parent 41875 854ef5325653
child 42282 faf3b6722c44
--- a/make/common/MakeBase.gmk	Thu Nov 17 22:18:22 2016 +0000
+++ b/make/common/MakeBase.gmk	Fri Nov 18 15:50:43 2016 +0100
@@ -122,6 +122,10 @@
 EscapeDollar = $(subst $$,\$$,$(subst \$$,$$,$(strip $1)))
 
 ################################################################################
+# This macro works just like EscapeDollar above, but for #.
+EscapeHash = $(subst \#,\\\#,$(subst \\\#,\#,$(strip $1)))
+
+################################################################################
 # This macro translates $ into $$ to protect the string from make itself.
 DoubleDollar = $(subst $$,$$$$,$(strip $1))
 
@@ -833,7 +837,7 @@
           $(if $(findstring $(LOG_LEVEL), trace), \
               $(info NewVariable $1: >$(strip $($1))<) \
               $(info OldVariable $1: >$(strip $($1_old))<)) \
-          $(call WriteFile, $1_old:=$(call DoubleDollar,$($1)), \
+          $(call WriteFile, $1_old:=$(call DoubleDollar,$(call EscapeHash,$($1))), \
               $(call DependOnVariableFileName, $1, $2))) \
         $(call DependOnVariableFileName, $1, $2) \
     )