码迷,mamicode.com
首页 > 其他好文 > 详细

makefile自动生成依赖关系 可自动检测头文件变化

时间:2017-06-09 17:23:04      阅读:378      评论:0      收藏:0      [点我收藏+]

标签:makefile 头文件修改检测 自动依赖检测

DEBUG=1

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自动生成依赖关系 可自动检测头文件变化

标签:makefile 头文件修改检测 自动依赖检测

原文地址:http://danielllf.blog.51cto.com/2442311/1933836

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!