Lately at work, I've been doing some translation from Makefiles to an alternative build system. I've seen some pretty hairy Make code in some places using functional map, filter, and foreach constructs. This surprised me since I think build scripts ought to be as declarative as possible.
Anyway, this got me thinking: is the Makefile language (say the latest GNU make to be specific) Turing complete?
Now for a negative answer: GNU make actively blocks some mechanisms to create recursion:
1) Recursively expanded variables
aren't recursive in the "recursive function" sense: they can't be defined in terms of themselves:
(I don't see how allowing them could be useful in practice, by the way.)
2) Rule chaining
can't be recursive, either:
(I lost quite a lot of time over this while debugging my Makefiles - in addition to all the other things that make makefiles hard to maintain.)
P.S. for a recent project I wrote a patch to GNU make 3.82 which removes this limitation with a new -M option (see discussion). It works fine for me.
Yes, see this. Once you have lambda, it's all downhill from there.
Here is a plagiarized Fibonacci example
This should be enough to build a foundation for more generality (I've got to get back to work, or I'd play more.)
This prints out squares, fibonacci numbers and factorials. There appears to be a 16 bit limit on number sizes. Bummer.