I wish to register a complaint! (about BSD make)
"G. Branden Robinson" <[email protected]>
| Newsgroups | gmane.comp.printing.groff.general,gmane.org.unix-heritage.general |
|---|---|
| Message-ID | <20260121083004.ildkmtjkd5uaukfl@illithid> |
[CCing Warren due to my usual GMail->TUHS interference problems]
...that's how my Hungarian phrasebook tells me to word it.
Since this issue burns me every time I do a groff release (formerly as
deputy maintainer, now as a full bird), I wish to risk offending BSD
partisans by griping about their make.
Apparently BSD make tracks file identity in its dependency graph by
using...strings.
That's it. Just strings.
So "foo" != "./foo" != "./././foo" and so on. To BSD make, these are
different things, even though by design they must be file specifications
("pathnames") _on the file system_, and on every Unix, they _are the
same_.
So you get spurious build failures when, say, macro contents naming a
target disagree with target names in rules in ways that don't make sense
when you know what's going on (outside of make implementation details).
Let me offer some simplified examples.
FOO = ./foo
$(FOO): bar
frob < bar > $(FOO)
If the "./" prefix seems like a silly thing to do, consider that it may
itself be the result of macro expansion.
FOO = $(BAZ)/foo
all: $(FOO)
$(FOO): bar
frob < bar > $(FOO)
$ make BAZ=/look/over/there
(Yes, a real Makefile for BSD make would probably not be written this
way.[1])
This design is a landmine with a tripwire in front of it because in the
shell command "recipes" of a makefile rule, you once again get the
semantics you expect as a Unix file system user, because the _shell_
resolves whatever $(FOO) expands to. So it is not fooled by "./" or
"./././." or any other variation on that theme.
I find this design choice even more confusing because Unix has had hard
links since day one, or just about. The _name_ of a file as a string or
even a directory entry is not its uniquely identifying characteristic
(ignoring content).
Why does the BSD make dependency graph not track the device and inode
pair instead?
And won't this string-based approach fail to detect file identity in the
case of symbolic links as well? Didn't BSD _invent_ symbolic links?
Can someone make this make sense?
Regards,
Branden
[1] You'd need "BAZ ?= ." to keep "foo" from being sought in the root
directory if the macro wasn't defined on make's command line. Or
via inclusion, depending on the implementation.
But "?=" is new to POSIX 2024 so I suppose that for a long time, one
couldn't rely on its availability.
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEh3PWHWjjDgcrENwa0Z6cfXEmbc4FAmlwjoMACgkQ0Z6cfXEm bc4fXA/+P8Txhq/cW0UadgAxkhLPLL6VT//Qbi7pDZip3FLRWSvZ0HPUGNmnS3v4 E38XMIss9ZnuwStBgMdlcKX2GHRxBTbqtpU7ASq5DVOTp/D5Ov/NWsD4LqQTe6fX RNFM3tfGWgi8zWP46pl24KXaRc03J0myOvesaJTOEMXSMK/8g1ydOeMIdbPoTd86 3ZIfzaAzbfzyMnNECp9FtcqTN8KO1DTLD6vEZA5IM2vrzCsuJYkaId1qeA9y2Aix rGon0/Q3nVFqzoaLDQWnz8hl+Vym6T8QMcqA62PdFMg2gylPlRWy1Z+s33JoEOHp GuKupU5Sq0SDJRuLkm56XAJ/IA9HvFLqmvOpbnQlr61sVnvH99rPdYBNQDLlk1tY 7aMJbP4uJlH8+tD4MqSKVxe3jpNFYm4oM5BUoxmRfwE5K4y4yjdIHyGyUnbAasyG e67v3T3cOspxej03nOeQcFJwm9ai+xlwci0UMyEf0c2cAadFEzLC74FZtrGl1MpG hHZn6/0M8+g4GRExpm9h0ilbe6Xgm+8Ng2hn/zAAgknKnsFqMvvNGFNbzGjMmnLJ fGqFATU/aVtgNmXyh4G+RvwICHlUEba486aYQZns1F7UUvHW60CT+j4Ydin+GIPM VpLg0oYrlzW1AZs+rJmXnfwhLwu8835Hd7Kcb53dvzDhfgzuWN8= =bMQI -----END PGP SIGNATURE-----