Skip to content

Commit

Permalink
Merge branch 'v2.x' into v2.x-aurora_autodiscovery-refactor_cluster_m…
Browse files Browse the repository at this point in the history
…ysql_servers-gr_bootstrap_mode
  • Loading branch information
renecannao authored Jan 9, 2024
2 parents e8d2254 + a3cb283 commit 83cf46d
Show file tree
Hide file tree
Showing 198 changed files with 2,087 additions and 1,494 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ heaptrack.*
#vscode
.vscode/

# test deps
test/deps/mariadb-connector-c/mariadb-connector-c-*/
test/deps/mysql-connector-c/mysql-5.7.*/

#tap tests
test/tap/tap/cpp-dotenv/cpp-dotenv-*
test/tap/tap/cpp-dotenv/static/cpp-dotenv-*
Expand Down
164 changes: 114 additions & 50 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
### export GIT_VERSION=2.x-dev
### ```

ifndef GIT_VERSION
GIT_VERSION := $(shell git describe --long --abbrev=7)
GIT_VERSION ?= $(shell git describe --long --abbrev=7)
ifndef GIT_VERSION
$(error GIT_VERSION is not set)
endif
endif

### NOTES:
### to compile without jemalloc, set environment variable NOJEMALLOC=1
Expand All @@ -28,26 +26,39 @@ endif
###
### ** to use on-demand coredump generation feature, compile code without ASAN option (WITHASAN=0).

O0=-O0
O2=-O2
O1=-O1
O3=-O3 -mtune=native
#OPTZ=$(O2)
EXTRALINK=#-pg
ALL_DEBUG=-ggdb -DDEBUG
NO_DEBUG=
DEBUG=${ALL_DEBUG}
O0 := -O0
O2 := -O2
O1 := -O1
O3 := -O3 -mtune=native

#EXTRALINK := #-pg
ALL_DEBUG := $(O0) -ggdb -DDEBUG
NO_DEBUG := $(O2) -ggdb
DEBUG := $(ALL_DEBUG)
CURVER ?= 2.6.0
#export DEBUG
#export OPTZ
#export EXTRALINK
export MAKE
export CURVER?=2.6.0
export CURVER

### 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 | grep -Po '\d\d\d\d\d\dL')
ifneq ($(CPLUSPLUS),201703L)
CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL')
LEGACY_BUILD := 1
ifneq ($(CPLUSPLUS),201103L)
$(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)

### detect distro
DISTRO := Unknown
ifneq (,$(wildcard /etc/os-release))
DISTRO := $(shell awk -F= '/^NAME/{print $$2}' /etc/os-release)
else
DISTRO := Unknown
endif

### multiprocessing
NPROCS := 1
OS := $(shell uname -s)
ifeq ($(OS),Linux)
Expand All @@ -56,20 +67,22 @@ endif
ifeq ($(OS),Darwin)
NPROCS := $(shell sysctl -n hw.ncpu)
endif
export MAKEOPT := -j${NPROCS}

export MAKEOPT=-j ${NPROCS}

### systemd
SYSTEMD := 0
ifeq ($(wildcard /usr/lib/systemd/system), /usr/lib/systemd/system)
SYSTEMD=1
else
SYSTEMD=0
SYSTEMD := 1
endif

### check user/group
USERCHECK := $(shell getent passwd proxysql)
GROUPCHECK := $(shell getent group proxysql)


### main targets

.DEFAULT: default
.PHONY: default
default: build_src

Expand Down Expand Up @@ -111,25 +124,49 @@ debug_clickhouse: build_src_debug_clickhouse
### helper targets

.PHONY: build_deps
build_deps:
cd deps && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE}
build_deps: $(if $(LEGACY_BUILD),build_deps_legacy,build_deps_default)

.PHONY: build_lib
build_lib: build_deps
cd lib && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE}
build_lib: $(if $(LEGACY_BUILD),build_lib_legacy,build_lib_default)

.PHONY: build_src
build_src: build_lib
cd src && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE}
build_src: $(if $(LEGACY_BUILD),build_src_legacy,build_src_default)

.PHONY: build_deps_debug
build_deps_debug:
cd deps && OPTZ="${O0} -ggdb -DDEBUG" PROXYDEBUG=1 CC=${CC} CXX=${CXX} ${MAKE}
build_deps_debug: $(if $(LEGACY_BUILD),build_deps_debug_legacy,build_deps_debug_default)

.PHONY: build_lib_debug
build_lib_debug: build_deps_debug
build_lib_debug: $(if $(LEGACY_BUILD),build_lib_debug_legacy,build_lib_debug_default)

.PHONY: build_src_debug
build_src_debug: $(if $(LEGACY_BUILD),build_src_debug_legacy,build_src_debug_default)

# legacy build targets (pre c++17)
.PHONY: build_deps_legacy
build_deps_legacy:
cd deps && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE}

