Are makefiles Turing complete?

后端 未结 2 1827
谎友^
谎友^ 2020-12-12 23:53

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,

2条回答
  •  别那么骄傲
    2020-12-13 00:17

    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:

    Actually make detects the infinite loop and reports an error.
    

    (I don't see how allowing them could be useful in practice, by the way.)

    2) Rule chaining

    can't be recursive, either:

    No single implicit rule can appear more than once in a chain. (...)
    This constraint has the added benefit of preventing any infinite loop
    in the search for an implicit rule chain.
    

    (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.

提交回复
热议问题