Re: Output quoting (was: Re: Possible solution for special characters in makefile paths)
Frank Heckenbach <[email protected]> Fri, 11 Apr 2014 12:54:15 +0200
| Newsgroups | gmane.comp.gnu.make.devel |
|---|---|
| Message-ID | <[email protected]> |
Tim Murphy wrote: > I don't mean that quoting is needed here but that people will find > uses for SHELL_QUOTE that are not the ones you expect. > > I would love, for example, to have a macro that was evaluated every > time an automatic variable was expanded. I don't think that's what SHELL_QUOTE is for. In particular it must not be used when make evaluates variables in file name lists (targets, prerequisites, $(file) 1st argument) where it processes the list itself and doesn't hand it to a shell. It also must not be used when variables are used to set another variable, i.e. "FOO = $(BAR)", otherwise FOO would already be quoted, and when used, doubly quoted. OTOH, it does not only apply to automatic variables, also normal variables. In this case we want quoting: FOO = foo\ bar biz\ baz all: ; echo $(FOO) > It would allow me to hook > into make for all sorts of useful purposes. > > even better if I knew which automatic variable was being expanded so > e.g. I could get a list of the targets in the makefile or all the > dependencies for target X. > > You might ask "what for?" well some makefiles are generated, some use > autodependency generation, some have very complex macros that work out > what to build and what not to build. At the end one wants to know what > did the makefile actually "try" to do so one can see how successful it > was and also see if it is trying to do the correct things. > > so e.g. $(call shell_quote,@,fred.exe) would be a very useful thing to > be able to implement - would make it easy to get a list of all the > targets the makefile ultimately tried to generate. Using it to quote, > in other words, would be just one application. I'm not sure I follow you here. $(SHELL_QUOTE), in my suggestion, is just a function (either built-in or composed of other make functions), that takes a (possible multi-word) string and returns a quoted string. It has one argument, so I don't even know what you mean by "$(call shell_quote,@,fred.exe)". I suppose @ should be $@? But what about the final argument? What you do expect this function call does? Again, in my suggestion, SHELL_QUOTE would just return a modified string, so if you insert it in places in your makefile, it would not output any additional list that you seem to want or anything like that, it would just modify the rules where you place it. Sorry, but I think what you want is something entirely different. Maybe it's more related to Paul's previous suggestion of some instrumentation API.