bug-make
[Top][All Lists]
Advanced

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

Expansion of $(eval..)


From: Gisle Vanem
Subject: Expansion of $(eval..)
Date: Sat, 22 Jan 2022 13:59:44 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

Hello list!

I have this really large makefile and
discovered the '$(eval..)' function was handy
to use for this. Like:

  define add_c_src
    VPATH += $(1)
    C_SRC += $(addprefix $(1)/, $(2))
    $(info Number of 'C_SRC': $(words $(C_SRC)))
  endef

  $(eval $(call add_c_src, frmts/ceos, ceosopen.c))
  $(eval $(call add_c_src, frmts/ceos2, ceos.c ceosrecipe.c ceossar.c))
  # ... plus a lot more

  my-target.dll: $(C_SRC:.c=.obj)
     link whatever $^
----------------

But I'm curious about how this gets expanded
since the '$(info ..)' tells the length of 'C_SRC'
*before* it's used:
  Number of 'C_SRC': 0
  Number of 'C_SRC': 1

How does this gets expanded an executed?
The chapter "8.1 The eval function" did not make
it clear to me. But adding a:
  count_C_SRC:
    $(info Number of 'C_SRC': $(words $(C_SRC)))

tells me the correct number.

Another thing is that if I change to '# $(info ..',
the 'Number of ..' gets printed after all (!)
So a comment gets ignored here AFAICS.

--
--gv



reply via email to

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