.PHONY: build_lib_legacy
build_lib_legacy: build_deps_legacy
cd lib && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE}

.PHONY: build_src_legacy
build_src_legacy: build_lib_legacy
cd src && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE}

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

.PHONY: build_lib_debug_legacy
build_lib_debug_legacy: build_deps_debug_legacy
cd lib && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE}

.PHONY: build_src_debug_legacy
build_src_debug_legacy: build_lib_debug_legacy
cd src && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE}
#--

.PHONY: build_src_testaurora
build_src_testaurora: build_lib_testaurora
cd src && OPTZ="${O0} -ggdb -DDEBUG -DTEST_AURORA" CC=${CC} CXX=${CXX} ${MAKE}
Expand Down Expand Up @@ -187,44 +224,67 @@ build_lib_testall: build_deps_debug
cd lib && OPTZ="${O0} -ggdb -DDEBUG -DTEST_AURORA -DTEST_GALERA -DTEST_GROUPREP -DTEST_READONLY -DTEST_REPLICATIONLAG" CC=${CC} CXX=${CXX} ${MAKE}

.PHONY: build_tap_test
build_tap_test: build_src
cd test/tap && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE}
build_tap_test: build_tap_tests
.PHONY: build_tap_tests
build_tap_tests: build_src
cd test/tap && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE}

.PHONY: build_tap_test_debug
build_tap_test_debug: build_src_debug
build_tap_test_debug: build_tap_tests_debug
.PHONY: build_tap_tests_debug
build_tap_tests_debug: build_src_debug
cd test/tap && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE} debug

.PHONY: build_src_debug
build_src_debug: build_lib_debug
cd src && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE}

# ClickHouse build targets are now default build targets.
# To maintain backward compatibility, ClickHouse targets are still available.
.PHONY: build_deps_clickhouse
build_deps_clickhouse:
cd deps && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE}
build_deps_clickhouse: build_deps_default

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

.PHONY: build_lib_clickhouse
build_lib_clickhouse: build_deps_clickhouse
cd lib && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE}
build_lib_clickhouse: build_lib_default

.PHONY: build_lib_debug_clickhouse
build_lib_debug_clickhouse: build_deps_debug_clickhouse
cd lib && OPTZ="${O0} -ggdb -DDEBUG" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE}
build_lib_debug_clickhouse: build_lib_debug_default

.PHONY: build_src_clickhouse
build_src_clickhouse: build_lib_clickhouse
cd src && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE}
build_src_clickhouse: build_src_default

.PHONY: build_src_debug_clickhouse
build_src_debug_clickhouse: build_lib_debug_clickhouse
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}

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

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

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

.PHONY: build_src_default
build_src_default: build_lib_default
cd src && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE}

.PHONY: build_src_debug_default
build_src_debug_default: build_lib_debug_default
cd src && OPTZ="${O0} -ggdb -DDEBUG" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE}


### packaging targets

SYS_KERN := $(shell uname -s)
#SYS_DIST := $(shell source /etc/os-release &>/dev/null; if [ -z ${NAME} ]; then head -1 /etc/redhat-release; else echo ${NAME}; fi | awk '{ print $1 })
SYS_ARCH := $(shell uname -m)
REL_ARCH := $(subst x86_64,amd64,$(subst aarch64,arm64,$(SYS_ARCH)))
RPM_ARCH := .$(SYS_ARCH)
Expand Down Expand Up @@ -292,16 +352,20 @@ clean:
cd lib && ${MAKE} clean
cd src && ${MAKE} clean
cd test/tap && ${MAKE} clean
cd test/deps && ${MAKE} clean
rm -f pkgroot || true

.PHONY: cleanall
cleanall:
cd deps && ${MAKE} cleanall
cd lib && ${MAKE} clean
cd src && ${MAKE} clean
cd test/tap && ${MAKE} clean
cd test/deps && ${MAKE} cleanall
rm -f binaries/*deb || true
rm -f binaries/*rpm || true
rm -f binaries/*id-hash || true
rm -rf pkgroot || true

.PHONY: cleanbuild
cleanbuild:
Expand Down Expand Up @@ -342,7 +406,7 @@ ifeq ($(DISTRO),"Debian GNU/Linux")
update-rc.d proxysql defaults
else
ifeq ($(DISTRO),"Unknown")
$(warning Not sure how to install proxysql service on this OS)
$(warning Not sure how to install proxysql service on this OS)
endif
endif
endif
Expand Down Expand Up @@ -379,7 +443,7 @@ ifeq ($(DISTRO),"Debian GNU/Linux")
update-rc.d proxysql remove
else
ifeq ($(DISTRO),"Unknown")
$(warning Not sure how to uninstall proxysql service on this OS)
$(warning Not sure how to uninstall proxysql service on this OS)
endif
endif
endif
Expand Down
Loading

0 comments on commit 83cf46d

Please sign in to comment.