Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ deps/sqlite3/sqlite-amalgamation-*/
deps/coredumper/coredumper-*/
deps/postgresql/postgresql-*/
deps/libusual/libusual-*/
deps/json/json-*/
deps/abseil/abseil-cpp-*/
deps/protobuf/protobuf-*/
deps/opentelemetry/opentelemetry-cpp-*/
deps/opentelemetry/opentelemetry-proto-*/

test/.vagrant
.DS_Store
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ ifneq (,$(findstring $(OS),Darwin FreeBSD))
LEGACY_BUILD := 1
export CC=gcc
export CXX=g++
export AR=ar
endif
export MAKEOPT := -j${NPROCS}

Expand Down Expand Up @@ -155,7 +156,7 @@ build_src_debug: $(if $(LEGACY_BUILD),build_src_debug_legacy,build_src_debug_def
# legacy build targets (pre c++17)
.PHONY: build_deps_legacy
build_deps_legacy:
cd deps && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE}
cd deps && CC=${CC} CXX=${CXX} ${MAKE}

.PHONY: build_lib_legacy
build_lib_legacy: build_deps_legacy
Expand All @@ -167,7 +168,7 @@ build_src_legacy: build_lib_legacy

.PHONY: build_deps_debug_legacy
build_deps_debug_legacy:
cd deps && OPTZ="${O0} -ggdb -DDEBUG" PROXYDEBUG=1 CC=${CC} CXX=${CXX} ${MAKE}
cd deps && PROXYDEBUG=1 CC=${CC} CXX=${CXX} ${MAKE}

.PHONY: build_lib_debug_legacy
build_lib_debug_legacy: build_deps_debug_legacy
Expand Down Expand Up @@ -269,11 +270,11 @@ build_src_debug_clickhouse: build_src_debug_default

.PHONY: build_deps_default
build_deps_default:
cd deps && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE}
cd deps && PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE}

PHONY: build_deps_debug_default
build_deps_debug_default:
cd deps && OPTZ="${O0} -ggdb -DDEBUG" PROXYSQLCLICKHOUSE=1 PROXYDEBUG=1 CC=${CC} CXX=${CXX} ${MAKE}
cd deps && PROXYSQLCLICKHOUSE=1 PROXYDEBUG=1 CC=${CC} CXX=${CXX} ${MAKE}

.PHONY: build_lib_default
build_lib_default: build_deps_default
Expand Down
11 changes: 4 additions & 7 deletions common_mk/openssl_flags.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@ ifeq ($(CUSTOM_OPENSSL_PATH),)
$(info No custom path specified.)
ifeq ($(OPENSSL_PACKAGE),openssl3)
SSL_IDIR := $(shell pkg-config --cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+")
SSL_LDIR := $(shell pkg-config --variable=libdir $(OPENSSL_PACKAGE))
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so.3" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so.3" 2>/dev/null | head -n 1)
SSL_LDIR := $(shell pkg-config --libs $(OPENSSL_PACKAGE) | grep -oP "(?<=-L)[^ ]+")
else
SSL_IDIR := $(shell export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1; export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1; pkg-config --cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+")
SSL_LDIR := $(shell pkg-config --variable=libdir $(OPENSSL_PACKAGE))
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so" 2>/dev/null | head -n 1)
endif
else
SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include
SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so" 2>/dev/null | head -n 1)
$(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH))
endif

LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so" 2>/dev/null | head -n 1)

# Check if required flags are set and provide feedback
ifneq ($(SSL_IDIR),)
ifneq ($(SSL_LDIR),)
Expand Down
159 changes: 139 additions & 20 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ endif
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)

