]> granicus.if.org Git - libvpx/commitdiff
Escape number sign in Makefiles
authorDaniel Sommermann <dcsommer@gmail.com>
Mon, 17 Aug 2020 16:42:08 +0000 (09:42 -0700)
committerJames Zern <jzern@google.com>
Wed, 19 Aug 2020 18:56:25 +0000 (11:56 -0700)
Number signs are handled differently in Makefile variable parsing as
compared to bash variable parsing. See this demo:

```
$ cat Makefile
A=foo#bar
B='foo#bar'
C="foo#bar"
D=foo\#bar
E='foo\#bar'
F="foo\#bar"

$(info $(A))
$(info $(B))
$(info $(C))
$(info $(D))
$(info $(E))
$(info $(F))

$ make
foo
'foo
"foo
foo#bar
'foo#bar'
"foo#bar"
make: *** No targets.  Stop.

$ make -v
GNU Make 4.2.1
```

In other words, the `#` character is evaluated first when parsing
Makefiles, causing the rest of the line to become a comment. The effect of
this is that paths that contain embedded `#` symbols are not handled
properly in the vpx build system.

To test this change, clone vpx to a directory containing a `#` symbol and
attempt a build. With this change, it worked for me on Fedora 31, however
without the change the build failed.

Change-Id: Iaee6383e2435049b680484cc5cefdea9f2d9df46

build/make/configure.sh

index f8aa102775975ea82d0b698f4a196945c63ab95c..8bdfef39dbca87f675b896c3b1c66335b17898ea 100644 (file)
@@ -262,6 +262,9 @@ if [ -z "$source_path" ] || [ "$source_path" = "." ]; then
   source_path="`pwd`"
   disable_feature source_path_used
 fi
+# Makefiles greedily process the '#' character as a comment, even if it is
+# inside quotes. So, this character must be escaped in all paths in Makefiles.
+source_path_mk=$(echo $source_path | sed -e 's;\#;\\\#;g')
 
 if test ! -z "$TMPDIR" ; then
   TMPDIRx="${TMPDIR}"
@@ -481,11 +484,11 @@ write_common_target_config_mk() {
 
   cat >> $1 << EOF
 # This file automatically generated by configure. Do not edit!
-SRC_PATH="$source_path"
-SRC_PATH_BARE=$source_path
+SRC_PATH="$source_path_mk"
+SRC_PATH_BARE=$source_path_mk
 BUILD_PFX=${BUILD_PFX}
 TOOLCHAIN=${toolchain}
-ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
+ASM_CONVERSION=${asm_conversion_cmd:-${source_path_mk}/build/make/ads2gas.pl}
 GEN_VCPROJ=${gen_vcproj_cmd}
 MSVS_ARCH_DIR=${msvs_arch_dir}
 
@@ -984,7 +987,7 @@ EOF
           fi
 
           enabled debug && add_asflags -g
-          asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
+          asm_conversion_cmd="${source_path_mk}/build/make/ads2gas.pl"
 
           case ${tgt_os} in
             win*)
@@ -1006,7 +1009,7 @@ EOF
           # respective SDKs' limitations. Fortunately, these are all 32-bit ABIs
           # and so can be selected as 'win32'.
           if [ ${tgt_os} = "win32" ]; then
-            asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl"
+            asm_conversion_cmd="${source_path_mk}/build/make/ads2armasm_ms.pl"
             AS_SFX=.S
             msvs_arch_dir=arm-msvs
             disable_feature multithread
@@ -1141,7 +1144,7 @@ EOF
             fi
           fi
 
-          asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
+          asm_conversion_cmd="${source_path_mk}/build/make/ads2gas_apple.pl"
           ;;
 
         linux*)