# Project: m3server
# Makefile created by Khan.Lau
# 应用程序名
BIN = m3server.exe
LIB = m3server.a
# 输出目录
CONFIGURATION = debug
#CONFIGURATION = release
# 取得项目的当前工作路径
PROJECT_PATH := $(shell cd)\src
CPP = g++
CC = gcc
COMPILER = $(CPP)
# c/c++库路径
LIBPATH = "D:/Develop/CPlus/MinGW/lib"
WINDRES = windres.exe
RES =
LINKOBJ = $(CONFIGURATION)/Khan_Queue.o \
$(CONFIGURATION)/db_mysql.o \
$(CONFIGURATION)/ThreadPool.o \
$(CONFIGURATION)/Util.o \
$(CONFIGURATION)/m3server.o \
$(CONFIGURATION)/CppObject.o \
$(CONFIGURATION)/CppSocket.o \
$(CONFIGURATION)/CppUdpSocket.o \
$(CONFIGURATION)/CppServerSocket.o \
$(CONFIGURATION)/ReadConfig.o \
$(RES)
# 包路径
LIBS = -L$(LIBPATH)\
-lws2_32\
-L"D:/Develop/CPlus/mysql5.0/lib" -lmysql\
-L"D:/Develop/CPlus/pthread/Pre-built.2/lib" -lpthreadGC2
# c的类库路径
INCS = -I$(LIBPATH)/include
# c++的类库路径
CXXINCS = -I$(LIBPATH)/include\
-I$(LIBPATH)/include/c++/3.2.3\
-I$(LIBPATH)/include/c++/3.2.3/backward\
-I$(LIBPATH)/include/c++/3.2.3/mingw32\
-I"D:/Develop/CPlus/pthread/Pre-built.2/include"\
-I$(PROJECT_PATH)\
-I"D:/Develop/CPlus/mysql5.0/include"
CXXFLAGS = -g -Wall $(CXXINCS)
CFLAGS = -g -Wall $(INCS)
RM = rm -f
.PHONY: all all-before all-after clean clean-custom rebuild strip
all: all-before $(LIB) $(BIN) all-after
clean: clean-custom
${RM} $(LINKOBJ) $(CONFIGURATION)/$(BIN) $(CONFIGURATION)/$(LIB)
#打包静态库
$(LIB): $(LINKOBJ)
ar -r $(CONFIGURATION)/$(LIB) $(LINKOBJ)
$(BIN): $(LINKOBJ)
$(COMPILER) $(CONFIGURATION)/$(LIB) -o $(CONFIGURATION)/$(BIN) $(LIBS)
#缩减可执行文件大小
strip:
strip $(CONFIGURATION)/$(BIN)
##################################################################################
#类库
$(CONFIGURATION)/Khan_Queue.o: src/lib/Khan_Queue.c
$(COMPILER) -c src/lib/Khan_Queue.c -o $(CONFIGURATION)/Khan_Queue.o $(CXXFLAGS)
$(CONFIGURATION)/db_mysql.o: src/lib/db_mysql.c
$(COMPILER) -c src/lib/db_mysql.c -o $(CONFIGURATION)/db_mysql.o $(CXXFLAGS)
$(CONFIGURATION)/ThreadPool.o: src/lib/ThreadPool.c
$(COMPILER) -c src/lib/ThreadPool.c -o $(CONFIGURATION)/ThreadPool.o $(CXXFLAGS)
$(CONFIGURATION)/Util.o: src/lib/Util.c
$(COMPILER) -c src/lib/Util.c -o $(CONFIGURATION)/Util.o $(CXXFLAGS)
$(CONFIGURATION)/CppObject.o: src/lib/CppObject.cpp
$(COMPILER) -c src/lib/CppObject.cpp -o $(CONFIGURATION)/CppObject.o $(CXXFLAGS)
$(CONFIGURATION)/CppSocket.o: src/lib/CppSocket.cpp
$(COMPILER) -c src/lib/CppSocket.cpp -o $(CONFIGURATION)/CppSocket.o $(CXXFLAGS)
$(CONFIGURATION)/CppUdpSocket.o: src/lib/CppUdpSocket.cpp
$(COMPILER) -c src/lib/CppUdpSocket.cpp -o $(CONFIGURATION)/CppUdpSocket.o $(CXXFLAGS)
$(CONFIGURATION)/CppServerSocket.o: src/lib/CppServerSocket.cpp
$(COMPILER) -c src/lib/CppServerSocket.cpp -o $(CONFIGURATION)/CppServerSocket.o $(CXXFLAGS)
$(CONFIGURATION)/ReadConfig.o: src/lib/ReadConfig.cpp
$(COMPILER) -c src/lib/ReadConfig.cpp -o $(CONFIGURATION)/ReadConfig.o $(CXXFLAGS)
###################################################################################
#核心代码
$(CONFIGURATION)/m3server.o: src/kernel/m3server.cpp
$(COMPILER) -c src/kernel/m3server.cpp -o $(CONFIGURATION)/m3server.o $(CXXFLAGS)
###################################################################################
rebuild: clean all