diff --git a/Makefile b/Makefile index 8b83471120..25aaabd3f2 100644 --- a/Makefile +++ b/Makefile @@ -42,15 +42,23 @@ DEBUG=${ALL_DEBUG} #export EXTRALINK export MAKE export CURVER?=2.6.0 -export CPLUSPLUS=$(shell ${CC} -dM -E -x c++ /dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') -$(warning __cplusplus=${CPLUSPLUS}) + +# determine compiler support for c++11/17 +export 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') +ifeq ($(CPLUSPLUS),) + export 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') +ifeq ($(CPLUSPLUS),) + $(error Compiler must support at least c++11) +endif +endif + +DISTRO := Unknown ifneq (,$(wildcard /etc/os-release)) DISTRO := $(shell awk -F= '/^NAME/{print $$2}' /etc/os-release) -else - DISTRO := Unknown endif + NPROCS := 1 OS := $(shell uname -s) ifeq ($(OS),Linux) @@ -59,14 +67,14 @@ endif ifeq ($(OS),Darwin) NPROCS := $(shell sysctl -n hw.ncpu) endif - export MAKEOPT=-j ${NPROCS} + +SYSTEMD := 0 ifeq ($(wildcard /usr/lib/systemd/system), /usr/lib/systemd/system) - SYSTEMD=1 -else - SYSTEMD=0 + SYSTEMD := 1 endif + USERCHECK := $(shell getent passwd proxysql) GROUPCHECK := $(shell getent group proxysql) diff --git a/deps/Makefile b/deps/Makefile index 367dbdd499..e82d006d8d 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -38,21 +38,14 @@ endif endif -# determine good compiler version for stdc++17 -#IS_CXX17 := 0 -#ifeq ($(CXX),clang++) -# CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -# CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -#ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER)))) -# IS_CXX17 := 1 -#endif -#else -# GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -# GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -#ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER)))) -# IS_CXX17 := 1 -#endif -#endif +# determine compiler support for c++11/17 +export 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') +ifeq ($(CPLUSPLUS),) + export 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') +ifeq ($(CPLUSPLUS),) + $(error Compiler must support at least c++11) +endif +endif PROXYSQLCLICKHOUSE := $(shell echo $(PROXYSQLCLICKHOUSE)) @@ -191,7 +184,7 @@ lz4: lz4/lz4/lib/liblz4.a clickhouse-cpp/clickhouse-cpp/clickhouse/libclickhouse-cpp-lib-static.a: cd clickhouse-cpp && rm -rf clickhouse-cpp-*/ || true -#ifeq ($(IS_CXX17), 1) +#ifeq ($(CPLUSPLUS),201703L) # echo ">>> Clickhouse CXX17" cd clickhouse-cpp && ln -fs clickhouse-cpp-2.3.0 clickhouse-cpp cd clickhouse-cpp && tar -zxf v2.3.0.tar.gz && sync diff --git a/lib/Makefile b/lib/Makefile index b664ddf654..634312c0c0 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -102,19 +102,12 @@ WGCOV= endif -# determine good compiler version for stdc++17 -IS_CXX17 := 0 -ifeq ($(CXX),clang++) - CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') - CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER)))) - IS_CXX17 := 1 -endif -else - GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') - GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER)))) - IS_CXX17 := 1 +# determine compiler support for c++11/17 +export 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') +ifeq ($(CPLUSPLUS),) + export 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') +ifeq ($(CPLUSPLUS),) + $(error Compiler must support at least c++11) endif endif @@ -137,7 +130,7 @@ endif MYCFLAGS=$(IDIRS) $(OPTZ) $(DEBUG) -Wall -DGITVERSION=\"$(GIT_VERSION)\" $(NOJEM) $(WGCOV) $(WASAN) MYCXXFLAGS=-std=c++11 -DCXX11 -ifeq ($(IS_CXX17),1) +ifeq ($(CPLUSPLUS),201703L) MYCXXFLAGS=-std=c++17 -DCXX17 endif MYCXXFLAGS+= $(MYCFLAGS) $(PSQLCH) $(ENABLE_EPOLL) diff --git a/src/Makefile b/src/Makefile index 6c02a5c5eb..dd8ebc1408 100644 --- a/src/Makefile +++ b/src/Makefile @@ -97,19 +97,12 @@ ifeq ($(UNAME_S),Darwin) endif -# determine good compiler version for stdc++17 -IS_CXX17 := 0 -ifeq ($(CXX),clang++) - CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') - CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER)))) - IS_CXX17 := 1 -endif -else - GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') - GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER)))) - IS_CXX17 := 1 +# determine compiler support for c++11/17 +export 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') +ifeq ($(CPLUSPLUS),) + export 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') +ifeq ($(CPLUSPLUS),) + $(error Compiler must support at least c++11) endif endif @@ -120,7 +113,6 @@ ifeq ($(PROXYSQLCLICKHOUSE),1) PSQLCH=-DPROXYSQLCLICKHOUSE endif - WITHGCOVVAR := $(shell echo $(WITHGCOV)) ifeq ($(WITHGCOVVAR),1) WGCOV=-DWITHGCOV --coverage @@ -143,7 +135,7 @@ WASAN+= -DTEST_WITHASAN endif MYCXXFLAGS=-std=c++11 -DCXX11 -ifeq ($(IS_CXX17),1) +ifeq ($(CPLUSPLUS),201703L) MYCXXFLAGS=-std=c++17 -DCXX17 endif ifeq ($(CXX),clang++)