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

makefile模板(生成.so)

时间:2014-10-09 18:34:57      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:blog   ar   for   sp   div   log   ad   ef   bs   

# Make command to use for dependencies
RM=rm
MKDIR=mkdir

OUTDIR=_obj
SODIR=./bin
LIBNAME=pdk_ai.so
OUTFILE=$(SODIR)/$(LIBNAME)
INC=-I../../../../lib/svrlib/include -I../../../../lib/tinyxml -I../../../include 
LIB=-lpthread -lrt -ldl 

#obj dir
TINYXML=../../../../lib/tinyxml
EXEFILE=$(EXEDIR)/$(APP)
SRC := $(wildcard *.cpp $(TINYXML)/*.cpp)
OBJ := $(patsubst %.cpp, $(OUTDIR)/%.o, $(notdir ${SRC}))
	
	
COMPILE=g++ -c -o "$(OUTDIR)/$(*F).o" $(INC) -fPIC -w "$<"
LINK=g++ -o "$(OUTFILE)" $(OBJ) $(LIB) -shared -fPIC

# Pattern rules
$(OUTDIR)/%.o : $(TINYXML)/%.cpp
	$(COMPILE)

$(OUTDIR)/%.o : ./%.cpp
	$(COMPILE)
	
# Build rules
all: $(OUTFILE)

$(OUTFILE): $(OUTDIR)  $(OBJ)
	$(LINK)
#	sh sh_ver.sh ./win/svrlib.rc $(OUTFILE)   #update ver. ( read by "readelf -h libsvr.so")
#	sh sh_tar.sh  ./win/*.rc  $(SODIR)  $(LIBNAME) #tar file

$(OUTDIR):
	$(MKDIR) -p "$(OUTDIR)"
	$(MKDIR) -p "$(SODIR)"
	
# Rebuild this project
rebuild: cleanall all

# Clean this project
clean:
	$(RM) -f $(OUTFILE)
	$(RM) -f $(OBJ)

# Clean this project and all dependencies
cleanall: clean

 

makefile模板(生成.so)

标签:blog   ar   for   sp   div   log   ad   ef   bs   

原文地址:http://www.cnblogs.com/kangbry/p/4013490.html

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