forked from plv8/plv8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
122 lines (88 loc) · 3.19 KB
/
Makefile
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
PLV8_VERSION = 3.2.3
CP := cp
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
SHLIB_LINK += -std=c++17
PG_CPPFLAGS := -fPIC -Wall -Wno-register -xc++
PG_LDFLAGS := -std=c++17
SRCS = plv8.cc plv8_type.cc plv8_func.cc plv8_param.cc plv8_allocator.cc plv8_guc.cc
OBJS = $(SRCS:.cc=.o)
MODULE_big = plv8-$(PLV8_VERSION)
EXTENSION = plv8
PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql
ifeq ($(OS),Windows_NT)
# noop for now
else
SHLIB_LINK += -Ldeps/v8-cmake/build
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
CCFLAGS += -stdlib=libc++
SHLIB_LINK += -stdlib=libc++ -std=c++17 -lc++
NUMPROC := $(shell sysctl hw.ncpu | awk '{print $$2}')
endif
ifeq ($(UNAME_S),Linux)
SHLIB_LINK += -lrt -std=c++17
NUMPROC := $(shell grep -c ^processor /proc/cpuinfo)
endif
endif
ifeq ($(NUMPROC),0)
NUMPROC = 1
endif
SHLIB_LINK += -Ldeps/v8-cmake/build
all: v8 $(OBJS)
# For some reason, this solves parallel make dependency.
plv8_config.h plv8.so: v8
deps/v8-cmake/README.md:
@git submodule update --init --recursive
deps/v8-cmake/build/libv8_libbase.a: deps/v8-cmake/README.md
@cd deps/v8-cmake && mkdir -p build && cd build && cmake -Denable-fPIC=ON -DCMAKE_BUILD_TYPE=Release ../ && make -j $(NUMPROC)
v8: deps/v8-cmake/build/libv8_libbase.a
# enable direct jsonb conversion by default
CCFLAGS += -DJSONB_DIRECT_CONVERSION
CCFLAGS += -Ideps/v8-cmake/v8/include -std=c++17
ifdef EXECUTION_TIMEOUT
CCFLAGS += -DEXECUTION_TIMEOUT
endif
ifdef BIGINT_GRACEFUL
CCFLAGS += -DBIGINT_GRACEFUL
endif
DATA = $(PLV8_DATA)
DATA_built = plv8.sql
REGRESS = init-extension plv8 plv8-errors scalar_args inline json startup_pre startup varparam json_conv \
jsonb_conv window guc es6 arraybuffer composites currentresource startup_perms bytea find_function_perms \
memory_limits reset show array_spread regression procedure
ifndef BIGINT_GRACEFUL
REGRESS += bigint
else
REGRESS += bigint_graceful
endif
SHLIB_LINK += -lv8_base_without_compiler -lv8_compiler -lv8_snapshot -lv8_inspector -lv8_libplatform -lv8_base_without_compiler -lv8_libsampler -lv8_torque_generated -lv8_libbase
OPTFLAGS = -std=c++17 -fno-rtti -O2
CCFLAGS += -Wall $(OPTFLAGS)
generate_upgrades:
@mkdir -p upgrade
@./generate_upgrade.sh $(PLV8_VERSION)
$(eval PLV8_DATA += $(wildcard upgrade/*.sql))
all: generate_upgrades
plv8_config.h: plv8_config.h.in Makefile
sed -e 's/^#undef PLV8_VERSION/#define PLV8_VERSION "$(PLV8_VERSION)"/' $< > $@
%.o : %.cc plv8_config.h plv8.h
$(CXX) $(CCFLAGS) $(CPPFLAGS) -fPIC -c -o $@ $<
COMPILE.cxx.bc = $(CLANG) -xc++ -Wno-ignored-attributes $(BITCODE_CXXFLAGS) $(CCFLAGS) $(CPPFLAGS) -emit-llvm -c
%.bc : %.cc
$(COMPILE.cxx.bc) $(CCFLAGS) $(CPPFLAGS) -fPIC -c -o $@ $<
$(LLVM_BINPATH)/opt -module-summary -f $@ -o $@
DATA_built =
all: $(DATA)
%--$(PLV8_VERSION).sql: plv8.sql.common
sed -e 's/@LANG_NAME@/$*/g' $< | sed -e 's/@PLV8_VERSION@/$(PLV8_VERSION)/g' | $(CC) -E -P $(CPPFLAGS) -DLANG_$* - > $@
%.control: plv8.control.common
sed -e 's/@PLV8_VERSION@/$(PLV8_VERSION)/g' $< | $(CXX) -E -P -DLANG_$* - > $@
subclean:
rm -f plv8_config.h $(DATA)
clean: subclean
distclean: clean
@cd deps/v8-cmake/build && make clean
.PHONY: subclean all clean installcheck
include $(PGXS)
CC=$(CXX)