From c413c8f18eb1932b100850505031980e27160d5f Mon Sep 17 00:00:00 2001 From: Daniel Sommermann Date: Mon, 17 Aug 2020 09:42:08 -0700 Subject: [PATCH] Escape number sign in Makefiles 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/build/make/configure.sh b/build/make/configure.sh index f8aa10277..8bdfef39d 100644 --- a/build/make/configure.sh +++ b/build/make/configure.sh @@ -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*) -- 2.40.0