最近在做icomet到f-stack的集成,需要对icomet进行改造,因此需要对icomet的Makefile文件进行解读和修改。
1.Makefile文件在icomet-master的同级目录下,具体代码如下:
$(shell sh build.sh 1>&2)
include build.mk
.PHONY: all tools clean
all:
mkdir -p logs //新建logs文件夹
cd src/util; make //切换到src/util下编译
cd src/comet; make //切换到src/come下编译
cp -f icomet-server icomet-server-`cat version` //给icomet-server改名为加版本号
tools:
cd tools; make //切换到tools下编译
clean:
rm -f *.exe.stackdump //删除后缀为.exe.stackdump的文件
cd src/util; make clean //切换到src/util下清理目标文件
cd src/comet; make clean //切换到src/comet下清理目标文件
rm -f icomet-server-* //删除前缀为icomet-server的文件夹
clean_all: clean
cd $(JEMALLOC_PATH); make clean
cd $(LIBEVENT_PATH); make clean
rm -f $(JEMALLOC_PATH)/Makefile $(LIBEVENT_PATH)/Makefile
2.src/util下Makefile文件如下:
include ../../build.mk
OBJS = log.o config.o bytes.o sorted_set.o //声明变量
EXES =
all: ${OBJS} //生成all的目标文件
ar -cru ./libutil.a ${OBJS} //创建库
log.o: log.h log.cpp
${CXX} ${CFLAGS} -c log.cpp
config.o: config.h config.cpp
${CXX} ${CFLAGS} -c config.cpp
bytes.o: bytes.h bytes.cpp
${CXX} ${CFLAGS} -c bytes.cpp
sorted_set.o: sorted_set.h sorted_set.cpp
${CXX} ${CFLAGS} -c sorted_set.cpp
clean:
rm -f ${EXES} ${OBJS} *.o *.exe *.a
3.src/comet下Makefile文件如下:
include ../../build.mk
OBJS = subscriber.o presence.o channel.o server.o //声明变量
CFLAGS += -I ../
all: $(OBJS) //生成all的目标文件
${CXX} -o ../../icomet-server $(CFLAGS) \ //创建库
icomet-server.cpp $(OBJS) \
../util/libutil.a \
$(LIBEVENT_PATH)/.libs/libevent.a \
$(CLIBS)
subscriber.o: subscriber.h subscriber.cpp
${CXX} -c $(CFLAGS) subscriber.cpp
presence.o: presence.h presence.cpp
${CXX} -c $(CFLAGS) presence.cpp
channel.o: channel.h channel.cpp
${CXX} -c $(CFLAGS) channel.cpp
server.o: server.h server.cpp
${CXX} -c $(CFLAGS) server.cpp
clean:
rm -f *.o ../../icomet-server
4.tools下Makefile文件如下:
include ../build.mk
all:
$(CXX) -o ./benchmark \
$(CFLAGS) \
-I../src \
../src/util/*.o benchmark.cpp \
$(LIBEVENT_PATH)/.libs/libevent.a \
$(CLIBS)
clean:
rm -f *.o