DISTRO := $(shell grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"')
DISTRO := $(shell grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d' ' -f1 | cut -d- -f1)
DISTVERS := $(shell grep '^VERSION=' /etc/os-release | cut -d= -f2 | tr -d '"' | cut -d' ' -f1 | cut -d. -f1)

CENTOSVER := Unknown
ifneq (,$(wildcard /etc/system-release))
Expand All @@ -22,12 +23,17 @@ IS_CENTOS := $(if $(findstring Unknown, $(CENTOSVER)),false,true)
# to compile libmariadb_client with support for valgrind enabled, run:
# export USEVALGRIND=1

# force CMake to always use lib, instead of lib64
CMAKE_FLAGS := -DCMAKE_INSTALL_LIBDIR=lib

ifeq ($(PROXYDEBUG),1)
MYCFLAGS := -O0
MYCFLAGS := -O0 -ggdb
MYJEOPT := --enable-xmalloc --enable-prof --enable-fill --enable-debug
CMAKE_FLAGS += -DCMAKE_BUILD_TYPE=Debug
else
MYCFLAGS := -O2
MYCFLAGS := -O2 -g
MYJEOPT := --enable-xmalloc --enable-prof
CMAKE_FLAGS += -DCMAKE_BUILD_TYPE=RelWithDebInfo
endif
ifeq ($(and $(IS_ARM),$(IS_CENTOS)),true)
MYJEOPT += --with-lg-page=16
Expand All @@ -36,16 +42,50 @@ endif

### detect compiler support for c++11/17
CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | egrep -o '[0-9]{6}L')
ifneq ($(CPLUSPLUS),201703L)
ifeq ($(CPLUSPLUS),201703L)
CMAKE_FLAGS += -DCMAKE_CXX_STANDARD=17
else
CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | egrep -o '[0-9]{6}L')
ifneq ($(CPLUSPLUS),201103L)
$(error Compiler must support at least c++11)
endif
ifeq ($(CPLUSPLUS),201103L)
CMAKE_FLAGS += -DCMAKE_CXX_STANDARD=11
else
$(error Compiler must support at least c++11)
endif
endif

STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4)

JSON_INSTALL_DIR := $(abspath json/json)
CURL_INSTALL_DIR := $(abspath curl/curl/local)
ABSL_INSTALL_DIR := $(abspath abseil/abseil-cpp/local)
PROTOBUF_INSTALL_DIR := $(abspath protobuf/protobuf/local)
OTEL_INSTALL_DIR := $(abspath opentelemetry/opentelemetry-cpp/local)
OTEL_PROTO_DIR := $(abspath opentelemetry/opentelemetry-proto)

targets := check_openssl_version \
libconfig \
libdaemon \
jemalloc \
mariadb_client \
re2 \
sqlite3 \
pcre \
lz4 \
cityhash \
microhttpd \
curl \
ev \
libhttpserver \
libinjection \
prometheus-cpp \
postgresql \
libusual \
libscram \
json \
abseil \
protobuf \
otel

targets := check_openssl_version libconfig libdaemon jemalloc mariadb_client re2 sqlite3 pcre lz4 cityhash microhttpd curl ev libhttpserver libinjection prometheus-cpp postgresql libusual libscram
ifeq ($(UNAME_S),Linux)
targets += coredumper
endif
Expand Down Expand Up @@ -76,9 +116,11 @@ endif

libinjection: libinjection/libinjection/src/libinjection.a


include ../common_mk/openssl_flags.mk
include ../common_mk/openssl_version_check.mk


libhttpserver/libhttpserver/build/src/.libs/libhttpserver.a: libmicrohttpd/libmicrohttpd/src/microhttpd/.libs/libmicrohttpd.a re2/re2/obj/libre2.a
cd libhttpserver && rm -rf libhttpserver-*/ || true
cd libhttpserver && tar -zxf libhttpserver-*.tar.gz
Expand Down Expand Up @@ -112,22 +154,24 @@ coredumper/coredumper/src/libcoredumper.a:
cd coredumper && rm -rf coredumper-*/ || true
cd coredumper && tar -zxf coredumper-*.tar.gz
cd coredumper/coredumper && patch -p1 < ../includes.patch
cd coredumper/coredumper && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug
cd coredumper/coredumper && cmake . $(CMAKE_FLAGS) -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF
cd coredumper/coredumper && CC=${CC} CXX=${CXX} ${MAKE}

coredumper: coredumper/coredumper/src/libcoredumper.a

curl/curl/lib/.libs/libcurl.a:

