Skip to content

Commit

Permalink
make
Browse files Browse the repository at this point in the history
  • Loading branch information
huahua132 committed Sep 28, 2024
1 parent b93c921 commit c1b7930
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
all: help

help:
@echo "make linux # linux 编译 skynet fly"
@echo "make freebsd # freebsd 编译 skynet fly"
@echo "make macosx # macosx 编译 skynet fly"
@echo "make clean # 清理"
@echo "make cleanall # 清理所有"
@echo "make upskynet # 更新skynet仓库代码"
@echo "make linux # linux 编译 skynet fly"
@echo "make freebsd # freebsd 编译 skynet fly"
@echo "make macosx # macosx 编译 skynet fly"
@echo "make clean # 清理"
@echo "make cleanall # 清理所有"
@echo "make upskynet # 更新skynet仓库代码"

# 定义平台默认变量
PLAT ?= none
Expand Down Expand Up @@ -34,10 +34,10 @@ macosx : SHARED := -fPIC -dynamiclib -Wl,-undefined,dynamic_lookup

# 创建目录 (仅当需要时创建)
$(LUA_CLIB_PATH) :
mkdir $(LUA_CLIB_PATH)
mkdir $(LUA_CLIB_PATH)

$(CSERVICE_PATH) :
mkdir $(CSERVICE_PATH)
mkdir $(CSERVICE_PATH)

# 新增的 C 服务
CSERVICE =
Expand All @@ -47,37 +47,37 @@ LUA_CLIB = lfs cjson pb zlib chat_filter openssl skiplist snapshot frpcpack sock

# Skynet 初始化(通过子模块)
$(SKYNET):
git submodule update --init
chmod -R 744 skynet
git submodule update --init
chmod -R 744 skynet

# 编译 Skynet(生成 skynet/skynet/skynet 文件)
$(SKYNET_BUILDER): $(SKYNET)
cd skynet && $(MAKE) PLAT=$(PLAT) TLS_MODULE=ltls TLS_INC=../$(TLS_INC) TLS_LIB=../$(TLS_LIB)
cd skynet && $(MAKE) PLAT=$(PLAT) TLS_MODULE=ltls TLS_INC=../$(TLS_INC) TLS_LIB=../$(TLS_LIB)

# 创建 Lua 模块并依赖 Skynet 完成编译
$(LUA_CLIB_PATH)/lfs.so : $(SKYNET_BUILDER) 3rd/luafilesystem-1_8_0/src/lfs.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -I3rd/luafilesystem-1_8_0/src $^ -o $@
$(CC) $(CFLAGS) $(SHARED) -I3rd/luafilesystem-1_8_0/src $^ -o $@

$(LUA_CLIB_PATH)/cjson.so : $(SKYNET_BUILDER) 3rd/lua-cjson/lua_cjson.c 3rd/lua-cjson/strbuf.c 3rd/lua-cjson/fpconv.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -I3rd/lua-cjson $^ -o $@
$(CC) $(CFLAGS) $(SHARED) -I3rd/lua-cjson $^ -o $@

$(LUA_CLIB_PATH)/pb.so : $(SKYNET_BUILDER) 3rd/lua-protobuf-0.4.0/pb.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -I3rd/lua-protobuf-0.4.0 $^ -o $@
$(CC) $(CFLAGS) $(SHARED) -I3rd/lua-protobuf-0.4.0 $^ -o $@

$(LUA_CLIB_PATH)/zlib.so : $(SKYNET_BUILDER) 3rd/lzlib/lzlib.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -Werror -pedantic -I3rd/lzlib -I3rd/zlib $^ -o $@ 3rd/zlib/libz.a
$(CC) $(CFLAGS) $(SHARED) -Werror -pedantic -I3rd/lzlib -I3rd/zlib $^ -o $@ 3rd/zlib/libz.a

