내 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.

처음 두 줄을 다음으로 바꾸면

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예상대로 작동하는지 확인해야 합니다 .

관련 정보