???????????
????1.Makefile??????
????target???????????????dependency?target???????????command?????????target???????У?
<target> : <dependency> <dependency> ...
(tab)<command>
(tab)<command>
.
.
.
????2.??????? := ?? =
????:=??=???????????????:=????????????????????磺
????A:=foo
????B:=$(A)
????A:=bar
?????????B??????foo???????????????????????A??????????
????3.????#??Makefile????????
????4.wildcard????
????SRCS:=$(wildcard *.cpp) ????о?????????????.cpp?????????????????????SRCS???????google???
????5.patsubst????
????OBJS := $(patsubst %.cpp??%.o??$(SRCS))???????$(SRCS)????????????%.cpp????????滻?%.o??
????6.filter-out????
????$(filter-out $(A)??$(B))?????B?й????A?е??????????????????
????7. “.PHONY”
??????.PHONY???ε?target??“α???”?????????????????????make???phony target??????????????????????????????????????±??????(command)??
????8.all deps objs clean veryclean rebuild info
??????Щ????“α???”??
????all?????????????????make??????????У?all????????????*.cpp????????*.d?????*.o???????????????*.o??????????????$(EXECUTABLE)??
????deps????????*.d?????.d?????????????????????????????????????
????objs????????*.o?????.o?????C++??????????м?????????????
????clean???????*.d?????*.o?????
????veryclean???*.d?????*.o????????????$(EXECUTABLE)???????????
????rebuild?????veryclean????????????????all???±?????????
????info???Щ?????
??????÷?????
????make deps???????deps??
????9.ifneq...else...endif
???????????ifneq??????????????...??
????10.include <files>???
????include?????<files>???????????????
????$(DEPS)????????????????????????????????.d?????-include $(DEPS)???????Щ?????????????????
????11.????*.o????????????????
?????????????
????$(EXECUTABLE) : $(OBJS)
????$(CC) -o $(EXECUTABLE) $(OBJS) $(addprefix -l??$(LIBS))
????$(EXECUTABLE)?????????????$(OBJS)?????.o???????$(CC)????????g++??$(addprefix -l??$(LIBS)????????
???????????*.d?????*.o????????????????ò??????????????????????????????????
????12. ????????(Implicit rules)
????$(EXECUTABLE)??????$(OBJS)????makefile????????$(OBJS)???????????????????????????
?????????make?????????????????????$(OBJS)?е???????make????????
????$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
????????????.o?????.d?????
????$<???????????б?????????????
????$@?????????????
??????????????.d???????????“-MMD”??????????g++??????????????????????????????????????????.d????С?
????????.cpp???????????????.d????????.o?????
????13.@????
?????????????@?????????????????У?
????14.CFLAGS??CPPFLAGS
???????????????????????????????Google???
????-g ???gdb?????????
????-Wall ???warning?????
????-O3 ?????3???????