2017-07-21 02:47:45 +02:00
|
|
|
all: library
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
############# Directories #############
|
|
|
|
#######################################
|
2015-12-23 16:01:08 +01:00
|
|
|
BIN = bin
|
|
|
|
SRC = src
|
|
|
|
SRCPARSER = src/parser
|
2014-12-15 18:32:46 +01:00
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
INSTALL = /usr/local
|
2017-05-27 00:18:52 +02:00
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
######################################
|
|
|
|
############ Compile Mode ############
|
|
|
|
######################################
|
2017-05-27 00:18:52 +02:00
|
|
|
# Set compile mode to -g or -O3.
|
2017-07-21 02:47:45 +02:00
|
|
|
# Debug mode: make mode=debug
|
|
|
|
|
2017-05-27 00:18:52 +02:00
|
|
|
mode ?= release
|
2017-07-21 02:47:45 +02:00
|
|
|
MODE_LOG = ""
|
|
|
|
OPT_FLAG =
|
2017-05-27 00:18:52 +02:00
|
|
|
ifeq ($(mode), debug)
|
2017-07-21 02:47:45 +02:00
|
|
|
OPT_FLAG = -g
|
2017-05-29 16:22:13 +02:00
|
|
|
MODE_LOG = "Building in \033[1;31mdebug\033[0m mode"
|
2017-05-27 00:18:52 +02:00
|
|
|
else
|
2017-07-21 02:47:45 +02:00
|
|
|
OPT_FLAG = -O3
|
2017-05-29 16:22:13 +02:00
|
|
|
MODE_LOG = "Building in \033[0;32mrelease\033[0m mode ('make mode=debug' for debug mode)"
|
2017-05-27 00:18:52 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
GMAKE = make mode=$(mode)
|
2014-12-15 18:32:46 +01:00
|
|
|
|
2015-08-28 13:46:07 +02:00
|
|
|
|
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
#######################################
|
|
|
|
############### Library ###############
|
|
|
|
#######################################
|
|
|
|
PARSER_CPP = $(SRCPARSER)/bison_parser.cpp $(SRCPARSER)/flex_lexer.cpp
|
|
|
|
PARSER_H = $(SRCPARSER)/bison_parser.h $(SRCPARSER)/flex_lexer.h
|
|
|
|
|
|
|
|
LIB_BUILD = libsqlparser.so
|
2017-09-05 12:55:46 +02:00
|
|
|
LIB_CFLAGS = -std=c++1z -Wall -Werror -fPIC $(OPT_FLAG)
|
2017-07-21 02:47:45 +02:00
|
|
|
LIB_LFLAGS = -shared $(OPT_FLAG)
|
|
|
|
LIB_CPP = $(shell find $(SRC) -name '*.cpp' -not -path "$(SRCPARSER)/*") $(PARSER_CPP)
|
|
|
|
LIB_H = $(shell find $(SRC) -name '*.h' -not -path "$(SRCPARSER)/*") $(PARSER_H)
|
|
|
|
LIB_ALL = $(shell find $(SRC) -name '*.cpp' -not -path "$(SRCPARSER)/*") $(shell find $(SRC) -name '*.h' -not -path "$(SRCPARSER)/*")
|
|
|
|
LIB_OBJ = $(LIB_CPP:%.cpp=%.o)
|
|
|
|
|
|
|
|
library: $(LIB_BUILD)
|
|
|
|
|
|
|
|
$(LIB_BUILD): $(LIB_OBJ)
|
|
|
|
$(CXX) $(LIB_LFLAGS) -o $(LIB_BUILD) $(LIB_OBJ)
|
2014-12-15 18:32:46 +01:00
|
|
|
|
2017-05-27 00:18:52 +02:00
|
|
|
$(SRCPARSER)/flex_lexer.o: $(SRCPARSER)/flex_lexer.cpp $(SRCPARSER)/bison_parser.cpp
|
2017-09-05 12:24:13 +02:00
|
|
|
$(CXX) $(LIB_CFLAGS) -c -o $@ $< -Wno-sign-compare -Wno-unneeded-internal-declaration
|
2017-04-21 16:15:07 +02:00
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
%.o: %.cpp $(PARSER_CPP) $(LIB_H)
|
|
|
|
$(CXX) $(LIB_CFLAGS) -c -o $@ $<
|
2015-12-23 16:01:08 +01:00
|
|
|
|
2017-04-21 16:15:07 +02:00
|
|
|
$(SRCPARSER)/bison_parser.cpp: $(SRCPARSER)/bison_parser.y
|
2017-05-27 00:18:52 +02:00
|
|
|
$(GMAKE) -C $(SRCPARSER)/ bison_parser.cpp
|
2017-04-06 17:02:40 +02:00
|
|
|
|
2017-04-21 16:15:07 +02:00
|
|
|
$(SRCPARSER)/flex_lexer.cpp: $(SRCPARSER)/flex_lexer.l
|
2017-05-27 00:18:52 +02:00
|
|
|
$(GMAKE) -C $(SRCPARSER)/ flex_lexer.cpp
|
2015-12-23 16:01:08 +01:00
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
$(SRCPARSER)/bison_parser.h: $(SRCPARSER)/bison_parser.cpp
|
|
|
|
$(SRCPARSER)/flex_lexer.h: $(SRCPARSER)/flex_lexer.cpp
|
|
|
|
|
2015-12-23 16:01:08 +01:00
|
|
|
clean:
|
2017-07-21 02:47:45 +02:00
|
|
|
rm -f $(LIB_BUILD)
|
2015-12-23 16:14:39 +01:00
|
|
|
rm -rf $(BIN)
|
2015-12-23 16:01:08 +01:00
|
|
|
find $(SRC) -type f -name '*.o' -delete
|
|
|
|
|
|
|
|
cleanparser:
|
2017-05-27 00:18:52 +02:00
|
|
|
$(GMAKE) -C $(SRCPARSER)/ clean
|
2015-12-23 16:01:08 +01:00
|
|
|
|
2015-12-23 17:00:41 +01:00
|
|
|
cleanall: clean cleanparser
|
2015-12-23 16:14:39 +01:00
|
|
|
|
2016-01-16 12:36:45 +01:00
|
|
|
install:
|
2017-07-21 02:47:45 +02:00
|
|
|
cp $(LIB_BUILD) $(INSTALL)/lib/$(LIB_BUILD)
|
2017-04-21 16:15:07 +02:00
|
|
|
rm -rf $(INSTALL)/include/hsql
|
2017-03-11 13:47:35 +01:00
|
|
|
cp -r src $(INSTALL)/include/hsql
|
|
|
|
find $(INSTALL)/include/hsql -not -name '*.h' -type f | xargs rm
|
|
|
|
|
2017-05-27 00:18:52 +02:00
|
|
|
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
#######################################
|
|
|
|
############## Benchmark ##############
|
|
|
|
#######################################
|
|
|
|
BM_BUILD = $(BIN)/benchmark
|
|
|
|
BM_CFLAGS = -std=c++17 -Wall -Isrc/ -L./ $(OPT_FLAG)
|
|
|
|
BM_PATH = benchmark
|
|
|
|
BM_CPP = $(shell find $(BM_PATH)/ -name '*.cpp')
|
|
|
|
BM_ALL = $(shell find $(BM_PATH)/ -name '*.cpp' -or -name '*.h')
|
|
|
|
|
|
|
|
benchmark: $(BM_BUILD)
|
|
|
|
|
|
|
|
run_benchmarks: benchmark
|
|
|
|
./$(BM_BUILD) --benchmark_counters_tabular=true
|
|
|
|
# --benchmark_filter="abc
|
|
|
|
|
|
|
|
save_benchmarks: benchmark
|
|
|
|
./$(BM_BUILD) --benchmark_format=csv > benchmarks.csv
|
|
|
|
|
|
|
|
$(BM_BUILD): $(BM_ALL) $(LIB_BUILD)
|
|
|
|
@mkdir -p $(BIN)/
|
|
|
|
$(CXX) $(BM_CFLAGS) $(BM_CPP) -o $(BM_BUILD) -lbenchmark -lpthread -lsqlparser -lstdc++ -lstdc++fs
|
|
|
|
|
|
|
|
|
2017-03-06 18:30:35 +01:00
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
########################################
|
|
|
|
############ Test & Example ############
|
|
|
|
########################################
|
|
|
|
TEST_BUILD = $(BIN)/tests
|
2017-09-05 12:55:46 +02:00
|
|
|
TEST_CFLAGS = -std=c++1z -Wall -Werror -Isrc/ -Itest/ -L./ $(OPT_FLAG)
|
2017-07-21 02:47:45 +02:00
|
|
|
TEST_CPP = $(shell find test/ -name '*.cpp')
|
|
|
|
TEST_ALL = $(shell find test/ -name '*.cpp') $(shell find test/ -name '*.h')
|
|
|
|
EXAMPLE_SRC = $(shell find example/ -name '*.cpp') $(shell find example/ -name '*.h')
|
2015-12-23 16:14:39 +01:00
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
test: $(TEST_BUILD)
|
2016-02-27 15:48:20 +01:00
|
|
|
bash test/test.sh
|
2015-12-23 16:14:39 +01:00
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
$(TEST_BUILD): $(TEST_ALL) $(LIB_BUILD)
|
|
|
|
@mkdir -p $(BIN)/
|
|
|
|
$(CXX) $(TEST_CFLAGS) $(TEST_CPP) -o $(TEST_BUILD) -lsqlparser -lstdc++
|
|
|
|
|
2017-05-27 00:18:52 +02:00
|
|
|
test_example:
|
|
|
|
$(GMAKE) -C example/
|
|
|
|
LD_LIBRARY_PATH=./ \
|
|
|
|
./example/example "SELECT * FROM students WHERE name = 'Max Mustermann';"
|
|
|
|
|
|
|
|
test_format:
|
2017-07-21 02:47:45 +02:00
|
|
|
@! astyle --options=astyle.options $(LIB_ALL) | grep -q "Formatted"
|
|
|
|
@! astyle --options=astyle.options $(TEST_ALL) | grep -q "Formatted"
|
2016-02-27 16:40:24 +01:00
|
|
|
|
2017-05-27 00:18:52 +02:00
|
|
|
|
|
|
|
|
2017-07-21 02:47:45 +02:00
|
|
|
########################################
|
|
|
|
################# Misc #################
|
|
|
|
########################################
|
2017-05-27 00:18:52 +02:00
|
|
|
|
|
|
|
format:
|
2017-07-21 02:47:45 +02:00
|
|
|
astyle --options=astyle.options $(LIB_ALL)
|
|
|
|
astyle --options=astyle.options $(TEST_ALL)
|
|
|
|
astyle --options=astyle.options $(EXAMPLE_SRC)
|
2017-05-27 00:18:52 +02:00
|
|
|
|
2017-05-29 16:22:13 +02:00
|
|
|
log_mode:
|
|
|
|
@echo $(MODE_LOG)
|
2017-07-21 02:47:45 +02:00
|
|
|
|