最近我遇到了一个非常奇怪的行为Makefile
:
在当前目录中,我有hello.pyx
:
#cython: language_level=3
print("Hello, world!")
and in ..
I have 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.so
在当前目录中使用make -f ../Makefile hello.so
,它删除.cc
建造后.so
:
cython --cplus hello.pyx -o hello.cc
clang++ -shared -pthread -fPIC -fwrapv -Oz -flto -Wall -fno-strict-aliasing -I/usr/include/python3.7m -Wl,-plugin-opt=O2 hello.cc -o hello.so
rm hello.cc
我尝试删除目标.PHONY
and clean
,但这没有帮助。
我怎样才能停下来make
from rm hello.cc
?
该文件被认为是中间文件 https://www.gnu.org/software/make/manual/html_node/Chained-Rules.html。为了防止它被删除,您所要做的就是在 makefile 中的任何位置将其作为目标或先决条件提及,如下所示:
sources: $(patsubst %.so,%.cc,$(MAKECMDGOALS))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)