There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

Variables in GNU Make: Simple and Recursive

cross-posted from: lemmy.ml/post/4908824

There are two major flavours of variables in GNU Make: “simple” and “recursive”.

While simple variables are quite simple and easy to understand, they can be limiting at times. On the other hand, recursive variables are powerful yet tricky.

There is exactly one rule to recall when using recursive variables…

🧠 The value of a recursive variable is computed every time it is expanded.

JoYo ,
@JoYo@lemmy.ml avatar

it’s that illegal?

bahmanm OP ,
@bahmanm@lemmy.ml avatar

Uh, I’m not sure I understand what you mean.

JoYo ,
@JoYo@lemmy.ml avatar

RMS notoriously fought against variables in make

bahmanm OP ,
@bahmanm@lemmy.ml avatar

I think I understand where RMS was coming from RE “recursive variables”. As I wrote in my blog:

Recursive variables are quite powerful as they introduce a pinch of imperative programming into the otherwise totally declarative nature of a Makefile.

They extend the capabilities of Make quite substantially. But like any other powerful tool, one needs to use them sparsely and responsibly or end up w/ a complex and hard to debug Makefile.

In my experience, most of the times I can avoid using recursive variables and instead lay out the rules and prerequisites in a way that does the same. However, occasionally, I’d have to resort to them and I’m thankful that RMS didn’t win and they exist in GNU Make today 😅 IMO purist solutions have a tendency to turn out impractical.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • [email protected]
  • lifeLocal
  • goranko
  • All magazines