summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/librdkafka-2.1.0/mklove
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 12:08:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 12:08:18 +0000
commit5da14042f70711ea5cf66e034699730335462f66 (patch)
tree0f6354ccac934ed87a2d555f45be4c831cf92f4a /src/fluent-bit/lib/librdkafka-2.1.0/mklove
parentReleasing debian version 1.44.3-2. (diff)
downloadnetdata-5da14042f70711ea5cf66e034699730335462f66.tar.xz
netdata-5da14042f70711ea5cf66e034699730335462f66.zip
Merging upstream version 1.45.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/fluent-bit/lib/librdkafka-2.1.0/mklove')
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/.gitignore1
-rwxr-xr-xsrc/fluent-bit/lib/librdkafka-2.1.0/mklove/Makefile.base329
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.atomics144
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.base2484
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.builtin70
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.cc186
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.cxx8
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.fileversion65
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.gitversion29
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.good_cflags18
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.host132
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.lib49
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libcurl99
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libsasl236
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libssl147
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libzstd58
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.parseversion95
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.pic16
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.socket20
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.zlib61
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/README.md8
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/libcurl.0000-no-runtime-linking-check.patch11
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/libssl.0000-osx-rand-include-fix-OpenSSL-PR16409.patch56
23 files changed, 4122 insertions, 0 deletions
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/.gitignore b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/.gitignore
new file mode 100644
index 000000000..3f9cfafd3
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/.gitignore
@@ -0,0 +1 @@
+deps
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/Makefile.base b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/Makefile.base
new file mode 100755
index 000000000..91be43917
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/Makefile.base
@@ -0,0 +1,329 @@
+# Base Makefile providing various standard targets
+# Part of mklove suite but may be used independently.
+
+MKL_RED?= \033[031m
+MKL_GREEN?= \033[032m
+MKL_YELLOW?= \033[033m
+MKL_BLUE?= \033[034m
+MKL_CLR_RESET?= \033[0m
+
+DEPS= $(OBJS:%.o=%.d)
+
+# TOPDIR is "TOPDIR/mklove/../" i.e., TOPDIR.
+# We do it with two dir calls instead of /.. to support mklove being symlinked.
+MKLOVE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+TOPDIR = $(MKLOVE_DIR:mklove/=.)
+
+
+# Convert LIBNAME ("libxyz") to "xyz"
+LIBNAME0=$(LIBNAME:lib%=%)
+
+# Silence lousy default ARFLAGS (rv)
+ARFLAGS=
+
+ifndef MKL_MAKEFILE_CONFIG
+-include $(TOPDIR)/Makefile.config
+endif
+
+# Use C compiler as default linker.
+# C++ libraries will need to override this with CXX after
+# including Makefile.base
+CC_LD?=$(CC)
+
+_UNAME_S := $(shell uname -s)
+ifeq ($(_UNAME_S),Darwin)
+ LIBFILENAME=$(LIBNAME).$(LIBVER)$(SOLIB_EXT)
+ LIBFILENAMELINK=$(LIBNAME)$(SOLIB_EXT)
+ LIBFILENAMEDBG=$(LIBNAME)-dbg.$(LIBVER)$(SOLIB_EXT)
+ LDD_PRINT="otool -L"
+else
+ LIBFILENAME=$(LIBNAME)$(SOLIB_EXT).$(LIBVER)
+ LIBFILENAMELINK=$(LIBNAME)$(SOLIB_EXT)
+ LIBFILENAMEDBG=$(LIBNAME)-dbg$(SOLIB_EXT).$(LIBVER)
+ LDD_PRINT="ldd"
+endif
+
+# DESTDIR must be an absolute path
+ifneq ($(DESTDIR),)
+DESTDIR:=$(abspath $(DESTDIR))
+endif
+
+INSTALL?= install
+INSTALL_PROGRAM?= $(INSTALL)
+INSTALL_DATA?= $(INSTALL) -m 644
+
+prefix?= /usr/local
+exec_prefix?= $(prefix)
+bindir?= $(exec_prefix)/bin
+sbindir?= $(exec_prefix)/sbin
+libexecdir?= $(exec_prefix)/libexec/ # append PKGNAME on install
+datarootdir?= $(prefix)/share
+datadir?= $(datarootdir) # append PKGNAME on install
+sysconfdir?= $(prefix)/etc
+sharedstatedir?=$(prefix)/com
+localestatedir?=$(prefix)/var
+runstatedir?= $(localestatedir)/run
+includedir?= $(prefix)/include
+docdir?= $(datarootdir)/doc/$(PKGNAME)
+infodir?= $(datarootdir)/info
+libdir?= $(prefix)/lib
+localedir?= $(datarootdir)/locale
+pkgconfigdir?= $(libdir)/pkgconfig
+mandir?= $(datarootdir)/man
+man1dir?= $(mandir)/man1
+man2dir?= $(mandir)/man2
+man3dir?= $(mandir)/man3
+man4dir?= $(mandir)/man4
+man5dir?= $(mandir)/man5
+man6dir?= $(mandir)/man6
+man7dir?= $(mandir)/man7
+man8dir?= $(mandir)/man8
+
+# An application Makefile should set DISABLE_LDS=y prior to
+# including Makefile.base if it does not wish to have a linker-script.
+ifeq ($(WITH_LDS)-$(DISABLE_LDS),y-)
+# linker-script file
+LIBNAME_LDS?=$(LIBNAME).lds
+endif
+
+# Checks that mklove is set up and ready for building
+mklove-check:
+ @if [ ! -f "$(TOPDIR)/Makefile.config" ]; then \
+ printf "$(MKL_RED)$(TOPDIR)/Makefile.config missing: please run ./configure$(MKL_CLR_RESET)\n" ; \
+ exit 1 ; \
+ fi
+
+%.o: %.c
+ $(CC) -MD -MP $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+
+%.o: %.cpp
+ $(CXX) -MD -MP $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+
+
+lib: $(LIBFILENAME) $(LIBNAME).a $(LIBNAME)-static.a $(LIBFILENAMELINK) lib-gen-pkg-config
+
+# Linker-script (if WITH_LDS=y): overridable by application Makefile
+$(LIBNAME_LDS):
+
+$(LIBFILENAME): $(OBJS) $(LIBNAME_LDS)
+ @printf "$(MKL_YELLOW)Creating shared library $@$(MKL_CLR_RESET)\n"
+ $(CC_LD) $(LDFLAGS) $(LIB_LDFLAGS) $(OBJS) -o $@ $(LIBS)
+ cp $@ $(LIBFILENAMEDBG)
+ifeq ($(WITH_STRIP),y)
+ $(STRIP) -S $@
+endif
+
+$(LIBNAME).a: $(OBJS)
+ @printf "$(MKL_YELLOW)Creating static library $@$(MKL_CLR_RESET)\n"
+ $(AR) rcs$(ARFLAGS) $@ $(OBJS)
+ cp $@ $(LIBNAME)-dbg.a
+ifeq ($(WITH_STRIP),y)
+ $(STRIP) -S $@
+ $(RANLIB) $@
+endif
+
+ifeq ($(MKL_NO_SELFCONTAINED_STATIC_LIB),y)
+_STATIC_FILENAME=$(LIBNAME).a
+$(LIBNAME)-static.a:
+
+else # MKL_NO_SELFCONTAINED_STATIC_LIB
+
+ifneq ($(MKL_STATIC_LIBS),)
+_STATIC_FILENAME=$(LIBNAME)-static.a
+$(LIBNAME)-static.a: $(LIBNAME).a
+ @printf "$(MKL_YELLOW)Creating self-contained static library $@$(MKL_CLR_RESET)\n"
+ifeq ($(HAS_LIBTOOL_STATIC),y)
+ $(LIBTOOL) -static -o $@ - $(LIBNAME).a $(MKL_STATIC_LIBS)
+else ifeq ($(HAS_GNU_AR),y)
+ (_tmp=$$(mktemp arstaticXXXXXX) ; \
+ echo "CREATE $@" > $$_tmp ; \
+ for _f in $(LIBNAME).a $(MKL_STATIC_LIBS) ; do \
+ echo "ADDLIB $$_f" >> $$_tmp ; \
+ done ; \
+ echo "SAVE" >> $$_tmp ; \
+ echo "END" >> $$_tmp ; \
+ cat $$_tmp ; \
+ ar -M < $$_tmp || exit 1 ; \
+ rm $$_tmp)
+else
+ for _f in $(LIBNAME).a $(MKL_STATIC_LIBS) ; do \
+ ar -r $@ $$_f ; \
+ done
+endif
+ cp $@ $(LIBNAME)-static-dbg.a
+# The self-contained static library is always stripped, regardless
+# of --enable-strip, since otherwise it would become too big.
+ $(STRIP) -S $@
+ $(RANLIB) $@
+
+ifneq ($(MKL_DYNAMIC_LIBS),)
+ @printf "$(MKL_RED)WARNING:$(MKL_YELLOW) $@: The following libraries were not available as static libraries and need to be linked dynamically: $(MKL_DYNAMIC_LIBS)$(MKL_CLR_RESET)\n"
+endif # MKL_DYNAMIC_LIBS
+
+else # MKL_STATIC_LIBS is empty
+_STATIC_FILENAME=$(LIBNAME).a
+$(LIBNAME)-static.a: $(LIBNAME).a
+ @printf "$(MKL_RED)WARNING:$(MKL_YELLOW) $@: No static libraries available/enabled for inclusion in self-contained static library $@: this library will be identical to $(LIBNAME).a$(MKL_CLR_RESET)\n"
+ifneq ($(MKL_DYNAMIC_LIBS),)
+ @printf "$(MKL_RED)WARNING:$(MKL_YELLOW) $@: The following libraries were not available as static libraries and need to be linked dynamically: $(MKL_DYNAMIC_LIBS)$(MKL_CLR_RESET)\n"
+ cp $(LIBNAME).a $@
+ cp $(LIBNAME)-dbg.a $(LIBNAME)-static-dbg.a
+ cp $@ $(LIBNAME)-static-dbg.a
+endif # MKL_DYNAMIC_LIBS
+endif # MKL_STATIC_LIBS
+
+endif # MKL_NO_SELFCONTAINED_STATIC_LIB
+
+$(LIBFILENAMELINK): $(LIBFILENAME)
+ @printf "$(MKL_YELLOW)Creating $@ symlink$(MKL_CLR_RESET)\n"
+ rm -f "$@" && ln -s "$^" "$@"
+
+
+# pkg-config .pc file definition
+ifeq ($(GEN_PKG_CONFIG),y)
+define _PKG_CONFIG_DEF
+prefix=$(prefix)
+libdir=$(libdir)
+includedir=$(includedir)
+
+Name: $(LIBNAME)
+Description: $(MKL_APP_DESC_ONELINE)
+Version: $(MKL_APP_VERSION)
+Requires.private: $(MKL_PKGCONFIG_REQUIRES_PRIVATE)
+Cflags: -I$${includedir}
+Libs: -L$${libdir} -l$(LIBNAME0)
+Libs.private: $(MKL_PKGCONFIG_LIBS_PRIVATE)
+endef
+
+export _PKG_CONFIG_DEF
+
+define _PKG_CONFIG_STATIC_DEF
+prefix=$(prefix)
+libdir=$(libdir)
+includedir=$(includedir)
+
+Name: $(LIBNAME)-static
+Description: $(MKL_APP_DESC_ONELINE) (static)
+Version: $(MKL_APP_VERSION)
+Requires: $(MKL_PKGCONFIG_REQUIRES:rdkafka=rdkafka-static)
+Cflags: -I$${includedir}
+Libs: -L$${libdir} $${pc_sysrootdir}$${libdir}/$(_STATIC_FILENAME) $(MKL_PKGCONFIG_LIBS_PRIVATE)
+endef
+
+export _PKG_CONFIG_STATIC_DEF
+
+$(LIBNAME0).pc: $(TOPDIR)/Makefile.config
+ @printf "$(MKL_YELLOW)Generating pkg-config file $@$(MKL_CLR_RESET)\n"
+ @echo "$$_PKG_CONFIG_DEF" > $@
+
+$(LIBNAME0)-static.pc: $(TOPDIR)/Makefile.config $(LIBNAME)-static.a
+ @printf "$(MKL_YELLOW)Generating pkg-config file $@$(MKL_CLR_RESET)\n"
+ @echo "$$_PKG_CONFIG_STATIC_DEF" > $@
+
+lib-gen-pkg-config: $(LIBNAME0).pc $(LIBNAME0)-static.pc
+
+lib-clean-pkg-config:
+ rm -f $(LIBNAME0).pc $(LIBNAME0)-static.pc
+else
+lib-gen-pkg-config:
+lib-clean-pkg-config:
+endif
+
+
+$(BIN): $(OBJS)
+ @printf "$(MKL_YELLOW)Creating program $@$(MKL_CLR_RESET)\n"
+ $(CC_LD) $(CPPFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(LIBS)
+
+
+file-check:
+ @printf "$(MKL_YELLOW)Checking $(LIBNAME) integrity$(MKL_CLR_RESET)\n"
+ @RET=true ; \
+ for f in $(CHECK_FILES) ; do \
+ printf "%-30s " $$f ; \
+ if [ -f "$$f" ]; then \
+ printf "$(MKL_GREEN)OK$(MKL_CLR_RESET)\n" ; \
+ else \
+ printf "$(MKL_RED)MISSING$(MKL_CLR_RESET)\n" ; \
+ RET=false ; \
+ fi ; \
+ done ; \
+ $$RET
+
+copyright-check:
+ @(_exit=0 ; \
+ for f in $$(git ls-tree -r --name-only HEAD | \
+ egrep '\.(c|h|cpp|sh|py|pl)$$' ) ; do \
+ if [ -n "$(MKL_COPYRIGHT_SKIP)" ] && echo "$$f" | egrep -q "$(MKL_COPYRIGHT_SKIP)" ; then \
+ continue ; \
+ fi ; \
+ if ! head -40 $$f | grep -qi copyright $$f ; then \
+ echo error: Copyright missing in $$f ; \
+ _exit=1 ; \
+ fi; \
+ done ; \
+ exit $$_exit)
+
+
+lib-install:
+ @printf "$(MKL_YELLOW)Install $(LIBNAME) to $$DESTDIR$(prefix)$(MKL_CLR_RESET)\n"
+ $(INSTALL) -d $$DESTDIR$(includedir)/$(PKGNAME)
+ $(INSTALL) -d $$DESTDIR$(libdir)
+ $(INSTALL) $(HDRS) $$DESTDIR$(includedir)/$(PKGNAME)
+ $(INSTALL) $(LIBNAME).a $$DESTDIR$(libdir)
+ [ ! -f $(LIBNAME)-static.a ] || $(INSTALL) $(LIBNAME)-static.a $$DESTDIR$(libdir)
+ $(INSTALL) $(LIBFILENAME) $$DESTDIR$(libdir)
+ [ -f "$(LIBNAME0).pc" ] && ( \
+ $(INSTALL) -d $$DESTDIR$(pkgconfigdir) && \
+ $(INSTALL) -m 0644 $(LIBNAME0).pc $$DESTDIR$(pkgconfigdir) \
+ )
+ [ -f "$(LIBNAME0)-static.pc" ] && ( \
+ $(INSTALL) -d $$DESTDIR$(pkgconfigdir) && \
+ $(INSTALL) -m 0644 $(LIBNAME0)-static.pc $$DESTDIR$(pkgconfigdir) \
+ )
+ (cd $$DESTDIR$(libdir) && ln -sf $(LIBFILENAME) $(LIBFILENAMELINK))
+
+lib-uninstall:
+ @printf "$(MKL_YELLOW)Uninstall $(LIBNAME) from $$DESTDIR$(prefix)$(MKL_CLR_RESET)\n"
+ for hdr in $(HDRS) ; do \
+ rm -f $$DESTDIR$(includedir)/$(PKGNAME)/$$hdr ; done
+ rm -f $$DESTDIR$(libdir)/$(LIBNAME).a
+ rm -f $$DESTDIR$(libdir)/$(LIBNAME)-static.a
+ rm -f $$DESTDIR$(libdir)/$(LIBFILENAME)
+ rm -f $$DESTDIR$(libdir)/$(LIBFILENAMELINK)
+ rmdir $$DESTDIR$(includedir)/$(PKGNAME) || true
+ rm -f $$DESTDIR$(pkgconfigdir)/$(LIBNAME0).pc
+ rm -f $$DESTDIR$(pkgconfigdir)/$(LIBNAME0)-static.pc
+ rmdir $$DESTDIR$(pkgconfigdir) || true
+
+bin-install:
+ @printf "$(MKL_YELLOW)Install $(BIN) to $$DESTDIR$(prefix)$(MKL_CLR_RESET)\n"
+ $(INSTALL) -d $$DESTDIR$(bindir) && \
+ $(INSTALL) $(BIN) $$DESTDIR$(bindir)
+
+bin-uninstall:
+ @printf "$(MKL_YELLOW)Uninstall $(BIN) from $$DESTDIR$(prefix)$(MKL_CLR_RESET)\n"
+ rm -f $$DESTDIR$(bindir)/$(BIN)
+ rmdir $$DESTDIR$(bindir) || true
+
+doc-install: $(DOC_FILES)
+ @printf "$(MKL_YELLOW)Installing documentation to $$DESTDIR$(prefix)$(MKL_CLR_RESET)\n"
+ $(INSTALL) -d $$DESTDIR$(docdir)
+ $(INSTALL) $(DOC_FILES) $$DESTDIR$(docdir)
+
+doc-uninstall:
+ @printf "$(MKL_YELLOW)Uninstall documentation from $$DESTDIR$(prefix)$(MKL_CLR_RESET)\n"
+ for _f in $(DOC_FILES) ; do rm -f $$DESTDIR$(docdir)/$$_f ; done
+ rmdir $$DESTDIR$(docdir) || true
+
+generic-clean:
+ rm -f $(OBJS) $(DEPS)
+
+lib-clean: generic-clean lib-clean-pkg-config
+ rm -f $(LIBNAME)*.a $(LIBFILENAME) $(LIBFILENAMEDBG) \
+ $(LIBFILENAMELINK) $(LIBNAME_LDS)
+
+bin-clean: generic-clean
+ rm -f $(BIN)
+
+deps-clean:
+ rm -rf "$(MKLOVE_DIR)/deps"
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.atomics b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.atomics
new file mode 100644
index 000000000..31639a7e4
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.atomics
@@ -0,0 +1,144 @@
+#!/bin/bash
+#
+# Checks for atomic ops:
+# compiler builtin (__sync_..) and portable libatomic's (__atomic_..)
+# Will also provide abstraction by defining the prefix to use.
+#
+# Sets:
+# HAVE_ATOMICS
+# HAVE_ATOMICS_32
+# HAVE_ATOMICS_64
+# HAVE_ATOMICS_32_ATOMIC __atomic interface
+# HAVE_ATOMICS_32_SYNC __sync interface
+# HAVE_ATOMICS_64_ATOMIC __atomic interface
+# HAVE_ATOMICS_64_SYNC __sync interface
+# WITH_LIBATOMIC
+# LIBS
+#
+# ATOMIC_OP(OP1,OP2,PTR,VAL)
+# ATOMIC_OP32(OP1,OP2,PTR,VAL)
+# ATOMIC_OP64(OP1,OP2,PTR,VAL)
+# where op* is 'add,sub,fetch'
+# e.g: ATOMIC_OP32(add, fetch, &i, 10)
+# becomes __atomic_add_fetch(&i, 10, ..) or
+# __sync_add_and_fetch(&i, 10)
+#
+
+function checks {
+
+
+ # We prefer the newer __atomic stuff, but 64-bit atomics might
+ # require linking with -latomic, so we need to perform these tests
+ # in the proper order:
+ # __atomic 32
+ # __atomic 32 -latomic
+ # __sync 32
+ #
+ # __atomic 64
+ # __atomic 64 -latomic
+ # __sync 64
+
+ local _libs=
+ local _a32="__atomic_ ## OP1 ## _ ## OP2(PTR, VAL, __ATOMIC_SEQ_CST)"
+ local _a64="__atomic_ ## OP1 ## _ ## OP2(PTR, VAL, __ATOMIC_SEQ_CST)"
+
+ # 32-bit:
+ # Try fully builtin __atomic
+ if ! mkl_compile_check __atomic_32 HAVE_ATOMICS_32 cont CC "" \
+ "
+#include <inttypes.h>
+int32_t foo (int32_t i) {
+ return __atomic_add_fetch(&i, 1, __ATOMIC_SEQ_CST);
+}"
+ then
+ # Try __atomic with -latomic
+ if mkl_compile_check --ldflags="-latomic" __atomic_32_lib HAVE_ATOMICS_32 \
+ cont CC "" \
+ "
+#include <inttypes.h>
+int32_t foo (int32_t i) {
+ return __atomic_add_fetch(&i, 1, __ATOMIC_SEQ_CST);
+}"
+ then
+ _libs="-latomic"
+ mkl_allvar_set "__atomic_32_lib" "HAVE_ATOMICS_32_ATOMIC" "y"
+ else
+ # Try __sync interface
+ if mkl_compile_check __sync_32 HAVE_ATOMICS_32 disable CC "" \
+ "
+#include <inttypes.h>
+int32_t foo (int32_t i) {
+ return __sync_add_and_fetch(&i, 1);
+}"
+ then
+ _a32="__sync_ ## OP1 ## _and_ ## OP2(PTR, VAL)"
+ mkl_allvar_set "__sync_32" "HAVE_ATOMICS_32_SYNC" "y"
+ else
+ _a32=""
+ fi
+ fi
+ else
+ mkl_allvar_set "__atomic_32" "HAVE_ATOMICS_32_ATOMIC" "y"
+ fi
+
+
+ if [[ ! -z $_a32 ]]; then
+ mkl_define_set "atomic_32" "ATOMIC_OP32(OP1,OP2,PTR,VAL)" "code:$_a32"
+ fi
+
+
+
+ # 64-bit:
+ # Try fully builtin __atomic
+ if ! mkl_compile_check __atomic_64 HAVE_ATOMICS_64 cont CC "" \
+ "
+#include <inttypes.h>
+int64_t foo (int64_t i) {
+ return __atomic_add_fetch(&i, 1, __ATOMIC_SEQ_CST);
+}"
+ then
+ # Try __atomic with -latomic
+ if mkl_compile_check --ldflags="-latomic" __atomic_64_lib HAVE_ATOMICS_64 \
+ cont CC "" \
+ "
+#include <inttypes.h>
+int64_t foo (int64_t i) {
+ return __atomic_add_fetch(&i, 1, __ATOMIC_SEQ_CST);
+}"
+ then
+ _libs="-latomic"
+ mkl_allvar_set "__atomic_64_lib" "HAVE_ATOMICS_64_ATOMIC" "y"
+ else
+ # Try __sync interface
+ if mkl_compile_check __sync_64 HAVE_ATOMICS_64 disable CC "" \
+ "
+#include <inttypes.h>
+int64_t foo (int64_t i) {
+ return __sync_add_and_fetch(&i, 1);
+}"
+ then
+ _a64="__sync_ ## OP1 ## _and_ ## OP2 (PTR, VAL)"
+ mkl_allvar_set "__sync_64" "HAVE_ATOMICS_64_SYNC" "y"
+ else
+ _a64=""
+ fi
+ fi
+ else
+ mkl_allvar_set "__atomic_64" "HAVE_ATOMICS_64_ATOMIC" "y"
+ fi
+
+
+ if [[ ! -z $_a64 ]]; then
+ mkl_define_set "atomic_64" "ATOMIC_OP64(OP1,OP2,PTR,VAL)" "code:$_a64"
+
+ # Define generic ATOMIC() macro identical to 64-bit atomics"
+ mkl_define_set "atomic_64" "ATOMIC_OP(OP1,OP2,PTR,VAL)" "code:$_a64"
+ fi
+
+
+ if [[ ! -z $_libs ]]; then
+ mkl_mkvar_append LDFLAGS LDFLAGS "-Wl,--as-needed"
+ mkl_mkvar_append LIBS LIBS "$_libs"
+ fi
+
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.base b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.base
new file mode 100644
index 000000000..1e216692b
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.base
@@ -0,0 +1,2484 @@
+#!/bin/bash
+#
+#
+# mklove base configure module, implements the mklove configure framework
+#
+
+MKL_MODULES="base"
+MKL_CACHEVARS="CFLAGS LDFLAGS PKG_CONFIG_PATH"
+MKL_MKVARS=""
+MKL_DEFINES=""
+MKL_CHECKS=""
+MKL_LOAD_STACK=""
+
+MKL_IDNEXT=1
+
+# Default mklove directory to PWD/mklove
+[[ -z "$MKLOVE_DIR" ]] && MKLOVE_DIR="$PWD/mklove"
+
+MKL_OUTMK="$PWD/_mklout.mk"
+MKL_OUTH="$PWD/_mklout.h"
+MKL_OUTDBG="$PWD/config.log"
+
+MKL_GENERATORS="base:mkl_generate_late_vars"
+MKL_CLEANERS=""
+
+MKL_FAILS=""
+MKL_LATE_VARS=""
+
+MKL_OPTS_SET=""
+
+MKL_RED=""
+MKL_GREEN=""
+MKL_YELLOW=""
+MKL_BLUE=""
+MKL_CLR_RESET=""
+
+
+MKL_NO_DOWNLOAD=0
+MKL_INSTALL_DEPS=n
+MKL_SOURCE_DEPS_ONLY=n
+
+MKL_DESTDIR_ADDED=n
+
+if [[ -z "$MKL_REPO_URL" ]]; then
+ MKL_REPO_URL="http://github.com/edenhill/mklove/raw/master"
+fi
+
+
+
+###########################################################################
+#
+# Variable types:
+# env - Standard environment variables.
+# var - mklove runtime variable, cached or not.
+# mkvar - Makefile variables, also sets runvar
+# define - config.h variables/defines
+#
+###########################################################################
+
+# Low level variable assignment
+# Arguments:
+# variable name
+# variable value
+function mkl_var0_set {
+ export "$1"="$2"
+}
+
+# Sets a runtime variable (only used during configure)
+# If "cache" is provided these variables are cached to config.cache.
+# Arguments:
+# variable name
+# variable value
+# [ "cache" ]
+function mkl_var_set {
+ mkl_var0_set "$1" "$2"
+ if [[ $3 == "cache" ]]; then
+ if ! mkl_in_list "$MKL_CACHEVARS" "$1" ; then
+ MKL_CACHEVARS="$MKL_CACHEVARS $1"
+ fi
+ fi
+}
+
+# Unsets a mkl variable
+# Arguments:
+# variable name
+function mkl_var_unset {
+ unset $1
+}
+
+# Appends to a mkl variable (space delimited)
+# Arguments:
+# variable name
+# variable value
+function mkl_var_append {
+ if [[ -z ${!1} ]]; then
+ mkl_var_set "$1" "$2"
+ else
+ mkl_var0_set "$1" "${!1} $2"
+ fi
+}
+
+
+# Prepends to a mkl variable (space delimited)
+# Arguments:
+# variable name
+# variable value
+function mkl_var_prepend {
+ if [[ -z ${!1} ]]; then
+ mkl_var_set "$1" "$2"
+ else
+ mkl_var0_set "$1" "$2 ${!1}"
+ fi
+}
+
+# Shift the first word off a variable.
+# Arguments:
+# variable name
+function mkl_var_shift {
+ local n="${!1}"
+ mkl_var0_set "$1" "${n#* }"
+ return 0
+}
+
+
+# Returns the contents of mkl variable
+# Arguments:
+# variable name
+function mkl_var_get {
+ echo "${!1}"
+}
+
+
+
+
+# Set environment variable (runtime)
+# These variables are not cached nor written to any of the output files,
+# its just simply a helper wrapper for standard envs.
+# Arguments:
+# varname
+# varvalue
+function mkl_env_set {
+ mkl_var0_set "$1" "$2"
+}
+
+# Append to environment variable
+# Arguments:
+# varname
+# varvalue
+# [ separator (" ") ]
+function mkl_env_append {
+ local sep=" "
+ if [[ -z ${!1} ]]; then
+ mkl_env_set "$1" "$2"
+ else
+ [ ! -z ${3} ] && sep="$3"
+ mkl_var0_set "$1" "${!1}${sep}$2"
+ fi
+
+}
+
+# Prepend to environment variable
+# Arguments:
+# varname
+# varvalue
+# [ separator (" ") ]
+function mkl_env_prepend {
+ local sep=" "
+ if [[ -z ${!1} ]]; then
+ mkl_env_set "$1" "$2"
+ else
+ [ ! -z ${3} ] && sep="$3"
+ mkl_var0_set "$1" "$2${sep}${!1}"
+ fi
+
+}
+
+
+
+
+# Set a make variable (Makefile.config)
+# Arguments:
+# config name
+# variable name
+# value
+function mkl_mkvar_set {
+ if [[ ! -z $2 ]]; then
+ mkl_env_set "$2" "$3"
+ mkl_in_list "$MKL_MKVARS" "$2"|| mkl_env_append MKL_MKVARS $2
+ fi
+}
+
+
+# Prepends to a make variable (Makefile.config)
+# Arguments:
+# config name
+# variable name
+# value
+# [ separator (" ") ]
+function mkl_mkvar_prepend {
+ if [[ ! -z $2 ]]; then
+ mkl_env_prepend "$2" "$3" "$4"
+ mkl_in_list "$MKL_MKVARS" "$2"|| mkl_env_append MKL_MKVARS $2
+ fi
+}
+
+
+# Appends to a make variable (Makefile.config)
+# Arguments:
+# config name
+# variable name
+# value
+# [ separator (" ") ]
+function mkl_mkvar_append {
+ if [[ ! -z $2 ]]; then
+ mkl_env_append "$2" "$3" "$4"
+ mkl_in_list "$MKL_MKVARS" "$2"|| mkl_env_append MKL_MKVARS $2
+ fi
+}
+
+
+# Prepends to a make variable (Makefile.config)
+# Arguments:
+# config name
+# variable name
+# value
+# [ separator (" ") ]
+function mkl_mkvar_prepend {
+ if [[ ! -z $2 ]]; then
+ mkl_env_prepend "$2" "$3" "$4"
+ mkl_in_list "$MKL_MKVARS" "$2"|| mkl_env_append MKL_MKVARS $2
+ fi
+}
+
+# Return mkvar variable value
+# Arguments:
+# variable name
+function mkl_mkvar_get {
+ [[ -z ${!1} ]] && return 1
+ echo ${!1}
+ return 0
+}
+
+
+
+# Defines a config header define (config.h)
+# Arguments:
+# config name
+# define name
+# define value (optional, default: 1)
+# if value starts with code: then no "" are added
+function mkl_define_set {
+
+ if [[ -z $2 ]]; then
+ return 0
+ fi
+
+ local stmt=""
+ local defid=
+ if [[ $2 = *\(* ]]; then
+ # macro
+ defid="def_${2%%(*}"
+ else
+ # define
+ defid="def_$2"
+ fi
+
+ [[ -z $1 ]] || stmt="// $1\n"
+
+ local val="$3"
+ if [[ -z "$val" ]]; then
+ val="$(mkl_def $2 1)"
+ fi
+
+ # Define as code, string or integer?
+ if [[ $val == code:* ]]; then
+ # Code block, copy verbatim without quotes, strip code: prefix
+ val=${val#code:}
+ elif [[ ! ( "$val" =~ ^[0-9]+([lL]?[lL][dDuU]?)?$ || \
+ "$val" =~ ^0x[0-9a-fA-F]+([lL]?[lL][dDuU]?)?$ ) ]]; then
+ # String: quote
+ val="\"$val\""
+ fi
+ # else: unquoted integer/hex
+
+ stmt="${stmt}#define $2 $val"
+ mkl_env_set "$defid" "$stmt"
+ mkl_env_append MKL_DEFINES "$defid"
+}
+
+
+
+
+
+# Sets "all" configuration variables, that is:
+# for name set: Makefile variable, config.h define
+# Will convert value "y"|"n" to 1|0 for config.h
+# Arguments:
+# config name
+# variable name
+# value
+function mkl_allvar_set {
+ mkl_mkvar_set "$1" "$2" "$3"
+ local val=$3
+ if [[ $3 = "y" ]]; then
+ val=1
+ elif [[ $3 = "n" ]]; then
+ val=0
+ fi
+ mkl_define_set "$1" "$2" "$val"
+}
+
+
+###########################################################################
+#
+# Dependency installation, et.al.
+#
+#
+###########################################################################
+
+# Returns the local dependency directory.
+function mkl_depdir {
+ local dir="$MKLOVE_DIR/deps"
+ [[ -d $dir ]] || mkdir -p "$dir"
+ if ! grep -q ^deps$ "$MKLOVE_DIR/.gitignore" 2>/dev/null ; then
+ echo "deps" >> "$MKLOVE_DIR/.gitignore"
+ fi
+
+ echo "$dir"
+}
+
+# Returns the package's installation directory / DESTDIR.
+function mkl_dep_destdir {
+ echo "$(mkl_depdir)/dest"
+}
+
+# Returns the package's source directory.
+function mkl_dep_srcdir {
+ echo "$(mkl_depdir)/src/$1"
+}
+
+
+# Get the static library file name(s) for a package.
+function mkl_lib_static_fnames {
+ local name=$1
+ mkl_meta_get $name "static" ""
+}
+
+
+# Returns true if previous ./configure ran a dep install for this package.
+function mkl_dep_install_cached {
+ local name=$1
+
+ if [[ -n $(mkl_var_get "MKL_STATUS_${1}_INSTALL") ]] ||
+ [[ -n $(mkl_var_get "MKL_STATUS_${1}_INSTALL_SRC") ]]; then
+ return 0 # true
+ else
+ return 1 # false
+ fi
+}
+
+# Install an external dependency using the platform's native
+# package manager.
+# Should only be called from mkl_dep_install
+#
+# Param 1: config name
+function mkl_dep_install_pkg {
+ local name=$1
+ local iname="${name}_INSTALL"
+ local retcode=1 # default to fail
+ local method="none"
+ local pkgs
+ local cmd
+
+ mkl_dbg "Attempting native install of dependency $name on $MKL_DISTRO with effective user $EUID"
+
+
+ # Try the platform specific installer first.
+ case ${MKL_DISTRO}-${EUID} in
+ debian-0|ubuntu-0)
+ method=apt
+ pkgs=$(mkl_meta_get $name deb)
+ cmd="apt install -y $pkgs"
+ ;;
+
+ centos-0|rhel-0|redhat-0|fedora-0)
+ method=yum
+ pkgs=$(mkl_meta_get $name rpm)
+ cmd="yum install -y $pkgs"
+ ;;
+
+ alpine-0)
+ method=apk
+ pkgs=$(mkl_meta_get $name apk)
+ cmd="apk add $pkgs"
+ ;;
+
+ osx-*)
+ method=brew
+ pkgs=$(mkl_meta_get $name brew)
+ cmd="brew install $pkgs"
+ ;;
+
+ *)
+ mkl_dbg "$name: No native installer set for $name on $MKL_DISTRO (euid $EUID)"
+ return 1
+ ;;
+ esac
+
+ if [[ -z $pkgs ]]; then
+ mkl_dbg "$name: No packages to install ($method)"
+ return 1
+ fi
+
+ mkl_check_begin --verb "installing dependencies ($cmd)" $iname "" no-cache "$name"
+ $cmd >>$MKL_OUTDBG 2>&1
+ retcode=$?
+
+ if [[ $retcode -eq 0 ]]; then
+ mkl_dbg "Native install of $name (using $method, $cmd) succeeded"
+ mkl_check_done "$iname" "" cont "using $method"
+ mkl_meta_set $name installed_with "$method"
+ elif [[ $method != "none" ]]; then
+ mkl_dbg "Native install of $name (using $method, $cmd) failed: retcode $retcode"
+ mkl_check_failed "$iname" "" cont "using $method"
+ fi
+
+ return $retcode
+}
+
+
+# Returns 0 (yes) if this dependency has a source builder, else 1 (no)
+function mkl_dep_has_builder {
+ local name=$1
+ local func="${name}_install_source"
+ mkl_func_exists $func
+}
+
+
+# Returns 0 (yes) if this dependency has a package installer, else 1 (no)
+function mkl_dep_has_installer {
+ local name=$1
+ if mkl_dep_has_builder "$name" || \
+ [[ -n $(mkl_meta_get $name deb) ]] || \
+ [[ -n $(mkl_meta_get $name rpm) ]] || \
+ [[ -n $(mkl_meta_get $name brew) ]] || \
+ [[ -n $(mkl_meta_get $name apk) ]]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+
+# Install an external dependency from source.
+#
+# The resulting libraries must be installed in $ddir/usr/lib (or lib64),
+# and include files in $ddir/usr/include.
+#
+# Any dependency installed from source will be linked statically
+# regardless of --enable-static, if the build produced static libraries.
+
+#
+# Param 1: config name
+function mkl_dep_install_source {
+ local name=$1
+ local iname="${name}_INSTALL_SRC"
+ local retcode=
+
+ local func="${name}_install_source"
+
+ if ! mkl_dep_has_builder $name ; then
+ mkl_dbg "No source builder for $name ($func) available"
+ return 1
+ fi
+
+ mkl_check_begin --verb "building dependency" $iname "" no-cache "$name"
+
+ # Create install directory / DESTDIR
+ local ddir=$(mkl_dep_destdir $name)
+ [[ -d $ddir ]] || mkdir -p "$ddir"
+
+ # Create and go to source directory
+ local sdir=$(mkl_dep_srcdir $name)
+ [[ -d $sdir ]] || mkdir -p "$sdir"
+ mkl_pushd "$sdir"
+
+ local ilog="${sdir}/_mkl_install.log"
+
+ # Build and install
+ mkl_dbg "Building $name from source in $sdir (func $func)"
+
+ $func $name "$ddir" >$ilog 2>&1
+ retcode=$?
+
+ mkl_popd # $sdir
+
+ if [[ $retcode -eq 0 ]]; then
+ mkl_dbg "Source install of $name succeeded"
+ mkl_check_done "$iname" "" cont "ok" "from source"
+ mkl_meta_set $name installed_with "source"
+ else
+ mkl_dbg "Source install of $name failed"
+ mkl_check_failed "$iname" "" disable "source installer failed (see $ilog)"
+ mkl_err "$name source build failed, see $ilog for details. First 50 and last 50 lines:"
+ head -50 "$ilog"
+ echo " .... and last 50 lines ...."
+ tail -50 "$ilog"
+ fi
+
+ return $retcode
+}
+
+
+# Tries to resolve/find full paths to static libraries for a module,
+# using the provided scan dir path.
+# Any found libraries are set as STATIC_LIB_.. defines.
+#
+# Param 1: config name
+# Param 2: scandir
+#
+# Returns 0 if libraries were found, else 1.
+function mkl_resolve_static_libs {
+ local name="$1"
+ local scandir="$2"
+ local stlibfnames=$(mkl_lib_static_fnames $name)
+ local stlibvar="STATIC_LIB_${name}"
+
+ if [[ -z $stlibfnames || -n "${!stlibvar}" ]]; then
+ mkl_dbg "$name: not resolving static libraries (stlibfnames=$stlibfnames, $stlibvar=${!stlibvar})"
+ mkl_allvar_set "$name" "WITH_STATIC_LIB_$name" y
+ return 1
+ fi
+
+ local fname=
+ local stlibs=""
+ mkl_dbg "$name: resolving static libraries from $stlibfnames in $scandir"
+ for fname in $stlibfnames ; do
+ local stlib=$(find "${scandir}" -name "$fname" 2>/dev/null | head -1)
+ if [[ -n $stlib ]]; then
+ stlibs="${stlibs} $stlib"
+ fi
+ done
+
+ # Trim leading whitespaces
+ stlibs=${stlibs# }
+
+ if [[ -n $stlibs ]]; then
+ mkl_dbg "$name: $stlibvar: found static libs: $stlibs"
+ mkl_var_set $stlibvar "$stlibs" "cache"
+ mkl_allvar_set "$name" "WITH_STATIC_LIB_$name" y
+ return 0
+ else
+ mkl_dbg "$name: did not find any static libraries for $stlibfnames in ${scandir}"
+ return 1
+ fi
+}
+
+
+# Install an external dependecy
+#
+# Param 1: config name (e.g zstd)
+function mkl_dep_install {
+ local name=$1
+ local retcode=
+
+ local ddir=$(mkl_dep_destdir $name)
+
+ if [[ $MKL_SOURCE_DEPS_ONLY != y ]] || ! mkl_dep_has_builder $name ; then
+ #
+ # Try native package manager first, or if no source builder
+ # is available for this dependency.
+ #
+ mkl_dep_install_pkg $name
+ retcode=$?
+
+ if [[ $retcode -eq 0 ]]; then
+ return $retcode
+ fi
+ fi
+
+ #
+ # Try source installer.
+ #
+ mkl_dep_install_source $name
+ retcode=$?
+
+ if [[ $retcode -ne 0 ]]; then
+ if [[ $MKL_SOURCE_DEPS_ONLY == y ]]; then
+ # Require dependencies, regardless of original action,
+ # if --source-deps-only is specified, to ensure
+ # that we do indeed link with the desired library.
+ mkl_fail "$name" "" fail "Failed to install dependency $name"
+ fi
+ return $retcode
+ fi
+
+ local ddir=$(mkl_dep_destdir $name)
+
+ # Find the static library(s), if any.
+ if ! mkl_resolve_static_libs "$name" "${ddir}/usr"; then
+ # No static libraries found, set up dynamic linker path
+ mkl_mkvar_prepend LDFLAGS LDFLAGS "-L${ddir}/usr/lib64 -L${ddir}/usr/lib"
+ fi
+
+ # Add the deps destdir to various build flags so that tools can pick
+ # up the artifacts (.pc files, includes, libs, etc) they need.
+ if [[ $MKL_DESTDIR_ADDED == n ]]; then
+ # Add environment variables so that later built dependencies
+ # can find this one.
+ mkl_env_prepend LDFLAGS "-L${ddir}/usr/lib64 -L${ddir}/usr/lib"
+ mkl_env_prepend CPPFLAGS "-I${ddir}/usr/include"
+ mkl_env_prepend PKG_CONFIG_PATH "${ddir}/usr/lib/pkgconfig" ":"
+ # And tell pkg-config to get static linker flags.
+ mkl_env_set PKG_CONFIG "${PKG_CONFIG} --static"
+ MKL_DESTDIR_ADDED=y
+ fi
+
+ # Append the package's install path to compiler and linker flags.
+ mkl_dbg "$name: Adding install-deps paths ($ddir) to compiler and linker flags"
+ mkl_mkvar_prepend CPPFLAGS CPPFLAGS "-I${ddir}/usr/include"
+
+ return $retcode
+}
+
+
+# Apply patch to a source dependency.
+#
+# Param 1: config name (e.g. libssl)
+# Param 2: patch number (optional, else all)
+#
+# Returns 0 on success or 1 on error.
+function mkl_patch {
+ local name=$1
+ local patchnr="$2"
+
+ if [[ -z $patchnr ]]; then
+ patchnr="????"
+ fi
+
+ local patchfile=
+ local cnt=0
+ for patchfile in $(echo ${MKLOVE_DIR}/modules/patches/${name}.${patchnr}-*.patch | sort); do
+ mkl_dbg "$1: applying patch $patchfile"
+ patch -p1 < $patchfile
+ local retcode=$?
+ if [[ $retcode != 0 ]]; then
+ mkl_err "mkl_patch: $1: failed to apply patch $patchfile: see source dep build log for details"
+ return 1
+ fi
+ cnt=$(($cnt + 1))
+ done
+
+ if [[ $cnt -lt 1 ]]; then
+ mkl_err "mkl_patch: $1: no patches matchign $patchnr found"
+ return 1
+ fi
+
+ return 0
+}
+
+
+###########################################################################
+#
+#
+# Check failure functionality
+#
+#
+###########################################################################
+
+
+# Summarize all fatal failures and then exits.
+function mkl_fail_summary {
+ echo "
+
+"
+
+ local pkg_cmd=""
+ local install_pkgs=""
+ mkl_err "###########################################################"
+ mkl_err "### Configure failed ###"
+ mkl_err "###########################################################"
+ mkl_err "### Accumulated failures: ###"
+ mkl_err "###########################################################"
+ local n
+ for n in $MKL_FAILS ; do
+ local conf=$(mkl_var_get MKL_FAIL__${n}__conf)
+ mkl_err " $conf ($(mkl_var_get MKL_FAIL__${n}__define)) $(mkl_meta_get $conf name)"
+ if mkl_meta_exists $conf desc; then
+ mkl_err0 " desc: $MKL_YELLOW$(mkl_meta_get $conf desc)$MKL_CLR_RESET"
+ fi
+ mkl_err0 " module: $(mkl_var_get MKL_FAIL__${n}__module)"
+ mkl_err0 " action: $(mkl_var_get MKL_FAIL__${n}__action)"
+ mkl_err0 " reason:
+$(mkl_var_get MKL_FAIL__${n}__reason)
+"
+ # Dig up some metadata to assist the user
+ case $MKL_DISTRO in
+ debian|ubuntu)
+ local debs=$(mkl_meta_get $conf "deb")
+ pkg_cmd="sudo apt install -y"
+ if [[ ${#debs} > 0 ]]; then
+ install_pkgs="$install_pkgs $debs"
+ fi
+ ;;
+ centos|rhel|redhat|fedora)
+ local rpms=$(mkl_meta_get $conf "rpm")
+ pkg_cmd="sudo yum install -y"
+ if [[ ${#rpms} > 0 ]]; then
+ install_pkgs="$install_pkgs $rpms"
+ fi
+ ;;
+ alpine)
+ local apks=$(mkl_meta_get $conf "apk")
+ pkg_cmd="apk add "
+ if [[ ${#apks} > 0 ]]; then
+ install_pkgs="$install_pkgs $apks"
+ fi
+ ;;
+ osx)
+ local pkgs=$(mkl_meta_get $conf "brew")
+ pkg_cmd="brew install"
+ if [[ ${#pkgs} > 0 ]]; then
+ install_pkgs="$install_pkgs $pkgs"
+ fi
+ ;;
+ esac
+ done
+
+ if [[ ! -z $install_pkgs ]]; then
+ mkl_err "###########################################################"
+ mkl_err "### Installing the following packages might help: ###"
+ mkl_err "###########################################################"
+ mkl_err0 "$pkg_cmd $install_pkgs"
+ mkl_err0 ""
+ fi
+ exit 1
+}
+
+
+# Checks if there were failures.
+# Returns 0 if there were no failures, else calls failure summary and exits.
+function mkl_check_fails {
+ if [[ ${#MKL_FAILS} = 0 ]]; then
+ return 0
+ fi
+ mkl_fail_summary
+}
+
+# A check has failed but we want to carry on (and we should!).
+# We fail it all later.
+# Arguments:
+# config name
+# define name
+# action
+# reason
+function mkl_fail {
+ local n="$(mkl_env_esc "$1")"
+ mkl_var_set "MKL_FAIL__${n}__conf" "$1"
+ mkl_var_set "MKL_FAIL__${n}__module" $MKL_MODULE
+ mkl_var_set "MKL_FAIL__${n}__define" $2
+ mkl_var_set "MKL_FAIL__${n}__action" "$3"
+ if [[ -z $(mkl_var_get "MKL_FAIL__${n}__reason") ]]; then
+ mkl_var_set "MKL_FAIL__${n}__reason" "$4"
+ else
+ mkl_var_append "MKL_FAIL__${n}__reason" "
+And also:
+$4"
+ fi
+ mkl_in_list "$MKL_FAILS" "$n" || mkl_var_append MKL_FAILS "$n"
+}
+
+
+# A check failed, handle it
+# Arguments:
+# config name
+# define name
+# action (fail|disable|ignore|cont)
+# reason
+function mkl_check_failed {
+ # Override action based on require directives, unless the action is
+ # set to cont (for fallthrough to sub-sequent tests).
+ local action="$3"
+ if [[ $3 != "cont" ]]; then
+ action=$(mkl_meta_get "MOD__$MKL_MODULE" "override_action" $3)
+ fi
+
+ # --fail-fatal option
+ [[ $MKL_FAILFATAL ]] && action="fail"
+
+ mkl_check_done "$1" "$2" "$action" "failed"
+ mkl_dbg "Check $1 ($2, action $action (originally $3)) failed: $4"
+
+
+ case $action in
+ fail)
+ # Check failed fatally, fail everything eventually
+ mkl_fail "$1" "$2" "$3" "$4"
+ return 1
+ ;;
+
+ disable)
+ # Check failed, disable
+ [[ ! -z $2 ]] && mkl_mkvar_set "$1" "$2" "n"
+ return 1
+ ;;
+ ignore)
+ # Check failed but we ignore the results and set it anyway.
+ [[ ! -z $2 ]] && mkl_define_set "$1" "$2" "1"
+ [[ ! -z $2 ]] && mkl_mkvar_set "$1" "$2" "y"
+ return 1
+ ;;
+ cont)
+ # Check failed but we ignore the results and do nothing.
+ return 0
+ ;;
+ esac
+}
+
+
+
+
+###########################################################################
+#
+#
+# Output generators
+#
+#
+###########################################################################
+
+# Generate late variables.
+# Late variables are those referenced in command line option defaults
+# but then never set by --option.
+function mkl_generate_late_vars {
+ local n
+ for n in $MKL_LATE_VARS ; do
+ local func=${n%:*}
+ local safeopt=${func#opt_}
+ local val=${n#*:}
+ if mkl_in_list "$MKL_OPTS_SET" "$safeopt" ; then
+ # Skip options set explicitly with --option
+ continue
+ fi
+ # Expand variable references "\$foo" by calling eval
+ # and pass it opt_... function.
+ $func "$(eval echo $val)"
+ done
+}
+
+
+# Generate MKL_DYNAMIC_LIBS and MKL_STATIC_LIBS for Makefile.config
+#
+# Params: $LIBS
+function mkl_generate_libs {
+ while [[ $# -gt 0 ]]; do
+ if [[ $1 == -l* ]]; then
+ mkl_mkvar_append "" MKL_DYNAMIC_LIBS $1
+ elif [[ $1 == *.a ]]; then
+ mkl_mkvar_append "" MKL_STATIC_LIBS $1
+ elif [[ $1 == -framework ]]; then
+ mkl_mkvar_append "" MKL_DYNAMIC_LIBS "$1 $2"
+ shift # two args
+ else
+ mkl_dbg "Ignoring arg $1 from LIBS while building STATIC and DYNAMIC lists"
+ fi
+ shift # remove arg
+ done
+}
+
+# Generate output files.
+# Must be called following a succesful configure run.
+function mkl_generate {
+
+ # Generate MKL_STATIC_LIBS and MKL_DYNAMIC_LIBS from LIBS
+ mkl_generate_libs $LIBS
+
+ local mf=
+ for mf in $MKL_GENERATORS ; do
+ MKL_MODULE=${mf%:*}
+ local func=${mf#*:}
+ $func || exit 1
+ done
+
+ # Generate a built-in options define based on WITH_..=y
+ local with_y=
+ for n in $MKL_MKVARS ; do
+ if [[ $n == WITH_* ]] && [[ $n != WITH_STATIC_LIB_* ]] && [[ ${!n} == y ]]; then
+ with_y="$with_y ${n#WITH_}"
+ fi
+ done
+ with_y="${with_y# }"
+
+ mkl_allvar_set "BUILT_WITH" "BUILT_WITH" "$with_y"
+
+ mkl_write_mk "# Automatically generated by $0 $*"
+ mkl_write_mk "# Config variables"
+ mkl_write_mk "#"
+ mkl_write_mk "# Generated by:"
+ mkl_write_mk "# $MKL_CONFIGURE_ARGS"
+ mkl_write_mk ""
+
+ # This variable is used by Makefile.base to avoid multiple inclusions.
+ mkl_write_mk "MKL_MAKEFILE_CONFIG=y"
+
+ # Export colors to Makefile.config
+ mkl_write_mk "MKL_RED=\t${MKL_RED}"
+ mkl_write_mk "MKL_GREEN=\t${MKL_GREEN}"
+ mkl_write_mk "MKL_YELLOW=\t${MKL_YELLOW}"
+ mkl_write_mk "MKL_BLUE=\t${MKL_BLUE}"
+ mkl_write_mk "MKL_CLR_RESET=\t${MKL_CLR_RESET}"
+
+ local n=
+ for n in $MKL_MKVARS ; do
+ # Some special variables should be prefixable by the caller, so
+ # define them in the makefile as appends.
+ local op="="
+ case $n in
+ CFLAGS|CPPFLAGS|CXXFLAGS|LDFLAGS|LIBS)
+ op="+="
+ ;;
+ esac
+ mkl_write_mk "$n$op\t${!n}"
+ done
+ mkl_write_mk "# End of config variables"
+
+ MKL_OUTMK_FINAL=Makefile.config
+ mv $MKL_OUTMK $MKL_OUTMK_FINAL
+
+ echo "Generated $MKL_OUTMK_FINAL"
+
+ # Generate config.h
+ mkl_write_h "// Automatically generated by $0 $*"
+ mkl_write_h "#ifndef _CONFIG_H_"
+ mkl_write_h "#define _CONFIG_H_"
+ for n in $MKL_DEFINES ; do
+ mkl_write_h "${!n}"
+ done
+ mkl_write_h "#endif /* _CONFIG_H_ */"
+
+ MKL_OUTH_FINAL=config.h
+ mv $MKL_OUTH $MKL_OUTH_FINAL
+
+ echo "Generated $MKL_OUTH_FINAL"
+}
+
+# Remove file noisily, if it exists
+function mkl_rm {
+ if [[ -f $fname ]]; then
+ echo "Removing $fname"
+ rm -f "$fname"
+ fi
+}
+
+# Remove files generated by configure
+function mkl_clean {
+ for fname in Makefile.config config.h config.cache config.log ; do
+ mkl_rm "$fname"
+ done
+
+ local mf=
+ for mf in $MKL_CLEANERS ; do
+ MKL_MODULE=${mf%:*}
+ local func=${mf#*:}
+ $func || exit 1
+ done
+
+}
+
+
+# Print summary of succesful configure run
+function mkl_summary {
+
+ echo "
+Configuration summary:"
+ local n=
+ for n in $MKL_MKVARS ; do
+ # Skip the boring booleans
+ if [[ $n == ENABLE_* || $n == WITH_* || $n == WITHOUT_* || $n == HAVE_* || $n == def_* ]]; then
+ continue
+ fi
+ printf " %-24s %s\n" "$n" "${!n}"
+ done
+}
+
+
+
+# Write to mk file
+# Argument:
+# string ..
+function mkl_write_mk {
+ echo -e "$*" >> $MKL_OUTMK
+}
+
+# Write to header file
+# Argument:
+# string ..
+function mkl_write_h {
+ echo -e "$*" >> $MKL_OUTH
+}
+
+
+
+###########################################################################
+#
+#
+# Logging and debugging
+#
+#
+###########################################################################
+
+# Debug print
+# Only visible on terminal if MKL_DEBUG is set.
+# Always written to config.log
+# Argument:
+# string ..
+function mkl_dbg {
+ if [[ ! -z $MKL_DEBUG ]]; then
+ echo -e "${MKL_BLUE}DBG:$$: $*${MKL_CLR_RESET}" 1>&2
+ fi
+ echo "DBG $$: $*" >> $MKL_OUTDBG
+}
+
+# Error print (with color)
+# Always printed to terminal and config.log
+# Argument:
+# string ..
+function mkl_err {
+ echo -e "${MKL_RED}$*${MKL_CLR_RESET}" 1>&2
+ echo "$*" >> $MKL_OUTDBG
+}
+
+# Same as mkl_err but without coloring
+# Argument:
+# string ..
+function mkl_err0 {
+ echo -e "$*" 1>&2
+ echo "$*" >> $MKL_OUTDBG
+}
+
+# Standard print
+# Always printed to terminal and config.log
+# Argument:
+# string ..
+function mkl_info {
+ echo -e "$*" 1>&2
+ echo -e "$*" >> $MKL_OUTDBG
+}
+
+
+
+
+
+
+
+###########################################################################
+#
+#
+# Misc helpers
+#
+#
+###########################################################################
+
+# Returns the absolute path (but not necesarily canonical) of the first argument
+function mkl_abspath {
+ echo $1 | sed -e "s|^\([^/]\)|$PWD/\1|"
+}
+
+# Returns true (0) if function $1 exists, else false (1)
+function mkl_func_exists {
+ declare -f "$1" > /dev/null
+ return $?
+}
+
+# Rename function.
+# Returns 0 on success or 1 if old function (origname) was not defined.
+# Arguments:
+# origname
+# newname
+function mkl_func_rename {
+ if ! mkl_func_exists $1 ; then
+ return 1
+ fi
+ local orig=$(declare -f $1)
+ local new="$2${orig#$1}"
+ eval "$new"
+ unset -f "$1"
+ return 0
+}
+
+
+# Push module function for later call by mklove.
+# The function is renamed to an internal name.
+# Arguments:
+# list variable name
+# module name
+# function name
+function mkl_func_push {
+ local newfunc="__mkl__f_${2}_$(( MKL_IDNEXT++ ))"
+ if mkl_func_rename "$3" "$newfunc" ; then
+ mkl_var_append "$1" "$2:$newfunc"
+ fi
+}
+
+
+
+# Returns value, or the default string if value is empty.
+# Arguments:
+# value
+# default
+function mkl_def {
+ if [[ ! -z $1 ]]; then
+ echo $1
+ else
+ echo $2
+ fi
+}
+
+
+# Render a string (e.g., evaluate its $varrefs)
+# Arguments:
+# string
+function mkl_render {
+ if [[ $* == *\$* ]]; then
+ eval "echo $*"
+ else
+ echo "$*"
+ fi
+}
+
+# Escape a string so that it becomes suitable for being an env variable.
+# This is a destructive operation and the original string cannot be restored.
+function mkl_env_esc {
+ echo $* | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'
+}
+
+# Convert arguments to upper case
+function mkl_upper {
+ echo "$*" | tr '[:lower:]' '[:upper:]'
+}
+
+# Convert arguments to lower case
+function mkl_lower {
+ echo "$*" | tr '[:upper:]' '[:lower:]'
+}
+
+
+# Checks if element is in list
+# Arguments:
+# list
+# element
+function mkl_in_list {
+ local n
+ for n in $1 ; do
+ [[ $n == $2 ]] && return 0
+ done
+ return 1
+}
+
+
+# Silent versions of pushd and popd
+function mkl_pushd {
+ pushd "$1" >/dev/null
+}
+
+function mkl_popd {
+ popd >/dev/null
+}
+
+
+###########################################################################
+#
+#
+# Cache functionality
+#
+#
+###########################################################################
+
+
+# Write cache file
+function mkl_cache_write {
+ [[ ! -z "$MKL_NOCACHE" ]] && return 0
+ echo "# mklove configure cache file generated at $(date)" > config.cache
+ for n in $MKL_CACHEVARS ; do
+ echo "$n=${!n}" >> config.cache
+ done
+ echo "Generated config.cache"
+}
+
+
+# Read cache file
+function mkl_cache_read {
+ [[ ! -z "$MKL_NOCACHE" ]] && return 0
+ [ -f config.cache ] || return 1
+
+ echo "using cache file config.cache"
+
+ local ORIG_IFS=$IFS
+ IFS="$IFS="
+ while read -r n v ; do
+ [[ -z $n || $n = \#* || -z $v ]] && continue
+ # Don't let cache overwrite variables
+ [[ -n ${n+r} ]] || mkl_var_set $n $v cache
+ done < config.cache
+ IFS=$ORIG_IFS
+}
+
+
+###########################################################################
+#
+#
+# Config name meta data
+#
+#
+###########################################################################
+
+# Set metadata for config name
+# This metadata is used by mkl in various situations
+# Arguments:
+# config name
+# metadata key
+# metadata value (appended)
+function mkl_meta_set {
+ local metaname="mkl__$1__$2"
+ eval "$metaname=\"\$$metaname $3\""
+}
+
+# Returns metadata for config name
+# Arguments:
+# config name
+# metadata key
+# default (optional)
+function mkl_meta_get {
+ local metaname="mkl__$1__$2"
+ if [[ ! -z ${!metaname} ]]; then
+ echo ${!metaname}
+ else
+ echo "$3"
+ fi
+}
+
+# Checks if metadata exists
+# Arguments:
+# config name
+# metadata key
+function mkl_meta_exists {
+ local metaname="mkl__$1__$2"
+ if [[ ! -z ${!metaname} ]]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+
+
+
+
+###########################################################################
+#
+#
+# Check framework
+#
+#
+###########################################################################
+
+
+# Print that a check is beginning to run
+# Returns 0 if a cached result was used (do not continue with your tests),
+# else 1.
+#
+# If the check should not be cachable then specify argument 3 as "no-cache",
+# this is useful when a check not only checks but actually sets config
+# variables itself (which is not recommended, but desired sometimes).
+#
+# Arguments:
+# [ --verb "verb.." ] (replace "checking for")
+# config name
+# define name
+# action (fail,cont,disable or no-cache)
+# [ display name ]
+function mkl_check_begin {
+ local verb="checking for"
+ if [[ $1 == "--verb" ]]; then
+ verb="$2"
+ shift
+ shift
+ fi
+
+ local name=$(mkl_meta_get $1 name "$4")
+ [[ -z $name ]] && name="$1"
+
+ echo -n "$verb $name..."
+ if [[ $3 != "no-cache" ]]; then
+ local status=$(mkl_var_get "MKL_STATUS_$1")
+ # Check cache (from previous run or this one).
+ # Only used cached value if the cached check succeeded:
+ # it is more likely that a failed check has been fixed than the other
+ # way around.
+ if [[ ! -z $status && ( $status = "ok" ) ]]; then
+ mkl_check_done "$1" "$2" "$3" $status "cached"
+ return 0
+ fi
+ fi
+ return 1
+}
+
+
+# Calls the manual_checks function for the given module.
+# Use this for modules that provide check hooks that require
+# certain call ordering, such as dependent library checks.
+#
+# Param 1: module name
+function mkl_check {
+ local modname=$1
+
+ local func="${modname}_manual_checks"
+ if ! mkl_func_exists "$func" ; then
+ mkl_fail "Check function for module $modname not found: missing mkl_require $modname ?"
+ return 1
+ fi
+
+ $func
+ return $?
+}
+
+
+# Print that a check is done
+# Arguments:
+# config name
+# define name
+# action
+# status (ok|failed)
+# extra-info (optional)
+function mkl_check_done {
+ # Clean up configname to be a safe varname
+ local cname=${1//-/_}
+ mkl_var_set "MKL_STATUS_$cname" "$4" cache
+
+ mkl_dbg "Setting $1 ($cname) status to $4 (action $3)"
+
+ local extra=""
+ if [[ $4 = "failed" ]]; then
+ local clr=$MKL_YELLOW
+ extra=" ($3)"
+ case "$3" in
+ fail)
+ clr=$MKL_RED
+ ;;
+ cont)
+ extra=""
+ ;;
+ esac
+ echo -e " $clr$4$MKL_CLR_RESET${extra}"
+ else
+ [[ ! -z $2 ]] && mkl_define_set "$cname" "$2" "1"
+ [[ ! -z $2 ]] && mkl_mkvar_set "$cname" "$2" "y"
+ [ ! -z "$5" ] && extra=" ($5)"
+ echo -e " $MKL_GREEN$4${MKL_CLR_RESET}$extra"
+ fi
+}
+
+
+# Perform configure check by compiling source snippet
+# Arguments:
+# [--sub] (run checker as a sub-check, not doing begin/fail/ok)
+# [--ldflags="..." ] (appended after "compiler arguments" below)
+# config name
+# define name
+# action (fail|disable)
+# compiler (CC|CXX)
+# compiler arguments (optional "", example: "-lzookeeper")
+# source snippet
+function mkl_compile_check {
+
+ local sub=0
+ if [[ $1 == --sub ]]; then
+ sub=1
+ shift
+ fi
+
+ local ldf=
+ if [[ $1 == --ldflags=* ]]; then
+ ldf=${1#*=}
+ shift
+ fi
+
+ if [[ $sub -eq 0 ]]; then
+ mkl_check_begin "$1" "$2" "$3" "$1 (by compile)" && return $?
+ fi
+
+ local cflags=
+
+ if [[ $4 = "CXX" ]]; then
+ local ext=cpp
+ cflags="$(mkl_mkvar_get CXXFLAGS)"
+ else
+ local ext=c
+ cflags="$(mkl_mkvar_get CFLAGS)"
+ fi
+
+ local srcfile=$(mktemp _mkltmpXXXXXX)
+ mv "$srcfile" "${srcfile}.$ext"
+ srcfile="$srcfile.$ext"
+ echo "$6" > $srcfile
+ echo "
+int main () { return 0; }
+" >> $srcfile
+
+ local cmd="${!4} $cflags $(mkl_mkvar_get CPPFLAGS) -Wall -Werror $srcfile -o ${srcfile}.o $ldf $(mkl_mkvar_get LDFLAGS) $5 $(mkl_mkvar_get LIBS)";
+ mkl_dbg "Compile check $1 ($2) (sub=$sub): $cmd"
+
+ local output
+ output=$($cmd 2>&1)
+
+ if [[ $? != 0 ]] ; then
+ mkl_dbg "compile check for $1 ($2) failed: $cmd: $output"
+ [[ $sub -eq 0 ]] && mkl_check_failed "$1" "$2" "$3" "compile check failed:
+CC: $4
+flags: $5
+$cmd:
+$output
+source: $6"
+ local ret=1
+ else
+ [[ $sub -eq 0 ]] && mkl_check_done "$1" "$2" "$3" "ok"
+ local ret=0
+ fi
+
+ # OSX XCode toolchain creates dSYM directories when -g is set,
+ # delete them specifically.
+ rm -rf "$srcfile" "${srcfile}.o" "$srcfile*dSYM"
+
+ return $ret
+}
+
+
+# Low-level: Try to link with a library.
+# Arguments:
+# linker flags (e.g. "-lpthreads")
+function mkl_link_check0 {
+ local libs=$1
+ local srcfile=$(mktemp _mktmpXXXXXX)
+ echo "#include <stdio.h>
+int main () { FILE *fp = stderr; return fp ? 0 : 0; }" > ${srcfile}.c
+
+ local cmd="${CC} $(mkl_mkvar_get CFLAGS) $(mkl_mkvar_get LDFLAGS) ${srcfile}.c -o ${srcfile}_out $libs";
+ mkl_dbg "Link check for $1: $cmd"
+
+ local output
+ output=$($cmd 2>&1)
+ local retcode=$?
+
+ if [[ $retcode -ne 0 ]] ; then
+ mkl_dbg "Link check for $1 failed: $output"
+ fi
+
+ rm -f $srcfile*
+ return $retcode
+}
+
+
+# Try to link with a library.
+# Arguments:
+# config name
+# define name
+# action (fail|disable)
+# linker flags (e.g. "-lpthreads")
+function mkl_link_check {
+ mkl_check_begin "$1" "$2" "$3" "$1 (by linking)" && return $?
+
+ if mkl_link_check0 "$4" ; then
+ mkl_check_done "$1" "$2" "$3" "ok" "$4"
+ return 0
+ else
+ mkl_dbg "link check for $1 ($2) failed: $output"
+ mkl_check_failed "$1" "$2" "$3" "compile check failed:
+$output"
+ return 1
+ fi
+}
+
+
+
+# Tries to figure out if we can use a static library or not.
+#
+# WARNING: This function must not emit any stdout output other than the
+# updated list of libs. Do not use any stdout-printing checker.
+#
+# Arguments:
+# config name (e.g., zstd)
+# compiler flags (optional "", e.g: "-lzstd")
+# Returns/outputs:
+# New list of compiler flags
+function mkl_lib_check_static {
+ local configname=$1
+ local libs=$2
+ local arfile_var=STATIC_LIB_${configname}
+ local stfnames=$(mkl_lib_static_fnames $configname)
+
+ mkl_dbg "$configname: Check for static library (libs $libs, arfile variable $arfile_var=${!arfile_var}, static filenames $stfnames)"
+
+ # If STATIC_LIB_<configname> specifies .a file(s) we use that instead.
+ if [[ -n ${!arfile_var} ]]; then
+ libs="${!arfile_var}"
+
+ elif [[ $WITH_STATIC_LINKING != y ]]; then
+ # Static linking not enabled
+ echo ""
+ return
+
+ elif [[ $HAS_LDFLAGS_STATIC == y ]] && [[ -n $stfnames ]]; then
+ local libname
+ local stlibs=
+ for libname in $stfnames; do
+ # Convert the static filename to a linker flag:
+ # libzstd.a -> -lzstd
+ libname=${libname#lib}
+ libname="-l${libname%.a}"
+ stlibs="${stlibs}${libname} "
+ done
+ libs="${LDFLAGS_STATIC} $stlibs ${LDFLAGS_DYNAMIC}"
+ mkl_dbg "$configname: after replacing libs: $libs"
+
+ elif [[ $libs == *-L* ]]; then
+ # Try to resolve full static paths using any -Lpaths in $libs
+ local lpath
+ for lpath in $libs; do
+ [[ $lpath == -L* ]] || continue
+
+ lpath="${lpath#-L}"
+ [[ -d $lpath ]] || continue
+
+ if mkl_resolve_static_libs "$configname" "$lpath"; then
+ break
+ fi
+ done
+
+ libs="${!arfile_var}"
+ mkl_dbg "$configname: after -L resolve, libs is $libs"
+
+ else
+ mkl_dbg "$configname: Neither $arfile_var=/path/to/libname.a specified nor static linker flags supported: static linking probably won't work"
+ libs=""
+ fi
+
+ if [[ -z $libs ]]; then
+ echo ""
+ return
+ fi
+
+ # Attempt to link a small program with these static libraries
+ mkl_dbg "$configname: verifying that linking \"$libs\" works"
+ if ! mkl_link_check0 "$libs" ; then
+ mkl_dbg "$configname: Could not use static libray flags: $libs"
+ echo ""
+ return
+ fi
+
+ mkl_allvar_set "$configname" "${configname}_STATIC" "y"
+
+ echo $libs
+}
+
+
+# Checks that the specified lib is available through a number of methods.
+# compiler flags are automatically appended to "LIBS" mkvar on success.
+#
+# If STATIC_LIB_<libname_without_-l> is set to the path of an <libname>.a file
+# it will be used instead of -l<libname>.
+#
+# <definename>_STATIC will be automatically defined (for both Makefile.config
+# and config.h) if the library is to be linked statically, or was installed
+# with a source dependency installer.
+#
+# Arguments:
+# [--override-action=<action>] (internal use, overrides action argument)
+# [--no-static] (do not attempt to link the library statically)
+# [--libname=<lib>] (library name if different from config name, such as
+# when the libname includes a dash)
+# config name (library name (for pkg-config))
+# define name
+# action (fail|disable|cont)
+# compiler (CC|CXX)
+# compiler flags (optional "", e.g: "-lyajl")
+# source snippet
+function mkl_lib_check0 {
+
+ local override_action=
+ local nostaticopt=
+ local libnameopt=
+ local libname=
+
+ while [[ $1 == --* ]]; do
+ if [[ $1 == --override-action=* ]]; then
+ override_action=${1#*=}
+ elif [[ $1 == --no-static ]]; then
+ nostaticopt=$1
+ elif [[ $1 == --libname* ]]; then
+ libnameopt=$1
+ libname="${libnameopt#*=}"
+ else
+ mkl_err "mkl_lib_check: invalid option $1"
+ exit 1
+ fi
+ shift
+ done
+
+ if [[ -z $libname ]]; then
+ libname=$1
+ fi
+
+ local action=$3
+ if [[ -n $override_action ]]; then
+ action=$override_action
+ fi
+
+ # pkg-config result (0=ok)
+ local pkg_conf_failed=1
+ if [[ $WITH_PKGCONFIG == "y" ]]; then
+ # Let pkg-config populate CFLAGS, et.al.
+ # Return on success.
+ mkl_pkg_config_check $nostaticopt $libnameopt "$1" "$2" cont "$4" "$6" && return $?
+ fi
+
+ local libs="$5"
+ local is_static=0
+
+ if [[ -z $nostaticopt ]]; then
+ local stlibs=$(mkl_lib_check_static $1 "$libs")
+ if [[ -n $stlibs ]]; then
+ libs=$stlibs
+ is_static=1
+ fi
+ fi
+
+ if ! mkl_compile_check "$1" "$2" "$action" "$4" "$libs" "$6"; then
+ return 1
+ fi
+
+ if [[ -n $libs ]]; then
+ # Add libraries in reverse order to make sure inter-dependencies
+ # are resolved in the correct order.
+ # E.g., check for crypto and then ssl should result in -lssl -lcrypto
+ mkl_dbg "$1: from lib_check: LIBS: prepend $libs"
+ mkl_mkvar_prepend "$1" LIBS "$libs"
+ if [[ $is_static == 0 ]]; then
+ # Static libraries are automatically bundled with
+ # librdkafka-static.a so there is no need to add them as an
+ # external linkage dependency.
+ mkl_mkvar_prepend "$1" MKL_PKGCONFIG_LIBS_PRIVATE "$libs"
+ fi
+ fi
+
+ return 0
+}
+
+
+# Wrapper for mkl_lib_check0 which attempts dependency installation
+# if --install-deps is specified.
+#
+# See mkl_lib_check0 for arguments and details.
+function mkl_lib_check {
+
+ local arg=
+ local name=
+
+ # Find config name parameter (first non-option (--...))
+ for arg in $* ; do
+ if [[ $arg == --* ]]; then
+ continue
+ fi
+ name=$arg
+ break
+ done
+
+ if [[ $MKL_INSTALL_DEPS != y ]] || ! mkl_dep_has_installer "$name" ; then
+ mkl_lib_check0 "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
+ return $?
+ fi
+
+
+ # Automatic dependency installation mode:
+ # First pass is lib check with cont,
+ # if it fails, attempt dependency installation,
+ # and then make second with caller's fail-action.
+
+ local retcode=
+
+ # With --source-deps-only we want to make sure the dependency
+ # being used is in-fact from the dependency builder (if supported),
+ # rather than a system installed alternative, so skip the pre-check and
+ # go directly to dependency installation/build below.
+ if [[ $MKL_SOURCE_DEPS_ONLY != y ]] || ! mkl_dep_has_builder $name ; then
+ mkl_lib_check0 --override-action=cont "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
+ retcode=$?
+ if [[ $retcode -eq 0 ]]; then
+ # Successful on first pass
+ return $retcode
+ fi
+ else
+ mkl_dbg "$name: skipping dependency pre-check in favour of --source-deps-only"
+ fi
+
+ # Install dependency
+ if ! mkl_dep_install "$name" ; then
+ return 1
+ fi
+
+ # Second pass: check again, this time fail hard
+ mkl_lib_check0 --override-action=fail "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
+ return $?
+}
+
+
+
+# Check for library with pkg-config
+# Automatically sets CFLAGS and LIBS from pkg-config information.
+# Arguments:
+# [--no-static] (do not attempt to link the library statically)
+# [--libname=<lib>] (library name if different from config name, such as
+# when the libname includes a dash)
+# config name
+# define name
+# action (fail|disable|ignore|cont)
+# compiler (CC|CXX)
+# source snippet
+function mkl_pkg_config_check {
+
+ local nostaticopt=
+ if [[ $1 == --no-static ]]; then
+ nostaticopt=$1
+ shift
+ fi
+
+ local libname=$1
+ if [[ $1 == --libname* ]]; then
+ libname="${libnameopt#*=}"
+ shift
+ fi
+
+ local cname="${1}_PKGCONFIG"
+ mkl_check_begin "$cname" "$2" "no-cache" "$1 (by pkg-config)" && return $?
+
+ local cflags=
+ local cmd="${PKG_CONFIG} --short-errors --cflags $libname"
+ mkl_dbg "pkg-config check $libname for CFLAGS ($2): $cmd"
+
+ cflags=$($cmd 2>&1)
+ if [[ $? != 0 ]]; then
+ mkl_dbg "'$cmd' failed: $cflags"
+ # Clear define name ($2): caller may have additional checks
+ mkl_check_failed "$cname" "" "$3" "'$cmd' failed:
+$cflags"
+ return 1
+ fi
+
+ if [[ $(mkl_meta_get $1 installed_with) == "source" && \
+ $WITH_STATIC_LINKING == y && \
+ $MKL_SOURCE_DEPS_ONLY == y ]]; then
+ # If attempting static linking and we're using source-only
+ # dependencies, then there is no need for pkg-config since
+ # the source installer will have set the required flags.
+ mkl_check_failed "$cname" "" "ignore" "pkg-config ignored for static build"
+ return 1
+ fi
+
+ local libs=
+ cmd="${PKG_CONFIG} --short-errors --libs $libname"
+ mkl_dbg "pkg-config check $libname for LIBS ($2): $cmd"
+ libs=$($cmd 2>&1)
+ if [[ $? != 0 ]]; then
+ mkl_dbg "${PKG_CONFIG} --libs $libname failed: $libs"
+ # Clear define name ($2): caller may have additional checks
+ mkl_check_failed "$cname" "" "$3" "pkg-config --libs failed"
+ return 1
+ fi
+
+ mkl_dbg "$1: from pkg-config: CFLAGS '$CFLAGS', LIBS '$LIBS'"
+
+ local snippet="$5"
+ if [[ -n $snippet ]]; then
+ mkl_dbg "$1: performing compile check using pkg-config info"
+
+ if ! mkl_compile_check --sub "$1" "$2" "no-cache" "$4" "$cflags $libs" "$snippet"; then
+ mkl_check_failed "$cname" "" "$3" "compile check failed"
+ return 1
+ fi
+ fi
+
+ mkl_mkvar_append $1 "MKL_PKGCONFIG_REQUIRES_PRIVATE" "$libname"
+
+ mkl_mkvar_append $1 "CFLAGS" "$cflags"
+
+ if [[ -z $nostaticopt ]]; then
+ local stlibs=$(mkl_lib_check_static $1 "$libs")
+ if [[ -n $stlibs ]]; then
+ libs=$stlibs
+ else
+ # if we don't find a static library to bundle into the
+ # -static.a, we need to export a pkgconfig dependency
+ # so it can be resolved when linking downstream packages
+ mkl_mkvar_append $1 "MKL_PKGCONFIG_REQUIRES" "$libname"
+ fi
+ fi
+
+ mkl_dbg "$1: from pkg-config: LIBS: prepend $libs"
+ mkl_mkvar_prepend "$1" LIBS "$libs"
+
+ mkl_check_done "$1" "$2" "$3" "ok"
+
+ return 0
+}
+
+
+# Check that a command runs and exits succesfully.
+# Arguments:
+# config name
+# define name (optional, can be empty)
+# action
+# command
+function mkl_command_check {
+ mkl_check_begin "$1" "$2" "$3" "$1 (by command)" && return $?
+
+ local out=
+ out=$($4 2>&1)
+ if [[ $? != 0 ]]; then
+ mkl_dbg "$1: $2: $4 failed: $out"
+ mkl_check_failed "$1" "$2" "$3" "command '$4' failed:
+$out"
+ return 1
+ fi
+
+ mkl_check_done "$1" "$2" "$3" "ok"
+
+ return 0
+}
+
+
+# Check that a program is executable, but will not execute it.
+# Arguments:
+# config name
+# define name (optional, can be empty)
+# action
+# program name (e.g, objdump)
+function mkl_prog_check {
+ mkl_check_begin --verb "checking executable" "$1" "$2" "$3" "$1" && return $?
+
+ local out=
+ out=$(command -v "$4" 2>&1)
+ if [[ $? != 0 ]]; then
+ mkl_dbg "$1: $2: $4 is not executable: $out"
+ mkl_check_failed "$1" "$2" "$3" "$4 is not executable"
+ return 1
+ fi
+
+ mkl_check_done "$1" "$2" "$3" "ok"
+
+ return 0
+}
+
+
+
+
+# Checks that the check for the given config name passed.
+# This does not behave like the other checks, if the given config name passed
+# its test then nothing is printed. Else the configure will fail.
+# Arguments:
+# checked config name
+function mkl_config_check {
+ local status=$(mkl_var_get "MKL_STATUS_$1")
+ [[ $status = "ok" ]] && return 0
+ mkl_fail $1 "" "fail" "$MKL_MODULE requires $1"
+ return 1
+}
+
+
+# Checks that all provided config names are set.
+# Arguments:
+# config name
+# define name
+# action
+# check_config_name1
+# check_config_name2..
+function mkl_config_check_all {
+ local cname=
+ local res="ok"
+ echo start this now for $1
+ for cname in ${@:4}; do
+ local st=$(mkl_var_get "MKL_STATUS_$cname")
+ [[ $status = "ok" ]] && continue
+ mkl_fail $1 $2 $3 "depends on $cname"
+ res="failed"
+ done
+
+ echo "try res $res"
+ mkl_check_done "$1" "$2" "$3" $res
+}
+
+
+# Check environment variable
+# Arguments:
+# config name
+# define name
+# action
+# environment variable
+function mkl_env_check {
+ mkl_check_begin "$1" "$2" "$3" "$1 (by env $4)" && return $?
+
+ if [[ -z ${!4} ]]; then
+ mkl_check_failed "$1" "$2" "$3" "environment variable $4 not set"
+ return 1
+ fi
+
+ mkl_check_done "$1" "$2" "$3" "ok" "${!4}"
+
+ return 0
+}
+
+
+# Run all checks
+function mkl_checks_run {
+ # Set up common variables
+ mkl_allvar_set "" MKL_APP_NAME $(mkl_meta_get description name)
+ mkl_allvar_set "" MKL_APP_DESC_ONELINE "$(mkl_meta_get description oneline)"
+
+ # Call checks functions in dependency order
+ local mf
+ for mf in $MKL_CHECKS ; do
+ MKL_MODULE=${mf%:*}
+ local func=${mf#*:}
+
+ if mkl_func_exists $func ; then
+ $func
+ else
+ mkl_err "Check function $func from $MKL_MODULE disappeared ($mf)"
+ fi
+ unset MKL_MODULE
+ done
+}
+
+
+# Check for color support in terminal.
+# If the terminal supports colors, the function will alter
+# MKL_RED
+# MKL_GREEN
+# MKL_YELLOW
+# MKL_BLUE
+# MKL_CLR_RESET
+function mkl_check_terminal_color_support {
+ local use_color=false
+ local has_tput=false
+
+ if [[ -z ${TERM} ]]; then
+ # tput and dircolors require $TERM
+ mkl_dbg "\$TERM is not set! Cannot check for color support in terminal."
+ return 1
+ elif hash tput 2>/dev/null; then
+ has_tput=true
+ [[ $(tput colors 2>/dev/null) -ge 8 ]] && use_color=true
+ mkl_dbg "tput reports color support: ${use_color}"
+ elif hash dircolors 2>/dev/null; then
+ # Enable color support only on colorful terminals.
+ # dircolors --print-database uses its own built-in database
+ # instead of using /etc/DIR_COLORS. Try to use the external file
+ # first to take advantage of user additions.
+ local safe_term=${TERM//[^[:alnum:]]/?}
+ local match_lhs=""
+ [[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
+ [[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
+ [[ -z ${match_lhs} ]] && match_lhs=$(dircolors --print-database)
+ [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true
+ mkl_dbg "dircolors reports color support: ${use_color}"
+ fi
+
+ if ${use_color}; then
+ if ${has_tput}; then
+ # In theory, user could have set different escape sequences
+ # Because tput is available we can use it to query the right values ...
+ mkl_dbg "Using color escape sequences from tput"
+ MKL_RED=$(tput setaf 1)
+ MKL_GREEN=$(tput setaf 2)
+ MKL_YELLOW=$(tput setaf 3)
+ MKL_BLUE=$(tput setaf 4)
+ MKL_CLR_RESET=$(tput sgr0)
+ else
+ mkl_dbg "Using hard-code ANSI color escape sequences"
+ MKL_RED="\033[031m"
+ MKL_GREEN="\033[032m"
+ MKL_YELLOW="\033[033m"
+ MKL_BLUE="\033[034m"
+ MKL_CLR_RESET="\033[0m"
+ fi
+ else
+ mkl_dbg "Did not detect color support in \"$TERM\" terminal!"
+ fi
+
+ return 0
+}
+
+
+
+
+###########################################################################
+#
+#
+# Module functionality
+#
+#
+###########################################################################
+
+# Downloads module from repository.
+# Arguments:
+# module name
+# Returns:
+# module file name
+function mkl_module_download {
+ local modname="$1"
+ local url="$MKL_REPO_URL/modules/configure.$modname"
+ local tmpfile=""
+
+ fname="${MKLOVE_DIR}/modules/configure.$modname"
+
+ if [[ $url != http*://* ]]; then
+ # Local path, just copy file.
+ if [[ ! -f $url ]]; then
+ mkl_err "Module $modname not found at $url"
+ return 1
+ fi
+
+ if ! cp "$url" "$fname" ; then
+ mkl_err "Failed to copy $url to $fname"
+ return 1
+ fi
+
+ echo "$fname"
+ return 0
+ fi
+
+ # Download
+ mkl_info "${MKL_BLUE}downloading missing module $modname from $url${MKL_CLR_RESET}"
+
+ tmpfile=$(mktemp _mkltmpXXXXXX)
+ local out=
+ out=$(curl -fLs -o "$tmpfile" "$url" 2>&1)
+
+ if [[ $? -ne 0 ]]; then
+ rm -f "$tmpfile"
+ mkl_err "Failed to download $modname:"
+ mkl_err0 $out
+ return 1
+ fi
+
+ # Move downloaded file into place replacing the old file.
+ mv "$tmpfile" "$fname" || return 1
+
+ # "Return" filename
+ echo "$fname"
+
+ return 0
+}
+
+
+# Load module by name or filename
+# Arguments:
+# "require"|"try"
+# filename
+# [ module arguments ]
+function mkl_module_load {
+ local try=$1
+ shift
+ local fname=$1
+ shift
+ local modname=${fname#*configure.}
+ local bypath=1
+
+ # Check if already loaded
+ if mkl_in_list "$MKL_MODULES" "$modname"; then
+ return 0
+ fi
+
+ if [[ $fname = $modname ]]; then
+ # Module specified by name, find the file.
+ bypath=0
+ for fname in configure.$modname \
+ ${MKLOVE_DIR}/modules/configure.$modname ; do
+ [[ -s $fname ]] && break
+ done
+ fi
+
+ # Calling module
+ local cmod=$MKL_MODULE
+ [[ -z $cmod ]] && cmod="base"
+
+ if [[ ! -s $fname ]]; then
+ # Attempt to download module, if permitted
+ if [[ $MKL_NO_DOWNLOAD != 0 || $bypath == 1 ]]; then
+ mkl_err "Module $modname not found at $fname (required by $cmod) and downloads disabled"
+ if [[ $try = "require" ]]; then
+ mkl_fail "$modname" "none" "fail" \
+ "Module $modname not found (required by $cmod) and downloads disabled"
+ fi
+ return 1
+ fi
+
+ fname=$(mkl_module_download "$modname")
+ if [[ $? -ne 0 ]]; then
+ mkl_err "Module $modname not found (required by $cmod)"
+ if [[ $try = "require" ]]; then
+ mkl_fail "$modname" "none" "fail" \
+ "Module $modname not found (required by $cmod)"
+ return 1
+ fi
+ fi
+
+ # Now downloaded, try loading the module again.
+ mkl_module_load $try "$fname" "$@"
+ return $?
+ fi
+
+ # Set current module
+ local save_MKL_MODULE=$MKL_MODULE
+ MKL_MODULE=$modname
+
+ mkl_dbg "Loading module $modname (required by $cmod) from $fname"
+
+ # Source module file (positional arguments are available to module)
+ source $fname
+
+ # Restore current module (might be recursive)
+ MKL_MODULE=$save_MKL_MODULE
+
+ # Add module to list of modules
+ mkl_var_append MKL_MODULES $modname
+
+ # Rename module's special functions so we can call them separetely later.
+ mkl_func_rename "options" "${modname}_options"
+ mkl_func_rename "install_source" "${modname}_install_source"
+ mkl_func_rename "manual_checks" "${modname}_manual_checks"
+ mkl_func_push MKL_CHECKS "$modname" "checks"
+ mkl_func_push MKL_GENERATORS "$modname" "generate"
+ mkl_func_push MKL_CLEANERS "$modname" "clean"
+}
+
+
+# Require and load module
+# Must only be called from module file outside any function.
+# Arguments:
+# [ --try ] Dont fail if module doesn't exist
+# module1
+# [ "must" "pass" ]
+# [ module arguments ... ]
+function mkl_require {
+ local try="require"
+ if [[ $1 = "--try" ]]; then
+ local try="try"
+ shift
+ fi
+
+ local mod=$1
+ shift
+ local override_action=
+
+ # Check for cyclic dependencies
+ if mkl_in_list "$MKL_LOAD_STACK" "$mod"; then
+ mkl_err "Cyclic dependency detected while loading $mod module:"
+ local cmod=
+ local lmod=$mod
+ for cmod in $MKL_LOAD_STACK ; do
+ mkl_err " $lmod required by $cmod"
+ lmod=$cmod
+ done
+ mkl_fail base "" fail "Cyclic dependency detected while loading module $mod"
+ return 1
+ fi
+
+ mkl_var_prepend MKL_LOAD_STACK "$mod"
+
+
+ if [[ "$1 $2" == "must pass" ]]; then
+ shift
+ shift
+ override_action="fail"
+ fi
+
+ if [[ ! -z $override_action ]]; then
+ mkl_meta_set "MOD__$mod" "override_action" "$override_action"
+ fi
+
+
+ mkl_module_load $try $mod "$@"
+ local ret=$?
+
+ mkl_var_shift MKL_LOAD_STACK
+
+ return $ret
+}
+
+
+
+###########################################################################
+#
+#
+# Usage options
+#
+#
+###########################################################################
+
+
+MKL_USAGE="Usage: ./configure [OPTIONS...]
+
+ mklove configure script - mklove, not autoconf
+ Copyright (c) 2014-2019 Magnus Edenhill - https://github.com/edenhill/mklove
+"
+
+function mkl_usage {
+ echo "$MKL_USAGE"
+ local name=$(mkl_meta_get description name)
+
+ if [[ ! -z ${name} ]]; then
+ echo " $name - $(mkl_meta_get description oneline)
+ $(mkl_meta_get description copyright)
+"
+ fi
+
+ local og
+ for og in $MKL_USAGE_GROUPS ; do
+ og="MKL_USAGE_GROUP__$og"
+ echo "${!og}"
+ done
+
+ echo "Honoured environment variables:
+ CC, CPP, CXX, CFLAGS, CPPFLAGS, CXXFLAGS, LDFLAGS, LIBS,
+ LD, NM, OBJDUMP, STRIP, RANLIB, PKG_CONFIG, PKG_CONFIG_PATH,
+ STATIC_LIB_<libname>=.../libname.a
+
+"
+
+}
+
+
+
+# Add usage option informative text
+# Arguments:
+# text
+function mkl_usage_info {
+ MKL_USAGE="$MKL_USAGE
+$1"
+}
+
+
+# Add option to usage output
+# Arguments:
+# option group ("Standard", "Cross-Compilation", etc..)
+# variable name
+# option ("--foo", "--foo=*", "--foo=args_required")
+# help
+# default (optional)
+# assignvalue (optional, default:"y")
+# function block (optional)
+#
+# If option takes the form --foo=* then arguments are optional.
+function mkl_option {
+ local optgroup=$1
+ local varname=$2
+
+ # Fixed width between option name and help in usage output
+ local pad=" "
+ if [[ ${#3} -lt ${#pad} ]]; then
+ pad=${pad:0:$(expr ${#pad} - ${#3})}
+ else
+ pad=""
+ fi
+
+ # Add to usage output
+ local optgroup_safe=$(mkl_env_esc $optgroup)
+ if ! mkl_in_list "$MKL_USAGE_GROUPS" "$optgroup_safe" ; then
+ mkl_env_append MKL_USAGE_GROUPS "$optgroup_safe"
+ mkl_env_set "MKL_USAGE_GROUP__$optgroup_safe" "$optgroup options:
+"
+ fi
+
+ local defstr=""
+ [[ ! -z $5 ]] && defstr=" [$5]"
+ mkl_env_append "MKL_USAGE_GROUP__$optgroup_safe" " $3 $pad $4$defstr
+"
+
+ local optname="${3#--}"
+ local safeopt=
+ local optval=""
+ if [[ $3 == *=* ]]; then
+ optname="${optname%=*}"
+ optval="${3#*=}"
+ if [[ $optval == '*' ]]; then
+ # Avoid globbing of --foo=* optional arguments
+ optval='\*'
+ fi
+ fi
+
+ safeopt=$(mkl_env_esc $optname)
+
+ mkl_meta_set "MKL_OPT_ARGS" "$safeopt" "$optval"
+
+ #
+ # Optional variable scoping by prefix: "env:", "mk:", "def:"
+ #
+ local setallvar="mkl_allvar_set ''"
+ local setmkvar="mkl_mkvar_set ''"
+
+ if [[ $varname = env:* ]]; then
+ # Set environment variable (during configure runtime only)
+ varname=${varname#*:}
+ setallvar=mkl_env_set
+ setmkvar=mkl_env_set
+ elif [[ $varname = mk:* ]]; then
+ # Set Makefile.config variable
+ varname=${varname#*:}
+ setallvar="mkl_mkvar_append ''"
+ setmkvar="mkl_mkvar_append ''"
+ elif [[ $varname = def:* ]]; then
+ # Set config.h define
+ varname=${varname#*:}
+ setallvar="mkl_define_set ''"
+ setmkvar="mkl_define_set ''"
+ fi
+
+
+ if [[ ! -z $7 ]]; then
+ # Function block specified.
+ eval "function opt_$safeopt { $7 }"
+ else
+ # Add default implementation of function simply setting the value.
+ # Application may override this by redefining the function after calling
+ # mkl_option.
+ if [[ $optval = "PATH" ]]; then
+ # PATH argument: make it an absolute path.
+ # Only set the make variable (not config.h)
+ eval "function opt_$safeopt { $setmkvar $varname \"\$(mkl_abspath \$(mkl_render \$1))\"; }"
+ else
+ # Standard argument: simply set the value
+ if [[ -z "$6" ]]; then
+ eval "function opt_$safeopt { $setallvar $varname \"\$1\"; }"
+ else
+ eval "function opt_$safeopt { $setallvar $varname \"$6\"; }"
+ fi
+ fi
+ fi
+
+ # If default value is provided and does not start with "$" (variable ref)
+ # then set it right away.
+ # $ variable refs are set after all checks have run during the
+ # generating step.
+ if [[ ${#5} != 0 ]] ; then
+ if [[ $5 = *\$* ]]; then
+ mkl_var_append "MKL_LATE_VARS" "opt_$safeopt:$5"
+ else
+ opt_$safeopt $5
+ fi
+ fi
+
+ if [[ ! -z $varname ]]; then
+ # Add variable to list
+ MKL_CONFVARS="$MKL_CONFVARS $varname"
+ fi
+
+}
+
+
+
+# Adds a toggle (--enable-X, --disable-X) option.
+# Arguments:
+# option group ("Standard", ..)
+# variable name (WITH_FOO)
+# option (--enable-foo, --enable-foo=*, or --enable-foo=req)
+# help ("foo.." ("Enable" and "Disable" will be prepended))
+# default (y or n)
+
+function mkl_toggle_option {
+
+ # Add option argument
+ mkl_option "$1" "$2" "$3" "$4" "$5"
+
+ # Add corresponding "--disable-foo" option for "--enable-foo".
+ local disname="${3/--enable/--disable}"
+ local dishelp="${4/Enable/Disable}"
+ mkl_option "$1" "$2" "$disname" "$dishelp" "" "n"
+}
+
+# Adds a toggle (--enable-X, --disable-X) option with builtin checker.
+# This is the library version.
+# Arguments:
+# option group ("Standard", ..)
+# config name (foo, must be same as pkg-config name)
+# variable name (WITH_FOO)
+# action (fail or disable)
+# option (--enable-foo)
+# help (defaults to "Enable <config name>")
+# linker flags (-lfoo)
+# default (y or n)
+
+function mkl_toggle_option_lib {
+
+ local help="$6"
+ [[ -z "$help" ]] && help="Enable $2"
+
+ # Add option argument
+ mkl_option "$1" "$3" "$5" "$help" "$8"
+
+ # Add corresponding "--disable-foo" option for "--enable-foo".
+ local disname="${5/--enable/--disable}"
+ local dishelp="${help/Enable/Disable}"
+ mkl_option "$1" "$3" "$disname" "$dishelp" "" "n"
+
+ # Create checks
+ eval "function _tmp_func { mkl_lib_check \"$2\" \"$3\" \"$4\" CC \"$7\"; }"
+ mkl_func_push MKL_CHECKS "$MKL_MODULE" _tmp_func
+}
+
+
+
+# Downloads, verifies checksum, and extracts an archive to
+# the current directory.
+#
+# Arguments:
+# url Archive URL
+# shabits The SHA algorithm bit count used to verify the checksum. E.g., "256".
+# checksum Expected checksum of archive (use "" to not perform check)
+function mkl_download_archive {
+ local url="$1"
+ local shabits="$2"
+ local exp_checksum="$3"
+
+ local tmpfile=$(mktemp _mkltmpXXXXXX)
+
+ # Try both wget and curl
+ if ! wget -nv -O "$tmpfile" "$url" ; then
+ if ! curl -fLsS -o "$tmpfile" "$url" ; then
+ rm -f "$tmpfile"
+ echo -e "ERROR: Download of $url failed" 1>&2
+ return 1
+ fi
+ fi
+
+ if [[ -n $exp_checksum ]]; then
+ # Verify checksum
+
+ local checksum_tool=""
+
+ # OSX has shasum by default, on Linux it is typically in
+ # some Perl package that may or may not be installed.
+ if $(which shasum >/dev/null 2>&1); then
+ checksum_tool="shasum -b -a ${shabits}"
+ else
+ # shaXsum is available in Linux coreutils
+ checksum_tool="sha${shabits}sum"
+ fi
+
+ local checksum=$($checksum_tool "$tmpfile" | cut -d' ' -f1)
+ if [[ $? -ne 0 ]]; then
+ rm -f "$tmpfile"
+ echo "ERROR: Failed to verify checksum of $url with $checksum_tool" 1>&2
+ return 1
+ fi
+
+ if [[ $checksum != $exp_checksum ]]; then
+ rm -f "$tmpfile"
+ echo "ERROR: $url: $checksum_tool: Checksum mismatch: expected $exp_checksum, calculated $checksum" 1>&2
+ return 1
+ fi
+
+ echo "### Checksum of $url verified ($checksum_tool):"
+ echo "### Expected: $exp_checksum"
+ echo "### Calculated: $checksum"
+ fi
+
+ tar xzf "$tmpfile" --strip-components 1
+ if [[ $? -ne 0 ]]; then
+ rm -f "$tmpfile"
+ echo "ERROR: $url: failed to extract archive" 1>&2
+ return 1
+ fi
+
+
+ rm -f "$tmpfile"
+ return 0
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.builtin b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.builtin
new file mode 100644
index 000000000..796528008
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.builtin
@@ -0,0 +1,70 @@
+#!/bin/bash
+#
+# mklove builtin checks and options
+# Sets:
+# prefix, etc..
+
+
+mkl_option "Standard" prefix "--prefix=PATH" \
+ "Install arch-independent files in PATH" "/usr/local"
+mkl_option "Standard" exec_prefix "--exec-prefix=PATH" \
+ "Install arch-dependent files in PATH" "\$prefix"
+mkl_option "Standard" bindir "--bindir=PATH" "User executables" "\$exec_prefix/bin"
+mkl_option "Standard" sbindir "--sbindir=PATH" "System admin executables" \
+ "\$exec_prefix/sbin"
+mkl_option "Standard" libexecdir "--libexecdir=PATH" "Program executables" \
+ "\$exec_prefix/libexec"
+mkl_option "Standard" datadir "--datadir=PATH" "Read-only arch-independent data" \
+ "\$prefix/share"
+mkl_option "Standard" sysconfdir "--sysconfdir=PATH" "Configuration data" \
+ "\$prefix/etc"
+mkl_option "Standard" sharedstatedir "--sharedstatedir=PATH" \
+ "Modifiable arch-independent data" "\$prefix/com"
+mkl_option "Standard" localstatedir "--localstatedir=PATH" \
+ "Modifiable local state data" "\$prefix/var"
+mkl_option "Standard" runstatedir "--runstatedir=PATH" \
+ "Modifiable per-process data" "\$prefix/var/run"
+mkl_option "Standard" libdir "--libdir=PATH" "Libraries" "\$exec_prefix/lib"
+mkl_option "Standard" includedir "--includedir=PATH" "C/C++ header files" \
+ "\$prefix/include"
+mkl_option "Standard" infodir "--infodir=PATH" "Info documentation" "\$prefix/info"
+mkl_option "Standard" mandir "--mandir=PATH" "Manual pages" "\$prefix/man"
+
+mkl_option "Configure tool" "" "--list-modules" "List loaded mklove modules"
+mkl_option "Configure tool" "" "--list-checks" "List checks"
+mkl_option "Configure tool" env:MKL_FAILFATAL "--fail-fatal" "All failures are fatal"
+mkl_option "Configure tool" env:MKL_NOCACHE "--no-cache" "Dont use or generate config.cache"
+mkl_option "Configure tool" env:MKL_DEBUG "--debug" "Enable configure debugging"
+mkl_option "Configure tool" env:MKL_CLEAN "--clean" "Remove generated configure files"
+mkl_option "Configure tool" "" "--reconfigure" "Rerun configure with same arguments as last run"
+mkl_option "Configure tool" env:MKL_NO_DOWNLOAD "--no-download" "Disable downloads of required mklove modules"
+mkl_option "Configure tool" env:MKL_UPDATE_MODS "--update-modules" "Update modules from global repository"
+mkl_option "Configure tool" env:MKL_REPO_URL "--repo-url=URL_OR_PATH" "Override mklove modules repo URL" "$MKL_REPO_URL"
+mkl_option "Configure tool" "" "--help" "Show configure usage"
+
+
+# These autoconf compatibility options are ignored by mklove
+mkl_toggle_option "Compatibility" "mk:COMPAT_MAINT_MODE" "--enable-maintainer-mode" "Maintainer mode (no-op)"
+mkl_option "Compatibility" "mk:PROGRAM_PREFIX" "--program-prefix=PFX" "Program prefix (no-op)"
+mkl_option "Compatibility" "mk:COMPAT_DISABLE_DEP_TRACK" "--disable-dependency-tracking" "Disable dependency tracking (no-op)"
+mkl_option "Compatibility" "mk:COMPAT_DISABLE_SILENT_RULES" "--disable-silent-rules" "Verbose build output (no-op)"
+mkl_option "Compatibility" "mk:COMPAT_SILENT" "--silent" "Less verbose build output (no-op)"
+mkl_toggle_option "Compatibility" "mk:COMPAT_ENABLE_SHARED" "--enable-shared" "Build shared library (no-op)"
+mkl_toggle_option "Compatibility" "mk:COMPAT_DISABLE_OPT_CHECK" '--enable-option-checking=*' "Disable configure option checking (no-op)"
+
+
+mkl_option "Dependency" env:MKL_INSTALL_DEPS "--install-deps" "Attempt to install missing dependencies"
+mkl_option "Dependency" env:MKL_SOURCE_DEPS_ONLY "--source-deps-only" "Only perform source builds of dependencies, not using any package managers"
+
+
+function checks {
+
+ if [[ ! -z $libdir ]]; then
+ mkl_mkvar_append "libdir" LDFLAGS "-L${libdir}"
+ fi
+
+ if [[ ! -z $includedir ]]; then
+ mkl_mkvar_append "includedir" CPPFLAGS "-I${includedir}"
+ fi
+
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.cc b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.cc
new file mode 100644
index 000000000..d29488383
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.cc
@@ -0,0 +1,186 @@
+#!/bin/bash
+#
+# Compiler detection
+# Sets:
+# CC, CXX, CFLAGS, CPPFLAGS, LDFLAGS, ARFLAGS, PKG_CONFIG, INSTALL, MBITS
+
+
+mkl_require host
+
+function checks {
+
+ # C compiler
+ mkl_meta_set "ccenv" "name" "C compiler from CC env"
+ if ! mkl_command_check "ccenv" "WITH_CC" cont "$CC --version"; then
+ if mkl_command_check "gcc" "WITH_GCC" cont "gcc --version"; then
+ CC=gcc
+ elif mkl_command_check "clang" "WITH_CLANG" cont "clang --version"; then
+ CC=clang
+ elif mkl_command_check "cc" "WITH_CC" fail "cc --version"; then
+ CC=cc
+ fi
+ fi
+ export CC="${CC}"
+ mkl_mkvar_set CC CC "$CC"
+
+ if [[ $MKL_CC_WANT_CXX == 1 ]]; then
+ # C++ compiler
+ mkl_meta_set "cxxenv" "name" "C++ compiler from CXX env"
+ if ! mkl_command_check "cxxenv" "WITH_CXX" cont "$CXX --version" ; then
+ mkl_meta_set "gxx" "name" "C++ compiler (g++)"
+ mkl_meta_set "clangxx" "name" "C++ compiler (clang++)"
+ mkl_meta_set "cxx" "name" "C++ compiler (c++)"
+ if mkl_command_check "gxx" "WITH_GXX" cont "g++ --version"; then
+ CXX=g++
+ elif mkl_command_check "clangxx" "WITH_CLANGXX" cont "clang++ --version"; then
+ CXX=clang++
+ elif mkl_command_check "cxx" "WITH_CXX" fail "c++ --version"; then
+ CXX=c++
+ fi
+ fi
+ export CXX="${CXX}"
+ mkl_mkvar_set "CXX" CXX "$CXX"
+ fi
+
+ # Handle machine bits, if specified.
+ if [[ ! -z "$MBITS" ]]; then
+ mkl_meta_set mbits_m name "mbits compiler flag (-m$MBITS)"
+ if mkl_compile_check mbits_m "" fail CC "-m$MBITS"; then
+ mkl_mkvar_append CPPFLAGS CPPFLAGS "-m$MBITS"
+ mkl_mkvar_append LDFLAGS LDFLAGS "-m$MBITS"
+ fi
+ if [[ -z "$ARFLAGS" && $MBITS == 64 && $MKL_DISTRO == "sunos" ]]; then
+ # Turn on 64-bit archives on SunOS
+ mkl_mkvar_append ARFLAGS ARFLAGS "S"
+ fi
+ fi
+
+ # Provide prefix and checks for various other build tools.
+ local t=
+ for t in LD:ld NM:nm OBJDUMP:objdump STRIP:strip LIBTOOL:libtool RANLIB:ranlib ; do
+ local tenv=${t%:*}
+ t=${t#*:}
+ local tval="${!tenv}"
+
+ [[ -z $tval ]] && tval="$t"
+
+ if mkl_prog_check "$t" "" disable "$tval" ; then
+ if [[ $tval != ${!tenv} ]]; then
+ export "$tenv"="$tval"
+ fi
+ mkl_mkvar_set $tenv $tenv "$tval"
+ fi
+ done
+
+ # Compiler and linker flags
+ [[ ! -z $CFLAGS ]] && mkl_mkvar_set "CFLAGS" "CFLAGS" "$CFLAGS"
+ [[ ! -z $CPPFLAGS ]] && mkl_mkvar_set "CPPFLAGS" "CPPFLAGS" "$CPPFLAGS"
+ [[ ! -z $CXXFLAGS ]] && mkl_mkvar_set "CXXFLAGS" "CXXFLAGS" "$CXXFLAGS"
+ [[ ! -z $LDFLAGS ]] && mkl_mkvar_set "LDFLAGS" "LDFLAGS" "$LDFLAGS"
+ [[ ! -z $ARFLAGS ]] && mkl_mkvar_set "ARFLAGS" "ARFLAGS" "$ARFLAGS"
+
+ if [[ $MKL_NO_DEBUG_SYMBOLS != "y" ]]; then
+ # Add debug symbol flag (-g)
+ # OSX 10.9 requires -gstrict-dwarf for some reason.
+ mkl_meta_set cc_g_dwarf name "debug symbols compiler flag (-g...)"
+ if [[ $MKL_DISTRO == "osx" ]]; then
+ if mkl_compile_check cc_g_dwarf "" cont CC "-gstrict-dwarf"; then
+ mkl_mkvar_append CPPFLAGS CPPFLAGS "-gstrict-dwarf"
+ else
+ mkl_mkvar_append CPPFLAGS CPPFLAGS "-g"
+ fi
+ else
+ mkl_mkvar_append CPPFLAGS CPPFLAGS "-g"
+ fi
+ fi
+
+
+ # pkg-config
+ if [ -z "$PKG_CONFIG" ]; then
+ PKG_CONFIG=pkg-config
+ fi
+
+ if mkl_command_check "pkgconfig" "WITH_PKGCONFIG" cont "$PKG_CONFIG --version"; then
+ export PKG_CONFIG
+ fi
+ mkl_mkvar_set "pkgconfig" PKG_CONFIG $PKG_CONFIG
+
+ [[ ! -z "$append_PKG_CONFIG_PATH" ]] && mkl_env_append PKG_CONFIG_PATH "$append_PKG_CONFIG_PATH" ":"
+
+ # install
+ if [ -z "$INSTALL" ]; then
+ if [[ $MKL_DISTRO == "sunos" ]]; then
+ mkl_meta_set ginstall name "GNU install"
+ if mkl_command_check ginstall "" ignore "ginstall --version"; then
+ INSTALL=$(which ginstall)
+ else
+ INSTALL=$(which install)
+ fi
+ else
+ INSTALL=$(which install)
+ fi
+ fi
+
+ if mkl_command_check "install" "WITH_INSTALL" cont "$INSTALL --version"; then
+ export INSTALL
+ fi
+ mkl_mkvar_set "install" INSTALL $INSTALL
+
+
+ # Enable profiling if desired
+ if [[ $WITH_PROFILING == y ]]; then
+ mkl_allvar_set "" "WITH_PROFILING" "y"
+ mkl_mkvar_append CPPFLAGS CPPFLAGS "-pg"
+ mkl_mkvar_append LDFLAGS LDFLAGS "-pg"
+ fi
+
+ # Optimization
+ if [[ $WITHOUT_OPTIMIZATION == n ]]; then
+ mkl_mkvar_append CPPFLAGS CPPFLAGS "-O2"
+ else
+ mkl_mkvar_append CPPFLAGS CPPFLAGS "-O0"
+ fi
+
+ # Static linking
+ if [[ $WITH_STATIC_LINKING == y ]]; then
+ # LDFLAGS_STATIC is the LDFLAGS needed to enable static linking
+ # of sub-sequent libraries, while
+ # LDFLAGS_DYNAMIC is the LDFLAGS needed to enable dynamic linking.
+ if [[ $MKL_DISTRO != "osx" ]]; then
+ mkl_mkvar_set staticlinking LDFLAGS_STATIC "-Wl,-Bstatic"
+ mkl_mkvar_set staticlinking LDFLAGS_DYNAMIC "-Wl,-Bdynamic"
+ mkl_mkvar_set staticlinking HAS_LDFLAGS_STATIC y
+ else
+ # OSX linker can't enable/disable static linking so we'll
+ # need to find the .a through STATIC_LIB_libname env var
+ mkl_mkvar_set staticlinking HAS_LDFLAGS_STATIC n
+ # libtool -static supported
+ mkl_mkvar_set staticlinking HAS_LIBTOOL_STATIC y
+ fi
+ fi
+
+ # Check for GNU ar (which has the -M option)
+ mkl_meta_set "gnuar" "name" "GNU ar"
+ mkl_command_check "gnuar" "HAS_GNU_AR" disable \
+ "ar -V 2>/dev/null | grep -q GNU"
+}
+
+
+mkl_option "Compiler" "env:CC" "--cc=CC" "Build using C compiler CC" "\$CC"
+mkl_option "Compiler" "env:CXX" "--cxx=CXX" "Build using C++ compiler CXX" "\$CXX"
+mkl_option "Compiler" "ARCH" "--arch=ARCH" "Build for architecture" "$(uname -m)"
+mkl_option "Compiler" "CPU" "--cpu=CPU" "Build and optimize for specific CPU" "generic"
+mkl_option "Compiler" "MBITS" "--mbits=BITS" "Machine bits (32 or 64)" ""
+
+for n in CFLAGS CPPFLAGS CXXFLAGS LDFLAGS ARFLAGS; do
+ mkl_option "Compiler" "mk:$n" "--$n=$n" "Add $n flags"
+done
+
+mkl_option "Compiler" "env:append_PKG_CONFIG_PATH" "--pkg-config-path=EXTRA_PATHS" "Extra paths for pkg-config"
+
+mkl_option "Compiler" "WITH_PROFILING" "--enable-profiling" "Enable profiling"
+mkl_option "Compiler" "WITH_STATIC_LINKING" "--enable-static" "Enable static linking"
+mkl_option "Compiler" "WITHOUT_OPTIMIZATION" "--disable-optimization" "Disable optimization flag to compiler" "n"
+mkl_option "Compiler" "env:MKL_NO_DEBUG_SYMBOLS" "--disable-debug-symbols" "Disable debugging symbols" "n"
+mkl_option "Compiler" "env:MKL_WANT_WERROR" "--enable-werror" "Enable compiler warnings as errors" "n"
+mkl_option "Compiler" "WITH_STRIP" "--enable-strip" "Strip libraries when installing" "n"
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.cxx b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.cxx
new file mode 100644
index 000000000..a38ac7367
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.cxx
@@ -0,0 +1,8 @@
+#!/bin/bash
+#
+# C++ detection
+#
+# This script simply limits the checks of configure.cc
+
+
+MKL_CC_WANT_CXX=1
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.fileversion b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.fileversion
new file mode 100644
index 000000000..9bea11786
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.fileversion
@@ -0,0 +1,65 @@
+#!/bin/bash
+#
+# Reads version from file and sets variables accordingly
+# The first non-commented line in the file is expected to be the version string.
+# Arguments:
+# filename
+# STR_VERSION_VARIABLE_NAME
+# [ HEX_VERSION_VARIABLE_NAME ]
+#
+# Example: Set string version in variable named "MYVERSION_STR" and
+# the hex representation in "MYVERSION"
+# mkl_require VERSION.txt MYVERSION_STR MYVERSION
+
+if [[ -z "$2" ]]; then
+ mkl_fail "fileversion" "none" "fail" "Missing argument(s), expected: FILENAME STR_VER HEX_VER"
+ return 0
+fi
+
+fileversion_file="$1"
+fileversion_strvar="$2"
+fileversion_hexvar="$3"
+
+function checks {
+ mkl_check_begin "fileversion" "" "no-cache" "version from file $fileversion_file"
+
+ if [[ ! -s $fileversion_file ]]; then
+ mkl_check_failed "fileversion" "" "fail" \
+ "Version file $fileversion_file is not readable"
+ return 1
+ fi
+
+ local orig=$(grep -v ^\# "$fileversion_file" | grep -v '^$' | head -1)
+ # Strip v prefix if any
+ orig=${orig#v}
+
+ # Try to decode version string into hex
+ # Supported format is "[v]NN.NN.NN[.NN]"
+ if [[ ! -z $fileversion_hexvar ]]; then
+ local hex=""
+ local s=${orig#v} # Strip v prefix, if any.
+ local ncnt=0
+ local n=
+ for n in ${s//./ } ; do
+ if [[ ! ( "$n" =~ ^[0-9][0-9]?$ ) ]]; then
+ mkl_check_failed "fileversion" "" "fail" \
+ "$fileversion_file: Could not decode '$orig' into hex version, expecting format 'NN.NN.NN[.NN]'"
+ return 1
+ fi
+ hex="$hex$(printf %02x $n)"
+ ncnt=$(expr $ncnt + 1)
+ done
+
+ if [[ ! -z $hex ]]; then
+ # Finish all four bytess
+ for n in {$ncnt..4} ; do
+ hex="$hex$(printf %02x 0)"
+ done
+ mkl_allvar_set "fileversion" "$fileversion_hexvar" "0x$hex"
+ fi
+ fi
+
+ mkl_allvar_set "fileversion" "$fileversion_strvar" "$orig"
+
+ mkl_check_done "fileversion" "" "cont" "ok" "${!fileversion_strvar}"
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.gitversion b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.gitversion
new file mode 100644
index 000000000..ad42291c7
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.gitversion
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# Sets version variable from git information.
+# Optional arguments:
+# "as"
+# VARIABLE_NAME
+#
+# Example: Set version in variable named "MYVERSION":
+# mkl_require gitversion as MYVERSION [default DEFVERSION]
+
+if [[ $1 == "as" ]]; then
+ shift
+ __MKL_GITVERSION_VARNAME="$1"
+ shift
+else
+ __MKL_GITVERSION_VARNAME="VERSION"
+fi
+
+if [[ $1 == "default" ]]; then
+ shift
+ __MKL_GITVERSION_DEFAULT="$1"
+ shift
+fi
+
+
+function checks {
+ mkl_allvar_set "gitversion" "$__MKL_GITVERSION_VARNAME" \
+ "$(git describe --abbrev=6 --tags HEAD --always 2>/dev/null || echo $__MKL_GITVERSION_DEFAULT)"
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.good_cflags b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.good_cflags
new file mode 100644
index 000000000..c8587f2e3
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.good_cflags
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# Provides some known-good CFLAGS
+# Sets:
+# CFLAGS
+# CXXFLAGS
+# CPPFLAGS
+
+
+function checks {
+ mkl_mkvar_append CPPFLAGS CPPFLAGS \
+ "-Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align"
+
+ if [[ $MKL_WANT_WERROR = "y" ]]; then
+ mkl_mkvar_append CPPFLAGS CPPFLAGS \
+ "-Werror"
+ fi
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.host b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.host
new file mode 100644
index 000000000..155fecc08
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.host
@@ -0,0 +1,132 @@
+#!/bin/bash
+#
+# Host OS support
+# Sets:
+# HOST
+# BUILD
+# TARGET
+
+# FIXME: No need for this right now
+#mkl_require host_linux
+#mkl_require host_osx
+#mkl_require host_cygwin
+
+#mkl_option "Cross-compilation" "mk:HOST_OS" "--host-os=osname" "Host OS (linux,osx,cygwin,..)" "auto"
+
+
+# autoconf compatibility - does nothing at this point
+mkl_option "Cross-compilation" "mk:HOST" "--host=HOST" "Configure to build programs to run on HOST (no-op)"
+mkl_option "Cross-compilation" "mk:BUILD" "--build=BUILD" "Configure for building on BUILD (no-op)"
+mkl_option "Cross-compilation" "mk:TARGET" "--target=TARGET" "Configure for building cross-toolkits for platform TARGET (no-op)"
+
+
+# Resolve the OS/distro at import time, rather than as a check,
+# so that MKL_DISTRO is available to other modules at import time.
+function resolve_distro {
+ solib_ext=.so
+
+ # Try lsb_release
+ local sys
+ sys=$(lsb_release -is 2>/dev/null)
+ if [[ $? -gt 0 ]]; then
+ # That didnt work, try uname.
+ local kn=$(uname -s)
+ case $kn in
+ Linux)
+ sys=Linux
+ solib_ext=.so
+
+ if [[ -f /etc/os-release ]]; then
+ eval $(grep ^ID= /etc/os-release)
+ if [[ -n $ID ]]; then
+ sys="$ID"
+ fi
+ elif [[ -f /etc/centos-release ]]; then
+ sys=centos
+ elif [[ -f /etc/alpine-release ]]; then
+ sys=alpine
+ fi
+ ;;
+ Darwin)
+ sys=osx
+ solib_ext=.dylib
+ ;;
+ CYGWIN*)
+ sys=Cygwin
+ solib_ext=.dll
+ ;;
+ *)
+ sys="$kn"
+ solib_ext=.so
+ ;;
+ esac
+ fi
+
+ # Convert to lower case
+ sys=$(echo $sys | tr '[:upper:]' '[:lower:]')
+ mkl_mkvar_set "distro" "MKL_DISTRO" "$sys"
+ mkl_allvar_set "distro" "SOLIB_EXT" "$solib_ext"
+}
+
+resolve_distro
+
+
+function checks {
+ # Try to figure out what OS/distro we are running on.
+ mkl_check_begin "distro" "" "no-cache" "OS or distribution"
+
+ if [[ -z $MKL_DISTRO ]]; then
+ mkl_check_failed "distro" "" "ignore" ""
+ else
+ mkl_check_done "distro" "" "ignore" "ok" "$MKL_DISTRO"
+ fi
+}
+
+#function checks {
+# mkl_check_begin "host" "HOST_OS" "no-cache" "host OS"
+#
+# #
+# # If --host-os=.. was not specified then this is most likely not a
+# # a cross-compilation and we can base the host-os on the native OS.
+# #
+# if [[ $HOST_OS != "auto" ]]; then
+# mkl_check_done "host" "HOST_OS" "cont" "ok" "$HOST_OS"
+# return 0
+# fi
+#
+# kn=$(uname -s)
+# case $kn in
+# Linux)
+# hostos=linux
+# ;;
+# Darwin)
+# hostos=osx
+# ;;
+# CYGWIN*)
+# hostos=cygwin
+# ;;
+# *)
+# hostos="$(mkl_lower $kn)"
+# mkl_err "Unknown host OS kernel name: $kn"
+# mkl_err0 " Will attempt to load module host_$hostos anyway."
+# mkl_err0 " Please consider writing a configure.host_$hostos"
+# ;;
+# esac
+#
+# if ! mkl_require --try "host_$hostos"; then
+# # Module not found
+# mkl_check_done "host" "HOST_OS" "cont" "failed" "$kn?"
+# else
+# # Module loaded
+#
+# if mkl_func_exists "host_${hostos}_setup" ; then
+# "host_${hostos}_setup"
+# fi
+#
+# mkl_check_done "host" "HOST_OS" "cont" "ok" "$hostos"
+# fi
+#
+# # Set HOST_OS var even if probing failed.
+# mkl_mkvar_set "host" "HOST_OS" "$hostos"
+#}
+
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.lib b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.lib
new file mode 100644
index 000000000..49ed29368
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.lib
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Module for building shared libraries
+# Sets:
+# WITH_GNULD | WITH_OSXLD
+# WITH_LDS - linker script support
+mkl_require pic
+
+function checks {
+
+ mkl_mkvar_append LIB_LDFLAGS LIB_LDFLAGS '-shared'
+
+ # Check what arguments to pass to CC or LD for shared libraries
+ mkl_meta_set gnulib name "GNU-compatible linker options"
+ mkl_meta_set osxlib name "OSX linker options"
+
+ if mkl_compile_check gnulib WITH_GNULD cont CC \
+ "-shared -Wl,-soname,mkltest.0" "" ; then
+ # GNU linker
+ mkl_mkvar_append LIB_LDFLAGS LIB_LDFLAGS '-Wl,-soname,$(LIBFILENAME)'
+
+ elif mkl_compile_check osxlib WITH_OSXLD cont CC \
+ "-dynamiclib -Wl,-install_name,/tmp/mkltest.so.0" ; then
+ # OSX linker
+ mkl_mkvar_append LIB_LDFLAGS LIB_LDFLAGS '-dynamiclib -Wl,-install_name,$(DESTDIR)$(libdir)/$(LIBFILENAME)'
+ fi
+
+ # Check what argument is needed for passing linker script.
+ local ldsfile=$(mktemp _mkltmpXXXXXX)
+ echo "{
+ global:
+ *;
+};
+" > $ldsfile
+
+ mkl_meta_set ldsflagvs name "GNU linker-script ld flag"
+ mkl_meta_set ldsflagm name "Solaris linker-script ld flag"
+ if mkl_compile_check ldsflagvs "" cont CC \
+ "-shared -Wl,--version-script=$ldsfile"; then
+ mkl_mkvar_set ldsflagvs LDFLAG_LINKERSCRIPT "-Wl,--version-script="
+ mkl_mkvar_set lib_lds WITH_LDS y
+ elif mkl_compile_check ldsflagm "" ignore CC \
+ "-shared -Wl,-M$ldsfile"; then
+ mkl_mkvar_set ldsflagm LDFLAG_LINKERSCRIPT "-Wl,-M"
+ mkl_mkvar_set lib_lds WITH_LDS y
+ fi
+
+ rm -f "$ldsfile"
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libcurl b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libcurl
new file mode 100644
index 000000000..05048745f
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libcurl
@@ -0,0 +1,99 @@
+#!/bin/bash
+#
+# libcurl support, with installer
+#
+# Usage:
+# mkl_require libcurl
+#
+# And then call the following function from the correct place/order in checks:
+# mkl_check libcurl
+#
+
+mkl_toggle_option "Feature" ENABLE_CURL "--enable-curl" "Enable HTTP client (using libcurl)" "try"
+
+function manual_checks {
+ case "$ENABLE_CURL" in
+ n) return 0 ;;
+ y) local action=fail ;;
+ try) local action=disable ;;
+ *) mkl_err "mklove internal error: invalid value for ENABLE_CURL: $ENABLE_CURL"; exit 1 ;;
+ esac
+
+ mkl_meta_set "libcurl" "apk" "curl-dev curl-static"
+ mkl_meta_set "libcurl" "deb" "libcurl4-openssl-dev"
+ mkl_meta_set "libcurl" "static" "libcurl.a"
+ if [[ $MKL_DISTRO == "osx" && $WITH_STATIC_LINKING ]]; then
+ mkl_env_append LDFLAGS "-framework CoreFoundation -framework SystemConfiguration"
+ mkl_mkvar_append "libcurl" MKL_PKGCONFIG_LIBS_PRIVATE "-framework CoreFoundation -framework SystemConfiguration"
+ fi
+ mkl_lib_check "libcurl" "WITH_CURL" $action CC "-lcurl" \
+ "
+#include <curl/curl.h>
+
+void foo (void) {
+ curl_global_init(CURL_GLOBAL_DEFAULT);
+}
+"
+}
+
+
+# Install curl from source tarball
+#
+# Param 1: name (libcurl)
+# Param 2: install-dir-prefix (e.g., DESTDIR)
+# Param 2: version (optional)
+function install_source {
+ local name=$1
+ local destdir=$2
+ local ver=7.86.0
+ local checksum="3dfdd39ba95e18847965cd3051ea6d22586609d9011d91df7bc5521288987a82"
+
+ echo "### Installing $name $ver from source to $destdir"
+ if [[ ! -f Makefile ]]; then
+ mkl_download_archive \
+ "https://curl.se/download/curl-${ver}.tar.gz" \
+ 256 \
+ $checksum || return 1
+ fi
+
+ # curl's configure has a runtime check where a program is built
+ # with all libs linked and then executed, since mklove's destdir
+ # is outside the standard ld.so search path this runtime check will
+ # fail due to missing libraries.
+ # We patch curl's configure file to skip this check altogether.
+ if ! mkl_patch libcurl 0000 ; then
+ return 1
+ fi
+
+ # Clear out LIBS to not interfer with lib detection process.
+ LIBS="" ./configure \
+ --with-openssl \
+ --enable-static \
+ --disable-shared \
+ --disable-ntlm{,-wb} \
+ --disable-dict \
+ --disable-ftp \
+ --disable-file \
+ --disable-gopher \
+ --disable-imap \
+ --disable-mqtt \
+ --disable-pop3 \
+ --disable-rtsp \
+ --disable-smb \
+ --disable-smtp \
+ --disable-telnet \
+ --disable-tftp \
+ --disable-manual \
+ --disable-ldap{,s} \
+ --disable-libcurl-option \
+ --without-{librtmp,libidn2,winidn,nghttp2,nghttp3,ngtcp2,quiche,brotli} &&
+ time make -j &&
+ make DESTDIR="${destdir}" prefix=/usr install
+ local ret=$?
+
+ if [[ $MKL_DISTRO == osx ]]; then
+ mkl_mkvar_append "libcurl" LIBS "-framework CoreFoundation -framework SystemConfiguration"
+ fi
+
+ return $ret
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libsasl2 b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libsasl2
new file mode 100644
index 000000000..e148e03da
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libsasl2
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# libsasl2 support (for GSSAPI/Kerberos), without source installer.
+#
+# Usage:
+# mkl_require libsasl2
+#
+#
+# And then call the following function from the correct place/order in checks:
+# mkl_check libsasl2
+#
+
+mkl_toggle_option "Feature" ENABLE_GSSAPI "--enable-gssapi" "Enable SASL GSSAPI support with Cyrus libsasl2" "try"
+mkl_toggle_option "Feature" ENABLE_GSSAPI "--enable-sasl" "Deprecated: Alias for --enable-gssapi"
+
+function manual_checks {
+ case "$ENABLE_GSSAPI" in
+ n) return 0 ;;
+ y) local action=fail ;;
+ try) local action=disable ;;
+ *) mkl_err "mklove internal error: invalid value for ENABLE_GSSAPI: $ENABLE_GSSAPI"; exit 1 ;;
+ esac
+
+ mkl_meta_set "libsasl2" "deb" "libsasl2-dev"
+ mkl_meta_set "libsasl2" "rpm" "cyrus-sasl"
+ mkl_meta_set "libsasl2" "apk" "cyrus-sasl-dev"
+
+ local sasl_includes="
+#include <stddef.h>
+#include <sasl/sasl.h>
+"
+
+ if ! mkl_lib_check "libsasl2" "WITH_SASL_CYRUS" $action CC "-lsasl2" "$sasl_includes" ; then
+ mkl_lib_check "libsasl" "WITH_SASL_CYRUS" $action CC "-lsasl" "$sasl_includes"
+ fi
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libssl b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libssl
new file mode 100644
index 000000000..8ce586422
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libssl
@@ -0,0 +1,147 @@
+#!/bin/bash
+#
+# libssl and libcrypto (OpenSSL or derivate) support, with installer.
+# Requires OpenSSL version v1.0.1 or later.
+#
+# Usage:
+# mkl_require libssl
+#
+
+# And then call the following function from the correct place/order in checks:
+# mkl_check libssl
+#
+#
+# This module is a bit hacky since OpenSSL provides both libcrypto and libssl,
+# the latter depending on the former, but from a user perspective it is
+# SSL that is the feature, not crypto.
+
+mkl_toggle_option "Feature" ENABLE_SSL "--enable-ssl" "Enable SSL support" "try"
+
+
+function manual_checks {
+ case "$ENABLE_SSL" in
+ n) return 0 ;;
+ y) local action=fail ;;
+ try) local action=disable ;;
+ *) mkl_err "mklove internal error: invalid value for ENABLE_SSL: $ENABLE_SSL"; exit 1 ;;
+ esac
+
+ if [[ $MKL_SOURCE_DEPS_ONLY != y && $MKL_DISTRO == "osx" ]]; then
+ # Add brew's OpenSSL pkg-config path on OSX
+ # to avoid picking up the outdated system-provided openssl/libcrypto.
+ mkl_env_append PKG_CONFIG_PATH "/usr/local/opt/openssl/lib/pkgconfig" ":"
+ # and similar path for M1 brew location
+ mkl_env_append PKG_CONFIG_PATH "/opt/homebrew/opt/openssl/lib/pkgconfig" ":"
+ fi
+
+ # OpenSSL provides both libcrypto and libssl
+ if [[ $WITH_STATIC_LINKING != y ]]; then
+ # Debian's OpenSSL static libraries are broken.
+ mkl_meta_set "libcrypto" "deb" "libssl-dev"
+ fi
+ mkl_meta_set "libcrypto" "rpm" "openssl-devel"
+ mkl_meta_set "libcrypto" "brew" "openssl"
+ mkl_meta_set "libcrypto" "apk" "openssl-dev"
+ mkl_meta_set "libcrypto" "static" "libcrypto.a"
+
+ if ! mkl_lib_check "libcrypto" "" $action CC "-lcrypto" "
+#include <openssl/ssl.h>
+#include <openssl/evp.h>
+#if OPENSSL_VERSION_NUMBER < 0x1000100fL
+#error \"Requires OpenSSL version >= v1.0.1\"
+#endif"; then
+ return
+ fi
+
+
+ #
+ # libssl
+ #
+ mkl_meta_set "libssl" "static" "libssl.a"
+
+ if [[ $(mkl_meta_get "libcrypto" "installed_with") == "source" ]]; then
+ # Try to resolve the libssl.a static library path based on the
+ # libcrypto (openssl) install path.
+ mkl_resolve_static_libs "libssl" "$(mkl_dep_destdir libcrypto)"
+ fi
+
+ mkl_lib_check "libssl" "WITH_SSL" $action CC "-lssl -lcrypto" \
+ "#include <openssl/ssl.h>
+#if OPENSSL_VERSION_NUMBER < 0x1000100fL
+#error \"Requires OpenSSL version >= v1.0.1\"
+#endif"
+
+ # Silence OpenSSL 3.0.0 deprecation warnings since they'll make
+ # -Werror fail.
+ if ! mkl_compile_check --sub "libcrypto" "" "" CC "-lcrypto" "
+#include <openssl/ssl.h>
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+#error \"OpenSSL version >= v3.0.0 needs OPENSSL_SUPPRESS_DEPRECATED\"
+#endif"; then
+ mkl_define_set "libcrypto" OPENSSL_SUPPRESS_DEPRECATED
+ fi
+}
+
+
+ # Install libcrypto/libssl from source tarball on linux.
+ #
+ # Param 1: name (libcrypto)
+ # Param 2: install-dir-prefix (e.g., DESTDIR)
+ # Param 2: version (optional)
+function libcrypto_install_source {
+ local name=$1
+ local destdir=$2
+ local ver=3.0.8
+ local checksum="6c13d2bf38fdf31eac3ce2a347073673f5d63263398f1f69d0df4a41253e4b3e"
+ local url=https://www.openssl.org/source/openssl-${ver}.tar.gz
+
+ local conf_args="--prefix=/usr --openssldir=/usr/lib/ssl no-shared no-zlib"
+
+ if [[ $ver == 1.0.* ]]; then
+ conf_args="${conf_args} no-krb5"
+ fi
+
+ if [[ $ver != 3.* ]]; then
+ # OpenSSL 3 deprecates ENGINE support, but we still need it, so only
+ # add no-deprecated to non-3.x builds.
+ conf_args="${conf_args} no-deprecated"
+ fi
+
+ # 1.1.1q tests fail to build on OSX/M1, so disable them.
+ if [[ $MKL_DISTRO == osx && $ver == 1.1.1q ]]; then
+ conf_args="${conf_args} no-tests"
+ fi
+
+ echo "### Installing $name $ver from source ($url) to $destdir"
+ if [[ ! -f config ]]; then
+ echo "### Downloading"
+ mkl_download_archive "$url" "256" "$checksum" || return 1
+ fi
+
+ if [[ $MKL_DISTRO == "osx" ]]; then
+ # Workaround build issue in 1.1.1l on OSX with older toolchains.
+ if [[ $ver == 1.1.1l ]]; then
+ if ! mkl_patch libssl 0000 ; then
+ return 1
+ fi
+ fi
+
+ # Silence a load of warnings on OSX
+ conf_args="${conf_args} -Wno-nullability-completeness"
+ fi
+
+ echo "### Configuring with args $conf_args"
+ ./config $conf_args || return $?
+
+ echo "### Building"
+ make
+
+ echo "### Installing to $destdir"
+ if [[ $ver == 1.0.* ]]; then
+ make INSTALL_PREFIX="$destdir" install_sw
+ else
+ make DESTDIR="$destdir" install
+ fi
+
+ return $?
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libzstd b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libzstd
new file mode 100644
index 000000000..e32378f78
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libzstd
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# libzstd support, with installer
+#
+# Usage:
+# mkl_require libzstd
+#
+# And then call the following function from the correct place/order in checks:
+# mkl_check libzstd
+#
+
+mkl_toggle_option "Feature" ENABLE_ZSTD "--enable-zstd" "Enable support for ZSTD compression" "try"
+
+function manual_checks {
+ case "$ENABLE_ZSTD" in
+ n) return 0 ;;
+ y) local action=fail ;;
+ try) local action=disable ;;
+ *) mkl_err "mklove internal error: invalid value for ENABLE_ZSTD: $ENABLE_ZSTD"; exit 1 ;;
+ esac
+
+ mkl_meta_set "libzstd" "brew" "zstd"
+ mkl_meta_set "libzstd" "apk" "zstd-dev zstd-static"
+ mkl_meta_set "libzstd" "static" "libzstd.a"
+ mkl_lib_check "libzstd" "WITH_ZSTD" $action CC "-lzstd" \
+ "
+#include <zstd.h>
+#include <zstd_errors.h>
+
+void foo (void) {
+ ZSTD_getFrameContentSize(NULL, 0);
+}
+"
+}
+
+
+# Install zstd from source tarball
+#
+# Param 1: name (libzstd)
+# Param 2: install-dir-prefix (e.g., DESTDIR)
+# Param 2: version (optional)
+function install_source {
+ local name=$1
+ local destdir=$2
+ local ver=1.5.2
+ local checksum="7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0"
+
+ echo "### Installing $name $ver from source to $destdir"
+ if [[ ! -f Makefile ]]; then
+ mkl_download_archive \
+ "https://github.com/facebook/zstd/releases/download/v${ver}/zstd-${ver}.tar.gz" \
+ "256" \
+ $checksum || return 1
+ fi
+
+ time make -j DESTDIR="${destdir}" prefix=/usr install
+ return $?
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.parseversion b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.parseversion
new file mode 100644
index 000000000..0ee0f577e
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.parseversion
@@ -0,0 +1,95 @@
+#!/bin/bash
+#
+# Parses the provided version string and creates variables accordingly.
+# [ "hex2str" <fmt> ] -- version-string is in hex (e.g., 0x00080300)
+# version-string
+# STR_VERSION_VARIABLE_NAME
+# [ HEX_VERSION_VARIABLE_NAME ]
+#
+# Note: The version will also be set in MKL_APP_VERSION
+#
+# Example: Set string version in variable named "MYVERSION_STR" and
+# the hex representation in "MYVERSION"
+# mkl_require parseversion "$(head -1 VERSION.txt)" MYVERSION_STR MYVERSION
+
+if [[ $1 == "hex2str" ]]; then
+ parseversion_type="hex"
+ parseversion_fmt="${2}:END:%d%d%d%d"
+ shift
+ shift
+else
+ parseversion_type=""
+ parseversion_fmt="%d.%d.%d.%d"
+fi
+
+if [[ -z "$2" ]]; then
+ mkl_fail "parseversion" "none" "fail" "Missing argument(s)"
+ return 0
+fi
+
+parseversion_orig="$1"
+parseversion_strvar="$2"
+parseversion_hexvar="$3"
+
+function checks {
+ mkl_check_begin --verb "parsing" "parseversion" "" "no-cache" \
+ "version '$parseversion_orig'"
+
+ # Strip v prefix if any
+ orig=${parseversion_orig#v}
+
+ if [[ $orig == 0x* ]]; then
+ parseversion_type="hex"
+ orig=${orig#0x}
+ fi
+
+ if [[ -z $orig ]]; then
+ mkl_check_failed "parseversion" "" "fail" "Version string is empty"
+ return 1
+ fi
+
+ # If orig is in hex we construct a string format instead.
+ if [[ $parseversion_type == "hex" ]]; then
+ local s=$orig
+ local str=""
+ local vals=""
+ while [[ ! -z $s ]]; do
+ local n=${s:0:2}
+ s=${s:${#n}}
+ vals="${vals}$(printf %d 0x$n) "
+ done
+ str=$(printf "$parseversion_fmt" $vals)
+ orig=${str%:END:*}
+ fi
+
+
+ # Try to decode version string into hex
+ # Supported format is "[v]NN.NN.NN[.NN]"
+ if [[ ! -z $parseversion_hexvar ]]; then
+ local hex=""
+ local s=$orig
+ local ncnt=0
+ local n=
+ for n in ${s//./ } ; do
+ if [[ ! ( "$n" =~ ^[0-9][0-9]?$ ) ]]; then
+ mkl_check_failed "parseversion" "" "fail" \
+ "Could not decode '$parseversion_orig' into hex version, expecting format 'NN.NN.NN[.NN]'"
+ return 1
+ fi
+ hex="$hex$(printf %02x $n)"
+ ncnt=$(expr $ncnt + 1)
+ done
+
+ if [[ ! -z $hex ]]; then
+ # Finish all four bytess
+ while [[ ${#hex} -lt 8 ]]; do
+ hex="$hex$(printf %02x 0)"
+ done
+ mkl_allvar_set "parseversion" "$parseversion_hexvar" "0x$hex"
+ fi
+ fi
+
+ mkl_allvar_set "parseversion" "$parseversion_strvar" "$orig"
+ mkl_allvar_set "parseversion" MKL_APP_VERSION "$orig"
+ mkl_check_done "parseversion" "" "cont" "ok" "${!parseversion_strvar}"
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.pic b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.pic
new file mode 100644
index 000000000..8f138f8d5
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.pic
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Checks if -fPIC is supported, and if so turns it on.
+#
+# Sets:
+# HAVE_PIC
+# CPPFLAGS
+#
+
+function checks {
+
+ if mkl_compile_check PIC HAVE_PIC disable CC "-fPIC" "" ; then
+ mkl_mkvar_append CPPFLAGS CPPFLAGS "-fPIC"
+ fi
+}
+
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.socket b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.socket
new file mode 100644
index 000000000..f0777ab3b
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.socket
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Provides proper compiler flags for socket support, e.g. socket(3).
+
+function checks {
+
+ local src="
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <unistd.h>
+void foo (void) {
+ int s = socket(0, 0, 0);
+ close(s);
+}"
+ if ! mkl_compile_check socket "" cont CC "" "$src"; then
+ if mkl_compile_check --ldflags="-lsocket -lnsl" socket_nsl "" fail CC "" "$src"; then
+ mkl_mkvar_append socket_nsl LIBS "-lsocket -lnsl"
+ fi
+ fi
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.zlib b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.zlib
new file mode 100644
index 000000000..08333e947
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.zlib
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# zlib support, with installer
+#
+# Usage:
+# mkl_require zlib
+#
+# And then call the following function from the correct place/order in checks:
+# mkl_check zlib
+#
+
+mkl_toggle_option "Feature" ENABLE_ZLIB "--enable-zlib" "Enable support for zlib compression" "try"
+
+function manual_checks {
+ case "$ENABLE_ZLIB" in
+ n) return 0 ;;
+ y) local action=fail ;;
+ try) local action=disable ;;
+ *) mkl_err "mklove internal error: invalid value for ENABLE_ZLIB: $ENABLE_ZLIB"; exit 1 ;;
+ esac
+
+ mkl_meta_set "zlib" "apk" "zlib-dev"
+ mkl_meta_set "zlib" "static" "libz.a"
+ mkl_lib_check "zlib" "WITH_ZLIB" $action CC "-lz" \
+ "
+#include <stddef.h>
+#include <zlib.h>
+
+void foo (void) {
+ z_stream *p = NULL;
+ inflate(p, 0);
+}
+"
+}
+
+
+# Install zlib from source tarball
+#
+# Param 1: name (zlib)
+# Param 2: install-dir-prefix (e.g., DESTDIR)
+# Param 2: version (optional)
+function install_source {
+ local name=$1
+ local destdir=$2
+ local ver=1.2.13
+ local checksum="b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30"
+
+ echo "### Installing $name $ver from source to $destdir"
+ if [[ ! -f Makefile ]]; then
+ mkl_download_archive \
+ "https://zlib.net/fossils/zlib-${ver}.tar.gz" \
+ "256" \
+ "$checksum" || return 1
+ fi
+
+ CFLAGS=-fPIC ./configure --static --prefix=/usr
+ make -j
+ make test
+ make DESTDIR="${destdir}" install
+ return $?
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/README.md b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/README.md
new file mode 100644
index 000000000..1208dc86d
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/README.md
@@ -0,0 +1,8 @@
+This directory contains patches to dependencies used by the source installers in configure.*
+
+
+Patch filename format is:
+<module>.NNNN-description_of_patch.patch
+
+Where module is the configure.<module> name, NNNN is the patch apply order, e.g. 0000.
+
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/libcurl.0000-no-runtime-linking-check.patch b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/libcurl.0000-no-runtime-linking-check.patch
new file mode 100644
index 000000000..6623b22fb
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/libcurl.0000-no-runtime-linking-check.patch
@@ -0,0 +1,11 @@
+--- a/configure 2022-06-27 12:15:45.000000000 +0200
++++ b/configure 2022-06-27 12:17:20.000000000 +0200
+@@ -33432,7 +33432,7 @@
+
+
+
+- if test "x$cross_compiling" != xyes; then
++ if false; then
+
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking run-time libs availability" >&5
+ printf %s "checking run-time libs availability... " >&6; }
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/libssl.0000-osx-rand-include-fix-OpenSSL-PR16409.patch b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/libssl.0000-osx-rand-include-fix-OpenSSL-PR16409.patch
new file mode 100644
index 000000000..b0e37e325
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/patches/libssl.0000-osx-rand-include-fix-OpenSSL-PR16409.patch
@@ -0,0 +1,56 @@
+From cef404f1e7a598166cbc2fd2e0048f7e2d752ad5 Mon Sep 17 00:00:00 2001
+From: David Carlier <devnexen@gmail.com>
+Date: Tue, 24 Aug 2021 22:40:14 +0100
+Subject: [PATCH] Darwin platform allows to build on releases before
+ Yosemite/ios 8.
+
+issue #16407 #16408
+---
+ crypto/rand/rand_unix.c | 5 +----
+ include/crypto/rand.h | 10 ++++++++++
+ 2 files changed, 11 insertions(+), 4 deletions(-)
+
+diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
+index 43f1069d151d..0f4525106af7 100644
+--- a/crypto/rand/rand_unix.c
++++ b/crypto/rand/rand_unix.c
+@@ -34,9 +34,6 @@
+ #if defined(__OpenBSD__)
+ # include <sys/param.h>
+ #endif
+-#if defined(__APPLE__)
+-# include <CommonCrypto/CommonRandom.h>
+-#endif
+
+ #if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__)
+ # include <sys/types.h>
+@@ -381,7 +378,7 @@ static ssize_t syscall_random(void *buf, size_t buflen)
+ if (errno != ENOSYS)
+ return -1;
+ }
+-# elif defined(__APPLE__)
++# elif defined(OPENSSL_APPLE_CRYPTO_RANDOM)
+ if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)
+ return (ssize_t)buflen;
+
+diff --git a/include/crypto/rand.h b/include/crypto/rand.h
+index 5350d3a93119..674f840fd13c 100644
+--- a/include/crypto/rand.h
++++ b/include/crypto/rand.h
+@@ -20,6 +20,16 @@
+
+ # include <openssl/rand.h>
+
++# if defined(__APPLE__) && !defined(OPENSSL_NO_APPLE_CRYPTO_RANDOM)
++# include <Availability.h>
++# if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || \
++ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000)
++# define OPENSSL_APPLE_CRYPTO_RANDOM 1
++# include <CommonCrypto/CommonCryptoError.h>
++# include <CommonCrypto/CommonRandom.h>
++# endif
++# endif
++
+ /* forward declaration */
+ typedef struct rand_pool_st RAND_POOL;
+