在一个makefile中
1 SHELL=/bin/zsh
2 CC=g++
3
4 TARGET = target/jj
5 SOURCES = $(shell echo src/*.cpp)
6 HEADERS = $(shell echo include/*.h)
7 OBJECTS = $(SOURCES:.c=.o)
8 FLAGS = -Wall -c
9
10 all: $(TARGET)
11
12 # Create final executable from .o
13 $(TARGET): $(OBJECTS)
14 $(CC) $(OBJECTS)
15
16 # Create .o from .cpp
17 $(OBJECTS): $(SOURCES) # <------------------------------
18 $(CC) $(FLAGS) -c $(SOURCES)
19
20 # Remove objects
21 clean:
22 rm -rf $(OBJECTS)
所以 .. 在第 17 行,$(OBJECTS)
创建确实取决于$(SOURCES)
.o 创建中使用的内容。为什么这条线会产生循环依赖?(改为$(TARGET):
改为,工作正常)