Re: Appending to variables

David Deutsch <[email protected]> Mon, 22 Jun 2026 22:44:46 +0200
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
Like in your other mail - you're trying to go against a fundamental 
concept in make.

A target is a target. What you're telling make with:

make -f myfile.mk trlfn #(or ndf)

  is "I want target myfile.mk to be one thing if I also tell you to 
build trlfn and another thing if I tell you to also build ndf and YET 
another thing if I tell it to also build trlfn and ndf at the same time".

That means your Makefile has - in your theory - four separate 
understandings of what myfile.mk fundamentally is.

If you keep pursuing this route, you're going to have a bad time because 
make works best when targets have clear and final meanings.

The reason why trlfn/ndf does not work is because you have not provided 
a recipe to it, in two different ways: First, you thought a recipe was 
"the thing that make executes when I tell it to make a target" - which 
is kind of true, but not for makefile syntax which is evaluated before 
recipes are built (but in this case, will be ignored). Second: You just 
wrote the recipe behind the colon. That's where the prerequisites go. 
The actual recipe goes into the next line after a tab.

I would think that you're looking for outside variables, but from your 
other email, you already seem to know about those.

What you're actually seem to be trying to do is use makefiles as though 
they were a bash script. Wrong tool for the job.

-David


On 6/22/26 22:04, Heime wrote:
> How can I have targets that append values to variables?
> Doing as follows produces error on hopc.
>
> .PHONY: trlfn ndf
>
> trlfn: hopc += --transliterate-file-names
> ndf: hopc += --node-files
>
> What I want is that calling
>
> make -f myfile.mk trlfn
>
> will append --transliterate-file-names to hopc
>
>
>