google / kati

An experimental GNU make clone

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multi-word MAKEFLAGS doesn't work properly

danw opened this issue · comments

We ran into this issue when upgrading Kati on AOSP, but I've solved this on our side separately by clearing MAKEFLAGS, since we don't want the MAKEFLAGS override behavior and the variables are already available in the environment.

Simple shell testcase to drop into testcase/cmdline_var_spaces.sh:

set -e

mk="$@"

cat <<EOF > Makefile
ifdef SUBMAKE
all:
       +@\$(SUBMAKE) SUBMAKE=
else
CLVAR := FAIL
CLVAR_RESULT := FAIL
ifeq (\$(CLVAR),multi word)
CLVAR_RESULT := PASS
endif
all:
       @echo \$(CLVAR_RESULT) \$(CLVAR) \$(origin CLVAR)
endif
EOF

make SUBMAKE="${mk}" CLVAR='multi word' 2> /dev/null

Which prints out:

(make)  PASS multi word command line
(ckati) FAIL multi command line

If you print out $(MAKEFLAGS), the makeflags is written as:

CLVAR=multi\ word SUBMAKE=../../ckati\ SHELL=/bin/bash

So kati's MAKEFLAGS parsing needs to handle the escaped spaces (I'm not sure if anything else can be escaped)