makefile自动生成依赖关系可自动检测头文件变化
DEBUG=1
创新互联建站-专业网站定制、快速模板网站建设、高性价比郧西网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式郧西网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖郧西地区。费用合理售后完善,十余年实体公司更值得信赖。
CC = gcc
CXX=g++
ifeq ($(DEBUG), 1)
OPTS=-O0 -g -DDEBUG
endif
CFLAGS = -fPIC -I$(COMPILE_DIR) -I$(vesdkdev) -I$(es_common) -I$(vesdk) -I$(vesdk)/boost-153/include -I$(vesdkproject)
CXXFLAGS=$(CFLAGS)
Target = libServerCfg.so
VPATH = src
OBJDIR=obj/
DEPDIR=deps/
CXXFLAGS +=$(OPTS)
CXXFLAGS +=-I../../global_include/ -I$(CrossOnvifLib)/ClientSo/wrapper -I$(CrossOnvifLib)/ClientSo/onvifgen -I$(CrossPlatformLib)/vesdkdev \
-I$(CrossOnvifLib)/Common/gsoap/share/gsoap/plugin -I$(CrossOnvifLib)/Common/gsoap/include -I$(CrossPlatformLib)/es_common -I$(CrossPlatformLib)/vesdk \
-I$(CrossPlatformLib)/vesdkdev/utils/mt/
LDFLAGS+=-shared -lm -pthread
LIBS = -lOnvifClient -lsqlite3 -lboost_system
OBJ= Helper.o Media.o DevicesMgmt.o Imaging.o PTZ.o DiskTool.o ServerCfg.o
OBJS = $(addprefix $(OBJDIR), $(OBJ))
DEPS = $(addprefix $(DEPDIR), $(OBJ))
all: obj $(Target)
$(Target): $(OBJS)
@echo make $(Target)
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS) $(LIBS)
cp $(Target) /usr/lib
$(OBJDIR)%.o: %.cpp
$(CC) $(CXXFLAGS) -c $< -o $@
obj:
mkdir -p obj
deps:
mkdir -p deps
.PHONY: clean
clean:
rm -rf $(OBJS) $(Target)
ifeq ("$(wildcard deps)", "")
DEP_DIR_DEPS:=deps
endif
include $(DEPS:.o=.d)
$(DEPDIR)%.d: %.cpp $(DEP_DIR_DEPS)
set -e; rm -f $@; \
$(CC) -MM $(CXXFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,$(OBJDIR)\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
文章标题:makefile自动生成依赖关系可自动检测头文件变化
标题来源:http://pwwzsj.com/article/pjejos.html