私のMakefileが変更なしで再コンパイルされるのはなぜですか?

私のMakefileが変更なしで再コンパイルされるのはなぜですか?

次のmakefileがあります。

all:    all_functions
all_functions:  a_functions.o b_functions.o c_functions.o d_functions.o main.o a.h b.h c.h d.h main.h 
      gcc -o program1 a_functions.o b_functions.o c_functions.o d_functions.o main.o
a_functions.o:  a_functions.c a.h
      gcc -c -o a_functions.o a_functions.c
b_functions.o:  b_functions.c b.h
      gcc -c -o b_functions.o b_functions.c
c_functions.o:  c_functions.c c.h
      gcc -c -o c_functions.o c_functions.c
d_functions.o:  d_functions.c d.h
      gcc -c -o d_functions.o d_functions.c
main.o: main.c main.h
      gcc -c -o main.o main.c
clean:
      rm *.o program1
install:
      cp ./program1 "/usr/local/program1"
uninstall:
      rm "/usr/local/program1"

makefileでスペースの代わりにタブを使用しました。これにより、make -f Makefileファイルが存在し、変更がない場合でも、makefileは毎回program1をコンパイルして生成します。私のメイクファイルに何の問題がありますか? "make: Nothing to be do for.." というエラー メッセージが表示されることが予想されます。

ベストアンサー1

あなたは使用しています間違った目標つまり有用な名前がありますが、そのレシピがターゲットを作成しないターゲットです。つまり、make最終的にターゲットを構築しようとしますall_functionsが、関連するレシピは名前付きアイテムを構築しませんall_functions

最初の2行を次に置き換えると

all: program1
program1: a_functions.o b_functions.o c_functions.o d_functions.o main.o a.h b.h c.h d.h main.h

make期待どおりに機能していることを確認してください。

おすすめ記事