4 ms·
> or you use special pattern rules I used make for years before I understood pattern rules, even though they're pretty simple. I kept trying to use foreach loo
by dahart 9y ago
> or you use special pattern rules
I used make for years before I understood pattern rules, even though they're pretty simple. I kept trying to use foreach loops all over the place. If you're using foreach loops, check whether a pattern rule can do the job.
> The popular clamour is that the autovars are too short & confusing.
I finally realized, after years of using make and then learning pattern rules, that the three autovars listed here are visual mnemonics. $@ looks like a target, a ring with a bullseye. $< is pointing left, so it's the first prereq. $^ is like a horizontal bracket that groups all prereqs.
- henry_flower 9y agothat's a wonderful mnemonic you have! I've quoted you in the updated version of the text (I hope you don't mind).
- dahart 9y agoI don't mind at all, though credit should really be given to make's authors, I'm sure it was intentional.
- gkya 9y ago> I finally realized, after years of using make and then learning pattern rules, that the three autovars listed here are visual mnemonics. $@ looks like a target, a ring with a bullseye. $< is pointing left, so it's the first prereq. $^ is like a horizontal bracket that groups all prereqs. I've been illuminated, sincerely! Meanwhile, bmake has some more memorable synonyms for them like ".TARGET" and ".ALLSRC".
- sjmulder 9y agoIt's a shame that there is no name for .ALLSRC shared between bmake and gmake. An alternative is to use a variable, but then you lose VPATH compatibility: foo: foo.o bar.o $(LD) foo.o bar.o ... My other gripe with bmake is that this rule is needed as there is no implicit rule for linking multiple object files, or so it seems.
- buserror 9y agoAhah funny I always seen these as ... these! Really I always thought it was quite elegant, in a nerdy way ;-)