#!/bin/sh

usage() {
	cat <<EOF
Usage:
  /opt/td-agent/embedded/bin/jemalloc-config <option>
Options:
  --help | -h  : Print usage.
  --version    : Print jemalloc version.
  --revision   : Print shared library revision number.
  --config     : Print configure options used to build jemalloc.
  --prefix     : Print installation directory prefix.
  --bindir     : Print binary installation directory.
  --datadir    : Print data installation directory.
  --includedir : Print include installation directory.
  --libdir     : Print library installation directory.
  --mandir     : Print manual page installation directory.
  --cc         : Print compiler used to build jemalloc.
  --cflags     : Print compiler flags used to build jemalloc.
  --cppflags   : Print preprocessor flags used to build jemalloc.
  --ldflags    : Print library flags used to build jemalloc.
  --libs       : Print libraries jemalloc was linked against.
EOF
}

prefix="/opt/td-agent/embedded"
exec_prefix="/opt/td-agent/embedded"

case "$1" in
--help | -h)
	usage
	exit 0
	;;
--version)
	echo "4.5.0-0-g04380e79f1e2428bd0ad000bbc6e3d2dfc6b66a5"
	;;
--revision)
	echo "2"
	;;
--config)
	echo "--disable-debug --prefix=/opt/td-agent/embedded 'CFLAGS=-I/opt/td-agent/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector' 'LDFLAGS=-Wl,-rpath,/opt/td-agent/embedded/lib -L/opt/td-agent/embedded/lib' 'CPPFLAGS=-I/opt/td-agent/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector'"
	;;
--prefix)
	echo "/opt/td-agent/embedded"
	;;
--bindir)
	echo "/opt/td-agent/embedded/bin"
	;;
--datadir)
	echo "/opt/td-agent/embedded/share"
	;;
--includedir)
	echo "/opt/td-agent/embedded/include"
	;;
--libdir)
	echo "/opt/td-agent/embedded/lib"
	;;
--mandir)
	echo "/opt/td-agent/embedded/share/man"
	;;
--cc)
	echo "gcc"
	;;
--cflags)
	echo "-std=gnu11 -Wall -Werror=declaration-after-statement -Wsign-compare -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -I/opt/td-agent/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector"
	;;
--cppflags)
	echo "-I/opt/td-agent/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -D_GNU_SOURCE -D_REENTRANT"
	;;
--ldflags)
	echo "-Wl,-rpath,/opt/td-agent/embedded/lib -L/opt/td-agent/embedded/lib "
	;;
--libs)
	echo "-lm  -lpthread"
	;;
*)
	usage
	exit 1
esac
