当前位置: 技术问答>linux和unix
Makefile问题
来源: 互联网 发布时间:2015-06-06
本文导语: 最近写的工程,Makefile如下,当我Make clean之后,删除了所有目标文件(*.o)、依赖性文件(*.d)、和库文件后,再执行一遍Make clean,发现又重新生成了依赖文件,然后再删除了它们。请问如何避免这种情况? # # libR...
最近写的工程,Makefile如下,当我Make clean之后,删除了所有目标文件(*.o)、依赖性文件(*.d)、和库文件后,再执行一遍Make clean,发现又重新生成了依赖文件,然后再删除了它们。请问如何避免这种情况?
#
# libRTI Makefile
#
OUTLIB = libRTI.so.1.0.0
SONAME = libRTI.so.1
LINKLIB = libRTI.so
CXX = g++
CXXFLAGS = -Wall -O2 -D_REENTRANT
COMPILE = $(CXX) $(CXXFLAGS)
#
# Included Files Path
#
INC_ASTDATA = -I./inc/AST_DATA
INC_VNET = -I./inc/VNet
INC_RTI = -I./inc/RTI
INC_BSTRUCT = -I./inc/BASE_STRUCT
INC_MAIN = $(INC_ASTDATA) $(INC_VNET) $(INC_RTI) $(INC_BSTRUCT)
#
# Files List
#
SRCS := $(wildcard ./src/AST_DATA/*.cpp) $(wildcard ./src/VNet/*.cpp) $(wildcard ./src/BASE_STRUCT/*.cpp) $(wildcard ./src/RTI/*.cpp)
OBJS := $(patsubst %.cpp,%.o, $(SRCS))
DEPS := $(patsubst %.o,%.d, $(OBJS))
#
# Output file
#
$(OUTLIB) : $(DEPS) $(OBJS)
$(COMPILE) -shared -lpthread -o $@ $(OBJS)
ln -sf $@ $(LINKLIB)
ln -sf $@ $(SONAME)
#
# specify that all .o files depend on .cpp files, and indicate how to realize it
#
%.d : %.cpp
$(CXX) $(INC_MAIN) -MM $ $@
$(CXX) $(INC_MAIN) -MM $> $@
#
# specify that all .o files depend on .cpp files, and indicate how to realize it
#
%.o : %.cpp
$(COMPILE) -fPIC -c $(INC_MAIN) -o $@ $
$@
#
# specify that all .o files depend on .cpp files, and indicate how to realize it
#
$(OBJS) : $(SRCS)
$(COMPILE) -fPIC -c $(INC_MAIN) -o $@ $
#
# libRTI Makefile
#
OUTLIB = libRTI.so.1.0.0
SONAME = libRTI.so.1
LINKLIB = libRTI.so
CXX = g++
CXXFLAGS = -Wall -O2 -D_REENTRANT
COMPILE = $(CXX) $(CXXFLAGS)
#
# Included Files Path
#
INC_ASTDATA = -I./inc/AST_DATA
INC_VNET = -I./inc/VNet
INC_RTI = -I./inc/RTI
INC_BSTRUCT = -I./inc/BASE_STRUCT
INC_MAIN = $(INC_ASTDATA) $(INC_VNET) $(INC_RTI) $(INC_BSTRUCT)
#
# Files List
#
SRCS := $(wildcard ./src/AST_DATA/*.cpp) $(wildcard ./src/VNet/*.cpp) $(wildcard ./src/BASE_STRUCT/*.cpp) $(wildcard ./src/RTI/*.cpp)
OBJS := $(patsubst %.cpp,%.o, $(SRCS))
DEPS := $(patsubst %.o,%.d, $(OBJS))
#
# Output file
#
$(OUTLIB) : $(DEPS) $(OBJS)
$(COMPILE) -shared -lpthread -o $@ $(OBJS)
ln -sf $@ $(LINKLIB)
ln -sf $@ $(SONAME)
#
# specify that all .o files depend on .cpp files, and indicate how to realize it
#
%.d : %.cpp
$(CXX) $(INC_MAIN) -MM $ $@
$(CXX) $(INC_MAIN) -MM $> $@
#
# specify that all .o files depend on .cpp files, and indicate how to realize it
#
%.o : %.cpp
$(COMPILE) -fPIC -c $(INC_MAIN) -o $@ $
$@
#
# specify that all .o files depend on .cpp files, and indicate how to realize it
#
$(OBJS) : $(SRCS)
$(COMPILE) -fPIC -c $(INC_MAIN) -o $@ $