$(CURL_INSTALL_DIR)/lib/libcurl.a:
cd curl && rm -rf curl-*/ || true
cd curl && tar -zxf curl-*.tar.gz
# cd curl/curl && ./configure --disable-debug --disable-ftp --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual --disable-ipv6 --disable-sspi --disable-crypto-auth --disable-ntlm-wb --disable-tls-srp --without-nghttp2 --without-libidn2 --without-libssh2 --without-brotli --with-ssl=$(shell pwd)/../../libssl/openssl/ && CC=${CC} CXX=${CXX} ${MAKE}
cd curl/curl && autoreconf -fi
ifeq ($(UNAME_S),Darwin)
cd curl/curl && patch configure < ../configure.patch
endif
cd curl/curl && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="$(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)" ./configure --disable-debug --disable-ftp --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual --disable-ipv6 --disable-sspi --disable-ntlm-wb --disable-tls-srp --without-nghttp2 --without-libidn2 --without-libssh2 --without-brotli --without-librtmp --without-libpsl --without-zstd --with-ssl --enable-shared=yes
cd curl/curl && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="-L$(SSL_LDIR)" ./configure --prefix=$(CURL_INSTALL_DIR) --disable-debug --disable-ftp --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual --disable-ipv6 --disable-sspi --disable-ntlm --disable-tls-srp --without-nghttp2 --without-libidn2 --without-libssh2 --without-brotli --without-librtmp --without-libpsl --without-zstd --with-openssl
cd curl/curl && CFLAGS=-fPIC CC=${CC} CXX=${CXX} ${MAKE}
cd curl/curl && ${MAKE} install

curl: curl/curl/lib/.libs/libcurl.a
curl: $(CURL_INSTALL_DIR)/lib/libcurl.a


libmicrohttpd/libmicrohttpd/src/microhttpd/.libs/libmicrohttpd.a:
Expand Down Expand Up @@ -156,12 +200,13 @@ lz4/lz4/lib/liblz4.a:
lz4: lz4/lz4/lib/liblz4.a


clickhouse-cpp/clickhouse-cpp/clickhouse/libclickhouse-cpp-lib-static.a:
clickhouse-cpp/clickhouse-cpp/clickhouse/libclickhouse-cpp-lib-static.a: abseil
cd clickhouse-cpp && rm -rf clickhouse-cpp-*/ || true
cd clickhouse-cpp && tar -zxf v2.3.0.tar.gz
cd clickhouse-cpp && ln -fs clickhouse-cpp-*/ clickhouse-cpp
cd clickhouse-cpp/clickhouse-cpp && patch clickhouse/base/wire_format.h < ../wire_format.patch
cd clickhouse-cpp/clickhouse-cpp && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .
cd clickhouse-cpp/clickhouse-cpp && cmake . \
$(CMAKE_FLAGS) \
-DCMAKE_PREFIX_PATH=$(abspath abseil/abseil-cpp/local)
cd clickhouse-cpp/clickhouse-cpp && CC=${CC} CXX=${CXX} ${MAKE}

