[buildout]
extends =
  ../autoconf/buildout.cfg
  ../automake/buildout.cfg
  ../bzip2/buildout.cfg
  ../cmake/buildout.cfg
  ../curl/buildout.cfg
  ../git/buildout.cfg
  ../gnutls/buildout.cfg
  ../jemalloc/buildout.cfg
  ../libmicrohttpd/buildout.cfg
  ../libtool/buildout.cfg
  ../m4/buildout.cfg
  ../openssl/buildout.cfg
  ../patch/buildout.cfg
  ../pcre/buildout.cfg
  ../perl/buildout.cfg
# https://github.com/libinjection/libinjection/issues/4
  ../python-2.7/buildout.cfg

parts =
  proxysql

[proxysql]
recipe = slapos.recipe.cmmi
shared = true
version = v2.3.2
url = https://github.com/sysown/proxysql/archive/refs/tags/${:version}.tar.gz
md5sum = 969129ac43c9f64641509891a116e0e1
configure-command = true
make-options = GIT_VERSION=${:version}
# The install target does not honor DESTDIR:
# let's forget it and only install what we need.
make-targets = src/proxysql
post-install =
  install -Dt %(location)s/bin %(make-targets)s
environment =
  PKG_CONFIG_PATH=${openssl:location}/lib/pkgconfig:${gnutls:location}/lib/pkgconfig:${libgcrypt:location}/lib/pkgconfig:${zlib:location}/lib/pkgconfig:${pcre:location}/lib/pkgconfig
  PATH=${m4:location}/bin:${libtool:location}/bin:${libgcrypt:location}/bin:${curl:location}/bin:${perl:location}/bin:${pkgconfig:location}/bin:${bzip2:location}/bin:${autoconf:location}/bin:${git:location}/bin:${automake:location}/bin:${patch:location}/bin:${cmake:location}/bin:${python2.7:location}/bin:%(PATH)s
  CXXFLAGS=-I${openssl:location}/include -I${gnutls:location}/include -I${zlib:location}/include
  CFLAGS=-I${gnutls:location}/include
  LDFLAGS=-L${openssl:location}/lib -Wl,-rpath -Wl,${gnutls:location}/lib -L${gnutls:location}/lib -Wl,-rpath=${curl:location}/lib -L${libtool:location}/lib -L${zlib:location}/lib -Wl,-rpath -Wl,${zlib:location}/lib -L${curl:location}/lib -L${pcre:location}/lib -L${jemalloc:location}/lib -L${libmicrohttpd:location}/lib
  CMAKE_INCLUDE_PATH=${openssl:location}/include:${gnutls:location}/include:${curl:location}/include:${pcre:location}/include:${jemalloc:location}/include:${libmicrohttpd:location}/include:${zlib:location}/include
  CMAKE_LIBRARY_PATH=${openssl:location}/lib:${gnutls:location}/lib:${curl:location}/lib:${pcre:location}/lib:${jemalloc:location}/lib:${libmicrohttpd:location}/lib:${zlib:location}/lib
  LIBTOOL=libtool
  ACLOCAL_PATH=${pkgconfig:location}/share/aclocal:${libtool:location}/share/aclocal
patch-options = -p1
patches =
# PR #3402 (mariadb_client: backport patch to fix syntax error in cmake 3.20)
  https://github.com/sysown/proxysql/commit/a3cfa56d257219f7610cd5711045bb5d84485a91.patch#34fd6366d4a75fde821cee93d25eee10
