记录第一次写Makefile文件

先将文件记录在此,以后再来总结 Makefile 的写法

楼主目前正在将 ravel 的java版本改写为C++ 版本,每次需要写很长的 gcc 命令,想到用 make 来代替GCC 的命令行。

  1. 公共部分的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 $@ $(OBJS)

$(BINARIES): libravel.a
	g++ $(CXXFLAGS) -o $@ $(filter %.cc,$^) $(LDFLAGS)

clean:
	rm -f $(BINARIES) *.o *.a core

  1. 服务端的 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
  1. 客户端的Makefile
LIB_SRC =                              \
        event/eventFuncs.cc            \

BINARIES = client

all: $(BINARIES)

include ../landlords-common/common.mk

client: client.cc

猜你喜欢

转载自blog.csdn.net/qq_22473333/article/details/114748908
今日推荐