#!/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-171-g630434bb0ac619f7beec927569782d924c459385"
	;;
--revision)
	echo "2"
	;;
--config)
	echo "--build=x86_64-linux --host=x86_64-poky-linux --target=x86_64-poky-linux --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/libexec --datadir=/usr/share --sysconfdir=/etc --sharedstatedir=/com --localstatedir=/var --libdir=/usr/lib --includedir=/usr/include --oldincludedir=/usr/include --infodir=/usr/share/info --mandir=/usr/share/man --disable-silent-rules --disable-dependency-tracking --disable-static --with-version=5.3.0-171-g630434bb0ac619f7beec927569782d924c459385 --enable-xmalloc build_alias=x86_64-linux host_alias=x86_64-poky-linux target_alias=x86_64-poky-linux 'CC=x86_64-poky-linux-gcc -m64 -march=x86-64-v3 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=' 'CFLAGS= -O2 -g -fcanon-prefix-map -ffile-prefix-map=/sources/jemalloc-5.3.0+git=/usr/src/debug/jemalloc/5.3.0+git -ffile-prefix-map=/build=/usr/src/debug/jemalloc/5.3.0+git -ffile-prefix-map== -ffile-prefix-map=-native= -pipe' 'LDFLAGS=-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now' CPPFLAGS= 'CPP=x86_64-poky-linux-gcc -E --sysroot= -m64 -march=x86-64-v3 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security' 'CXX=x86_64-poky-linux-g++ -m64 -march=x86-64-v3 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=' 'CXXFLAGS= -O2 -g -fcanon-prefix-map -ffile-prefix-map=/sources/jemalloc-5.3.0+git=/usr/src/debug/jemalloc/5.3.0+git -ffile-prefix-map=/build=/usr/src/debug/jemalloc/5.3.0+git -ffile-prefix-map== -ffile-prefix-map=-native= -pipe -fvisibility-inlines-hidden'"
	;;
--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 "x86_64-poky-linux-gcc  -m64 -march=x86-64-v3 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot="
	;;
--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 -Wimplicit-fallthrough -Wdeprecated-declarations -O3 -funroll-loops  -O2 -g -fcanon-prefix-map  -ffile-prefix-map=/sources/jemalloc-5.3.0+git=/usr/src/debug/jemalloc/5.3.0+git  -ffile-prefix-map=/build=/usr/src/debug/jemalloc/5.3.0+git  -ffile-prefix-map==  -ffile-prefix-map=-native=  -pipe"
	;;
--cppflags)
	echo "-D_GNU_SOURCE -D_REENTRANT"
	;;
--cxxflags)
	echo "-Wall -Wextra -g3 -fvisibility=hidden -Wimplicit-fallthrough -Wdeprecated-declarations -O3  -O2 -g -fcanon-prefix-map  -ffile-prefix-map=/sources/jemalloc-5.3.0+git=/usr/src/debug/jemalloc/5.3.0+git  -ffile-prefix-map=/build=/usr/src/debug/jemalloc/5.3.0+git  -ffile-prefix-map==  -ffile-prefix-map=-native=  -pipe -fvisibility-inlines-hidden"
	;;
--ldflags)
	echo "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now "
	;;
--libs)
	echo "-lm -lstdc++ -pthread"
	;;
*)
	usage
	exit 1
esac
