Re: Appending to variables
Heime <[email protected]> Mon, 22 Jun 2026 22:35:29 +0000
| Newsgroups | gmane.comp.gnu.make.general |
|---|---|
| Message-ID | <TWBLF5TZ2ztcrfGRWeScSu__Os0PJaUGs0H4E1bWF1yLvsx1Fx-NhdkHW6C9WqA66O3nMk7PIeM3k1m3CUF1rQw2VwlFOHCYay5GPob1WPc=@protonmail.com> |
On Tuesday, June 23rd, 2026 at 9:25 AM, David Deutsch <[email protected]> wr= ote: > To translate what your command is "saying" to make: >=20 > make -f myfile.mk trlfn >=20 > equates to "read myfile.mk and then execute the recipe to produce the > target trlfn". >=20 > But trlfn is not a target because it has no recipe. >=20 > > Would there be no prerequisites for such cases? >=20 > Prerequisites are targets that need to be resolved before building the > desired targets. They are not dynamic bits of code like in your example. >=20 > > If I want to build my program with gcc, I might need to set compiler > options by specifying what I want to the makefile. How would it be a > wrong idea? >=20 > That's an entirely separate topic. You typically set compiler flags with > an environment variable. NOT with a target (.PHONY or otherwise) >=20 > I also slightly misread your makefile because it's so off-syntax: >=20 > trlfn: hopc +=3D --transliterate-file-names >=20 > This makes even less sense than I thought - if hopc is your executable, > you cannot "add to it" with +=3D, which is an extension to an existing > variable (although it might work slightly by accidend by just assuming > that "hopc" is a string that you then append to) >=20 > The target shape that you want could be something like >=20 > # myfile.mk >=20 > hopc-result.trlfn: > hopc --transliterate-file-names >=20 > hopc-result.ndf: > hopc --node-files >=20 > hopc-result.trlfn.ndf: > hopc --transliterate-file-names --node-files >=20 > and then call it via >=20 > make -f myfile.mk hopc-result.trlfn >=20 > but that's overly contrived. >=20 >=20 > Anyhow - maybe what you're actually looking for here IS an environment > variable? hopc accumulates options for makeinfo. =20 Using multiple options, I would have something like --html --split=3Dnode --transliterate-file-names --node-files Then I would need the call=20 $(hmldir)/antares.html: $(srcs) | $$(@D) =09makeinfo $(opts) --html $(hopc) -o $@ $< What would you suggest? Have looked at how emacs generates its documentation and it uses a makefile that calls makeinfo. =20 > > I do not think I am using wrong tool for the job. >=20 > You're using make like a bash script. That's not inherently wrong, but > what Make really wants to do is resolve dependency graphs to build > targets via their recipes. >=20 > -David >=20