0

I'm using GNU Make with Guile. How do I pass Make variables to Guile?

%.txt:
    @echo $* $(guile (string-upcase $*))

What I want to see is this:

$ make foo.txt
foo FOO

What I get is an error, Unbound variable: foo. My Guile invocation expands to (string-upcase foo), and foo is unbound. I can put quotes around the variable and then I get the result I'm looking for:

$(guile (string-upcase "$*"))

This feels wrong. What if the string contains double quotes? It feels like there would be a more formal mechanism for passing values into Guile.

https://www.gnu.org/software/make/manual/html_node/Guile-Types.html goes into some detail about passing values from Guile to to Make, but I can't immediately see anything about passing them in.

iter
  • 4,171
  • 8
  • 35
  • 59
  • 1
    The example in the docs uses that `"$var"` style. You could probably use `subst` to escape double quotes if that's a concern. – Shawn Dec 26 '22 at 00:59
  • Thank you @Shawn. Sometimes I forget that make programming is closer to shell programming than "real" programming in the sense that everything gets concatenated into a string and parsed out from a string; there are no higher-level constructs. The impedance mismatch with Guile is jarring :=) – iter Dec 26 '22 at 02:25

0 Answers0