Compile safestringlib using regular configure

This is needed to automatically generate .bc (bitcode) files when
postgres is compiled with llvmjit support.

It also has the advantage that cmake is not required for the build
anymore.
pull/3626/head
Jelte Fennema 2020-03-18 17:58:02 +01:00
parent 6ff79c5ea9
commit 6db7d87618
2 changed files with 6 additions and 20 deletions

View File

@ -7,13 +7,6 @@ safestringlib_builddir = $(citus_top_builddir)/vendor/safestringlib/build
safestringlib_a = $(safestringlib_builddir)/libsafestring_static.a safestringlib_a = $(safestringlib_builddir)/libsafestring_static.a
safestringlib_sources = $(wildcard $(safestringlib_srcdir)/safeclib/*) safestringlib_sources = $(wildcard $(safestringlib_srcdir)/safeclib/*)
# Use cmake3 if it exists, otherwise just use the string "cmake" and let bash
# figure out its exact path later.
# Using "which cmake" instead will make the error very hard to understand if
# you have neither "cmake3" or "cmake" in path. In that case the "CMAKE3"
# variable would be an empty string.
CMAKE3 = $(shell which cmake3 || echo cmake)
MODULE_big = citus MODULE_big = citus
EXTENSION = citus EXTENSION = citus
@ -23,7 +16,11 @@ generated_sql_files = $(patsubst %,$(citus_abs_srcdir)/build/%,$(template_sql_fi
DATA_built = $(generated_sql_files) DATA_built = $(generated_sql_files)
# directories with source files # directories with source files
SUBDIRS = . commands connection ddl deparser executor master metadata planner progress relay test transaction utils worker SUBDIRS = . commands connection ddl deparser executor master metadata planner progress relay safeclib test transaction utils worker
# Symlinks are not copied over to the build directory if a separete build
# directory is used during configure (such as on CI)
ENSURE_SUBDIRS_EXIST := $(shell mkdir -p $(SUBDIRS))
# That patsubst rule searches all directories listed in SUBDIRS for .c # That patsubst rule searches all directories listed in SUBDIRS for .c
# files, and adds the corresponding .o files to OBJS # files, and adds the corresponding .o files to OBJS
@ -50,23 +47,11 @@ utils/citus_version.o: $(CITUS_VERSION_INVALIDATE)
SHLIB_LINK += $(filter -lssl -lcrypto -lssleay32 -leay32, $(LIBS)) SHLIB_LINK += $(filter -lssl -lcrypto -lssleay32 -leay32, $(LIBS))
override LDFLAGS += $(safestringlib_a)
override CPPFLAGS += -I$(libpq_srcdir) -I$(safestringlib_srcdir)/include override CPPFLAGS += -I$(libpq_srcdir) -I$(safestringlib_srcdir)/include
SQL_DEPDIR=.deps/sql SQL_DEPDIR=.deps/sql
SQL_BUILDDIR=build/sql SQL_BUILDDIR=build/sql
$(safestringlib_a): $(safestringlib_sources)
rm -rf $(safestringlib_builddir)
mkdir -p $(safestringlib_builddir)
@# exports of LDFLAGS and CPPFLAGS are to make sure the ones from this
@# Makefile are not used
+cd $(safestringlib_builddir) && \
export LDFLAGS='' && export CPPFLAGS='' && \
$(CMAKE3) $(safestringlib_srcdir) && make
citus.so: $(safestringlib_a)
$(generated_sql_files): $(citus_abs_srcdir)/build/%: % $(generated_sql_files): $(citus_abs_srcdir)/build/%: %
@mkdir -p $(citus_abs_srcdir)/$(SQL_DEPDIR) $(citus_abs_srcdir)/$(SQL_BUILDDIR) @mkdir -p $(citus_abs_srcdir)/$(SQL_DEPDIR) $(citus_abs_srcdir)/$(SQL_BUILDDIR)
cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@ cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@

View File

@ -0,0 +1 @@
../../../vendor/safestringlib/safeclib/