简体   繁体   中英

Circular dependency exists in makefile

I tried executing the following (found on a website)

.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 $@

But I am getting Circular dependency error when executed on cygwin. Here is the output

     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

Need help...

Use GNU make. Here's the evidence:

  1. You are using a make copyrighted to Borland, which indicates that the make you are using is not GNU make.

  2. I've found the example here . The author provides a link to GNU make, suggesting that his examples expect GNU make.

  3. The make you are running interprets ; as a dependency. Clearly it is not interpreting your Makefile correctly.

  4. If I use GNU make with your example, here's what I get:

     $ 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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM