2015-12-23 16:01:08 +01:00
|
|
|
# directories
|
|
|
|
BIN = bin
|
|
|
|
SRC = src
|
|
|
|
SRCPARSER = src/parser
|
2014-12-15 18:32:46 +01:00
|
|
|
|
2015-12-23 16:01:08 +01:00
|
|
|
# files
|
|
|
|
PARSERFILES = $(SRCPARSER)/bison_parser.cpp $(SRCPARSER)/flex_lexer.cpp
|
2016-01-16 12:36:45 +01:00
|
|
|
LIBCPP = $(shell find $(SRC) -name '*.cpp' -not -path "$(SRCPARSER)/*") $(SRCPARSER)/bison_parser.cpp $(SRCPARSER)/flex_lexer.cpp
|
2015-12-23 16:01:08 +01:00
|
|
|
LIBOBJ = $(LIBCPP:%.cpp=%.o)
|
2015-12-23 16:14:39 +01:00
|
|
|
TESTCPP = $(shell find test/lib/ -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)/*")
|
|
|
|
ALLTEST = $(shell find test/lib/ -name '*.cpp') $(shell find test/lib/ -name '*.h')
|
|
|
|
|
2015-12-23 16:01:08 +01:00
|
|
|
# compile & link flages
|
|
|
|
CC = g++
|
|
|
|
CFLAGS = -std=c++11 -Wall -fPIC
|
|
|
|
LIBFLAGS = -shared
|
|
|
|
TARGET = libsqlparser.so
|
2016-01-16 12:36:45 +01:00
|
|
|
INSTALL = /usr/local
|
2014-12-15 18:32:46 +01:00
|
|
|
|
2015-12-23 16:14:39 +01:00
|
|
|
CTESTFLAGS = -Wall -Isrc/ -Itest/ -L./ -std=c++11
|
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)
|
2015-12-23 16:01:08 +01:00
|
|
|
$(CC) $(LIBFLAGS) -o $(TARGET) $(LIBOBJ)
|
2014-12-15 18:32:46 +01:00
|
|
|
|
|
|
|
|
2015-12-23 16:01:08 +01:00
|
|
|
%.o: %.cpp $(PARSERFILES)
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
$(SRCPARSER)/bison_parser.cpp: parser
|
|
|
|
$(SRCPARSER)/flex_lexer.cpp: parser
|
|
|
|
|
|
|
|
parser:
|
|
|
|
make -C $(SRCPARSER)/
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
cleanparser:
|
|
|
|
make -C $(SRCPARSER)/ clean
|
|
|
|
|
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)
|
|
|
|
|
2016-02-27 15:01:06 +01:00
|
|
|
format:
|
|
|
|
astyle --options=astyle.options $(ALLLIB)
|
|
|
|
astyle --options=astyle.options $(ALLTEST)
|
|
|
|
|
2015-12-23 16:14:39 +01:00
|
|
|
############
|
|
|
|
### Test ###
|
|
|
|
############
|
|
|
|
|
|
|
|
test: $(BIN)/sql_tests $(BIN)/sql_grammar_test
|
2016-02-27 15:22:22 +01:00
|
|
|
@LD_LIBRARY_PATH=./ $(BIN)/sql_grammar_test -f "test/lib/valid_queries.sql"
|
|
|
|
@LD_LIBRARY_PATH=./ $(BIN)/sql_tests
|
2015-12-23 16:14:39 +01:00
|
|
|
|
|
|
|
$(BIN)/sql_tests: library
|
|
|
|
@mkdir -p $(BIN)/
|
|
|
|
$(CC) $(CTESTFLAGS) $(TESTCPP) test/sql_tests.cpp -o $(BIN)/sql_tests -lsqlparser
|
|
|
|
|
|
|
|
$(BIN)/sql_grammar_test: library
|
|
|
|
@mkdir -p $(BIN)/
|
|
|
|
$(CC) $(CTESTFLAGS) test/sql_grammar_test.cpp -o $(BIN)/sql_grammar_test -lsqlparser
|