2017-05-27 00:18:52 +02:00
|
|
|
# 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-05-27 00:18:52 +02:00
|
|
|
# Files.
|
2017-04-21 16:15:07 +02:00
|
|
|
PARSERCPP = $(SRCPARSER)/bison_parser.cpp $(SRCPARSER)/flex_lexer.cpp
|
|
|
|
LIBCPP = $(shell find $(SRC) -name '*.cpp' -not -path "$(SRCPARSER)/*") $(PARSERCPP)
|
2015-12-23 16:01:08 +01:00
|
|
|
LIBOBJ = $(LIBCPP:%.cpp=%.o)
|
2017-02-10 21:41:34 +01:00
|
|
|
TESTCPP = $(shell find test/ -name '*.cpp')
|
2015-08-28 13:46:07 +02:00
|
|
|
|
2016-02-27 15:01:06 +01:00
|
|
|
ALLLIB = $(shell find $(SRC) -name '*.cpp' -not -path "$(SRCPARSER)/*") $(shell find $(SRC) -name '*.h' -not -path "$(SRCPARSER)/*")
|
2017-03-07 02:01:00 +01:00
|
|
|
ALLTEST = $(shell find test/ -name '*.cpp') $(shell find test/ -name '*.h')
|
2017-05-27 00:18:52 +02:00
|
|
|
EXAMPLESRC = $(shell find example/ -name '*.cpp') $(shell find example/ -name '*.h')
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-05-27 00:18:52 +02:00
|
|
|
# Compiler & linker flags.
|
2017-06-14 20:17:22 +02:00
|
|
|
CFLAGS = -std=c++11 -Wall -Werror -fPIC
|
2015-12-23 16:01:08 +01:00
|
|
|
LIBFLAGS = -shared
|
|
|
|
TARGET = libsqlparser.so
|
2016-01-16 12:36:45 +01:00
|
|
|
INSTALL = /usr/local
|
2014-12-15 18:32:46 +01:00
|
|
|
|
2017-06-14 20:17:22 +02:00
|
|
|
CTESTFLAGS = -Wall -Werror -Isrc/ -Itest/ -L./ -std=c++11 -lstdc++
|
2017-05-27 00:18:52 +02:00
|
|
|
|
|
|
|
# Set compile mode to -g or -O3.
|
2017-05-29 16:22:13 +02:00
|
|
|
MODE_LOG = ""
|
2017-05-27 00:18:52 +02:00
|
|
|
mode ?= release
|
|
|
|
ifeq ($(mode), debug)
|
|
|
|
CFLAGS += -g
|
2017-05-29 16:22:13 +02:00
|
|
|
CTESTFLAGS += -g
|
|
|
|
MODE_LOG = "Building in \033[1;31mdebug\033[0m mode"
|
2017-05-27 00:18:52 +02:00
|
|
|
else
|
|
|
|
CFLAGS += -O3
|
2017-05-29 16:22:13 +02:00
|
|
|
CTESTFLAGS += -O3
|
|
|
|
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-12-23 16:01:08 +01:00
|
|
|
all: library
|
2015-08-28 13:46:07 +02:00
|
|
|
|
2015-12-23 16:14:39 +01:00
|
|
|
library: $(TARGET)
|
2015-08-28 13:46:07 +02:00
|
|
|
|
2015-12-23 16:14:39 +01:00
|
|
|
$(TARGET): $(LIBOBJ)
|
2016-02-27 17:44:42 +01:00
|
|
|
$(CXX) $(LIBFLAGS) -o $(TARGET) $(LIBOBJ)
|
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-04-21 16:15:07 +02:00
|
|
|
$(CXX) $(CFLAGS) -c -o $@ $< -Wno-sign-compare -Wno-unneeded-internal-declaration -Wno-deprecated-register
|
|
|
|
|
|
|
|
%.o: %.cpp $(PARSERCPP)
|
2016-02-27 17:44:42 +01:00
|
|
|
$(CXX) $(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
|
|
|
|
|
|
|
clean:
|
2015-12-23 16:14:39 +01:00
|
|
|
rm -f $(TARGET)
|
|
|
|
rm -rf $(BIN)
|
2015-12-23 16:01:08 +01:00
|
|
|
find $(SRC) -type f -name '*.o' -delete
|
2017-05-27 00:18:52 +02:00
|
|
|
$(GMAKE) -C benchmark/ clean
|
2015-12-23 16:01:08 +01:00
|
|
|
|
|
|
|
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:
|
|
|
|
cp $(TARGET) $(INSTALL)/lib/$(TARGET)
|
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
|
|
|
#################
|
|
|
|
### Benchmark ###
|
|
|
|
#################
|
|
|
|
|
|
|
|
benchmark: library
|
|
|
|
$(GMAKE) -C benchmark/ clean run
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-05-27 00:18:52 +02:00
|
|
|
build_benchmark: library
|
|
|
|
$(GMAKE) -C benchmark/ parser_benchmark
|
2017-03-06 18:30:35 +01:00
|
|
|
|
2015-12-23 16:14:39 +01:00
|
|
|
############
|
|
|
|
### Test ###
|
|
|
|
############
|
|
|
|
|
2017-02-10 21:41:34 +01:00
|
|
|
test: $(BIN)/sql_tests
|
2016-02-27 15:48:20 +01:00
|
|
|
bash test/test.sh
|
2015-12-23 16:14:39 +01:00
|
|
|
|
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:
|
|
|
|
@! astyle --options=astyle.options $(ALLLIB) | grep -q "Formatted"
|
|
|
|
@! astyle --options=astyle.options $(ALLTEST) | grep -q "Formatted"
|
2016-02-27 16:40:24 +01:00
|
|
|
|
2015-12-23 16:14:39 +01:00
|
|
|
$(BIN)/sql_tests: library
|
|
|
|
@mkdir -p $(BIN)/
|
2017-02-10 21:41:34 +01:00
|
|
|
$(CXX) $(CTESTFLAGS) $(TESTCPP) -o $(BIN)/sql_tests -lsqlparser
|
2017-05-27 00:18:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
############
|
|
|
|
### Misc ###
|
|
|
|
############
|
|
|
|
|
|
|
|
format:
|
|
|
|
astyle --options=astyle.options $(ALLLIB)
|
|
|
|
astyle --options=astyle.options $(ALLTEST)
|
|
|
|
astyle --options=astyle.options $(EXAMPLESRC)
|
|
|
|
|
2017-05-29 16:22:13 +02:00
|
|
|
log_mode:
|
|
|
|
@echo $(MODE_LOG)
|