我有一个简单的项目,看起来像这样
\n\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 build\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.o\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 one\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.o\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 file2.o\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .depend\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Makefile\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 src\n \xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.cpp\n \xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 one\n \xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.cpp\n \xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 file2.cpp\nRun Code Online (Sandbox Code Playgroud)\n\nMakefile 是这样的:
\n\n# Get all of the source files\nSRC = $(shell find src/ -name "*.cpp")\n# Get all of the object files\nOBJ = $(subst src,build,$(SRC:.cpp=.o))\n\n$(OBJ):\n @mkdir -p $(shell dirname $@)\n g++ -g -c $(subst build,src,$(subst .o,.cpp,$@)) -o $@\n\nall: depend build\n\nbuild: $(OBJ)\n gcc -o project $^\n\ndepend:\n g++ -MM $(SRC) > .depend\n sed -i …Run Code Online (Sandbox Code Playgroud)