1
2MYSQL_INC = HANDLERSOCKET_MYSQL_INC
3MYSQL_LIB = HANDLERSOCKET_MYSQL_LIB
4
5CXX = g++ -Wall -g -fno-rtti -fno-exceptions -fPIC -DPIC
6LIBS = $(MYSQL_LIB) -lhsclient -lpthread -lz
7CXXFLAGS = -I/usr/include/handlersocket $(MYSQL_INC)
8LDFLAGS =
9
10CXXFLAGS += -O3 -DNDEBUG
11
12HANDLERSOCKET_OBJS = database.o hstcpsvr.o hstcpsvr_worker.o
13
14all: handlersocket.so
15
16handlersocket.so: $(HANDLERSOCKET_OBJS) handlersocket.cpp
17	$(CXX) $(CXXFLAGS) -fno-strict-aliasing -shared $^ -o $@ $(LDFLAGS) \
18		-Wl,-soname -Wl,$@ $(LIBS)
19clean:
20	rm -f *.a *.so *.o
21
22LIBDIR = $(shell \
23  if [ -e /usr/lib64/mysql ]; then echo /usr/lib64; else echo /usr/lib; fi)
24
25install: handlersocket.so
26	sudo sh -c 'ulimit -c unlimited ; /etc/init.d/mysql stop ; \
27		cp handlersocket.so handlersocket.so.cpy && \
28		mv handlersocket.so.cpy \
29			$(LIBDIR)/mysql/plugin/handlersocket.so && \
30		/etc/init.d/mysql start'
31
32