You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
proxysql/plugins/mysqlx/Makefile

102 lines
3.8 KiB

#!/bin/make -f
# Walk upward until we find the repo root (src/proxysql_global.cpp). A hop
# counter stops the climb at / on a sparse checkout that omits the marker
# file -- otherwise we'd loop forever. Fails fast with a clear message so
# build output doesn't look like it's hanging.
PROXYSQL_PATH := $(shell set -e; d="$$PWD"; for _ in 1 2 3 4 5 6 7 8 9 10 11 12; do if [ -f "$$d/src/proxysql_global.cpp" ]; then echo "$$d"; exit 0; fi; if [ "$$d" = "/" ]; then break; fi; d="$$(dirname "$$d")"; done; echo "ERROR: plugins/mysqlx/Makefile: could not find src/proxysql_global.cpp (repo root) from $$PWD; sparse checkout missing include/ and src/proxysql_global.cpp?" >&2; exit 1)
ifneq (,$(findstring ERROR,$(PROXYSQL_PATH)))
$(error $(PROXYSQL_PATH))
endif
include $(PROXYSQL_PATH)/include/makefiles_vars.mk
include $(PROXYSQL_PATH)/include/makefiles_paths.mk
PLUGIN_DIR := $(PROXYSQL_PATH)/plugins/mysqlx
ODIR := $(PLUGIN_DIR)/obj
PLUGIN_SO := $(PLUGIN_DIR)/ProxySQL_MySQLX_Plugin.so
# Protobuf generated sources.
# Generated from test/deps/mysql-connector-c-8.4.0/.../plugin/x/protocol/protobuf/*.proto
# using protoc 3.21.12. To regenerate:
# PROTO_SRC=test/deps/mysql-connector-c-8.4.0/mysql-8.4.0/plugin/x/protocol/protobuf
# protoc --proto_path=$PROTO_SRC --cpp_out=plugins/mysqlx/proto \
# mysqlx.proto mysqlx_connection.proto mysqlx_session.proto \
# mysqlx_datatypes.proto mysqlx_notice.proto mysqlx_sql.proto \
# mysqlx_resultset.proto mysqlx_expect.proto
PROTO_DIR := $(PLUGIN_DIR)/proto
PROTO_SRCS := $(wildcard $(PROTO_DIR)/*.pb.cc)
PROTO_OBJS := $(patsubst $(PROTO_DIR)/%.pb.cc,$(ODIR)/%.pb.o,$(PROTO_SRCS))
IDIRS := -I$(PROXYSQL_IDIR) -I$(PLUGIN_DIR)/include -I$(SQLITE3_IDIR) -I$(PROTO_DIR) -I$(SSL_IDIR) -I$(PROMETHEUS_IDIR) -I$(LIBCONFIG_IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) -I$(RE2_IDIR)
OPTZ ?= -O2 -ggdb
# Propagate feature-tier flags from the top-level build. These MUST match
# the flags libproxysql.a was built with; a mismatch silently changes the
# ProxySQL_PluginDescriptor / ProxySQL_PluginServices layout the core and
# the plugin each see, and the loader then reads past the end of the
# plugin's static descriptor. (If this Makefile is run standalone, the
# caller is expected to export PROXYSQL40/31/etc. to match the lib.)
PSQL40 :=
ifeq ($(PROXYSQL40),1)
PSQL40 := -DPROXYSQL40
endif
PSQL31 :=
ifeq ($(PROXYSQL31),1)
PSQL31 := -DPROXYSQL31
endif
PSQLFFTO :=
ifeq ($(PROXYSQLFFTO),1)
PSQLFFTO := -DPROXYSQLFFTO
endif
PSQLTSDB :=
ifeq ($(PROXYSQLTSDB),1)
PSQLTSDB := -DPROXYSQLTSDB
endif
PSQLGA :=
ifeq ($(PROXYSQLGENAI),1)
PSQLGA := -DPROXYSQLGENAI
endif
CXXFLAGS := $(STDCPP) -fPIC $(OPTZ) $(WGCOV) $(WASAN) -pthread \
$(PSQL40) $(PSQL31) $(PSQLFFTO) $(PSQLTSDB) $(PSQLGA)
.DEFAULT_GOAL := all
SRCS := $(PLUGIN_DIR)/src/mysqlx_plugin.cpp \
$(PLUGIN_DIR)/src/mysqlx_admin_schema.cpp \
$(PLUGIN_DIR)/src/mysqlx_config_store.cpp \
$(PLUGIN_DIR)/src/mysqlx_worker.cpp \
$(PLUGIN_DIR)/src/mysqlx_protocol.cpp \
$(PLUGIN_DIR)/src/mysqlx_frontend_session.cpp \
$(PLUGIN_DIR)/src/mysqlx_backend_session.cpp \
$(PLUGIN_DIR)/src/mysqlx_data_stream.cpp \
$(PLUGIN_DIR)/src/mysqlx_connection.cpp \
$(PLUGIN_DIR)/src/mysqlx_stats.cpp \
$(PLUGIN_DIR)/src/mysqlx_session.cpp \
$(PLUGIN_DIR)/src/mysqlx_thread.cpp
HEADERS := $(wildcard $(PLUGIN_DIR)/include/*.h) \
$(PROXYSQL_PATH)/include/ProxySQL_Plugin.h
OBJS := $(patsubst $(PLUGIN_DIR)/src/%.cpp,$(ODIR)/%.o,$(SRCS))
$(ODIR):
mkdir -p $(ODIR)
$(ODIR)/%.o: $(PLUGIN_DIR)/src/%.cpp $(HEADERS) | $(ODIR)
$(CXX) -c -o $@ $< $(CXXFLAGS) $(IDIRS)
$(ODIR)/%.pb.o: $(PROTO_DIR)/%.pb.cc | $(ODIR)
$(CXX) -c -o $@ $< $(CXXFLAGS) -I$(PROTO_DIR) -w
$(PLUGIN_SO): $(OBJS) $(PROTO_OBJS)
$(CXX) -shared -o $@ $^ $(CXXFLAGS) -pthread -lprotobuf -lssl -lcrypto
.PHONY: all
all: $(PLUGIN_SO)
.PHONY: clean
clean:
rm -rf $(ODIR) $(PLUGIN_SO)