tech-toolchain archive

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

Re: make :Q breakage



On May 26,  6:25pm, uwe%stderr.spb.ru@localhost (Valery Ushakov) wrote:
-- Subject: Re: make :Q breakage

| :Q is defined to quote *shell* meta-characters.  The problem with $$
| $$$$ $$$$$$$$ etc is not unique to make but is endemic to all
| macro-processors in some form.  At least make does recursive
| expansion, so you mostly (only?) run into this with submakes.
| 
| As far as I understand you don't really need a new modifier, as
| existing :S should do:
| 
|     DOLLAR=$$
|     ...
|         make DOLLAR=${DOLLAR:S/\$/&&/g:Q}
| 
| When a variable is expanded, the only remaining '$' characters in it
| are from $$ in the original, since you know you are passing this to
| another make you use :S to double them again for the nested make.  And
| shell-quote the result with :Q
| 
| E.g.
| 
| # ---8<--- d.mk ---8<---
| PID=$$$$
| .if !defined(NESTED)
| all:
| 	echo ${PID}
| 	echo ${PID:Q}
| 	make -f d.mk NESTED=${PID:S/\$/&&/g:Q}
| .else
| all:
| 	echo ${NESTED}
| 	echo ${NESTED:Q}
| .endif
| # ---8<---
| 
| 
| If you want to hide the gory details you can probably even do
| something like
| 
| MAKEQUOTE=S/\$$/&&/g:Q
| ...
| 	make .... NESTED=${PID:${MAKEQUOTE}}

This is still ugly. When would you *not* want :Q to do this automatically?
I.e. if a variable expansion ends up having a $ in it, you want it to work,
don't you?

I.e. if I want to pass a variable to a submake, right now I have to use
MAKEQUOTE, or it will not work if it contains a '$'. So you are saying:

    1. define MAKEQUOTE
    2. find all the uses of :Q and change them with :${MAKEQUOTE}

Or I am mis-undestanding how this should be fixed?

christos


Home | Main Index | Thread Index | Old Index