######### 标准Makefile Lv1.1 / 生成动态库 ######## EXE=libexample.so SUBDIR=src 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++ -shared $(CXX_OBJECTS) -o $(EXE) %.o: %.cpp g++ -c -fPIC -MMD $< -o $@ -include $(DEP_FILES) clean: rm -rf $(CXX_OBJECTS) $(DEP_FILES) $(EXE) test: echo $(CXX_OBJECTS)