#!/bin/sh

usage() {
	cat <<EOF
Usage:
  /opt/metasploit-framework/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.
  --cxxflags   : Print C++ compiler flags used to build jemalloc.
  --ldflags    : Print library flags used to build jemalloc.
  --libs       : Print libraries jemalloc was linked against.
EOF
}

prefix="/opt/metasploit-framework/embedded"
exec_prefix="/opt/metasploit-framework/embedded"

case "$1" in
--help | -h)
	usage
	exit 0
	;;
--version)
	echo "6.4.9-42-g3c9829c0bf67e70bfd8cebb1b2e0478c0fae4f55"
	;;
--revision)
	echo "2"
	;;
--config)
	echo "--prefix=/opt/metasploit-framework/embedded --with-jemalloc-prefix= 'CFLAGS=-I/opt/metasploit-framework/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector' 'LDFLAGS=-Wl,-rpath,/opt/metasploit-framework/embedded/lib -L/opt/metasploit-framework/embedded/lib' 'CPPFLAGS=-I/opt/metasploit-framework/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector' 'CXXFLAGS=-I/opt/metasploit-framework/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector'"
	;;
--prefix)
	echo "/opt/metasploit-framework/embedded"
	;;
--bindir)
	echo "/opt/metasploit-framework/embedded/bin"
	;;
--datadir)
	echo "/opt/metasploit-framework/embedded/share"
	;;
--includedir)
	echo "/opt/metasploit-framework/embedded/include"
	;;
--libdir)
	echo "/opt/metasploit-framework/embedded/lib"
	;;
--mandir)
	echo "/opt/metasploit-framework/embedded/share/man"
	;;
--cc)
	echo "gcc"
	;;
--cflags)
	echo "-std=gnu11 -Wall -Wextra -Wsign-compare -Wundef -Wno-format-zero-length -Wpointer-arith -Wno-missing-braces -Wno-missing-field-initializers -Wno-missing-attributes -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -I/opt/metasploit-framework/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector"
	;;
--cppflags)
	echo "-I/opt/metasploit-framework/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector -D_GNU_SOURCE -D_REENTRANT"
	;;
--cxxflags)
	echo "-fvisibility=hidden -O3 -I/opt/metasploit-framework/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector"
	;;
--ldflags)
	echo "-Wl,-rpath,/opt/metasploit-framework/embedded/lib -L/opt/metasploit-framework/embedded/lib "
	;;
--libs)
	echo "-lm  -pthread -ldl"
	;;
*)
	usage
	exit 1
esac
