我是makefiles的新手并且面临一些问题.我创建了以下makefile.它工作正常.但是当我修改main.cpp并运行make时,它会说"一切都是最新的".我需要做一个make clean并再次运行make,一切都会正常工作.
看起来这个makefile存在一些问题,我无法弄清楚它出错的地方.任何人都可以帮我找出这个makefile中的错误在哪里以及它为什么不构建更改的文件?
#Main makefile which does the build
CFLAGS =
CC = g++
PROG = fooexe
#each module will append the source files to here
SRC :=
#including the description
include foo/module.mk
OBJ := $(patsubst %.cpp, %.o, $(filter %.cpp,$(SRC))) main.o
#linking the program
fooexe: $(OBJ)
$(CC) -o $(PROG) $(OBJ)
%.o:
$(CC) -c $(SRC) -o $(patsubst %.cpp, %.o, $(filter %.cpp,$(SRC)))
main.o:
$(CC) -c main.cpp
depend:
makedepend -- $(CFLAGS) -- $(SRC)
.PHONY:clean
clean: …
Run Code Online (Sandbox Code Playgroud)