2015-11-19 97 views
-1

儘管我一步一步跟着GNU make online manual,但makefiles上的問題仍令我困惑。
我工作在一個非常簡單的makefile: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瞭解到,funz.forfunz.o的先決條件。每當我更改源代碼funz.for時,make應更新funz.o並再次將其鏈接到main。但每當我啓動make時,我都會被告知main是最新的,並且不會識別funz.for中的更改。 This question我發現與相同的問題有關,但並未解決我的問題,因爲我認爲我的先決條件已正確提出。
我錯過了什麼嗎?

更新1

由於要求由伊坦賴斯納,這裏是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; touch funz.for; stat funz.o funz.for; make -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客戶端編輯我的源文件,而且在更新我的源文件後,「最後修改時間」出錯了。正如您在this picture中看到的那樣,即使幾分鐘前我修改了funz.for,其最後一次更改的顯示時間在我的實際時間(這裏差不多5個小時)之前的6個小時也是無法解釋的。

+1

你可以顯示'make -rRd'的輸出嗎? –

+0

@EtanReisner:當然!我已經用你提供的信息更新了這個問題。 – 19lorenz88

+0

'先決條件\'funz.for'比目標'funz.o'更老''認爲你的源文件比你的目標文件早。你有沒有改變它? –

回答

0

看起來像我正在使用的遠程計算機有一個不同於本地計算機的時間,因此不同的時間戳和生成文件不起作用。