clickhouse-cpp: clickhouse-cpp/clickhouse-cpp/clickhouse/libclickhouse-cpp-lib-static.a
Expand Down Expand Up @@ -194,7 +239,7 @@ mariadb-client-library/mariadb_client/libmariadb/libmariadbclient.a:
cd mariadb-client-library && rm -rf mariadb-connector-c-*/ || true
cd mariadb-client-library && tar -zxf mariadb-connector-c-3.3.8-src.tar.gz
cd mariadb-client-library/mariadb_client && patch -p0 < ../plugin_auth_CMakeLists.txt.patch
cd mariadb-client-library/mariadb_client && cmake . -Wno-dev -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(SSL_IDIR) -DOPENSSL_LIBRARIES=$(SSL_LDIR) -DICONV_LIBRARIES=$(brew --prefix libiconv)/lib -DICONV_INCLUDE=$(brew --prefix libiconv)/include .
cd mariadb-client-library/mariadb_client && cmake . $(CMAKE_FLAGS) -Wno-dev -DOPENSSL_ROOT_DIR=$(SSL_IDIR) -DOPENSSL_LIBRARIES=$(SSL_LDIR) -DICONV_LIBRARIES=$(brew --prefix libiconv)/lib -DICONV_INCLUDE=$(brew --prefix libiconv)/include .
ifeq ($(PROXYDEBUG),1)
cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_context.h.patch
else ifeq ($(USEVALGRIND),1)
Expand Down Expand Up @@ -268,7 +313,7 @@ prometheus-cpp/prometheus-cpp/lib/libprometheus-cpp-core.a:
cd prometheus-cpp/prometheus-cpp && patch -p1 < ../serial_exposer.patch
cd prometheus-cpp/prometheus-cpp && patch -p1 < ../registry_counters_reset.patch
cd prometheus-cpp/prometheus-cpp && patch -p1 < ../fix_old_distros.patch
cd prometheus-cpp/prometheus-cpp && cmake . -DBUILD_SHARED_LIBS=OFF -DENABLE_TESTING=OFF -DENABLE_PUSH=OFF
cd prometheus-cpp/prometheus-cpp && cmake . $(CMAKE_FLAGS) -DBUILD_SHARED_LIBS=OFF -DENABLE_TESTING=OFF -DENABLE_PUSH=OFF
cd prometheus-cpp/prometheus-cpp && CC=${CC} CXX=${CXX} ${MAKE}

prometheus-cpp: prometheus-cpp/prometheus-cpp/lib/libprometheus-cpp-core.a
Expand Down Expand Up @@ -318,7 +363,7 @@ libusual/libusual/.libs/libusual.a:
cd libusual && rm -rf libusual-*/ || true
cd libusual && tar -zxf libusual-*.tar.gz
cd libusual/libusual && ./autogen.sh
cd libusual/libusual && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="$(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)" ./configure --with-openssl="$(SSL_LDIR)" --disable-shared
cd libusual/libusual && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="-L$(SSL_LDIR)" ./configure --with-openssl="$(SSL_LDIR)" --disable-shared
cd libusual/libusual && CC=${CC} CXX=${CXX} ${MAKE}

libusual: libusual/libusual/.libs/libusual.a
Expand All @@ -329,6 +374,76 @@ libscram/lib/libscram.a:postgresql/postgresql/src/interfaces/libpq/libpq.a

libscram: libscram/lib/libscram.a

$(JSON_INSTALL_DIR)/include/nlohmann/json.hpp:
cd json && rm -rf json-*/ || true
cd json && tar -zxf json-3.12.0.tar.gz
cd json/json && cmake . $(CMAKE_FLAGS)

json: $(JSON_INSTALL_DIR)/include/nlohmann/json.hpp

$(ABSL_INSTALL_DIR)/lib/libabsl.a:
cd abseil && rm -rf abseil-cpp-*/ || true
cd abseil && tar -zxf abseil-cpp-20250512.0.tar.gz
ifneq (,$(filter $(DISTRO)$(DISTVERS),almalinux8 opensuse15))
cd abseil/abseil-cpp && patch -p0 < ../constexpr.patch
endif
cd abseil/abseil-cpp && mkdir -p build
cd abseil/abseil-cpp/build && cmake .. $(CMAKE_FLAGS) -DCMAKE_INSTALL_PREFIX=$(ABSL_INSTALL_DIR) -DBUILD_TESTING=OFF
cd abseil/abseil-cpp/build && CC=${CC} CXX=${CXX} ${MAKE}
cd abseil/abseil-cpp/build && ${MAKE} install
cd $(ABSL_INSTALL_DIR)/lib && ${AR} -crs --thin libabsl.a *.a
# cd $(ABSL_INSTALL_DIR)/lib && ls libabsl_*.a | xargs -n1 ${AR} -x
# cd $(ABSL_INSTALL_DIR)/lib && ${AR} -crs libabsl.a *.o && rm *.o

abseil: $(ABSL_INSTALL_DIR)/lib/libabsl.a

