SRCS=$(wildcard *.cpp common/*.cpp)
PROTO_SRCS=$(wildcard *.pb.cc)
BIN_SRCS=$(shell grep "int main" -l *.cpp) $(shell grep "IMPLEMENT_MAIN" -l *.cpp)
LIB_SRCS=$(patsubst $(BIN_SRCS),,$(SRCS))
DEPS=$(SRCS:.cpp=.d)
OBJS=$(SRCS:.cpp=.o) $(PROTO_SRCS:.cc=.o)
LIB_OBJS=$(patsubst %.cpp,%.o,$(LIB_SRCS)) $(PROTO_SRCS:.cc=.o)
BINS=logic_application
DEP_LIBS= ../public/libpublic.a ../third_party/libthird_party.a
LDFLAGS = -lpthread -L/usr/lib64/mysql/ -lmysqlclient_r -lz
LIB_NAME=
SO_LIB=$(patsubst %,lib%.so,$(LIB_NAME))
STATIC_LIB=$(patsubst %,lib%.a,$(LIB_NAME))
CC=g++
CFLAGS= -Wall -D_REENTRANT -D_GNU_SOURCE -fPIC
CFLAGS += -std=c++11
CFLAGS += -Wno-deprecated
#INC= -I${THRIFT_DIR} -I${BOOST_DIR} -I. -I../public
INC= -I. -I../framework -I./common -I../ -I../public -I../config -I../tools -I../third_party -I/usr/include/mysql
ifeq ($(release), 1)
CFLAGS += -O2 -DNDEBUG
else
CFLAGS += -g -DDEBUG
endif
all: $(BINS) $(SO_LIB) $(STATIC_LIB)
$(BINS): % : %.o $(LIB_OBJS) $(DEP_LIBS)
$(CC) -o $(notdir $@) $^ $(LDFLAGS)
$(SO_LIB): $(LIB_OBJS)
$(CC) $(CFLAGS) -shared -o $@ $^
$(STATIC_LIB): $(LIB_OBJS)
ar -rcs -o $@ $^
dist :
rm -f $(DEPS)
clean:
rm -f $(BINS) $(OBJS) $(DEPS) $(SO_LIB) $(STATIC_LIB)
release: clean
@make release=1
%.d : %.cpp
$(CC) $(CFLAGS) -MT $(subst .cpp,.o,$<) -MM $(INC) $$@
%.o : %.cpp
$(CC) $(CFLAGS) $(INC) -c $< -o $@
-include $(DEPS)
阅读(1203) | 评论(0) | 转发(0) |