-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (63 loc) · 1.86 KB
/
Makefile
File metadata and controls
81 lines (63 loc) · 1.86 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
SRCTREE?= $(shell pwd)
CC?=gcc
CXX?=g++
OPTIMIZATION?=-O2
WARNINGS=-Wall -Wno-deprecated-register
DEBUG?= -g -ggdb -DDEBUG=1 -DYYDEBUG=1
LEX=flex
YACC=bison
INCLUDE= -Iinclude -Ibuild/include
REAL_CFLAGS= -std=gnu++11 -fPIC $(OPTIMIZATION) $(WARNINGS) $(DEBUG) $(INCLUDE) -c
LKFALG= -Lbuild/lib -L. -Wl,-rpath=$(SRCTREE)/build/lib -Wl,-rpath=$(SRCTREE)
LDLIB = -ltcmalloc
OS = $(shell uname -s)
SONAME?=so
ifeq ("$(OS)","Darwin")
SONAME:=dylib
LKFALG=-Lbuild/lib -L. -Wl,-F$(SRCTREE)/build/lib -Wl,-F$(SRCTREE)
endif
ifeq ("MINGW","$(findstring MINGW,$(OS))")
SONAME:=dll
INCLUDE+= -I3rd/gperftools/src/windows
LKFALG+= -L3rd/gperftools/x64/Debug
LDLIB=-ltcmalloc_minimal
endif
.PHONY: all clean test
OBJS = allocator.o keywords.o parser.o scan.o sql.o
TESTOBJS = test/test.o
all:libsqlparser.$(SONAME) testparser
libsqlparser.$(SONAME):$(OBJS)
$(CXX) -shared $(LKFALG) $(OBJS) $(LDLIB) -o $@
testparser:$(OBJS) $(TESTOBJS)
$(CXX) $(LKFALG) $(TESTOBJS) $(LDLIB) $(OBJS) -o $@
clean:
-rm -f $(OBJS) sql.cpp include/sql.hpp scan.cpp *.d sql.output libsqlparser.$(SONAME) $(TESTOBJS) testparser 2>/dev/null
distclean:clean
@if [ -d build ] ; then \
cd 3rd/gperftools; \
make distclean; \
cd $(SRCTREE); \
rm -rf build ; \
fi
test:
./testparser test/test.sql
%.o:%.cpp
$(CXX) $(REAL_CFLAGS) -o $@ $<
%.cpp:%.l
$(LEX) -CF -o $@ $<
%.cpp:%.yy
$(YACC) --debug --report=itemset --defines=include/$*.hpp -o $@ $<
build/include/gperftools/tcmalloc.h:
cd 3rd/gperftools && ./autogen.sh && ./configure --prefix=$(SRCTREE)/build && make install
include/kwlist.h:sql.yy
python keyword.py $< $@
%.d:%.cpp
rm -f $@; $(CC) -MM $< $(INCLUDE) > $@.$$$$; \
if [ -s $@.$$$$ ] ; then \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
fi; \
rm -f $@.$$$$;
allocator.d:build/include/gperftools/tcmalloc.h
include/sql.hpp:sql.cpp
scan.cpp:scan.l
-include $(OBJS:.o=.d)