-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (71 loc) · 2.49 KB
/
Makefile
File metadata and controls
99 lines (71 loc) · 2.49 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
CC=gcc
CFLAGS=-std=c99 -Wall -Wextra -pedantic -fPIC
CXX=g++
CXXFLAGS=-std=c++11 -Wall -Wextra -pedantic -fPIC
LDFLAGS=-shared
# Using O2 flag for C++ was forced by fatal errors in function
# VString::copy(const char*) when O3 was used. That behavior occured in
# Vertica 8.1.1-0 and a couple of earlier versions. As a workaround the
# O2 optimization level is used.
ifdef DEBUG
CFLAGS+=-g
CXXFLAGS+=-g
endif
ifndef DEBUG
CFLAGS+=-O3
CXXFLAGS+=-O2
endif
VSQL?=vsql
MEMTEST?=valgrind --error-exitcode=1 --tool=memcheck --leak-check=full
SDK?=/opt/vertica/sdk
VERTICA_SDK_INCLUDE=$(SDK)/include
INCLUDE=include/
.PHONY: build install grant_permissions uninstall test memtest examples clean
# Auxiliary tasks.
build: lib/JsonLib.so
test: build/test/json_selector build/test/json_slice
./build/test/json_selector
./build/test/json_slice
memtest: build/test/json_selector build/test/json_slice
$(MEMTEST) ./build/test/json_selector
$(MEMTEST) ./build/test/json_slice
examples:
$(VSQL) -f examples/simple.sql
$(VSQL) -f examples/dots.sql
$(VSQL) -f examples/table.sql
$(VSQL) -f examples/strings.sql
$(VSQL) -f examples/unnest.sql
install: ddl/install.sql lib/JsonLib.so
$(VSQL) -f $<
grant_permissions: ddl/grant_permissions.sql
$(VSQL) -f $<
uninstall: ddl/uninstall.sql
$(VSQL) -f $<
clean:
rm -rf build/ lib/
# Build the library.
lib/JsonLib.so: build/Vertica.o build/JsonQuery.o build/JsonUnnest.o build/json/selector.o build/json/slice.o
mkdir -p `dirname $@`
$(CXX) $(LDFLAGS) -o $@ $^
build/Vertica.o: $(VERTICA_SDK_INCLUDE)/Vertica.cpp
mkdir -p `dirname $@`
$(CXX) -I $(VERTICA_SDK_INCLUDE) $(CXXFLAGS) -c -o $@ $<
build/JsonQuery.o: src/JsonQuery.cpp include/json/slice.h include/json/selector.h
mkdir -p `dirname $@`
$(CXX) -I $(VERTICA_SDK_INCLUDE) -I $(INCLUDE) $(CXXFLAGS) -c -o $@ $<
build/JsonUnnest.o: src/JsonUnnest.cpp include/json/slice.h
mkdir -p `dirname $@`
$(CXX) -I $(VERTICA_SDK_INCLUDE) -I $(INCLUDE) $(CXXFLAGS) -c -o $@ $<
build/json/selector.o: src/json/selector.c include/json/selector.h
mkdir -p `dirname $@`
$(CC) -I $(INCLUDE) $(CFLAGS) -c -o $@ $<
build/json/slice.o: src/json/slice.c include/json/slice.h
mkdir -p `dirname $@`
$(CC) -I $(INCLUDE) $(CFLAGS) -c -o $@ $<
# Build test runners.
build/test/json_selector: test/json_selector.c build/json/selector.o
mkdir -p `dirname $@`
$(CC) -I $(INCLUDE) $(CFLAGS) -o $@ $^
build/test/json_slice: test/json_slice.c build/json/selector.o build/json/slice.o
mkdir -p `dirname $@`
$(CC) -I $(INCLUDE) $(CFLAGS) -o $@ $^