$(PROTOBUF_INSTALL_DIR)/lib/libprotobuf.a: abseil
cd protobuf && rm -rf protobuf-*/ || true
cd protobuf && tar -zxf protobuf-31.0.tar.gz
cd protobuf/protobuf && mkdir -p build
cd protobuf/protobuf/build && cmake .. \
$(CMAKE_FLAGS) \
-DCMAKE_PREFIX_PATH=$(ABSL_INSTALL_DIR) \
-DCMAKE_INSTALL_PREFIX=$(PROTOBUF_INSTALL_DIR) \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_LOCAL_DEPENDENCIES_ONLY=ON
cd protobuf/protobuf/build && CC=${CC} CXX=${CXX} ${MAKE}
cd protobuf/protobuf/build && ${MAKE} install
cd $(PROTOBUF_INSTALL_DIR)/lib && ${AR} -crs --thin libutf8.a *.a
# cd $(PROTOBUF_INSTALL_DIR)/lib && ls libutf8_*.a | xargs -n1 ${AR} -x
# cd $(PROTOBUF_INSTALL_DIR)/lib && ${AR} -crs libutf8.a *.o && rm *.o
ifeq ($(PROXYDEBUG),1)
cd $(PROTOBUF_INSTALL_DIR)/lib && cp libprotobufd.a libprotobuf.a
endif

protobuf: $(PROTOBUF_INSTALL_DIR)/lib/libprotobuf.a

$(OTEL_INSTALL_DIR)/lib/libopentelemetry.a: protobuf abseil curl json
cd opentelemetry && rm -rf opentelemetry-cpp-*/ || true
cd opentelemetry && tar -zxf opentelemetry-cpp-1.21.0.tar.gz
cd opentelemetry && rm -rf opentelemetry-proto-*/ || true
cd opentelemetry && tar -zxf opentelemetry-proto-1.6.0.tar.gz
cd opentelemetry/opentelemetry-cpp && patch -p0 < ../active_span.patch
cd opentelemetry/opentelemetry-cpp && mkdir -p build
cd opentelemetry/opentelemetry-cpp/build && cmake .. \
$(CMAKE_FLAGS) \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DWITH_BENCHMARK=OFF \
-DWITH_EXAMPLES=OFF \
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_GRPC=OFF \
-DOTELCPP_PROTO_PATH=$(OTEL_PROTO_DIR) \
-DCMAKE_INSTALL_PREFIX=$(OTEL_INSTALL_DIR) \
-DCMAKE_PREFIX_PATH="$(PROTOBUF_INSTALL_DIR);$(ABSL_INSTALL_DIR);$(CURL_INSTALL_DIR);$(JSON_INSTALL_DIR)"
cd opentelemetry/opentelemetry-cpp/build && CC=${CC} CXX=${CXX} ${MAKE}
cd opentelemetry/opentelemetry-cpp/build && ${MAKE} install
cd $(OTEL_INSTALL_DIR)/lib && ${AR} -crs --thin libopentelemetry.a *.a
# cd $(OTEL_INSTALL_DIR)/lib && ls libopentelemetry_*.a | xargs -n1 ${AR} -x
# cd $(OTEL_INSTALL_DIR)/lib && ${AR} -crs libopentelemetry.a *.o && rm *.o

otel: $(OTEL_INSTALL_DIR)/lib/libopentelemetry.a

### clean targets

cleanpart:
Expand Down Expand Up @@ -360,5 +475,9 @@ cleanall:
cd postgresql && rm -rf postgresql-*/ || true
cd libusual && rm -rf libusual-*/ || true
cd libscram && rm -rf lib/* obj/* || true
cd json && rm -rf json-*/ || true
cd abseil && rm -rf abseil-cpp-*/ || true
cd protobuf && rm -rf protobuf-*/ || true
cd opentelemetry && rm -rf opentelemetry-cpp-*/ || true
cd opentelemetry && rm -rf opentelemetry-proto-*/ || true
.PHONY: cleanall

1 change: 1 addition & 0 deletions deps/abseil/abseil-cpp
Binary file added deps/abseil/abseil-cpp-20250512.0.tar.gz
Binary file not shown.
Loading