编译动态链接库:
# Project:
# Makefile created by zieckey@yahoo.com.cn
CPP = g++
#need to assign IKSEMEL_HOME to your own path
IKSEMEL_HOME = /data/soft/iksemel-1.3
OBJ = config.o msgheader.o msgbody.o msgmgr.o locker.o
LINKOBJ = $(OBJ)
LIBFLAGS = -liksemel
LIBS = -L. -L$(IKSEMEL_HOME)/lib
INCS = -I.
CXXINCS = -I. -I$(IKSEMEL_HOME)/include
CXXFLAGS = $(CXXINCS) -g -fPIC -Wall
RM = rm -f
TAG_SO = libmsg.so
TAG_A = libmsg.a
all : $(TAG_SO)
cp -rf $(TAG_SO) ./lib
$(TAG_SO) : $(OBJ)
$(CPP) -s -shared $(LIBS) $(LIBFLAGS) $^ -o $@
msgheader.o: msgheader.cpp
$(CPP) -c $(CXXFLAGS) $< -o $@
config.o: config.cpp
$(CPP) -c $(CXXFLAGS) $< -o $@
msgbody.o: msgbody.cpp
$(CPP) -c $(CXXFLAGS) $< -o $@
msgmgr.o: msgmgr.cpp
$(CPP) -c $(CXXFLAGS) $< -o $@
locker.o: locker.cpp
$(CPP) -c $(CXXFLAGS) $< -o $@
.PHONY : clean
clean:
${RM} $(OBJ) *.out *.o *.so.* $(TAG_SO)
|
递归调用子目录下的makefile文件:
SUBDIRS = ./msg_mgr ./lock_class ./msg_mgr_testcase ./socket_class
all:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir; \
done
clean:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean; \
done
|
值得注意的地方:
$@ 目标文件,$^ 所有的依赖文件,$< 第一个依赖文件.
阅读(1990) | 评论(0) | 转发(0) |