diff --git a/src/Makefile b/src/Makefile index 5899a97531..b137548211 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,14 +6,18 @@ ifndef GIT_VERSION $(error GIT_VERSION is not set) endif -DEPS_PATH := ../deps - CENTOSVER := Unknown ifneq (,$(wildcard /etc/system-release)) CENTOSVER := $(shell rpm --eval %rhel) endif +PROXYSQL_PATH := .. +PROXYSQL_IDIR := $(PROXYSQL_PATH)/include +PROXYSQL_LDIR := $(PROXYSQL_PATH)/lib + +DEPS_PATH := $(PROXYSQL_PATH)/deps + MARIADB_PATH := $(DEPS_PATH)/mariadb-client-library/mariadb_client MARIADB_IDIR := $(MARIADB_PATH)/include MARIADB_LDIR := $(MARIADB_PATH)/libmariadb @@ -27,8 +31,8 @@ JEMALLOC_IDIR := $(JEMALLOC_PATH)/include/jemalloc JEMALLOC_LDIR := $(JEMALLOC_PATH)/lib LIBCONFIG_PATH := $(DEPS_PATH)/libconfig/libconfig -LIBCONFIG_IDIR=-I$(LIBCONFIG_PATH)/lib -LIBCONFIG_LDIR=-L$(LIBCONFIG_PATH)/lib/.libs +LIBCONFIG_IDIR := $(LIBCONFIG_PATH)/lib +LIBCONFIG_LDIR := $(LIBCONFIG_PATH)/lib/.libs PROMETHEUS_PATH := $(DEPS_PATH)/prometheus-cpp/prometheus-cpp PROMETHEUS_IDIR := $(PROMETHEUS_PATH)/pull/include -I$(PROMETHEUS_PATH)/core/include @@ -86,10 +90,8 @@ EV_IDIR := $(EV_PATH) EV_LDIR := $(EV_PATH)/.libs -IDIR := ../include -LDIR := ../lib -IDIRS := -I$(IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) $(LIBCONFIG_IDIR) -I$(LIBDAEMON_IDIR) -I$(RE2_IDIR) -L$(PCRE_IDIR) -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(LIBINJECTION_IDIR) -I$(CURL_IDIR) -I$(EV_IDIR) -I$(SSL_IDIR) -I$(PROMETHEUS_IDIR) -I$(SQLITE3_IDIR) -I$(CLICKHOUSE_CPP_IDIR) -I$(CLICKHOUSE_CPP_CDIR) -I$(0) -LDIRS := -L$(LDIR) -L$(JEMALLOC_LDIR) -L$(MARIADB_LDIR) $(LIBCONFIG_LDIR) -L$(LIBDAEMON_LDIR) -L$(RE2_LDIR) -L$(PCRE_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(LIBINJECTION_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(SSL_LDIR) -L$(PROMETHEUS_LDIR) +IDIRS := -I$(PROXYSQL_IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) -I$(LIBCONFIG_IDIR) -I$(LIBDAEMON_IDIR) -I$(RE2_IDIR) -L$(PCRE_IDIR) -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(LIBINJECTION_IDIR) -I$(CURL_IDIR) -I$(EV_IDIR) -I$(SSL_IDIR) -I$(PROMETHEUS_IDIR) -I$(SQLITE3_IDIR) -I$(CLICKHOUSE_CPP_IDIR) -I$(CLICKHOUSE_CPP_CDIR) -I$(0) +LDIRS := -L$(PROXYSQL_LDIR) -L$(JEMALLOC_LDIR) -L$(MARIADB_LDIR) -L$(LIBCONFIG_LDIR) -L$(LIBDAEMON_LDIR) -L$(RE2_LDIR) -L$(PCRE_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(LIBINJECTION_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(SSL_LDIR) -L$(PROMETHEUS_LDIR) UNAME_S := $(shell uname -s) @@ -120,12 +122,12 @@ endif WGCOV := ifeq ($(WITHGCOV),1) - WGCOV := -DWITHGCOV --coverage + WGCOV := -DWITHGCOV -lgcov --coverage endif WASAN := ifeq ($(WITHASAN),1) - WASAN := -fsanitize=address + WASAN := -WITHASAN -fsanitize=address # Force the disable of JEMALLOC, since ASAN isn't compatible. export NOJEMALLOC = 1 endif @@ -139,14 +141,6 @@ ifeq ($(CXX),clang++) endif MYCXXFLAGS += $(IDIRS) $(OPTZ) $(DEBUG) $(PSQLCH) -DGITVERSION=\"$(GIT_VERSION)\" $(WGCOV) $(WASAN) -ifeq ($(WITHGCOV),1) - LDFLAGS += -lgcov --coverage -endif - -ifeq ($(WITHASAN),1) - LDFLAGS += -fsanitize=address -endif - STATICMYLIBS := -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lcurl -lssl -lcrypto -lev ifneq ($(NOJEMALLOC),1) @@ -155,8 +149,8 @@ endif ifeq ($(UNAME_S),Linux) STATICMYLIBS += -lcoredumper endif -MYLIBS := -Wl,--export-dynamic $(STATICMYLIBS) -Wl,-Bdynamic -lgnutls -lpthread -lm -lz -lrt -lprometheus-cpp-pull -lprometheus-cpp-core -luuid $(EXTRALINK) +MYLIBS := -Wl,--export-dynamic $(STATICMYLIBS) -Wl,-Bdynamic -lgnutls -lpthread -lm -lz -lrt -lprometheus-cpp-pull -lprometheus-cpp-core -luuid $(EXTRALINK) ifeq ($(UNAME_S),Darwin) MYLIBS :=-lre2 -lmariadbclient -lpthread -lm -lz -liconv -lgnutls -lprometheus-cpp-pull -lprometheus-cpp-core -luuid else @@ -174,12 +168,25 @@ ifeq ($(CENTOSVER),6) MYLIBS += -lgcrypt endif -LIBPROXYSQLAR := $(LDIR)/libproxysql.a +LIBPROXYSQLAR := $(PROXYSQL_LDIR)/libproxysql.a ifeq ($(UNAME_S),Darwin) - LIBPROXYSQLAR := $(LDIR)/libproxysql.a ../deps/jemalloc/jemalloc/lib/libjemalloc.a ../deps/libmicrohttpd/libmicrohttpd/src/microhttpd/.libs/libmicrohttpd.a ../deps/libhttpserver/libhttpserver/build/src/.libs/libhttpserver.a ../deps/pcre/pcre/.libs/libpcre.a ../deps/pcre/pcre/.libs/libpcrecpp.a ../deps/libdaemon/libdaemon/libdaemon/.libs/libdaemon.a ../deps/libconfig/libconfig/lib/.libs/libconfig++.a ../deps/libconfig/libconfig/lib/.libs/libconfig.a ../deps/curl/curl/lib/.libs/libcurl.a ../deps/sqlite3/sqlite3/sqlite3.o ../deps/libinjection/libinjection/src/libinjection.a ../deps/libhttpserver/libhttpserver/build/src/.libs/libhttpserver.a ../deps/libev/libev/.libs/libev.a -endif + LIBPROXYSQLAR += $(JEMALLOC_LDIR)/libjemalloc.a + LIBPROXYSQLAR += $(MICROHTTPD_LDIR)/libmicrohttpd.a + LIBPROXYSQLAR += $(LIBHTTPSERVER_LDIR)/libhttpserver.a + LIBPROXYSQLAR += $(PCRE_LDIR)/libpcre.a + LIBPROXYSQLAR += $(PCRE_LDIR)/libpcrecpp.a + LIBPROXYSQLAR += $(LIBDAEMON_LDIR)/libdaemon.a + LIBPROXYSQLAR += $(LIBCONFIG_LDIR)/libconfig++.a + LIBPROXYSQLAR += $(LIBCONFIG_LDIR)/libconfig.a + LIBPROXYSQLAR += $(CURL_LDIR)/libcurl.a + LIBPROXYSQLAR += $(SQLITE3_LDIR)/sqlite3.o + LIBPROXYSQLAR += $(LIBINJECTION_LDIR)/libinjection.a + LIBPROXYSQLAR += $(EV_LDIR)/libev.a +endif +LIBPROXYSQLAR += $(SSL_LDIR)/libssl.a +LIBPROXYSQLAR += $(SSL_LDIR)/libcrypto.a +LIBPROXYSQLAR += $(CITYHASH_LDIR)/libcityhash.a -LIBPROXYSQLAR += $(SSL_LDIR)/libssl.a $(SSL_LDIR)/libcrypto.a $(CITYHASH_LDIR)/libcityhash.a ODIR := obj EXECUTABLE := proxysql @@ -192,9 +199,9 @@ $(ODIR)/%.o: %.cpp $(EXECUTABLE): $(ODIR) $(OBJ) $(LIBPROXYSQLAR) ifeq ($(PROXYSQLCLICKHOUSE),1) - $(CXX) -o $@ $(OBJ) $(LIBPROXYSQLAR) $(CLICKHOUSE_CPP_LDIR)/libclickhouse-cpp-lib-static.a $(LZ4_LDIR)/liblz4.a $(MYCXXFLAGS) $(CXXFLAGS) $(LDIRS) $(LIBS) $(LDFLAGS) $(MYLIBS) + $(CXX) -o $@ $(OBJ) $(LIBPROXYSQLAR) $(CLICKHOUSE_CPP_LDIR)/libclickhouse-cpp-lib-static.a $(LZ4_LDIR)/liblz4.a $(MYCXXFLAGS) $(CXXFLAGS) $(LDIRS) $(LIBS) $(MYLIBS) else - $(CXX) -o $@ $(OBJ) $(LIBPROXYSQLAR) $(MYCXXFLAGS) $(CXXFLAGS) $(LDIRS) $(LIBS) $(LDFLAGS) $(MYLIBS) + $(CXX) -o $@ $(OBJ) $(LIBPROXYSQLAR) $(MYCXXFLAGS) $(CXXFLAGS) $(LDIRS) $(LIBS) $(MYLIBS) endif ifeq ($(UNAME_S),Darwin) shasum $(EXECUTABLE) > $(EXECUTABLE).sha1 @@ -206,7 +213,10 @@ $(ODIR): mkdir $(ODIR) $(LIBPROXYSQLAR): - cd $(LDIR) && ${MAKE} + cd $(PROXYSQL_LDIR) && ${MAKE} + + +### main targets default: $(EXECUTABLE) diff --git a/test/tap/tap/Makefile b/test/tap/tap/Makefile index 0d80eee97d..4d51e0332f 100644 --- a/test/tap/tap/Makefile +++ b/test/tap/tap/Makefile @@ -1,9 +1,20 @@ #!/bin/make -f -DEPS_PATH := ../../../deps +GIT_VERSION ?= $(shell git describe --long --abbrev=7) +ifndef GIT_VERSION + $(error GIT_VERSION is not set) +endif -JSON_IDIR := $(DEPS_PATH)/json + +PROXYSQL_PATH := ../../.. +PROXYSQL_IDIR := $(PROXYSQL_PATH)/include +PROXYSQL_LDIR := $(PROXYSQL_PATH)/lib + +DEPS_PATH := $(PROXYSQL_PATH)/deps + +JSON_PATH := $(DEPS_PATH)/json +JSON_IDIR := $(JSON_PATH) MARIADB_PATH := $(DEPS_PATH)/mariadb-client-library/mariadb_client MARIADB_IDIR := $(MARIADB_PATH)/include @@ -21,34 +32,47 @@ DOTENV_PATH := ./cpp-dotenv/static/cpp-dotenv DOTENV_IDIR := $(DOTENV_PATH)/include DOTENV_LDIR := $(DOTENV_PATH) -IDIR := ../../../include -LDIR := ../../../lib -LIBPROXYSQLAR := $(LDIR)/libproxysql.a -INCLUDEDIRS := -I$(IDIR) -I$(JSON_IDIR) -I$(MARIADB_IDIR) -I${CURL_IDIR} -I${SQLITE3_IDIR} -I$(DOTENV_IDIR) +LIBPROXYSQLAR := $(PROXYSQL_LDIR)/libproxysql.a -.PHONY: all -all: libtap.a libtap.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so +IDIRS := -I$(PROXYSQL_IDIR) -I$(JSON_IDIR) -I$(MARIADB_IDIR) -I${CURL_IDIR} -I${SQLITE3_IDIR} -I$(DOTENV_IDIR) -.PHONY: clean -clean: - rm -f *.o libtap.a libtap.so || true - find cpp-dotenv/dynamic -name '*.o' -or -name '*.a' -delete || true - find cpp-dotenv/static -name '*.o' -or -name '*.a' -delete || true +### 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') +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) + +WASAN := +ifeq ($(WITHASAN),1) + WASAN := -fsanitize=address +endif + +OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed -OPT=-O2 -debug: OPT := -O0 -DDEBUG -ggdb +.PHONY: default +default: all + +.PHONY: all +all: libtap.a libtap.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so + +debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WASAN) debug: libtap.a libtap.so + command_line.o: command_line.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so - g++ -fPIC -c command_line.cpp -std=c++11 $(INCLUDEDIRS) $(OPT) + g++ -fPIC -c command_line.cpp $(IDIRS) $(OPT) utils.o: utils.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so - g++ -fPIC -c utils.cpp -std=c++11 $(INCLUDEDIRS) $(OPT) + g++ -fPIC -c utils.cpp $(IDIRS) $(OPT) tap.o: tap.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so - g++ -fPIC -c tap.cpp -std=c++11 $(INCLUDEDIRS) $(OPT) + g++ -fPIC -c tap.cpp $(IDIRS) $(OPT) libtap.a: tap.cpp tap.h command_line.cpp command_line.h utils.cpp utils.h tap.o command_line.o utils.o cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a ar rcs libtap.a tap.o command_line.o utils.o $(SQLITE3_LDIR)/sqlite3.o @@ -83,3 +107,10 @@ cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so: cd cpp-dotenv/dynamic/cpp-dotenv && patch include/dotenv.h < ../../dotenv.h.patch cd cpp-dotenv/dynamic/cpp-dotenv && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug cd cpp-dotenv/dynamic/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE} + + +.PHONY: clean +clean: + rm -f *.o libtap.a libtap.so || true + find cpp-dotenv/dynamic -name '*.o' -or -name '*.a' -delete || true + find cpp-dotenv/static -name '*.o' -or -name '*.a' -delete || true diff --git a/test/tap/tests/Makefile b/test/tap/tests/Makefile index de8e9a78a7..30296fe513 100644 --- a/test/tap/tests/Makefile +++ b/test/tap/tests/Makefile @@ -1,7 +1,17 @@ #!/bin/make -f -DEPS_PATH := ../../../deps +GIT_VERSION ?= $(shell git describe --long --abbrev=7) +ifndef GIT_VERSION + $(error GIT_VERSION is not set) +endif + + +PROXYSQL_PATH := ../../.. +PROXYSQL_IDIR := $(PROXYSQL_PATH)/include +PROXYSQL_LDIR := $(PROXYSQL_PATH)/lib + +DEPS_PATH := $(PROXYSQL_PATH)/deps MARIADB_PATH := $(DEPS_PATH)/mariadb-client-library/mariadb_client MARIADB_IDIR := $(MARIADB_PATH)/include @@ -11,15 +21,15 @@ JEMALLOC_PATH := $(DEPS_PATH)/jemalloc/jemalloc JEMALLOC_IDIR := $(JEMALLOC_PATH)/include/jemalloc JEMALLOC_LDIR := $(JEMALLOC_PATH)/lib -PROXYSQL_PATH := ../../.. -PROXYSQL_IDIR := $(PROXYSQL_PATH)/include - JSON_IDIR := $(DEPS_PATH)/json RE2_PATH := $(DEPS_PATH)/re2/re2 RE2_IDIR := $(RE2_PATH) +RE2_LDIR := $(RE2_PATH)/obj -SQLITE3_DIR := $(DEPS_PATH)/sqlite3/sqlite3 +SQLITE3_PATH := $(DEPS_PATH)/sqlite3/sqlite3 +SQLITE3_IDIR := $(SQLITE3_PATH) +SQLITE3_LDIR := $(SQLITE3_PATH) LIBHTTPSERVER_DIR := $(DEPS_PATH)/libhttpserver/libhttpserver LIBHTTPSERVER_IDIR := $(LIBHTTPSERVER_DIR)/src @@ -27,7 +37,7 @@ LIBHTTPSERVER_LDIR := $(LIBHTTPSERVER_DIR)/build/src/.libs/ LIBCONFIG_PATH := $(DEPS_PATH)/libconfig/libconfig LIBCONFIG_IDIR := $(LIBCONFIG_PATH)/lib -LIBCONFIG_LDIR := -L$(LIBCONFIG_PATH)/lib/.libs +LIBCONFIG_LDIR := $(LIBCONFIG_PATH)/lib/.libs CURL_DIR := $(DEPS_PATH)/curl/curl CURL_IDIR := $(CURL_DIR)/include @@ -68,25 +78,25 @@ COREDUMPER_DIR := $(DEPS_PATH)/coredumper/coredumper COREDUMPER_IDIR := $(COREDUMPER_DIR)/include COREDUMPER_LDIR := $(COREDUMPER_DIR)/src -IDIR := ../../../include -LDIR := ../../../lib -TAP_LIBDIR := ../tap +TAP_PATH := ../tap +TAP_IDIR := ../tap +TAP_LDIR := ../tap DOTENV_DYN_DIR := ../tap/cpp-dotenv/dynamic/cpp-dotenv DOTENV_DYN_IDIR := $(DOTENV_DYN_DIR)/include #DOTENV_DYN_LDIR := $(DOTENV_DYN_DIR) -DOTENV_DYN_LDIR := $(TAP_LIBDIR) +DOTENV_DYN_LDIR := $(TAP_LDIR) -LIBPROXYSQLAR := $(LDIR)/libproxysql.a +LIBPROXYSQLAR := $(PROXYSQL_LDIR)/libproxysql.a -ODIR := ../../../obj +ODIR := $(PROXYSQL_PATH)//obj EXECUTABLE := proxysql -OBJ := ../../../src/obj/proxysql_global.o ../../../src/obj/main.o ../../../src/obj/proxy_tls.o +OBJ := $(PROXYSQL_PATH)//src/obj/proxysql_global.o $(PROXYSQL_PATH)//src/obj/main.o $(PROXYSQL_PATH)//src/obj/proxy_tls.o -INCLUDEDIRS := -I../tap -I$(RE2_PATH) -I$(IDIR) -I$(JEMALLOC_IDIR) -I$(SQLITE3_DIR) -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(CURL_IDIR) -I$(DAEMONPATH_IDIR) -I$(MARIADB_IDIR) -I$(SSL_IDIR) -I$(JSON_IDIR) -I$(LIBCONFIG_IDIR) -I$(PROMETHEUS_IDIR) -I$(EV_IDIR) -I$(DOTENV_DYN_IDIR) -LDIRS := -L$(TAP_LIBDIR) -L$(DOTENV_DYN_LDIR) -L$(LDIR) -L$(JEMALLOC_LDIR) $(LIBCONFIG_LDIR) -L$(RE2_PATH)/obj -L$(MARIADB_LDIR) -L$(DAEMONPATH_LDIR) -L$(PCRE_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(LIBINJECTION_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(PROMETHEUS_LDIR) +IDIRS := -I$(TAP_IDIR) -I$(RE2_IDIR) -I$(PROXYSQL_IDIR) -I$(JEMALLOC_IDIR) -I$(LIBCONFIG_IDIR) -I$(MARIADB_IDIR) -I$(DAEMONPATH_IDIR) -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(CURL_IDIR) -I$(EV_IDIR) -I$(PROMETHEUS_IDIR) -I$(DOTENV_DYN_IDIR) -I$(SSL_IDIR) -I$(SQLITE3_IDIR) -I$(JSON_IDIR) +LDIRS := -L$(TAP_LDIR) -L$(RE2_LDIR) -L$(PROXYSQL_LDIR) -L$(JEMALLOC_LDIR) -L$(LIBCONFIG_LDIR) -L$(MARIADB_LDIR) -L$(DAEMONPATH_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(PROMETHEUS_LDIR) -L$(DOTENV_DYN_LDIR) -L$(PCRE_LDIR) -L$(LIBINJECTION_LDIR) UNAME_S := $(shell uname -s) @@ -94,7 +104,10 @@ ifeq ($(UNAME_S),Linux) LDIRS += -L$(COREDUMPER_LDIR) endif -MYLIBS := -Wl,--export-dynamic -Wl,-Bdynamic -lssl -lcrypto -lgnutls -ltap -lcpp_dotenv -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lcurl -lev -lprometheus-cpp-pull -lprometheus-cpp-core -luuid -Wl,-Bdynamic -lpthread -lm -lz -lrt -ldl $(EXTRALINK) +MYLIBS := -Wl,--export-dynamic +MYLIBS += -Wl,-Bdynamic -lssl -lcrypto -lgnutls -ltap -lcpp_dotenv +MYLIBS += -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lcurl -lev -lprometheus-cpp-pull -lprometheus-cpp-core -luuid +MYLIBS += -Wl,-Bdynamic -lpthread -lm -lz -lrt -ldl $(EXTRALINK) #MYLIBS := -Wl,--export-dynamic -Wl,-Bdynamic -lssl -lcrypto -lgnutls -ltap -lcpp_dotenv -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lev -lprometheus-cpp-pull -lprometheus-cpp-core -luuid -Wl,-Bdynamic -lpthread -lm -lz -lrt -ldl $(EXTRALINK) MYLIBSJEMALLOC := -Wl,-Bstatic -ljemalloc STATIC_LIBS := $(CITYHASH_LDIR)/libcityhash.a @@ -106,12 +119,15 @@ ifeq ($(UNAME_S),Linux) STATIC_LIBS += $(LIBCOREDUMPERAR) endif -.PHONY: all -all: tests - -.PHONY: clean -clean: - rm -f *-t galera_1_timeout_count galera_2_timeout_no_count aurora generate_set_session_csv set_testing-240.csv clickhouse_php_conn-t reg_test_3992_fast_forward_malformed_packet-pymysql-t || true +### 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') +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) WGCOV := ifeq ($(WITHGCOV),1) @@ -123,8 +139,18 @@ ifeq ($(WITHASAN),1) WASAN := -fsanitize=address -DTEST_WITHASAN endif -OPT := -O2 $(WGCOV) -Wl,--no-as-needed -debug: OPT := -O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WGCOV) $(WASAN) +OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed $(WGCOV) -DGITVERSION=\"$(GIT_VERSION)\" + + +### main targets + +.PHONY: default +default: all + +.PHONY: all +all: tests + +debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WGCOV) $(WASAN) -DGITVERSION=\"$(GIT_VERSION)\" debug: tests tests: tests-cpp tests-php tests-py \ @@ -140,6 +166,9 @@ tests-py: $(patsubst %,py-%,$(wildcard *-t.py)) testgalera: galera_1_timeout_count galera_2_timeout_no_count testaurora: aurora + +### helper targets + set_testing-240.csv: generate_set_session_csv ./generate_set_session_csv > set_testing-240.csv @@ -151,84 +180,94 @@ py-%: cp $(patsubst py-%,%,$@) $(patsubst py-%.py,%,$@) chmod +x $(patsubst py-%.py,%,$@) -%-t: %-t.cpp $(TAP_LIBDIR)/libtap.so - $(CXX) -std=c++11 $< $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ -# $(CXX) -std=c++11 $< $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl $(STATIC_LIBS) $(TAP_LIBDIR)/libtap.a -o $@ +%-t: %-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ +# $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl $(STATIC_LIBS) $(TAP_LDIR)/libtap.so -o $@ -galera_1_timeout_count: galera_1_timeout_count.cpp $(TAP_LIBDIR)/libtap.a - g++ -DTEST_GALERA galera_1_timeout_count.cpp ../tap/SQLite3_Server.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o galera_1_timeout_count -DGITVERSION=\"$(GIT_VERSION)\" +galera_1_timeout_count: galera_1_timeout_count.cpp $(TAP_LDIR)/libtap.so + g++ -DTEST_GALERA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ -galera_2_timeout_no_count: galera_2_timeout_no_count.cpp $(TAP_LIBDIR)/libtap.a - g++ -DTEST_GALERA galera_2_timeout_no_count.cpp ../tap/SQLite3_Server.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o galera_2_timeout_no_count -DGITVERSION=\"$(GIT_VERSION)\" +galera_2_timeout_no_count: galera_2_timeout_no_count.cpp $(TAP_LDIR)/libtap.so + g++ -DTEST_GALERA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ generate_set_session_csv: generate_set_session_csv.cpp - g++ -o generate_set_session_csv generate_set_session_csv.cpp $(OPT) + g++ $< $(OPT) -o $@ -aurora: aurora.cpp $(TAP_LIBDIR)/libtap.a - g++ -DTEST_AURORA aurora.cpp ../tap/SQLite3_Server.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o aurora -DGITVERSION=\"$(GIT_VERSION)\" +aurora: aurora.cpp $(TAP_LDIR)/libtap.so + g++ -DTEST_AURORA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ -test_tokenizer-t: test_tokenizer-t.cpp $(TAP_LIBDIR)/libtap.a - g++ test_tokenizer-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) -o test_tokenizer-t -DGITVERSION=\"$(GIT_VERSION)\" +test_tokenizer-t: test_tokenizer-t.cpp $(TAP_LDIR)/libtap.so + g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ -test_mysql_query_digests_stages-t: test_mysql_query_digests_stages-t.cpp $(TAP_LIBDIR)/libtap.a - g++ test_mysql_query_digests_stages-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) -o test_mysql_query_digests_stages-t -DGITVERSION=\"$(GIT_VERSION)\" +test_mysql_query_digests_stages-t: test_mysql_query_digests_stages-t.cpp $(TAP_LDIR)/libtap.so + g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ -sqlite3-t: sqlite3-t.cpp $(TAP_LIBDIR)/libtap.a - g++ sqlite3-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) $(LIBCOREDUMPERAR) -o sqlite3-t -DGITVERSION=\"$(GIT_VERSION)\" +sqlite3-t: sqlite3-t.cpp $(TAP_LDIR)/libtap.so + g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ -test_gtid_forwarding-t: test_gtid_forwarding-t.cpp $(TAP_LIBDIR)/libtap.a - g++ test_gtid_forwarding-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) -o test_gtid_forwarding-t -DGITVERSION=\"$(GIT_VERSION)\" +test_gtid_forwarding-t: test_gtid_forwarding-t.cpp $(TAP_LDIR)/libtap.so + g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ -test_admin_prometheus_metrics_dump-t: test_admin_prometheus_metrics_dump-t.cpp $(TAP_LIBDIR)/libtap.a - g++ test_admin_prometheus_metrics_dump-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) -o test_admin_prometheus_metrics_dump-t -DGITVERSION=\"$(GIT_VERSION)\" +test_admin_prometheus_metrics_dump-t: test_admin_prometheus_metrics_dump-t.cpp $(TAP_LDIR)/libtap.so + g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ -create_connection_annotation: test_connection_annotation-t.cpp - g++ -DTEST_AURORA test_connection_annotation-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(OBJ) $(MYLIBS) $(STATIC_LIBS) -o test_connection_annotation-t -DGITVERSION=\"$(GIT_VERSION)\" +create_connection_annotation: test_connection_annotation-t.cpp $(TAP_LDIR)/libtap.so + g++ -DTEST_AURORA $< $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBS) $(STATIC_LIBS) -o $@ -setparser_test: setparser_test.cpp $(TAP_LIBDIR)/libtap.a $(RE2_PATH)/util/test.cc $(LDIR)/set_parser.cpp $(LIBPROXYSQLAR) $(LIBCOREDUMPERAR) - g++ setparser_test.cpp $(RE2_PATH)/util/test.cc $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) $(WASAN) $(LIBCOREDUMPERAR) -o setparser_test -DGITVERSION=\"$(GIT_VERSION)\" +setparser_test: setparser_test.cpp $(TAP_LDIR)/libtap.so $(RE2_PATH)/util/test.cc $(PROXYSQL_LDIR)/set_parser.cpp $(LIBPROXYSQLAR) $(LIBCOREDUMPERAR) + g++ $< $(RE2_PATH)/util/test.cc $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(WASAN) $(LIBCOREDUMPERAR) -o $@ setparser_test2-t: setparser_test2 rm setparser_test2-t || true ln -s setparser_test2 setparser_test2-t -setparser_test2: setparser_test2.cpp $(TAP_LIBDIR)/libtap.a $(LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR) - g++ setparser_test2.cpp $(LDIR)/set_parser.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) $(WASAN) $(LIBCOREDUMPERAR) -o setparser_test2 -DGITVERSION=\"$(GIT_VERSION)\" +setparser_test2: setparser_test2.cpp $(TAP_LDIR)/libtap.so $(PROXYSQL_LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR) + g++ $< $(PROXYSQL_LDIR)/set_parser.cpp $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(WASAN) $(LIBCOREDUMPERAR) -o $@ setparser_test3-t: setparser_test3 rm setparser_test3-t || true ln -s setparser_test3 setparser_test3-t -setparser_test3: setparser_test3.cpp $(TAP_LIBDIR)/libtap.a $(LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR) - g++ -DPARSERDEBUG setparser_test3.cpp $(LDIR)/set_parser.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) $(WASAN) $(LIBCOREDUMPERAR) -o setparser_test3 -DGITVERSION=\"$(GIT_VERSION)\" +setparser_test3: setparser_test3.cpp $(TAP_LDIR)/libtap.so $(PROXYSQL_LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR) + g++ -DPARSERDEBUG $< $(PROXYSQL_LDIR)/set_parser.cpp $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(WASAN) $(LIBCOREDUMPERAR) -o $@ -CUSTOMARGS := -DGITVERSION=\"$(GIT_VERSION)\" -I$(SQLITE3_DIR) -I$(IDIR) -I$(CURL_IDIR) -I$(JSON_IDIR) -I../tap -L$(TAP_LIBDIR) -L$(CURL_LDIR) -Wl,-Bstatic -lcurl -Wl,-Bdynamic -ltap -lcpp_dotenv -lpthread -std=c++11 -lz -ldl +CUSTOMARGS := -I$(TAP_IDIR) -I$(CURL_IDIR) -I$(SQLITE3_IDIR) -I$(PROXYSQL_IDIR) -I$(JSON_IDIR) +CUSTOMARGS += -L$(TAP_LDIR) -L$(CURL_LDIR) +CUSTOMARGS += -Wl,-Bstatic -lcurl +CUSTOMARGS += -Wl,-Bdynamic -ltap -lcpp_dotenv -lpthread -lz -ldl CUSTOMARGS += $(OPT) -reg_test_3504-change_user_libmariadb_helper: reg_test_3504-change_user_helper.cpp $(TAP_LIBDIR)/libtap.so - $(CXX) reg_test_3504-change_user_helper.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -std=c++11 $(STATIC_LIBS) -o reg_test_3504-change_user_libmariadb_helper -DGITVERSION=\"$(GIT_VERSION)\" +reg_test_3504-change_user_libmariadb_helper: reg_test_3504-change_user_helper.cpp $(TAP_LDIR)/libtap.so + $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ + +reg_test_3504-change_user_libmysql_helper: reg_test_3504-change_user_helper.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DLIBMYSQL_HELPER $< -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o $@ + +test_clickhouse_server_libmysql-t: test_clickhouse_server-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DLIBMYSQL_HELPER $< -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o $@ -reg_test_3504-change_user_libmysql_helper: reg_test_3504-change_user_helper.cpp - $(CXX) -DLIBMYSQL_HELPER reg_test_3504-change_user_helper.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o reg_test_3504-change_user_libmysql_helper +reg_test_stmt_resultset_err_no_rows_libmysql-t: reg_test_stmt_resultset_err_no_rows-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DLIBMYSQL_HELPER $< -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o $@ -test_clickhouse_server_libmysql-t: test_clickhouse_server-t.cpp - $(CXX) -DLIBMYSQL_HELPER test_clickhouse_server-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o test_clickhouse_server_libmysql-t +reg_test_mariadb_stmt_store_result_libmysql-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DLIBMYSQL_HELPER $< -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o $@ -reg_test_stmt_resultset_err_no_rows_libmysql-t: reg_test_stmt_resultset_err_no_rows-t.cpp - $(CXX) -DLIBMYSQL_HELPER reg_test_stmt_resultset_err_no_rows-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o reg_test_stmt_resultset_err_no_rows_libmysql-t +reg_test_mariadb_stmt_store_result_async-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DASYNC_API $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl -ltap $(STATIC_LIBS) -o $@ -reg_test_mariadb_stmt_store_result_libmysql-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) -DLIBMYSQL_HELPER reg_test_mariadb_stmt_store_result-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o reg_test_mariadb_stmt_store_result_libmysql-t +prepare_statement_err3024_libmysql-t: prepare_statement_err3024-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DLIBMYSQL_HELPER $< -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o $@ -reg_test_mariadb_stmt_store_result_async-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) -DASYNC_API reg_test_mariadb_stmt_store_result-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl -std=c++11 -ltap $(STATIC_LIBS) -o reg_test_mariadb_stmt_store_result_async-t +prepare_statement_err3024_async-t: prepare_statement_err3024-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DASYNC_API $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl -ltap $(STATIC_LIBS) -o $@ -prepare_statement_err3024_libmysql-t: prepare_statement_err3024-t.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) -DLIBMYSQL_HELPER prepare_statement_err3024-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o prepare_statement_err3024_libmysql-t +test_wexecvp_syscall_failures-t: test_wexecvp_syscall_failures-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) $^ $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -Wl,--wrap=pipe,--wrap=fcntl,--wrap=read,--wrap=poll -lpthread -ldl -ltap $(STATIC_LIBS) -o $@ -prepare_statement_err3024_async-t: prepare_statement_err3024-t.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) -DASYNC_API prepare_statement_err3024-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl -std=c++11 -ltap $(STATIC_LIBS) -o prepare_statement_err3024_async-t -DGITVERSION=\"$(GIT_VERSION)\" -test_wexecvp_syscall_failures-t: test_wexecvp_syscall_failures-t.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) $^ $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -std=c++11 -Wl,--wrap=pipe,--wrap=fcntl,--wrap=read,--wrap=poll -lpthread -ldl -ltap $(STATIC_LIBS) -o $@ +### clean targets + +.PHONY: clean +clean: + rm -f *-t galera_1_timeout_count galera_2_timeout_no_count aurora generate_set_session_csv set_testing-240.csv clickhouse_php_conn-t reg_test_3992_fast_forward_malformed_packet-pymysql-t || true diff --git a/test/tap/tests_with_deps/deprecate_eof_support/Makefile b/test/tap/tests_with_deps/deprecate_eof_support/Makefile index 29a8f4600f..496551f531 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/Makefile +++ b/test/tap/tests_with_deps/deprecate_eof_support/Makefile @@ -9,15 +9,36 @@ MARIADB_TEST_DEP := $(TEST_DEPS_PATH)/mariadb-client-library-3.1.9/mariadb-conne BASE_DIR_EXIST := $(shell if [ -d $(MARIADB_BASE_FOLDER) ]; then echo 1; else echo 0; fi) DEP_FOLDER_EMPTY := $(shell if [ -f $(MARIADB_TEST_DEP)/CMakeLists.txt ]; then echo 1; else echo 0; fi) + ifeq ($(BASE_DIR_EXIST),1) ifeq ($(DEP_FOLDER_EMPTY),0) $(error "Dependency folder '$(MARIADB_TEST_DEP)' is empty. Make sure folder is initialized.") endif + +GIT_VERSION ?= $(shell git describe --long --abbrev=7) +ifndef GIT_VERSION + $(error GIT_VERSION is not set) +endif + + PROXYSQL_PATH := ../../../.. +PROXYSQL_LDIR := $(PROXYSQL_PATH)/lib + DEPS_PATH := $(PROXYSQL_PATH)/deps + +### 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') +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) + WGCOV := ifeq ($(WITHGCOV),1) WGCOV := -DWITHGCOV --coverage -lgcov @@ -28,25 +49,26 @@ ifeq ($(WITHASAN),1) WASAN := -fsanitize=address endif -OPT := -O2 $(WGCOV) -Wl,--no-as-needed -LLP := $(shell pwd)/../../tap -TAP_LIBDIR := ../../tap +OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed $(WGCOV) -TESTS_DEPS := $(TAP_LIBDIR)/libtap.a $(MARIADB_TEST_DEP)/libmariadb/libmariadbclient.a +TAP_PATH := ../../tap +TAP_IDIR := $(TAP_PATH) +TAP_LDIR := $(TAP_PATH) -INCLUDEDIRS := -I$(PROXYSQL_PATH)/include -INCLUDEDIRS += -I$(DEPS_PATH)/sqlite3/sqlite3 -INCLUDEDIRS += -I$(DEPS_PATH)/json -INCLUDEDIRS += -I$(DEPS_PATH)/prometheus-cpp/prometheus-cpp/core/include -I$(DEPS_PATH)/prometheus-cpp/prometheus-cpp/pull/include -INCLUDEDIRS += -I$(DEPS_PATH)/libconfig/libconfig/lib -INCLUDEDIRS += -I$(DEPS_PATH)/jemalloc/jemalloc/include/jemalloc -INCLUDEDIRS += -I$(DEPS_PATH)/libhttpserver/libhttpserver/src -INCLUDEDIRS += -I$(DEPS_PATH)/libmicrohttpd/libmicrohttpd/src/include/ -INCLUDEDIRS += -I$(DEPS_PATH)/re2/re2 -INCLUDEDIRS += -I$(DEPS_PATH)/libev/libev -INCLUDEDIRS += -I$(MARIADB_TEST_DEP)/include +IDIRS := -I$(PROXYSQL_PATH)/include +IDIRS += -I$(DEPS_PATH)/sqlite3/sqlite3 +IDIRS += -I$(DEPS_PATH)/json +IDIRS += -I$(DEPS_PATH)/prometheus-cpp/prometheus-cpp/core/include -I$(DEPS_PATH)/prometheus-cpp/prometheus-cpp/pull/include +IDIRS += -I$(DEPS_PATH)/libconfig/libconfig/lib +IDIRS += -I$(DEPS_PATH)/jemalloc/jemalloc/include/jemalloc +IDIRS += -I$(DEPS_PATH)/libhttpserver/libhttpserver/src +IDIRS += -I$(DEPS_PATH)/libmicrohttpd/libmicrohttpd/src/include/ +IDIRS += -I$(DEPS_PATH)/re2/re2 +IDIRS += -I$(DEPS_PATH)/libev/libev +IDIRS += -I$(MARIADB_TEST_DEP)/include + +TESTS_DEPS := $(TAP_LDIR)/libtap.so $(MARIADB_TEST_DEP)/libmariadb/libmariadbclient.a -PROXYLDIR := $(PROXYSQL_PATH)/lib .PHONY: default default: all @@ -56,7 +78,7 @@ all: build_deps tests .PHONY: debug debug: DEBUG := -DDEBUG -debug: OPT := -O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WGCOV) $(WASAN) +debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WGCOV) $(WASAN) debug: build_deps tests @@ -64,7 +86,7 @@ $(MARIADB_TEST_DEP)/libmariadb/libmariadbclient.a: cd $(MARIADB_BASE_FOLDER) && CC=${CC} CXX=${CXX} ${MAKE} mariadb_client .PHONY: build_deps -build_deps: $(MARIADB_TEST_DEP)/libmariadb/libmariadbclient.a +build_deps: $(TESTS_DEPS) .PHONY: clean @@ -78,43 +100,43 @@ clean: tests: $(patsubst %.cpp,%,$(wildcard *-t.cpp)) fwd_eof_query fwd_eof_ok_query -COMMONARGS1 := $(OPT) -std=c++11 -I$(TAP_LIBDIR) -L$(TAP_LIBDIR) -ltap -lcpp_dotenv -Wl,--no-as-needed -lz -ldl -lpthread -DGITVERSION=\"$(GIT_VERSION)\" -DDEBUG -COMMONARGS := $(COMMONARGS1) $(MYLIBS) + +COMMONARGS := $(OPT) -I$(TAP_IDIR) -L$(TAP_LDIR) -ltap -lcpp_dotenv -Wl,--no-as-needed -lz -ldl -lpthread -DGITVERSION=\"$(GIT_VERSION)\" ok_packet_mixed_queries-t: eof_packet_mixed_queries-t.cpp $(TESTS_DEPS) - $(CXX) $< $(INCLUDEDIRS) $(LDIRS) -lmysqlclient $(COMMONARGS) -o $@ + $(CXX) $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadb $(COMMONARGS) -o $@ eof_packet_mixed_queries-t: eof_packet_mixed_queries-t.cpp ok_packet_mixed_queries-t $(TESTS_DEPS) - $(CXX) -DNON_EOF_SUPPORT $< $(INCLUDEDIRS) -I$(MARIADB_TEST_DEP)/include/ -L$(MARIADB_TEST_DEP)/libmariadb -lmysqlclient $(COMMONARGS) -o $@ + $(CXX) -DNON_EOF_SUPPORT $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadb $(COMMONARGS) -o $@ fwd_eof_query: fwd_eof_query.cpp $(TESTS_DEPS) - $(CXX) -DNON_EOF_SUPPORT $< $(INCLUDEDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmysqlclient $(COMMONARGS) -o $@ - -#fwd_eof_ok_query: fwd_eof_query.cpp $(TESTS_DEPS) -# $(CXX) -DDEBUG fwd_eof_query.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 -I$(TAP_LIBDIR) -L$(TAP_LIBDIR) $(MYLIBS) -L$(SSL_LDIR) -ltap -Wl,--no-as-needed -ldl -lpthread -o fwd_eof_ok_query -DGITVERSION=\"$(GIT_VERSION)\" + $(CXX) -DNON_EOF_SUPPORT $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadb $(COMMONARGS) -o $@ # NOTE: Compilation with 'libmysql' instead of 'libmariadb' client to confirm packet sequence id isn't check by 'libmariadb' -fwd_eof_ok_query: fwd_eof_query.cpp fwd_eof_query $(TAP_LIBDIR)/libtap.a - $(CXX) $< $(INCLUDEDIRS) -I/usr/include/mysql/ -lmysqlclient -I$(IDIR) -L/usr/lib/x86_64-linux-gnu/ $(COMMONARGS1) -o $@ +fwd_eof_ok_query: fwd_eof_query.cpp fwd_eof_query $(TAP_LDIR)/libtap.so + $(CXX) $< $(IDIRS) -I/usr/include/mysql/ -lmysqlclient -I$(IDIR) -L/usr/lib/x86_64-linux-gnu/ $(COMMONARGS) -o $@ +# NOTE end deprecate_eof_cache-t: deprecate_eof_cache-t.cpp $(TESTS_DEPS) - $(CXX) $^ $(INCLUDEDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -L$(PROXYLDIR) -lproxysql $(COMMONARGS) -o $@ + $(CXX) $^ $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadb -L$(PROXYSQL_LDIR) -lproxysql $(COMMONARGS) -o $@ eof_cache_mixed_flags-t: eof_cache_mixed_flags-t.cpp $(TESTS_DEPS) - $(CXX) $^ $(INCLUDEDIRS) -L$(MARIADB_TEST_DEP)/libmariadb $(COMMONARGS) -o $@ + $(CXX) $^ $(IDIRS) $(COMMONARGS) -o $@ eof_mixed_flags_queries-t: eof_mixed_flags_queries-t.cpp $(TESTS_DEPS) - $(CXX) $^ $(INCLUDEDIRS) -L$(MARIADB_TEST_DEP)/libmariadb $(COMMONARGS) -o $@ + $(CXX) $^ $(IDIRS) $(COMMONARGS) -o $@ eof_conn_options_check-t: eof_conn_options_check-t.cpp $(TESTS_DEPS) - $(CXX) $< $(INCLUDEDIRS) $(LDIRS) -lmysqlclient $(COMMONARGS) -o $@ + $(CXX) $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadb $(COMMONARGS) -o $@ eof_fast_forward-t: eof_fast_forward-t.cpp $(TESTS_DEPS) - $(CXX) $< $(INCLUDEDIRS) $(LDIRS) -lmysqlclient $(COMMONARGS) -o $@ + $(CXX) $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadb $(COMMONARGS) -o $@ + $(TAP_LIBDIR)/libtap.a: cd ../../tap && CC=${CC} CXX=${CXX} ${MAKE} + else .PHONY: all all: