######### 标准Makefile Lv1.2 / 使用动态库 ######## EXE=helloworld SUBDIR=src object #CXXFLAGS:编译选项, LDFLAGS:链接选项 CXXFLAGS += -I/home/mytest/example/include/ LDFLAGS += -L/home/mytest/example/lib -lexample CXX_SOURCES =$(foreach dir,$(SUBDIR), $(wildcard $(dir)/*.cpp)) CXX_OBJECTS=$(patsubst %.cpp, %.o, $(CXX_SOURCES)) DEP_FILES =$(patsubst %.o, %.d, $(CXX_OBJECTS)) $(EXE): $(CXX_OBJECTS) g++ $(CXX_OBJECTS) -o $(EXE) $(LDFLAGS) %.o: %.cpp g++ -c $(CXXFLAGS) -MMD $< -o $@ -include $(DEP_FILES) clean: rm -rf $(CXX_OBJECTS) $(DEP_FILES) $(EXE) test: echo $(CXX_OBJECTS)