具有多个目标的Makefile [英] Makefile with multiple targets
问题描述
希望这是一个非常简单的问题.我有一个makefile模式规则,如下所示:
Hopefully this is a very simple question. I have a makefile pattern rule that looks like this:
%.so : %.f %.pyf
f2py -c -L${LAPACK_DIR} ${GRASPLIBS} -m $* $^ ${SOURCES} --opt='-02' --f77flags='-fcray-pointer' >> silent.txt
我希望makefile生成多个.so文件,因此我尝试通过执行以下操作来使其生成两个文件(radgrd_py.so和lodiso_py.so):
I want the makefile to build a number of .so files, so I tried to get it to build two files (radgrd_py.so and lodiso_py.so) by doing this:
radgrd_py.so lodiso_py.so:
%.so : %.f %.pyf
f2py -c -L${LAPACK_DIR} ${GRASPLIBS} -m $* $^ ${SOURCES} --opt='-02' --f77flags='-fcray-pointer' >> silent.txt
,然后尝试以下操作:
radgrd_py.so:
lodiso_py.so:
%.so : %.f %.pyf
f2py -c -L${LAPACK_DIR} ${GRASPLIBS} -m $* $^ ${SOURCES} --opt='-02' --f77flags='-fcray-pointer' >> silent.txt
但是在每种情况下,它只会构建我指定的第一个目标.如果我运行'make radgrd_py.so'可以正常工作,我只是不确定如何指定需要构建的文件列表,这样我就可以运行'make'.
But in each case, it only builds the first target that I specify. If I run 'make radgrd_py.so' it works fine, I'm just not sure how to specify a list of files that need to be built so I can just run 'make'.
推荐答案
通常的技巧是添加一个虚拟"目标作为第一个目标,该目标取决于运行普通make
时要构建的所有目标:>
The usual trick is to add a 'dummy' target as the first that depends on all targets you want to build when running a plain make
:
all: radgrd_py.so lodiso_py.so
惯例是将此目标称为全部"或默认".为了更加正确,请在Makefile
中添加以下行,以使make
知道这不是真实文件:
It is a convention to call this target 'all' or 'default'. For extra correctness, let make
know that this is not a real file by adding this line to your Makefile
:
.PHONY: all
这篇关于具有多个目标的Makefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!