我正在尝试编写一个Fortran makefile:有一个“main”文件,但我已将模块放在单独的.f90文件中。附加的makefile可以工作,但是即使我不做任何更改,它也会强制重新编译。我使用gfortan 4.7.2和GNU Make 3.81运行x86-64 Linux。Fortran makefile每次重新编译
FC = gfortran
FCFLAGS += -ffree-line-length-none -finit-local-zero
#FCFLAGS += -fbounds-check -ffpe-trap=invalid
all: new
new: ALE.o curvilinear.o new.o
$(FC) $(FCFLAGS) -o new new.o ALE.o curvilinear.o
new.o: ALE.mod curvilinear.mod new.f90
$(FC) $(FCFLAGS) -c new.f90
ALE.o: ALE.f90
$(FC) $(FCFLAGS) -c ALE.f90
ALE.mod: ALE.o ALE.f90
curvilinear.o: ALE.o curvilinear.f90
$(FC) $(FCFLAGS) -c curvilinear.f90
curvilinear.mod: curvilinear.o curvilinear.f90
clean:
rm ale.mod curvilinear.mod ALE.o curvilinear.o new new.o
输出:
$ make clean
rm ale.mod curvilinear.mod ALE.o curvilinear.o new new.o
$ make
gfortran -ffree-line-length-none -finit-local-zero -c ALE.f90
gfortran -ffree-line-length-none -finit-local-zero -c curvilinear.f90
gfortran -ffree-line-length-none -finit-local-zero -c new.f90
gfortran -ffree-line-length-none -finit-local-zero -o new new.o ALE.o curvilinear.o
$ make
gfortran -ffree-line-length-none -finit-local-zero -c new.f90
gfortran -ffree-line-length-none -finit-local-zero -o new new.o ALE.o curvilinear.o
为什么 “新” 在没有修改过被重新编译?
谢谢;你是对的,我不需要在makefile中有.mod文件。删除它们会为制作提供“正确”的行为。 – 2013-03-12 16:25:44