Makefile 为什么要删除我的临时文件?
我有一个简单的MakefileMakefile 为什么要删除我的临时文件?,makefile,Makefile,我有一个简单的Makefile .PHONY: clean PROGRAMS=$(patsubst main%.cpp,example%,$(wildcard main*.cpp)) all: ${PROGRAMS} GCCVERSION=$(shell gcc -dumpversion) GLCFLAGS=$(shell pkg-config --cflags gl) CPPFLAGS=-Wall -O2 ${GLCFLAGS} ifeq "${GCCVERSION}" "4.5.2"
.PHONY: clean
PROGRAMS=$(patsubst main%.cpp,example%,$(wildcard main*.cpp))
all: ${PROGRAMS}
GCCVERSION=$(shell gcc -dumpversion)
GLCFLAGS=$(shell pkg-config --cflags gl)
CPPFLAGS=-Wall -O2 ${GLCFLAGS}
ifeq "${GCCVERSION}" "4.5.2"
CXXFLAGS=-std=c++0x
else
CXXFLAGS=-std=c++11
endif
GLLIBS=$(shell pkg-config --libs gl)
LIBS=${GLLIBS} -lglut
example%: main%.o shaders.o fileutils.o
${CXX} $^ ${LIBS} -o $@
clean:
rm -f *.o ${PROGRAMS}
但当我执行它时,它会将*.o文件作为最后一个命令删除。我不知道为什么:
$ make
g++ -std=c++11 -Wall -O2 -I/usr/include/libdrm -c -o main01.o main01.cpp
g++ -std=c++11 -Wall -O2 -I/usr/include/libdrm -c -o shaders.o shaders.cpp
g++ -std=c++11 -Wall -O2 -I/usr/include/libdrm -c -o fileutils.o fileutils.cpp
g++ main01.o shaders.o fileutils.o -lGL -lglut -o example01
rm main01.o fileutils.o shaders.o
我的Makefile有什么问题吗?中间文件被设计删除:请参阅GNU make手册中的
使用
.SECONDARY
或.PRECIOUS
目标保存precioussss临时文件。为了澄清之前的响应,您需要添加一个特殊规则,如
.PRECIOUS: myfile.o
我遇到了这样的问题,但只是。珍贵的没有起作用。第二(见),如果你介意看看。。。