diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2023-03-21 09:31:18 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2023-03-21 09:31:18 +0000 |
commit | 2fb2364686e5470437f0ee3d214662d51067eb90 (patch) | |
tree | 608c55078ae7f45e7c577b0990a58a57787241ef | |
parent | ed7ab52e273e8fcf61c6e95ec28c392ff9ed4023 (diff) | |
download | rockbox-2fb2364686e5470437f0ee3d214662d51067eb90.tar.gz rockbox-2fb2364686e5470437f0ee3d214662d51067eb90.zip |
makefiles: Fix escaping issues under GNU make 4.2
Make 4.3 and newer doesn't interpret comments in a shell call,
whereas Make 4.2 and older do. Escaping the comment directly
works on old makes, but on new makes the backslash is passed
as well -- which we want to avoid.
The safe way to pass a literal "#" character to the shell on
both versions is by embedding it in a variable and expanding
that. It's ugly, but it works...
Change-Id: I1a217c42d747fd5aa83f9990c234e06966ac1a00
-rw-r--r-- | tools/functions.make | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/functions.make b/tools/functions.make index d9acbba2ba..c2237c9547 100644 --- a/tools/functions.make +++ b/tools/functions.make | |||
@@ -14,12 +14,18 @@ | |||
14 | # | 14 | # |
15 | # The sed line is to prepend the directory to all source files | 15 | # The sed line is to prepend the directory to all source files |
16 | 16 | ||
17 | # This is needed because GNU Make older than 4.3 treats this as the start | ||
18 | # of a comment even within a $(shell) call and requires a backslash escape. | ||
19 | # Newer Makes pass the whole "\#" through, making the backslash visible in | ||
20 | # the shell. To safely pass a literal "#", it has to go in a variable. | ||
21 | _hash_ = \# | ||
22 | |||
17 | preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c -include config.h $(1) | \ | 23 | preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c -include config.h $(1) | \ |
18 | grep -v '^#' | grep -v "^ *$$" | \ | 24 | grep -v "^$(_hash_)" | grep -v "^ *$$" | \ |
19 | sed -e 's:^..*:$(dir $(1))&:') | 25 | sed -e 's:^..*:$(dir $(1))&:') |
20 | 26 | ||
21 | preprocess2file = $(shell $(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) | \ | 27 | preprocess2file = $(shell $(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) | \ |
22 | grep -v '^#' | grep -v "^$$" > $(2)) | 28 | grep -v '^$(_hash_)' | grep -v "^$$" > $(2)) |
23 | 29 | ||
24 | asmdefs2file = $(SILENT)$(CC) $(PPCFLAGS) $(3) -S -x c -o - -include config.h $(1) | \ | 30 | asmdefs2file = $(SILENT)$(CC) $(PPCFLAGS) $(3) -S -x c -o - -include config.h $(1) | \ |
25 | perl -ne 'if(/^_?AD_(\w+):$$/){$$var=$$1}else{/^\W\.(?:word|long)\W(.*)$$/ && $$var && print "\#define $$var $$1\n";$$var=0}' > $(2) | 31 | perl -ne 'if(/^_?AD_(\w+):$$/){$$var=$$1}else{/^\W\.(?:word|long)\W(.*)$$/ && $$var && print "\#define $$var $$1\n";$$var=0}' > $(2) |