-1

我尝试执行以下操作(在网站上找到)

.PHONY: coat shoes mobile sweater socks trousers shirt pants undershirt

# target    prerequisite           command
# ------------------------------------------------
coat:       shoes mobile sweater;  @echo put on $@
shoes:      socks trousers;        @echo put on $@
mobile:     trousers;              @echo put on $@
sweater:    shirt;                 @echo put on $@
socks:      ;                      @echo put on $@
trousers:   pants shirt;           @echo put on $@
shirt:      undershirt;            @echo put on $@
pants:      ;                      @echo put on $@
undershirt: ;                      @echo put on $@

但是在 cygwin 上执行时出现循环依赖错误。这是输出

     1  MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
     2  Error: Circular dependency exists in makefile
     3    socks -> socks
     4  Error: Circular dependency exists in makefile
     5    shoes -> socks
     6  Error: Circular dependency exists in makefile
     7    mobile -> mobile
     8  Error: Circular dependency exists in makefile
     9    coat -> shoes
    10  Fatal: ';' does not exist - don't know how to make it

需要帮忙...

4

1 回答 1

3

使用 GNU 制作。这是证据:

  1. 您正在使用受 Borland 版权保护的 make,这表明您使用的 make 不是 GNU make。

  2. 我在这里找到了这个例子。作者提供了 GNU make 的链接,表明他的示例期望使用 GNU make。

  3. 您正在运行的 make 解释;为依赖项。显然它没有正确解释您的 Makefile。

  4. 如果我在您的示例中使用 GNU make,这就是我得到的:

    $ make
    put on socks
    put on pants
    put on undershirt
    put on shirt
    put on trousers
    put on shoes
    put on mobile
    put on sweater
    put on coat
    
于 2013-11-15T11:42:20.480 回答