Makefile 生成文件不更新对象
尽管我正在一步一步地进行,但makefiles上的一个问题仍然困扰着我。Makefile 生成文件不更新对象,makefile,fortran,gfortran,fortran77,Makefile,Fortran,Gfortran,Fortran77,尽管我正在一步一步地进行,但makefiles上的一个问题仍然困扰着我。 我正在编写一个非常简单的makefile: OBJ = main.o funz.o main : $(OBJ) gfortran -g -o main $(OBJ) funz.o : funz.for gfortran -g -c funz.for main.o : main.for gfortran -g -c main.for clean : rm main.o funz.o
我正在编写一个非常简单的makefile:
OBJ = main.o funz.o
main : $(OBJ)
gfortran -g -o main $(OBJ)
funz.o : funz.for
gfortran -g -c funz.for
main.o : main.for
gfortran -g -c main.for
clean :
rm main.o funz.o
根据我对makefiles的了解,funz.for
是funz.o
的先决条件。每次我更改源代码funz.for
,make
都应该更新funz.o
,并再次将其链接到main
。但是每当我启动make
时,我都会被告知main
是最新的,并且无法识别funz.for
中的更改。我发现它与相同的问题有关,但不能解决我的问题,因为我认为我的先决条件提出得正确。我错过什么了吗 更新1 按照Etan Reisner的要求,以下是
make-rRd
的输出:
This program built for x86_64-redhat-linux-gnu
Reading makefiles...
Reading makefile `Makefile'...
Updating makefiles....
Considering target file `Makefile'.
Looking for an implicit rule for `Makefile'.
No implicit rule found for `Makefile'.
Finished prerequisites of target file `Makefile'.
No need to remake target `Makefile'.
Updating goal targets....
Considering target file `main'.
Considering target file `main.o'.
Considering target file `main.for'.
Looking for an implicit rule for `main.for'.
No implicit rule found for `main.for'.
Finished prerequisites of target file `main.for'.
No need to remake target `main.for'.
Finished prerequisites of target file `main.o'.
Prerequisite `main.for' is older than target `main.o'.
No need to remake target `main.o'.
Considering target file `funz.o'.
Considering target file `funz.for'.
Looking for an implicit rule for `funz.for'.
No implicit rule found for `funz.for'.
Finished prerequisites of target file `funz.for'.
No need to remake target `funz.for'.
Finished prerequisites of target file `funz.o'.
Prerequisite `funz.for' is older than target `funz.o'.
No need to remake target `funz.o'.
Finished prerequisites of target file `main'.
Prerequisite `main.o' is older than target `main'.
Prerequisite `funz.o' is older than target `main'.
No need to remake target `main'.
make: `main' is up to date.
这里是stat funz.o funz.for的输出;触摸funz.for;统计funz.o funz.for;品牌-rRd
File: `funz.o'
Size: 3176 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 58197897 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 505/ lorenzo) Gid: ( 505/ lorenzo)
Access: 2015-11-19 16:23:06.200737262 -0500
Modify: 2015-11-19 16:23:06.192737262 -0500
Change: 2015-11-19 16:23:06.192737262 -0500
File: `funz.for'
Size: 129 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 58196947 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 505/ lorenzo) Gid: ( 505/ lorenzo)
Access: 2015-11-19 16:23:06.183737262 -0500
Modify: 2015-11-19 16:23:06.174737262 -0500
Change: 2015-11-19 16:23:06.174737262 -0500
File: `funz.o'
Size: 3176 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 58197897 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 505/ lorenzo) Gid: ( 505/ lorenzo)
Access: 2015-11-19 16:23:06.200737262 -0500
Modify: 2015-11-19 16:23:06.192737262 -0500
Change: 2015-11-19 16:23:06.192737262 -0500
File: `funz.for'
Size: 129 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 58196947 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 505/ lorenzo) Gid: ( 505/ lorenzo)
Access: 2015-11-19 16:23:47.478737151 -0500
Modify: 2015-11-19 16:23:47.478737151 -0500
Change: 2015-11-19 16:23:47.478737151 -0500
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-redhat-linux-gnu
Reading makefiles...
Reading makefile `Makefile'...
Updating makefiles....
Considering target file `Makefile'.
Looking for an implicit rule for `Makefile'.
No implicit rule found for `Makefile'.
Finished prerequisites of target file `Makefile'.
No need to remake target `Makefile'.
Updating goal targets....
Considering target file `main'.
Considering target file `main.o'.
Considering target file `main.for'.
Looking for an implicit rule for `main.for'.
No implicit rule found for `main.for'.
Finished prerequisites of target file `main.for'.
No need to remake target `main.for'.
Finished prerequisites of target file `main.o'.
Prerequisite `main.for' is older than target `main.o'.
No need to remake target `main.o'.
Considering target file `funz.o'.
Considering target file `funz.for'.
Looking for an implicit rule for `funz.for'.
No implicit rule found for `funz.for'.
Finished prerequisites of target file `funz.for'.
No need to remake target `funz.for'.
Finished prerequisites of target file `funz.o'.
Prerequisite `funz.for' is newer than target `funz.o'.
Must remake target `funz.o'.
gfortran -g -c funz.for
Putting child 0x0197ea80 (funz.o) PID 69914 on the chain.
Live child 0x0197ea80 (funz.o) PID 69914
Reaping winning child 0x0197ea80 PID 69914
Removing child 0x0197ea80 PID 69914 from chain.
Successfully remade target file `funz.o'.
Finished prerequisites of target file `main'.
Prerequisite `main.o' is older than target `main'.
Prerequisite `funz.o' is newer than target `main'.
Must remake target `main'.
gfortran -g -o main main.o funz.o
Putting child 0x019830d0 (main) PID 69917 on the chain.
Live child 0x019830d0 (main) PID 69917
Reaping winning child 0x019830d0 PID 69917
Removing child 0x019830d0 PID 69917 from chain.
Successfully remade target file `main'.
更新2
我注意到了一件非常奇怪的事情(我总是忽略了这一点):我正在通过WinSCP客户端编辑我的源文件,似乎在更新源文件之后,“上次修改”的时间出错了。正如您在中所看到的,即使我在几分钟前修改了
funz.
,显示的上次更改时间也比我的实际时间早了6个小时(这里几乎是下午5点)。我正在使用的远程计算机的时间似乎与本地计算机的时间不同,因此不同的时间戳和makefile不起作用。
您能显示make-rRd
的输出吗?@EtanReisner:当然!我已使用您询问的信息更新了问题。先决条件'funz.for'比目标'funz.o'旧。
make认为源文件比目标文件旧。您对其进行了更改吗?@EtanReisner:是的,我对funz.for
进行了更改并保存了源文件:但是,make
将其视为比funz.o
旧,并认为无需更新main
。您使用的是自动编译的IDE还是其他什么?stat funz.o funz.for的输出是什么;触摸funz.for;统计funz.o funz.for;品牌-rRd?(测试设备是否正常工作。)