$(LUA_CLIB_PATH)/chat_filter.so : $(SKYNET_BUILDER) 3rd/lua-chat_filter/lua-chat_filter.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@ -I3rd/lua-chat_filter
$(CC) $(CFLAGS) $(SHARED) $^ -o $@ -I3rd/lua-chat_filter

$(LUA_CLIB_PATH)/skiplist.so : $(SKYNET_BUILDER) 3rd/lua-zset/skiplist.c 3rd/lua-zset/lua-skiplist.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@ -I3rd/lua-zset
$(CC) $(CFLAGS) $(SHARED) $^ -o $@ -I3rd/lua-zset

$(LUA_CLIB_PATH)/snapshot.so : $(SKYNET_BUILDER) 3rd/lua-snapshot/snapshot.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@
$(CC) $(CFLAGS) $(SHARED) $^ -o $@

$(LUA_CLIB_PATH)/frpcpack.so : $(SKYNET_BUILDER) lualib-src/lua-frpcpack.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@ -Iskynet/skynet-src
$(CC) $(CFLAGS) $(SHARED) $^ -o $@ -Iskynet/skynet-src

# OpenSSL 动态库生成
SSL_SRCS := $(shell find 3rd/lua-openssl-0.9.0-0 -name '*.c')
Expand All @@ -92,30 +92,30 @@ $(LUA_CLIB_PATH)/openssl.so : $(SKYNET_BUILDER) $(SSL_SRCS) | $(LUA_CLIB_PATH)

# LuaSocket 生成,依赖 Skynet
$(LUA_CLIB_PATH)/socket.so : $(SKYNET_BUILDER)
cd 3rd/luasocket && $(MAKE) PLAT=$(PLAT) LUAV=5.4 prefix=../../../$(LUA_CLIB_PATH) LUAINC_$(PLAT)=../../../$(LUA_INC) LUALIB_$(PLAT)=../../../$(LUA_INC)
mv 3rd/luasocket/src/socket-3.1.0.so $(LUA_CLIB_PATH)/socket.so
cd 3rd/luasocket && $(MAKE) PLAT=$(PLAT) LUAV=5.4 prefix=../../../$(LUA_CLIB_PATH) LUAINC_$(PLAT)=../../../$(LUA_INC) LUALIB_$(PLAT)=../../../$(LUA_INC)
mv 3rd/luasocket/src/socket-3.1.0.so $(LUA_CLIB_PATH)/socket.so

$(SKYNET):
git submodule update --init
chmod -R 744 skynet
git submodule update --init
chmod -R 744 skynet

# 编译 Skynet,依赖 Makefile 和子模块
$(SKYNET_BULDER): $(SKYNET)
cd skynet && $(MAKE) PLAT=$(PLAT) TLS_MODULE=ltls TLS_INC=../$(TLS_INC) TLS_LIB=../$(TLS_LIB)
cd skynet && $(MAKE) PLAT=$(PLAT) TLS_MODULE=ltls TLS_INC=../$(TLS_INC) TLS_LIB=../$(TLS_LIB)

# 更新 Skynet 子模块
upskynet: $(SKYNET)
git submodule update --remote
git submodule update --remote

# 依赖 Skynet 完全编译再去编译 Lua 模块
linux macosx freebsd: $(SKYNET_BUILDER) $(LUA_CLIB_PATH) \
$(foreach v,$(LUA_CLIB), $(LUA_CLIB_PATH)/$(v).so)
$(foreach v,$(LUA_CLIB), $(LUA_CLIB_PATH)/$(v).so)

# 清理生成的 .so 文件
clean:
cd skynet && $(MAKE) clean
rm -f $(LUA_CLIB_PATH)/*.so
rm -f $(CSERVICE_PATH)/*.so
cd skynet && $(MAKE) clean
rm -f $(LUA_CLIB_PATH)/*.so
rm -f $(CSERVICE_PATH)/*.so

cleanall: clean
cd skynet && $(MAKE) cleanall
cd skynet && $(MAKE) cleanall

0 comments on commit c1b7930

Please sign in to comment.