Basin, This should do what you want:
SQLFILES := $(info finding SQLFILES...)$(shell cd "$(srcdir)" && find . -name "*.sql") Sam Kendall On Tue, Apr 10, 2018 at 11:08 AM Basin Ilya <basini...@gmail.com> wrote: > Hi David. > I'll try to explain what I want better. The evaluation should print a > diagnostic message and it should be printed to a file descriptor that was > the stdout of the make program when it was started. That is, when you run > the make command with output redirected to /dev/null, the diagnostic > message should be suppressed as well, because it's not an error or warning: > > $ make >/dev/null > $ > > $ make > blah blah > finding SQLFILES... > blah blah > ... > $ > > > Currently my message is printed to stderr and therefore always printed: > > $ make >/dev/null > finding SQLFILES... > $ > > The problem is with make, not with the shell programming. Here's an > equivalent of my current variable assignment, rewritten for shell: > > SQLFILES=`>&2 echo finding SQLFILES... && cd "${srcdir}" && find . > -name "*.sql"` > > And this is how my problem would be solved, if it was shell: > > exec 4>&1 > SQLFILES=`>&4 echo finding SQLFILES... && cd "${srcdir}" && find . > -name "*.sql"` > > The message is printed to the fd "4", which is the original stdout, while > everything else is printed to fd "1", which is the stdout redirected by the > parent shell to perform the assignment. > > Unfortunately, I can't find anything like "exec 4>&1" (globally) in Make. > The only workaround I can think of is calling make from a wrapper, which > performs the redirection. > > > On 10.04.2018 17:25, David Boyce wrote: > > This looks like a basic shell programming issue, not a make problem at > all. Try pulling this logic out of make and running it directly in the > shell; if it behaves correctly there but not when plugged back into make, > then you'll have a make question. This looks more like a scoping problem. > Here is (effectively) your original script: > > > > % sh -c ">&2 echo finding SQLFILES... && date" 1>1 2>2 > > > > % head 1 2 > > ==> 1 <== > > Tue Apr 10 07:18:56 PDT 2018 > > > > ==> 2 <== > > finding SQLFILES... > > > > And here's a variant with different scoping: > > > > % sh -c "(echo finding SQLFILES... && date) 1>&2" 1>1 2>2 > > > > % head 1 2 > > ==> 1 <== > > > > ==> 2 <== > > finding SQLFILES... > > Tue Apr 10 07:19:09 PDT 2018 > > > > It's not clear to me exactly what you want but this should illustrate > that the issue is shell redirection. > > > > Personally I prefer techniques that let the shell handle verbosity > instead of typing ad-hoc messages: > > > > SQLFILES := $(shell set -x; cd "$(srcdir)" && find . -name "*.sql") > > > > David > > > > On Tue, Apr 10, 2018 at 3:07 AM, Basin Ilya <basini...@gmail.com > <mailto:basini...@gmail.com>> wrote: > > > > Hi. I want to print a diagnostic message whenever my shell > expression is evaluated. Currently, I have the following line in my > makefile: > > > > SQLFILES := $(shell >&2 echo finding SQLFILES... && cd > "$(srcdir)" && find . -name "*.sql") > > > > As you can see, the message "finding SQLFILES..." is printed to > stderr, but I want the original stdout instead. Does GNU Make make it > available as some other fd, say, "4"? > > > > _______________________________________________ > > Help-make mailing list > > Help-make@gnu.org <mailto:Help-make@gnu.org> > > https://lists.gnu.org/mailman/listinfo/help-make < > https://lists.gnu.org/mailman/listinfo/help-make> > > > > > > _______________________________________________ > Help-make mailing list > Help-make@gnu.org > https://lists.gnu.org/mailman/listinfo/help-make > _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make