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: Mon, 10 Jul 2023 22:26:11 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

Hi Bruno, Paul,

On 7/10/23 21:41, Bruno Haible wrote:
Paul Smith wrote:
Showing the "macroexpanded make sources" is difficult because make
doesn't just expand an entire line then parse it.  Makefile syntax is
context-sensitive so you can't know how or if to expand parts of a line
until you've already expanded other parts.  Of course make could keep
track of this for generating this kind of output.

If no perfect solution to this problem is possible, how about
implementing a simple approximation first, and then improve it based
on user feedback?

Because how is a GNU make user supposed to understand a Makefile and
the expansion of things like

    $(1): $$($(1)_OBJS) $$($(1)_LIBS:%=-l%)

or

    $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)

if 'make' does not help them? [1]

My approach to debugging has always been fprintf(3) with C programs, as
I find debuggers too complex for what I need.  When debugging GNU
Makefiles, I have a similar approach, and it usually works.  I need some
intuition to know where to place the statements, but after a few tries,
I usually find the bug.  In GNU Make, the "printf" statement is the
$(info ...) function.  Maybe you didn't know about it?

So, I usually add a few of them before suspicious lines.  It could be:

$(info DBG: $(1))
$(info DBG: $$($(1)_OBJS))
$(info DBG: $$($(1)_LIBS:%=-l%))
$(info DBG: $$($(1)_LIBS))
$(1): $$($(1)_OBJS) $$($(1)_LIBS:%=-l%)

That should solve most of your doubts, doesn't it?

Cheers,
Alex


--
<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]