#!/bin/sh

usage() {
	cat <<EOF
Usage:
  /usr/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="/usr"
exec_prefix="/usr"

case "$1" in
--help | -h)
	usage
	exit 0
	;;
--version)
	echo "5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c"
	;;
--revision)
	echo "2"
	;;
--config)
	echo "--enable-prof --enable-autogen --prefix=/usr CC=clang 'CFLAGS=-march=i686 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/jemalloc/src=/usr/src/debug/jemalloc' 'LDFLAGS=-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs' CXX=clang++ 'CXXFLAGS=-march=i686 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/jemalloc/src=/usr/src/debug/jemalloc'"
	;;
--prefix)
	echo "/usr"
	;;
--bindir)
	echo "/usr/bin"
	;;
--datadir)
	echo "/usr/share"
	;;
--includedir)
	echo "/usr/include"
	;;
--libdir)
	echo "/usr/lib"
	;;
--mandir)
	echo "/usr/share/man"
	;;
--cc)
	echo "clang"
	;;
--cflags)
	echo "-std=gnu11 -Werror=unknown-warning-option -Wall -Wextra -Wshorten-64-to-32 -Wsign-compare -Wundef -Wno-format-zero-length -Wpointer-arith -Wno-missing-braces -Wno-missing-field-initializers -pipe -g3 -fvisibility=hidden -Wimplicit-fallthrough -O3 -funroll-loops -march=i686 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection          -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/jemalloc/src=/usr/src/debug/jemalloc"
	;;
--cppflags)
	echo "-D_GNU_SOURCE -D_REENTRANT"
	;;
--cxxflags)
	echo "-Wall -Wextra -g3 -fvisibility=hidden -Wimplicit-fallthrough -O3 -march=i686 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection          -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/jemalloc/src=/usr/src/debug/jemalloc"
	;;
--ldflags)
	echo "-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now          -Wl,-z,pack-relative-relocs "
	;;
--libs)
	echo "-lm -lstdc++ -lgcc -lm -pthread"
	;;
*)
	usage
	exit 1
esac
