Record the first write of the Makefile

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.

  1. 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

  1. 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
  1. Client Makefile
LIB_SRC =                              \
        event/eventFuncs.cc            \

BINARIES = client

all: $(BINARIES)

include ../landlords-common/common.mk

client: client.cc

Guess you like

Origin blog.csdn.net/qq_22473333/article/details/114748908