How do I make Makefile to recompile only changed files?
问题 I have been struggling a bit to get make to compile only the files that have been edited. However I didn't have much success and all the files get recompiled. Can someone explain me why? My files are: main.c a_functions.c where main.c includes main.h and a_functions.c includes a.h Here is my makefile: CC=gcc CFLAGS=-Wall -I. -c EXEC_FILE=program1 all: program a_functions.o: a_functions.c a_functions.c: a.h main.o: main.c main.c: main.h objects: a_functions.c main.c $(CC) a_functions.c main.c