Makefile 在构建后使remove.cc。因此不受控制
最近我遇到了一个非常奇怪的行为Makefile 在构建后使remove.cc。因此不受控制,makefile,cython,Makefile,Cython,最近我遇到了一个非常奇怪的行为Makefile: includes=$(shell python3 -c "import sysconfig; print(sysconfig.get_path('include'))") CFLAGS=-shared -pthread -fPIC -fwrapv -Oz -flto -Wall -fno-strict-aliasing -I$(includes) LDFLAGS=-Wl,-plugin-opt=O2 %.cc: %.pyx cy
Makefile
:
includes=$(shell python3 -c "import sysconfig; print(sysconfig.get_path('include'))")
CFLAGS=-shared -pthread -fPIC -fwrapv -Oz -flto -Wall -fno-strict-aliasing -I$(includes)
LDFLAGS=-Wl,-plugin-opt=O2
%.cc: %.pyx
cython --cplus $< -o $@
%.so: %.cc
clang++ ${CFLAGS} ${LDFLAGS} $< -o $@
clean:
rm -f *.cc *.so
.PHONY: clean
在当前目录中,我有hello.pyx
:
#cython: language_level=3
print("Hello, world!")
在。
中,我有Makefile
:
includes=$(shell python3 -c "import sysconfig; print(sysconfig.get_path('include'))")
CFLAGS=-shared -pthread -fPIC -fwrapv -Oz -flto -Wall -fno-strict-aliasing -I$(includes)
LDFLAGS=-Wl,-plugin-opt=O2
%.cc: %.pyx
cython --cplus $< -o $@
%.so: %.cc
clang++ ${CFLAGS} ${LDFLAGS} $< -o $@
clean:
rm -f *.cc *.so
.PHONY: clean
我试图删除target.PHONY
和clean
,但没有效果
如何从
rm hello.cc
停止make
?该文件被视为一个文件。要防止其被删除,只需在makefile中的任何位置将其作为目标或先决条件,如下所示:
sources: $(patsubst %.so,%.cc,$(MAKECMDGOALS))