记录第一次写Makefile文件
程序员文章站
2022-06-20 08:40:00
...
先将文件记录在此,以后再来总结 Makefile 的写法
楼主目前正在将 ravel 的java版本改写为C++ 版本,每次需要写很长的 gcc 命令,想到用 make 来代替GCC 的命令行。
- 公共部分的Makefile
CXXFLAGS = -g -I /home/san/eclipse-workspace/ratel/landlords-common -pthread -L/home/san/apps/build/debug-install-cpp11/lib
LDFLAGS = -lboost_serialization -lprotobuf -lz -lmuduo_base -lpthread -lmuduo_net -L/home/san/apps/build/debug-install-cpp11/lib -L. -lravel -lz
landlord_root = /home/san/eclipse-workspace/ratel/landlords-common
BASE_SRC = $(landlord_root)/protobuf/codec.cc $(landlord_root)/protobuf/query.pb.cc $(landlord_root)/helper/PokerHelper.cc $(landlord_root)/entity/PokerSell.cc $(landlord_root)/robot/RobotDecisionMakers.cc
MUDUO_SRC = $(notdir $(LIB_SRC) $(BASE_SRC))
OBJS = $(patsubst %.cc,%.o,$(MUDUO_SRC))
libravel.a: $(BASE_SRC) $(LIB_SRC)
g++ $(CXXFLAGS) -c $^
ar rcs [email protected] $(OBJS)
$(BINARIES): libravel.a
g++ $(CXXFLAGS) -o [email protected] $(filter %.cc,$^) $(LDFLAGS)
clean:
rm -f $(BINARIES) *.o *.a core
- 服务端的 Makefile
LIB_SRC = \
event/EventFuncs.cc \
event/ServerEventListener.cc \
event/ServerContains.cc \
robot/RobotEventListener.cc \
robot/RobotEventFuncs.cc \
BINARIES = server
all: $(BINARIES)
include ../landlords-common/common.mk
server: server.cc
- 客户端的Makefile
LIB_SRC = \
event/eventFuncs.cc \
BINARIES = client
all: $(BINARIES)
include ../landlords-common/common.mk
client: client.cc
上一篇: python之lambda函数/表达式
下一篇: uniapp获取input文本框中的值