1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# the tunables
MYSQL_SRC = $(HOME)/mysql-5.1.23-rc
MYSQL_LIBDIR = $(HOME)/mysql-5.1.23-rc-build/lib/mysql
TOKUDB = /usr/local/tokudb-4.4
TOKUDB_VERSION = "Tokudb"
DEBUG = 1
GCOV = 0
SINGLESO = 1
SYSTEM = $(shell uname -s | tr [A-Z] [a-z])
# sources to target
SRCS = $(wildcard *.cc)
OBJS = $(patsubst %.cc,%.o,$(SRCS))
TARGET = ha_tokudb.so
ifeq ($(GCOV),1)
GCOV_FLAGS = -ftest-coverage -fprofile-arcs
endif
ifeq ($(DEBUG),0)
OPTFLAGS = -O2
MYSQL_FLAGS =
CXXFLAGS =
else
OPTFLAGS = -O0
MYSQL_FLAGS = -DHAVE_CONFIG_H -DDBUG_ON -DSAFE_MUTEX -DEXTRA_DEBUG -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC -DSAFE_MUTEX
CXXFLAGS = -Wall -Werror
endif
MYSQL_FLAGS += -DMYSQL_DYNAMIC_PLUGIN
MYSQL_CXXFLAGS = -fno-implicit-templates -fno-exceptions -fno-rtti
CPPFLAGS = -I. -I$(MYSQL_SRC)/sql -I$(MYSQL_SRC)/include -I$(MYSQL_SRC)/regex -I$(TOKUDB)/include -I$(TOKUDB)/toku_include -I$(TOKUDB)/src
ifeq ($(SYSTEM),linux)
CPPFLAGS += -I$(TOKUDB)/linux
endif
CPPFLAGS += $(MYSQL_FLAGS)
CPPFLAGS += -DTOKUDB_VERSION=\"$(TOKUDB_VERSION)\"
CXXFLAGS += -g $(OPTFLAGS) $(GCOV_FLAGS) $(MYSQL_CXXFLAGS)
CXXFLAGS += -fPIC
LDFLAGS = -fPIC -shared -Wl,-soname -Wl,libtokudb_engine.so
ifeq ($(SINGLESO),1)
LIBS = $(TOKUDB)/lib/libtokudb.a $(TOKUDB)/lib/libtokuportability.a
else
LIBS = -L$(TOKUDB)/lib -ltokudb -ltokuportability
endif
LIBS += -lpthread -lz -lstdc++ -lm -lgcc_s -lc
# LIBDIR = /usr/lib
# GCCLIBDIR = /usr/lib/gcc/i386-redhat-linux/4.1.1
# BEGINLIBS = $(LIBDIR)/crti.o $(GCCLIBDIR)/crtbeginS.o
# ENDLIBS = $(GCCLIBDIR)/crtendS.o $(LIBDIR)/crtn.o
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) $(GCOV_FLAGS) $(MYSQL_CXXFLAGS) $(BEGINLIBS) $^ $(LIBS) $(ENDLIBS) -o $@
clean:
rm -rf $(TARGET) $(OBJS) *.gcno *.gcda *.gcov
install: $(TARGET)
cp $(TARGET) $(MYSQL_LIBDIR)/libtokudb_engine.so