Skip to content

添加编译的Makefile #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

CC = gcc # or clang
SHARED = -fPIC -shared
CFLAGS = -g -O2 -Wall -I$(LUA_INC)

PBC_PATH = ./3rd/pbc
PBC_LIB = $(PBC_PATH)/build/libpbc.a

SKYNET_PATH ?= skynet
LUA_INC ?= $(SKYNET_PATH)/3rd/lua

LUA_LIB_PATH ?= $(SKYNET_PATH)/lualib
LUA_CLIB_PATH ?= $(SKYNET_PATH)/luaclib
SERVICE_PATH ?= $(SKYNET_PATH)/service
CSERVICE_PATH ?= $(SKYNET_PATH)/cservice

RES_PATH = ./res

ALL_FILE = $(LUA_CLIB_PATH)/protobuf.so $(LUA_LIB_PATH)/protobuf.lua \
$(LUA_CLIB_PATH)/p.so \
$(RES_PATH)/talkbox.pb \

all: $(PBC_LIB) $(SKYNET_PATH)/skynet $(ALL_FILE)
@:

# pbc

$(PBC_LIB):
git submodule update --init
cd $(PBC_PATH) && $(MAKE) lib CC=$(CC) CFLAGS="-O2 -fPIC"

# skynet

$(SKYNET_PATH)/skynet: $(PBC_LIB)
cd $(SKYNET_PATH) && $(MAKE) linux CC=$(CC)

# pbc-lua

$(LUA_CLIB_PATH)/protobuf.so: $(PBC_PATH)/binding/lua/pbc-lua.c
$(CC) $(CFLAGS) $(SHARED) -o $@ -I$(PBC_PATH) $< $(PBC_LIB)

$(LUA_LIB_PATH)/protobuf.lua: $(PBC_PATH)/binding/lua/protobuf.lua $(LUA_CLIB_PATH)/protobuf.so
cp -f $< $@

# pack

$(LUA_CLIB_PATH)/p.so: ./3rd/p/lua-p.c
$(CC) $(CFLAGS) $(SHARED) -o $@ $<

# proto file

$(RES_PATH)/talkbox.pb: $(RES_PATH)/talkbox.proto
protoc -o $@ $<

clean:
rm -f $(ALL_FILE)

cleanall: clean
cd $(PBC_PATH) && $(MAKE) clean
cd $(SKYNET_PATH) && $(MAKE) clean

29 changes: 2 additions & 27 deletions start.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,12 @@ run()
}

echo " >>---------- 开始 ----------"

git submodule update --init

echo " >>---------- 处理protocbuf ----------"

# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

mv ./3rd/pbc/Makefile ./3rd/pbc/Makefile.bak
mv ./3rd/pbc/binding/lua/Makefile ./3rd/pbc/binding/lua/Makefile.bak
cp ./3rd/pbcMakefile ./3rd/pbc/Makefile
cp ./3rd/pbcluaMakefile ./3rd/pbc/binding/lua/Makefile

cd ./3rd/pbc/ && make && cd ./binding/lua/ && make && cd ../../../../

protoc -o ./res/talkbox.pb ./res/talkbox.proto

echo " >>---------- 处理协议 ----------"
cd ./3rd/p/ && gcc -g -O2 -Wall -I../../skynet/3rd/lua -fPIC --shared ./lua-p.c -o ./p.so && cd ../../
make

echo " >>---------- 进入skynet目录 ----------"
echo ""
cd ${SKYNET_PATH};

#日志目录
LOG_PATH="../log/"
if [ ! -x "$LOG_PATH" ]; then
Expand All @@ -85,15 +69,6 @@ TMP_PATH="../tmp/"
if [ ! -x "$TMP_PATH" ]; then
mkdir "$TMP_PATH"
fi
echo ""
echo " >>---------- 编译 ----------"
echo ""
make linux;
echo ""
echo " >>---------- 拷贝协议so模块 ----------"
cp -f ../3rd/pbc/binding/lua/protobuf.lua ./lualib/ && cp -f ../3rd/pbc/binding/lua/protobuf.so ./luaclib/
cp -f ../3rd/p/p.so ./luaclib/


echo ""
echo " >>---------- 执行 ---------"
Expand Down