First record the file here, and then summarize the writing of Makefile
The host is currently rewriting the java version of ravel to the C++ version. Every time I need to write a long gcc command, I think of using make instead of the GCC command line.
- Common part of 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
- Server 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
- Client Makefile
LIB_SRC = \
event/eventFuncs.cc \
BINARIES = client
all: $(BINARIES)
include ../landlords-common/common.mk
client: client.cc