bug-make
[Top][All Lists]
Advanced

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

Re: GNU make troubleshooting


From: Alejandro Colomar
Subject: Re: GNU make troubleshooting
Date: Tue, 11 Jul 2023 16:13:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0

Hi Jeff,

On 2023-07-11 16:01, Jeffrey Walton wrote:
>> But, what about this do you want to know?
> 
> I want to see an output for the evaluation of each statement, like
> what I would see with 'set -x'. I need to know where something goes
> sideways when shell'ing out in a pipe.

Could you show an example of an approximation of the output you would
want to see?  I'm not sure about that shell comparison, because in the
shell there's also a lot of stuff that you can't follow with set -x.
However, you can follow it with "printf"-like stuff:

        $ set -x
        + set -x
        $ echo foo | sed s/o/a/ | sh -c 'sed s/f/g/' | cat
        + sed s/o/a/
        + sh -c 'sed s/f/g/'
        + cat
        + echo foo
        gao

set -x wasn't very useful.  However, see with tee(1).

        $ echo foo | sed s/o/a/ | tee /dev/tty | sh -c 'sed s/f/g/' | cat
        fao
        gao

Of course, it is very manual, but a lot of debugging is very manual.

> 
>> If what you want to know is "what was the result of all this", the
>> database print (-p) option will show you what make computed as the
>> final value for each of these variables, and also what linenumber of
>> the makefile was used to set the final version:
>>
>>   # makefile (from 'Makefile', line 12)
>>   GCC_COMPILER := 0
>>    ...
>>   # makefile (from 'Makefile', line 1)
>>   GREP = grep
>>    ...
>>
>> I don't want to suggest that everything is just peachy.  There are lots
>> of rough edges for working with GNU Make and Makefiles, there is no
>> question about that.  I'm just trying to understand clearly what things
>> will actually be useful, rather than simply spewing out more output
>> similar to what -d does.
> 
> Here's 'make -d' for a project I help maintain. No info on the
> evaluations shown above, which would be useful to me. There is lots of
> information that looks like it would be useful to a GNU Make
> maintainer.

I know you said you don't enjoy printf, but $(info) would really tell you
what you need to know.  Maybe make(1) could have a flag to run something
like an info statement at every variable setting and/or evaluation, but
I'm not sure how easy it would be to do that.  In the meantime, printf
does exactly that, but you need to ask exactly what you need to print.

Cheers,
Alex

> 
> $ make -d
> GNU Make 4.3
> Built for x86_64-pc-linux-gnu
> Copyright (C) 1988-2020 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> Reading makefiles...
> Reading makefile 'GNUmakefile'...
> Updating makefiles....
[...]
>       Must remake target 'cryptlib.o'.
> g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -c cryptlib.cpp
> 
>> I do agree with Bruno that there is a lot of implicit knowledge for
>> working with Makefiles that is not well described, or in some cases
>> even hinted at, in the manual.  Maybe I'll try to add a new chapter
>> this weekend... writing will be a nice change from hacking.  I've spent
>> enough time on StackOverflow that I have a good idea of the places
>> people have troubles.
> 
> I'm not sure what folks are doing on Stack Overflow.
> 
> We use GNU Make for its power. If we did not want/need the power, then
> we would use an anemic make, like Posix make.
> 
> Jeff
> 

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]