tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: make: sysV subst with variables



On Wed, 1 Jun 2011 18:49:00 +0000, David Holland writes:
>What's an example of the recursive modifier behavior that conflicts
>with handling those variables the way you want?

Sure - these are all from my sys.mk and get used heavily.

# some useful modifiers

# A useful trick for testing multiple :M's against something
# :L says to use the variable's name as its value - ie. literal
# got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}}
M_ListToMatch = L:@m@$${V:M$$m}@
# match against our initial targets (see above)
M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,}

# turn a list into a set of :N modifiers
# NskipFoo = ${Foo:${M_ListToSkip}}
M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N,

# type should be a builtin in any sh since about 1980,
# AUTOCONF := ${autoconf:L:${M_whence}}
M_type = @x@(type $$x 2> /dev/null); echo;@:sh:[0]:N* found*:[@]:C,[()],,g
M_whence = ${M_type}:M/*

# convert a path to a valid shell variable
M_P2V = tu:C,[./-],_,g

So take the example M_ListToSkip as an example:

SUBTREE := ${SUBTREE:${SKIP_SUBTREE:${M_ListToSkip}}}

SUBTREE is a list of top-level dirs, and SKIP_SUBTREE is a list to be
skipped (eg. because we expect them to be provided by a backing tree).

This all works fine, but when someone does something like:

${FOO:${BAR}/%.x=%}

ApplyModiefiers tries to apply just ${BAR} which will very likely fail.
So this patch adds a check that what Var_Parse() consumed is what we
expect in this case it would not be since '/' is not ':', '}' or ""
so it consumes up to one of those, with the result that  ApplyModifiers
is called with ${BAR}/%.x=% instead.

--sjg


Home | Main Index | Thread Index | Old Index